Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
ff626ac7
Commit
ff626ac7
authored
Oct 19, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*: use references instead of pointers
parent
59f8144c
Hide whitespace changes
Inline
Side-by-side
Showing
122 changed files
with
1077 additions
and
1083 deletions
+1077
-1083
AllCommands.cxx
src/AllCommands.cxx
+20
-25
AllCommands.hxx
src/AllCommands.hxx
+1
-1
Client.cxx
src/Client.cxx
+9
-6
Client.hxx
src/Client.hxx
+9
-7
ClientFile.cxx
src/ClientFile.cxx
+1
-1
ClientFile.hxx
src/ClientFile.hxx
+1
-1
ClientIdle.cxx
src/ClientIdle.cxx
+2
-2
ClientInternal.hxx
src/ClientInternal.hxx
+2
-2
ClientNew.cxx
src/ClientNew.cxx
+1
-1
ClientProcess.cxx
src/ClientProcess.cxx
+21
-21
ClientRead.cxx
src/ClientRead.cxx
+1
-1
ClientSubscribe.cxx
src/ClientSubscribe.cxx
+21
-24
ClientSubscribe.hxx
src/ClientSubscribe.hxx
+4
-4
ClientWrite.cxx
src/ClientWrite.cxx
+6
-6
CommandError.cxx
src/CommandError.cxx
+2
-3
CommandError.hxx
src/CommandError.hxx
+2
-2
DatabaseCommands.cxx
src/DatabaseCommands.cxx
+13
-13
DatabaseCommands.hxx
src/DatabaseCommands.hxx
+10
-10
DatabasePlaylist.cxx
src/DatabasePlaylist.cxx
+1
-1
DatabasePrint.cxx
src/DatabasePrint.cxx
+24
-23
DatabasePrint.hxx
src/DatabasePrint.hxx
+8
-10
DatabaseSave.cxx
src/DatabaseSave.cxx
+2
-6
DatabaseSave.hxx
src/DatabaseSave.hxx
+2
-2
DecoderAPI.cxx
src/DecoderAPI.cxx
+82
-83
DecoderInternal.cxx
src/DecoderInternal.cxx
+14
-14
DecoderInternal.hxx
src/DecoderInternal.hxx
+3
-2
DecoderList.cxx
src/DecoderList.cxx
+5
-5
DecoderPlugin.cxx
src/DecoderPlugin.cxx
+6
-8
DecoderPlugin.hxx
src/DecoderPlugin.hxx
+20
-20
DecoderPrint.cxx
src/DecoderPrint.cxx
+2
-2
DecoderPrint.hxx
src/DecoderPrint.hxx
+1
-1
DecoderThread.cxx
src/DecoderThread.cxx
+83
-85
DecoderThread.hxx
src/DecoderThread.hxx
+1
-1
Directory.cxx
src/Directory.cxx
+8
-8
Directory.hxx
src/Directory.hxx
+4
-4
DirectorySave.cxx
src/DirectorySave.cxx
+18
-18
DirectorySave.hxx
src/DirectorySave.hxx
+2
-2
Main.cxx
src/Main.cxx
+1
-1
Mapper.cxx
src/Mapper.cxx
+11
-11
Mapper.hxx
src/Mapper.hxx
+3
-3
MessageCommands.cxx
src/MessageCommands.cxx
+9
-9
MessageCommands.hxx
src/MessageCommands.hxx
+5
-5
OtherCommands.cxx
src/OtherCommands.cxx
+17
-17
OtherCommands.hxx
src/OtherCommands.hxx
+14
-14
OutputAll.cxx
src/OutputAll.cxx
+6
-6
OutputAll.hxx
src/OutputAll.hxx
+2
-2
OutputCommands.cxx
src/OutputCommands.cxx
+4
-4
OutputCommands.hxx
src/OutputCommands.hxx
+4
-4
OutputInit.cxx
src/OutputInit.cxx
+2
-2
OutputInternal.hxx
src/OutputInternal.hxx
+1
-1
OutputPrint.cxx
src/OutputPrint.cxx
+1
-1
OutputPrint.hxx
src/OutputPrint.hxx
+2
-1
PlayerCommands.cxx
src/PlayerCommands.cxx
+49
-49
PlayerCommands.hxx
src/PlayerCommands.hxx
+21
-21
PlayerThread.cxx
src/PlayerThread.cxx
+3
-3
Playlist.cxx
src/Playlist.cxx
+36
-36
PlaylistCommands.cxx
src/PlaylistCommands.cxx
+16
-16
PlaylistCommands.hxx
src/PlaylistCommands.hxx
+11
-11
PlaylistControl.cxx
src/PlaylistControl.cxx
+1
-1
PlaylistEdit.cxx
src/PlaylistEdit.cxx
+1
-1
PlaylistFile.cxx
src/PlaylistFile.cxx
+3
-3
PlaylistFile.hxx
src/PlaylistFile.hxx
+1
-1
PlaylistPrint.cxx
src/PlaylistPrint.cxx
+27
-28
PlaylistPrint.hxx
src/PlaylistPrint.hxx
+12
-11
PlaylistQueue.cxx
src/PlaylistQueue.cxx
+3
-3
PlaylistQueue.hxx
src/PlaylistQueue.hxx
+2
-2
PlaylistSave.cxx
src/PlaylistSave.cxx
+12
-12
PlaylistSave.hxx
src/PlaylistSave.hxx
+4
-4
PlaylistSong.cxx
src/PlaylistSong.cxx
+1
-1
PlaylistState.cxx
src/PlaylistState.cxx
+51
-51
PlaylistState.hxx
src/PlaylistState.hxx
+5
-5
Queue.cxx
src/Queue.cxx
+5
-3
Queue.hxx
src/Queue.hxx
+3
-3
QueueCommands.cxx
src/QueueCommands.cxx
+45
-45
QueueCommands.hxx
src/QueueCommands.hxx
+19
-19
QueuePrint.cxx
src/QueuePrint.cxx
+20
-20
QueuePrint.hxx
src/QueuePrint.hxx
+5
-5
QueueSave.cxx
src/QueueSave.cxx
+12
-12
QueueSave.hxx
src/QueueSave.hxx
+2
-2
Song.hxx
src/Song.hxx
+4
-0
SongPrint.cxx
src/SongPrint.cxx
+18
-18
SongPrint.hxx
src/SongPrint.hxx
+2
-2
SongSave.cxx
src/SongSave.cxx
+9
-9
SongSave.hxx
src/SongSave.hxx
+1
-1
SongSticker.cxx
src/SongSticker.cxx
+6
-6
SongSticker.hxx
src/SongSticker.hxx
+2
-2
SongUpdate.cxx
src/SongUpdate.cxx
+3
-3
StateFile.cxx
src/StateFile.cxx
+7
-7
Stats.cxx
src/Stats.cxx
+2
-2
Stats.hxx
src/Stats.hxx
+1
-1
StickerCommands.cxx
src/StickerCommands.cxx
+6
-6
StickerCommands.hxx
src/StickerCommands.hxx
+1
-1
StickerDatabase.cxx
src/StickerDatabase.cxx
+5
-5
StickerDatabase.hxx
src/StickerDatabase.hxx
+2
-2
StickerPrint.cxx
src/StickerPrint.cxx
+4
-4
StickerPrint.hxx
src/StickerPrint.hxx
+2
-2
TagFile.cxx
src/TagFile.cxx
+2
-2
TagPrint.cxx
src/TagPrint.cxx
+2
-2
TagPrint.hxx
src/TagPrint.hxx
+2
-2
TimePrint.cxx
src/TimePrint.cxx
+1
-1
TimePrint.hxx
src/TimePrint.hxx
+1
-1
UpdateArchive.cxx
src/UpdateArchive.cxx
+11
-11
UpdateArchive.hxx
src/UpdateArchive.hxx
+2
-2
UpdateContainer.cxx
src/UpdateContainer.cxx
+9
-9
UpdateContainer.hxx
src/UpdateContainer.hxx
+2
-2
UpdateDatabase.cxx
src/UpdateDatabase.cxx
+10
-10
UpdateDatabase.hxx
src/UpdateDatabase.hxx
+2
-2
UpdateIO.cxx
src/UpdateIO.cxx
+7
-7
UpdateIO.hxx
src/UpdateIO.hxx
+5
-5
UpdateSong.cxx
src/UpdateSong.cxx
+13
-13
UpdateSong.hxx
src/UpdateSong.hxx
+1
-1
UpdateWalk.cxx
src/UpdateWalk.cxx
+41
-40
SimpleDatabasePlugin.cxx
src/db/SimpleDatabasePlugin.cxx
+2
-2
ls.cxx
src/ls.cxx
+1
-1
ls.hxx
src/ls.hxx
+1
-1
ArgParser.cxx
src/protocol/ArgParser.cxx
+6
-6
ArgParser.hxx
src/protocol/ArgParser.hxx
+6
-6
Result.cxx
src/protocol/Result.cxx
+3
-4
Result.hxx
src/protocol/Result.hxx
+3
-3
read_tags.cxx
test/read_tags.cxx
+2
-2
run_decoder.cxx
test/run_decoder.cxx
+2
-2
run_output.cxx
test/run_output.cxx
+1
-1
No files found.
src/AllCommands.cxx
View file @
ff626ac7
...
@@ -56,15 +56,15 @@ struct command {
...
@@ -56,15 +56,15 @@ struct command {
unsigned
permission
;
unsigned
permission
;
int
min
;
int
min
;
int
max
;
int
max
;
enum
command_return
(
*
handler
)(
Client
*
client
,
int
argc
,
char
**
argv
);
enum
command_return
(
*
handler
)(
Client
&
client
,
int
argc
,
char
**
argv
);
};
};
/* don't be fooled, this is the command handler for "commands" command */
/* don't be fooled, this is the command handler for "commands" command */
static
enum
command_return
static
enum
command_return
handle_commands
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_commands
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
static
enum
command_return
static
enum
command_return
handle_not_commands
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_not_commands
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
/**
/**
* The command registry.
* The command registry.
...
@@ -179,7 +179,7 @@ command_available(gcc_unused const struct command *cmd)
...
@@ -179,7 +179,7 @@ command_available(gcc_unused const struct command *cmd)
/* don't be fooled, this is the command handler for "commands" command */
/* don't be fooled, this is the command handler for "commands" command */
static
enum
command_return
static
enum
command_return
handle_commands
(
Client
*
client
,
handle_commands
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
const
unsigned
permission
=
client_get_permission
(
client
);
const
unsigned
permission
=
client_get_permission
(
client
);
...
@@ -197,7 +197,7 @@ handle_commands(Client *client,
...
@@ -197,7 +197,7 @@ handle_commands(Client *client,
}
}
static
enum
command_return
static
enum
command_return
handle_not_commands
(
Client
*
client
,
handle_not_commands
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
const
unsigned
permission
=
client_get_permission
(
client
);
const
unsigned
permission
=
client_get_permission
(
client
);
...
@@ -249,17 +249,16 @@ command_lookup(const char *name)
...
@@ -249,17 +249,16 @@ command_lookup(const char *name)
}
}
static
bool
static
bool
command_check_request
(
const
struct
command
*
cmd
,
Client
*
client
,
command_check_request
(
const
struct
command
*
cmd
,
Client
&
client
,
unsigned
permission
,
int
argc
,
char
*
argv
[])
unsigned
permission
,
int
argc
,
char
*
argv
[])
{
{
int
min
=
cmd
->
min
+
1
;
int
min
=
cmd
->
min
+
1
;
int
max
=
cmd
->
max
+
1
;
int
max
=
cmd
->
max
+
1
;
if
(
cmd
->
permission
!=
(
permission
&
cmd
->
permission
))
{
if
(
cmd
->
permission
!=
(
permission
&
cmd
->
permission
))
{
if
(
client
!=
nullptr
)
command_error
(
client
,
ACK_ERROR_PERMISSION
,
command_error
(
client
,
ACK_ERROR_PERMISSION
,
"you don't have permission for
\"
%s
\"
"
,
"you don't have permission for
\"
%s
\"
"
,
cmd
->
cmd
);
cmd
->
cmd
);
return
false
;
return
false
;
}
}
...
@@ -267,27 +266,24 @@ command_check_request(const struct command *cmd, Client *client,
...
@@ -267,27 +266,24 @@ command_check_request(const struct command *cmd, Client *client,
return
true
;
return
true
;
if
(
min
==
max
&&
max
!=
argc
)
{
if
(
min
==
max
&&
max
!=
argc
)
{
if
(
client
!=
nullptr
)
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"wrong number of arguments for
\"
%s
\"
"
,
"wrong number of arguments for
\"
%s
\"
"
,
argv
[
0
]);
argv
[
0
]);
return
false
;
return
false
;
}
else
if
(
argc
<
min
)
{
}
else
if
(
argc
<
min
)
{
if
(
client
!=
nullptr
)
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"too few arguments for
\"
%s
\"
"
,
argv
[
0
]);
"too few arguments for
\"
%s
\"
"
,
argv
[
0
]);
return
false
;
return
false
;
}
else
if
(
argc
>
max
&&
max
/* != 0 */
)
{
}
else
if
(
argc
>
max
&&
max
/* != 0 */
)
{
if
(
client
!=
nullptr
)
command_error
(
client
,
ACK_ERROR_ARG
,
command_error
(
client
,
ACK_ERROR_ARG
,
"too many arguments for
\"
%s
\"
"
,
argv
[
0
]);
"too many arguments for
\"
%s
\"
"
,
argv
[
0
]);
return
false
;
return
false
;
}
else
}
else
return
true
;
return
true
;
}
}
static
const
struct
command
*
static
const
struct
command
*
command_checked_lookup
(
Client
*
client
,
unsigned
permission
,
command_checked_lookup
(
Client
&
client
,
unsigned
permission
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
const
struct
command
*
cmd
;
const
struct
command
*
cmd
;
...
@@ -299,9 +295,8 @@ command_checked_lookup(Client *client, unsigned permission,
...
@@ -299,9 +295,8 @@ command_checked_lookup(Client *client, unsigned permission,
cmd
=
command_lookup
(
argv
[
0
]);
cmd
=
command_lookup
(
argv
[
0
]);
if
(
cmd
==
nullptr
)
{
if
(
cmd
==
nullptr
)
{
if
(
client
!=
nullptr
)
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
command_error
(
client
,
ACK_ERROR_UNKNOWN
,
"unknown command
\"
%s
\"
"
,
argv
[
0
]);
"unknown command
\"
%s
\"
"
,
argv
[
0
]);
return
nullptr
;
return
nullptr
;
}
}
...
@@ -314,7 +309,7 @@ command_checked_lookup(Client *client, unsigned permission,
...
@@ -314,7 +309,7 @@ command_checked_lookup(Client *client, unsigned permission,
}
}
enum
command_return
enum
command_return
command_process
(
Client
*
client
,
unsigned
num
,
char
*
line
)
command_process
(
Client
&
client
,
unsigned
num
,
char
*
line
)
{
{
Error
error
;
Error
error
;
char
*
argv
[
COMMAND_ARGV_MAX
]
=
{
nullptr
};
char
*
argv
[
COMMAND_ARGV_MAX
]
=
{
nullptr
};
...
...
src/AllCommands.hxx
View file @
ff626ac7
...
@@ -29,6 +29,6 @@ void command_init(void);
...
@@ -29,6 +29,6 @@ void command_init(void);
void
command_finish
(
void
);
void
command_finish
(
void
);
enum
command_return
enum
command_return
command_process
(
Client
*
client
,
unsigned
num
,
char
*
line
);
command_process
(
Client
&
client
,
unsigned
num
,
char
*
line
);
#endif
#endif
src/Client.cxx
View file @
ff626ac7
...
@@ -23,17 +23,20 @@
...
@@ -23,17 +23,20 @@
const
Domain
client_domain
(
"client"
);
const
Domain
client_domain
(
"client"
);
int
client_get_uid
(
const
Client
*
client
)
int
client_get_uid
(
const
Client
&
client
)
{
{
return
client
->
uid
;
return
client
.
uid
;
}
}
unsigned
client_get_permission
(
const
Client
*
client
)
unsigned
client_get_permission
(
const
Client
&
client
)
{
{
return
client
->
permission
;
return
client
.
permission
;
}
}
void
client_set_permission
(
Client
*
client
,
unsigned
permission
)
void
client_set_permission
(
Client
&
client
,
unsigned
permission
)
{
{
client
->
permission
=
permission
;
client
.
permission
=
permission
;
}
}
src/Client.hxx
View file @
ff626ac7
...
@@ -41,7 +41,8 @@ client_new(EventLoop &loop, Partition &partition,
...
@@ -41,7 +41,8 @@ client_new(EventLoop &loop, Partition &partition,
* uid is unknown
* uid is unknown
*/
*/
gcc_pure
gcc_pure
int
client_get_uid
(
const
Client
*
client
);
int
client_get_uid
(
const
Client
&
client
);
/**
/**
* Is this client running on the same machine, connected with a local
* Is this client running on the same machine, connected with a local
...
@@ -49,31 +50,32 @@ int client_get_uid(const Client *client);
...
@@ -49,31 +50,32 @@ int client_get_uid(const Client *client);
*/
*/
gcc_pure
gcc_pure
static
inline
bool
static
inline
bool
client_is_local
(
const
Client
*
client
)
client_is_local
(
const
Client
&
client
)
{
{
return
client_get_uid
(
client
)
>
0
;
return
client_get_uid
(
client
)
>
0
;
}
}
gcc_pure
gcc_pure
unsigned
client_get_permission
(
const
Client
*
client
);
unsigned
client_get_permission
(
const
Client
&
client
);
void
client_set_permission
(
Client
*
client
,
unsigned
permission
);
void
client_set_permission
(
Client
&
client
,
unsigned
permission
);
/**
/**
* Write a C string to the client.
* Write a C string to the client.
*/
*/
void
client_puts
(
Client
*
client
,
const
char
*
s
);
void
client_puts
(
Client
&
client
,
const
char
*
s
);
/**
/**
* Write a printf-like formatted string to the client.
* Write a printf-like formatted string to the client.
*/
*/
void
client_vprintf
(
Client
*
client
,
const
char
*
fmt
,
va_list
args
);
void
client_vprintf
(
Client
&
client
,
const
char
*
fmt
,
va_list
args
);
/**
/**
* Write a printf-like formatted string to the client.
* Write a printf-like formatted string to the client.
*/
*/
gcc_printf
(
2
,
3
)
gcc_printf
(
2
,
3
)
void
void
client_printf
(
Client
*
client
,
const
char
*
fmt
,
...);
client_printf
(
Client
&
client
,
const
char
*
fmt
,
...);
#endif
#endif
src/ClientFile.cxx
View file @
ff626ac7
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
#include <unistd.h>
#include <unistd.h>
bool
bool
client_allow_file
(
const
Client
*
client
,
Path
path_fs
,
Error
&
error
)
client_allow_file
(
const
Client
&
client
,
Path
path_fs
,
Error
&
error
)
{
{
#ifdef WIN32
#ifdef WIN32
(
void
)
client
;
(
void
)
client
;
...
...
src/ClientFile.hxx
View file @
ff626ac7
...
@@ -35,6 +35,6 @@ class Error;
...
@@ -35,6 +35,6 @@ class Error;
* @return true if access is allowed
* @return true if access is allowed
*/
*/
bool
bool
client_allow_file
(
const
Client
*
client
,
Path
path_fs
,
Error
&
error
);
client_allow_file
(
const
Client
&
client
,
Path
path_fs
,
Error
&
error
);
#endif
#endif
src/ClientIdle.cxx
View file @
ff626ac7
...
@@ -36,11 +36,11 @@ Client::IdleNotify()
...
@@ -36,11 +36,11 @@ Client::IdleNotify()
const
char
*
const
*
idle_names
=
idle_get_names
();
const
char
*
const
*
idle_names
=
idle_get_names
();
for
(
unsigned
i
=
0
;
idle_names
[
i
];
++
i
)
{
for
(
unsigned
i
=
0
;
idle_names
[
i
];
++
i
)
{
if
(
flags
&
(
1
<<
i
)
&
idle_subscriptions
)
if
(
flags
&
(
1
<<
i
)
&
idle_subscriptions
)
client_printf
(
this
,
"changed: %s
\n
"
,
client_printf
(
*
this
,
"changed: %s
\n
"
,
idle_names
[
i
]);
idle_names
[
i
]);
}
}
client_puts
(
this
,
"OK
\n
"
);
client_puts
(
*
this
,
"OK
\n
"
);
TimeoutMonitor
::
ScheduleSeconds
(
client_timeout
);
TimeoutMonitor
::
ScheduleSeconds
(
client_timeout
);
}
}
...
...
src/ClientInternal.hxx
View file @
ff626ac7
...
@@ -43,7 +43,7 @@ class Client final : private FullyBufferedSocket, TimeoutMonitor {
...
@@ -43,7 +43,7 @@ class Client final : private FullyBufferedSocket, TimeoutMonitor {
public
:
public
:
Partition
&
partition
;
Partition
&
partition
;
struct
playlist
&
playlist
;
struct
playlist
&
playlist
;
struct
player_control
*
player_control
;
struct
player_control
&
player_control
;
unsigned
permission
;
unsigned
permission
;
...
@@ -126,6 +126,6 @@ extern size_t client_max_command_list_size;
...
@@ -126,6 +126,6 @@ extern size_t client_max_command_list_size;
extern
size_t
client_max_output_buffer_size
;
extern
size_t
client_max_output_buffer_size
;
enum
command_return
enum
command_return
client_process_line
(
Client
*
client
,
char
*
line
);
client_process_line
(
Client
&
client
,
char
*
line
);
#endif
#endif
src/ClientNew.cxx
View file @
ff626ac7
...
@@ -50,7 +50,7 @@ Client::Client(EventLoop &_loop, Partition &_partition,
...
@@ -50,7 +50,7 @@ Client::Client(EventLoop &_loop, Partition &_partition,
:
FullyBufferedSocket
(
_fd
,
_loop
,
16384
,
client_max_output_buffer_size
),
:
FullyBufferedSocket
(
_fd
,
_loop
,
16384
,
client_max_output_buffer_size
),
TimeoutMonitor
(
_loop
),
TimeoutMonitor
(
_loop
),
partition
(
_partition
),
partition
(
_partition
),
playlist
(
partition
.
playlist
),
player_control
(
&
partition
.
pc
),
playlist
(
partition
.
playlist
),
player_control
(
partition
.
pc
),
permission
(
getDefaultPermissions
()),
permission
(
getDefaultPermissions
()),
uid
(
_uid
),
uid
(
_uid
),
num
(
_num
),
num
(
_num
),
...
...
src/ClientProcess.cxx
View file @
ff626ac7
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#define CLIENT_LIST_MODE_END "command_list_end"
#define CLIENT_LIST_MODE_END "command_list_end"
static
enum
command_return
static
enum
command_return
client_process_command_list
(
Client
*
client
,
bool
list_ok
,
client_process_command_list
(
Client
&
client
,
bool
list_ok
,
std
::
list
<
std
::
string
>
&&
list
)
std
::
list
<
std
::
string
>
&&
list
)
{
{
enum
command_return
ret
=
COMMAND_RETURN_OK
;
enum
command_return
ret
=
COMMAND_RETURN_OK
;
...
@@ -42,7 +42,7 @@ client_process_command_list(Client *client, bool list_ok,
...
@@ -42,7 +42,7 @@ client_process_command_list(Client *client, bool list_ok,
FormatDebug
(
client_domain
,
"process command
\"
%s
\"
"
,
cmd
);
FormatDebug
(
client_domain
,
"process command
\"
%s
\"
"
,
cmd
);
ret
=
command_process
(
client
,
num
++
,
cmd
);
ret
=
command_process
(
client
,
num
++
,
cmd
);
FormatDebug
(
client_domain
,
"command returned %i"
,
ret
);
FormatDebug
(
client_domain
,
"command returned %i"
,
ret
);
if
(
ret
!=
COMMAND_RETURN_OK
||
client
->
IsExpired
())
if
(
ret
!=
COMMAND_RETURN_OK
||
client
.
IsExpired
())
break
;
break
;
else
if
(
list_ok
)
else
if
(
list_ok
)
client_puts
(
client
,
"list_OK
\n
"
);
client_puts
(
client
,
"list_OK
\n
"
);
...
@@ -52,14 +52,14 @@ client_process_command_list(Client *client, bool list_ok,
...
@@ -52,14 +52,14 @@ client_process_command_list(Client *client, bool list_ok,
}
}
enum
command_return
enum
command_return
client_process_line
(
Client
*
client
,
char
*
line
)
client_process_line
(
Client
&
client
,
char
*
line
)
{
{
enum
command_return
ret
;
enum
command_return
ret
;
if
(
strcmp
(
line
,
"noidle"
)
==
0
)
{
if
(
strcmp
(
line
,
"noidle"
)
==
0
)
{
if
(
client
->
idle_waiting
)
{
if
(
client
.
idle_waiting
)
{
/* send empty idle response and leave idle mode */
/* send empty idle response and leave idle mode */
client
->
idle_waiting
=
false
;
client
.
idle_waiting
=
false
;
command_success
(
client
);
command_success
(
client
);
}
}
...
@@ -68,44 +68,44 @@ client_process_line(Client *client, char *line)
...
@@ -68,44 +68,44 @@ client_process_line(Client *client, char *line)
client_idle_notify(), which he can now evaluate */
client_idle_notify(), which he can now evaluate */
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
else
if
(
client
->
idle_waiting
)
{
}
else
if
(
client
.
idle_waiting
)
{
/* during idle mode, clients must not send anything
/* during idle mode, clients must not send anything
except "noidle" */
except "noidle" */
FormatWarning
(
client_domain
,
FormatWarning
(
client_domain
,
"[%u] command
\"
%s
\"
during idle"
,
"[%u] command
\"
%s
\"
during idle"
,
client
->
num
,
line
);
client
.
num
,
line
);
return
COMMAND_RETURN_CLOSE
;
return
COMMAND_RETURN_CLOSE
;
}
}
if
(
client
->
cmd_list
.
IsActive
())
{
if
(
client
.
cmd_list
.
IsActive
())
{
if
(
strcmp
(
line
,
CLIENT_LIST_MODE_END
)
==
0
)
{
if
(
strcmp
(
line
,
CLIENT_LIST_MODE_END
)
==
0
)
{
FormatDebug
(
client_domain
,
FormatDebug
(
client_domain
,
"[%u] process command list"
,
"[%u] process command list"
,
client
->
num
);
client
.
num
);
auto
&&
cmd_list
=
client
->
cmd_list
.
Commit
();
auto
&&
cmd_list
=
client
.
cmd_list
.
Commit
();
ret
=
client_process_command_list
(
client
,
ret
=
client_process_command_list
(
client
,
client
->
cmd_list
.
IsOKMode
(),
client
.
cmd_list
.
IsOKMode
(),
std
::
move
(
cmd_list
));
std
::
move
(
cmd_list
));
FormatDebug
(
client_domain
,
FormatDebug
(
client_domain
,
"[%u] process command "
"[%u] process command "
"list returned %i"
,
client
->
num
,
ret
);
"list returned %i"
,
client
.
num
,
ret
);
if
(
ret
==
COMMAND_RETURN_CLOSE
||
if
(
ret
==
COMMAND_RETURN_CLOSE
||
client
->
IsExpired
())
client
.
IsExpired
())
return
COMMAND_RETURN_CLOSE
;
return
COMMAND_RETURN_CLOSE
;
if
(
ret
==
COMMAND_RETURN_OK
)
if
(
ret
==
COMMAND_RETURN_OK
)
command_success
(
client
);
command_success
(
client
);
client
->
cmd_list
.
Reset
();
client
.
cmd_list
.
Reset
();
}
else
{
}
else
{
if
(
!
client
->
cmd_list
.
Add
(
line
))
{
if
(
!
client
.
cmd_list
.
Add
(
line
))
{
FormatWarning
(
client_domain
,
FormatWarning
(
client_domain
,
"[%u] command list size "
"[%u] command list size "
"is larger than the max (%lu)"
,
"is larger than the max (%lu)"
,
client
->
num
,
client
.
num
,
(
unsigned
long
)
client_max_command_list_size
);
(
unsigned
long
)
client_max_command_list_size
);
return
COMMAND_RETURN_CLOSE
;
return
COMMAND_RETURN_CLOSE
;
}
}
...
@@ -114,22 +114,22 @@ client_process_line(Client *client, char *line)
...
@@ -114,22 +114,22 @@ client_process_line(Client *client, char *line)
}
}
}
else
{
}
else
{
if
(
strcmp
(
line
,
CLIENT_LIST_MODE_BEGIN
)
==
0
)
{
if
(
strcmp
(
line
,
CLIENT_LIST_MODE_BEGIN
)
==
0
)
{
client
->
cmd_list
.
Begin
(
false
);
client
.
cmd_list
.
Begin
(
false
);
ret
=
COMMAND_RETURN_OK
;
ret
=
COMMAND_RETURN_OK
;
}
else
if
(
strcmp
(
line
,
CLIENT_LIST_OK_MODE_BEGIN
)
==
0
)
{
}
else
if
(
strcmp
(
line
,
CLIENT_LIST_OK_MODE_BEGIN
)
==
0
)
{
client
->
cmd_list
.
Begin
(
true
);
client
.
cmd_list
.
Begin
(
true
);
ret
=
COMMAND_RETURN_OK
;
ret
=
COMMAND_RETURN_OK
;
}
else
{
}
else
{
FormatDebug
(
client_domain
,
FormatDebug
(
client_domain
,
"[%u] process command
\"
%s
\"
"
,
"[%u] process command
\"
%s
\"
"
,
client
->
num
,
line
);
client
.
num
,
line
);
ret
=
command_process
(
client
,
0
,
line
);
ret
=
command_process
(
client
,
0
,
line
);
FormatDebug
(
client_domain
,
FormatDebug
(
client_domain
,
"[%u] command returned %i"
,
"[%u] command returned %i"
,
client
->
num
,
ret
);
client
.
num
,
ret
);
if
(
ret
==
COMMAND_RETURN_CLOSE
||
if
(
ret
==
COMMAND_RETURN_CLOSE
||
client
->
IsExpired
())
client
.
IsExpired
())
return
COMMAND_RETURN_CLOSE
;
return
COMMAND_RETURN_CLOSE
;
if
(
ret
==
COMMAND_RETURN_OK
)
if
(
ret
==
COMMAND_RETURN_OK
)
...
...
src/ClientRead.cxx
View file @
ff626ac7
...
@@ -40,7 +40,7 @@ Client::OnSocketInput(void *data, size_t length)
...
@@ -40,7 +40,7 @@ Client::OnSocketInput(void *data, size_t length)
BufferedSocket
::
ConsumeInput
(
newline
+
1
-
p
);
BufferedSocket
::
ConsumeInput
(
newline
+
1
-
p
);
enum
command_return
result
=
client_process_line
(
this
,
p
);
enum
command_return
result
=
client_process_line
(
*
this
,
p
);
switch
(
result
)
{
switch
(
result
)
{
case
COMMAND_RETURN_OK
:
case
COMMAND_RETURN_OK
:
case
COMMAND_RETURN_IDLE
:
case
COMMAND_RETURN_IDLE
:
...
...
src/ClientSubscribe.cxx
View file @
ff626ac7
...
@@ -26,22 +26,21 @@
...
@@ -26,22 +26,21 @@
#include <string.h>
#include <string.h>
enum
client_subscribe_result
enum
client_subscribe_result
client_subscribe
(
Client
*
client
,
const
char
*
channel
)
client_subscribe
(
Client
&
client
,
const
char
*
channel
)
{
{
assert
(
client
!=
nullptr
);
assert
(
channel
!=
nullptr
);
assert
(
channel
!=
nullptr
);
if
(
!
client_message_valid_channel_name
(
channel
))
if
(
!
client_message_valid_channel_name
(
channel
))
return
CLIENT_SUBSCRIBE_INVALID
;
return
CLIENT_SUBSCRIBE_INVALID
;
if
(
client
->
num_subscriptions
>=
CLIENT_MAX_SUBSCRIPTIONS
)
if
(
client
.
num_subscriptions
>=
CLIENT_MAX_SUBSCRIPTIONS
)
return
CLIENT_SUBSCRIBE_FULL
;
return
CLIENT_SUBSCRIBE_FULL
;
auto
r
=
client
->
subscriptions
.
insert
(
channel
);
auto
r
=
client
.
subscriptions
.
insert
(
channel
);
if
(
!
r
.
second
)
if
(
!
r
.
second
)
return
CLIENT_SUBSCRIBE_ALREADY
;
return
CLIENT_SUBSCRIBE_ALREADY
;
++
client
->
num_subscriptions
;
++
client
.
num_subscriptions
;
idle_add
(
IDLE_SUBSCRIPTION
);
idle_add
(
IDLE_SUBSCRIPTION
);
...
@@ -49,44 +48,42 @@ client_subscribe(Client *client, const char *channel)
...
@@ -49,44 +48,42 @@ client_subscribe(Client *client, const char *channel)
}
}
bool
bool
client_unsubscribe
(
Client
*
client
,
const
char
*
channel
)
client_unsubscribe
(
Client
&
client
,
const
char
*
channel
)
{
{
const
auto
i
=
client
->
subscriptions
.
find
(
channel
);
const
auto
i
=
client
.
subscriptions
.
find
(
channel
);
if
(
i
==
client
->
subscriptions
.
end
())
if
(
i
==
client
.
subscriptions
.
end
())
return
false
;
return
false
;
assert
(
client
->
num_subscriptions
>
0
);
assert
(
client
.
num_subscriptions
>
0
);
client
->
subscriptions
.
erase
(
i
);
client
.
subscriptions
.
erase
(
i
);
--
client
->
num_subscriptions
;
--
client
.
num_subscriptions
;
idle_add
(
IDLE_SUBSCRIPTION
);
idle_add
(
IDLE_SUBSCRIPTION
);
assert
((
client
->
num_subscriptions
==
0
)
==
assert
((
client
.
num_subscriptions
==
0
)
==
client
->
subscriptions
.
empty
());
client
.
subscriptions
.
empty
());
return
true
;
return
true
;
}
}
void
void
client_unsubscribe_all
(
Client
*
client
)
client_unsubscribe_all
(
Client
&
client
)
{
{
client
->
subscriptions
.
clear
();
client
.
subscriptions
.
clear
();
client
->
num_subscriptions
=
0
;
client
.
num_subscriptions
=
0
;
}
}
bool
bool
client_push_message
(
Client
*
client
,
const
ClientMessage
&
msg
)
client_push_message
(
Client
&
client
,
const
ClientMessage
&
msg
)
{
{
assert
(
client
!=
nullptr
);
if
(
client
.
messages
.
size
()
>=
CLIENT_MAX_MESSAGES
||
!
client
.
IsSubscribed
(
msg
.
GetChannel
()))
if
(
client
->
messages
.
size
()
>=
CLIENT_MAX_MESSAGES
||
!
client
->
IsSubscribed
(
msg
.
GetChannel
()))
return
false
;
return
false
;
if
(
client
->
messages
.
empty
())
if
(
client
.
messages
.
empty
())
client
->
IdleAdd
(
IDLE_MESSAGE
);
client
.
IdleAdd
(
IDLE_MESSAGE
);
client
->
messages
.
push_back
(
msg
);
client
.
messages
.
push_back
(
msg
);
return
true
;
return
true
;
}
}
src/ClientSubscribe.hxx
View file @
ff626ac7
...
@@ -40,15 +40,15 @@ enum client_subscribe_result {
...
@@ -40,15 +40,15 @@ enum client_subscribe_result {
};
};
enum
client_subscribe_result
enum
client_subscribe_result
client_subscribe
(
Client
*
client
,
const
char
*
channel
);
client_subscribe
(
Client
&
client
,
const
char
*
channel
);
bool
bool
client_unsubscribe
(
Client
*
client
,
const
char
*
channel
);
client_unsubscribe
(
Client
&
client
,
const
char
*
channel
);
void
void
client_unsubscribe_all
(
Client
*
client
);
client_unsubscribe_all
(
Client
&
client
);
bool
bool
client_push_message
(
Client
*
client
,
const
ClientMessage
&
msg
);
client_push_message
(
Client
&
client
,
const
ClientMessage
&
msg
);
#endif
#endif
src/ClientWrite.cxx
View file @
ff626ac7
...
@@ -27,23 +27,23 @@
...
@@ -27,23 +27,23 @@
* Write a block of data to the client.
* Write a block of data to the client.
*/
*/
static
void
static
void
client_write
(
Client
*
client
,
const
char
*
data
,
size_t
length
)
client_write
(
Client
&
client
,
const
char
*
data
,
size_t
length
)
{
{
/* if the client is going to be closed, do nothing */
/* if the client is going to be closed, do nothing */
if
(
client
->
IsExpired
()
||
length
==
0
)
if
(
client
.
IsExpired
()
||
length
==
0
)
return
;
return
;
client
->
Write
(
data
,
length
);
client
.
Write
(
data
,
length
);
}
}
void
void
client_puts
(
Client
*
client
,
const
char
*
s
)
client_puts
(
Client
&
client
,
const
char
*
s
)
{
{
client_write
(
client
,
s
,
strlen
(
s
));
client_write
(
client
,
s
,
strlen
(
s
));
}
}
void
void
client_vprintf
(
Client
*
client
,
const
char
*
fmt
,
va_list
args
)
client_vprintf
(
Client
&
client
,
const
char
*
fmt
,
va_list
args
)
{
{
char
*
p
=
FormatNewV
(
fmt
,
args
);
char
*
p
=
FormatNewV
(
fmt
,
args
);
client_write
(
client
,
p
,
strlen
(
p
));
client_write
(
client
,
p
,
strlen
(
p
));
...
@@ -51,7 +51,7 @@ client_vprintf(Client *client, const char *fmt, va_list args)
...
@@ -51,7 +51,7 @@ client_vprintf(Client *client, const char *fmt, va_list args)
}
}
void
void
client_printf
(
Client
*
client
,
const
char
*
fmt
,
...)
client_printf
(
Client
&
client
,
const
char
*
fmt
,
...)
{
{
va_list
args
;
va_list
args
;
...
...
src/CommandError.cxx
View file @
ff626ac7
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#include <errno.h>
#include <errno.h>
enum
command_return
enum
command_return
print_playlist_result
(
Client
*
client
,
enum
playlist_result
result
)
print_playlist_result
(
Client
&
client
,
enum
playlist_result
result
)
{
{
switch
(
result
)
{
switch
(
result
)
{
case
PLAYLIST_RESULT_SUCCESS
:
case
PLAYLIST_RESULT_SUCCESS
:
...
@@ -89,9 +89,8 @@ print_playlist_result(Client *client, enum playlist_result result)
...
@@ -89,9 +89,8 @@ print_playlist_result(Client *client, enum playlist_result result)
}
}
enum
command_return
enum
command_return
print_error
(
Client
*
client
,
const
Error
&
error
)
print_error
(
Client
&
client
,
const
Error
&
error
)
{
{
assert
(
client
!=
NULL
);
assert
(
error
.
IsDefined
());
assert
(
error
.
IsDefined
());
LogError
(
error
);
LogError
(
error
);
...
...
src/CommandError.hxx
View file @
ff626ac7
...
@@ -27,12 +27,12 @@ class Client;
...
@@ -27,12 +27,12 @@ class Client;
class
Error
;
class
Error
;
enum
command_return
enum
command_return
print_playlist_result
(
Client
*
client
,
enum
playlist_result
result
);
print_playlist_result
(
Client
&
client
,
enum
playlist_result
result
);
/**
/**
* Send the #Error to the client.
* Send the #Error to the client.
*/
*/
enum
command_return
enum
command_return
print_error
(
Client
*
client
,
const
Error
&
error
);
print_error
(
Client
&
client
,
const
Error
&
error
);
#endif
#endif
src/DatabaseCommands.cxx
View file @
ff626ac7
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
#include <string.h>
#include <string.h>
enum
command_return
enum
command_return
handle_lsinfo2
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_lsinfo2
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
const
char
*
uri
;
const
char
*
uri
;
...
@@ -55,7 +55,7 @@ handle_lsinfo2(Client *client, int argc, char *argv[])
...
@@ -55,7 +55,7 @@ handle_lsinfo2(Client *client, int argc, char *argv[])
}
}
static
enum
command_return
static
enum
command_return
handle_match
(
Client
*
client
,
int
argc
,
char
*
argv
[],
bool
fold_case
)
handle_match
(
Client
&
client
,
int
argc
,
char
*
argv
[],
bool
fold_case
)
{
{
SongFilter
filter
;
SongFilter
filter
;
if
(
!
filter
.
Parse
(
argc
-
1
,
argv
+
1
,
fold_case
))
{
if
(
!
filter
.
Parse
(
argc
-
1
,
argv
+
1
,
fold_case
))
{
...
@@ -72,19 +72,19 @@ handle_match(Client *client, int argc, char *argv[], bool fold_case)
...
@@ -72,19 +72,19 @@ handle_match(Client *client, int argc, char *argv[], bool fold_case)
}
}
enum
command_return
enum
command_return
handle_find
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_find
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
return
handle_match
(
client
,
argc
,
argv
,
false
);
return
handle_match
(
client
,
argc
,
argv
,
false
);
}
}
enum
command_return
enum
command_return
handle_search
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_search
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
return
handle_match
(
client
,
argc
,
argv
,
true
);
return
handle_match
(
client
,
argc
,
argv
,
true
);
}
}
static
enum
command_return
static
enum
command_return
handle_match_add
(
Client
*
client
,
int
argc
,
char
*
argv
[],
bool
fold_case
)
handle_match_add
(
Client
&
client
,
int
argc
,
char
*
argv
[],
bool
fold_case
)
{
{
SongFilter
filter
;
SongFilter
filter
;
if
(
!
filter
.
Parse
(
argc
-
1
,
argv
+
1
,
fold_case
))
{
if
(
!
filter
.
Parse
(
argc
-
1
,
argv
+
1
,
fold_case
))
{
...
@@ -94,25 +94,25 @@ handle_match_add(Client *client, int argc, char *argv[], bool fold_case)
...
@@ -94,25 +94,25 @@ handle_match_add(Client *client, int argc, char *argv[], bool fold_case)
const
DatabaseSelection
selection
(
""
,
true
,
&
filter
);
const
DatabaseSelection
selection
(
""
,
true
,
&
filter
);
Error
error
;
Error
error
;
return
AddFromDatabase
(
client
->
partition
,
selection
,
error
)
return
AddFromDatabase
(
client
.
partition
,
selection
,
error
)
?
COMMAND_RETURN_OK
?
COMMAND_RETURN_OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
enum
command_return
handle_findadd
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_findadd
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
return
handle_match_add
(
client
,
argc
,
argv
,
false
);
return
handle_match_add
(
client
,
argc
,
argv
,
false
);
}
}
enum
command_return
enum
command_return
handle_searchadd
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_searchadd
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
return
handle_match_add
(
client
,
argc
,
argv
,
true
);
return
handle_match_add
(
client
,
argc
,
argv
,
true
);
}
}
enum
command_return
enum
command_return
handle_searchaddpl
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_searchaddpl
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
const
char
*
playlist
=
argv
[
1
];
const
char
*
playlist
=
argv
[
1
];
...
@@ -129,7 +129,7 @@ handle_searchaddpl(Client *client, int argc, char *argv[])
...
@@ -129,7 +129,7 @@ handle_searchaddpl(Client *client, int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_count
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_count
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
SongFilter
filter
;
SongFilter
filter
;
if
(
!
filter
.
Parse
(
argc
-
1
,
argv
+
1
,
false
))
{
if
(
!
filter
.
Parse
(
argc
-
1
,
argv
+
1
,
false
))
{
...
@@ -144,7 +144,7 @@ handle_count(Client *client, int argc, char *argv[])
...
@@ -144,7 +144,7 @@ handle_count(Client *client, int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_listall
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_listall
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
const
char
*
directory
=
""
;
const
char
*
directory
=
""
;
...
@@ -158,7 +158,7 @@ handle_listall(Client *client, gcc_unused int argc, char *argv[])
...
@@ -158,7 +158,7 @@ handle_listall(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_list
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_list
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
unsigned
tagType
=
locate_parse_type
(
argv
[
1
]);
unsigned
tagType
=
locate_parse_type
(
argv
[
1
]);
...
@@ -207,7 +207,7 @@ handle_list(Client *client, int argc, char *argv[])
...
@@ -207,7 +207,7 @@ handle_list(Client *client, int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_listallinfo
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_listallinfo
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
const
char
*
directory
=
""
;
const
char
*
directory
=
""
;
...
...
src/DatabaseCommands.hxx
View file @
ff626ac7
...
@@ -25,33 +25,33 @@
...
@@ -25,33 +25,33 @@
class
Client
;
class
Client
;
enum
command_return
enum
command_return
handle_lsinfo2
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_lsinfo2
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_find
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_find
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_findadd
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_findadd
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_search
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_search
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_searchadd
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_searchadd
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_searchaddpl
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_searchaddpl
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_count
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_count
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_listall
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_listall
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_list
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_list
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_listallinfo
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_listallinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/DatabasePlaylist.cxx
View file @
ff626ac7
...
@@ -30,7 +30,7 @@ static bool
...
@@ -30,7 +30,7 @@ static bool
AddSong
(
const
char
*
playlist_path_utf8
,
AddSong
(
const
char
*
playlist_path_utf8
,
Song
&
song
,
Error
&
error
)
Song
&
song
,
Error
&
error
)
{
{
return
spl_append_song
(
playlist_path_utf8
,
&
song
,
error
);
return
spl_append_song
(
playlist_path_utf8
,
song
,
error
);
}
}
bool
bool
...
...
src/DatabasePrint.cxx
View file @
ff626ac7
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
#include <functional>
#include <functional>
static
bool
static
bool
PrintDirectoryBrief
(
Client
*
client
,
const
Directory
&
directory
)
PrintDirectoryBrief
(
Client
&
client
,
const
Directory
&
directory
)
{
{
if
(
!
directory
.
IsRoot
())
if
(
!
directory
.
IsRoot
())
client_printf
(
client
,
"directory: %s
\n
"
,
directory
.
GetPath
());
client_printf
(
client
,
"directory: %s
\n
"
,
directory
.
GetPath
());
...
@@ -43,7 +43,7 @@ PrintDirectoryBrief(Client *client, const Directory &directory)
...
@@ -43,7 +43,7 @@ PrintDirectoryBrief(Client *client, const Directory &directory)
}
}
static
bool
static
bool
PrintDirectoryFull
(
Client
*
client
,
const
Directory
&
directory
)
PrintDirectoryFull
(
Client
&
client
,
const
Directory
&
directory
)
{
{
if
(
!
directory
.
IsRoot
())
{
if
(
!
directory
.
IsRoot
())
{
client_printf
(
client
,
"directory: %s
\n
"
,
directory
.
GetPath
());
client_printf
(
client
,
"directory: %s
\n
"
,
directory
.
GetPath
());
...
@@ -55,7 +55,7 @@ PrintDirectoryFull(Client *client, const Directory &directory)
...
@@ -55,7 +55,7 @@ PrintDirectoryFull(Client *client, const Directory &directory)
static
void
static
void
print_playlist_in_directory
(
Client
*
client
,
print_playlist_in_directory
(
Client
&
client
,
const
Directory
&
directory
,
const
Directory
&
directory
,
const
char
*
name_utf8
)
const
char
*
name_utf8
)
{
{
...
@@ -67,11 +67,11 @@ print_playlist_in_directory(Client *client,
...
@@ -67,11 +67,11 @@ print_playlist_in_directory(Client *client,
}
}
static
bool
static
bool
PrintSongBrief
(
Client
*
client
,
Song
&
song
)
PrintSongBrief
(
Client
&
client
,
const
Song
&
song
)
{
{
assert
(
song
.
parent
!=
nullptr
);
assert
(
song
.
parent
!=
nullptr
);
song_print_uri
(
client
,
&
song
);
song_print_uri
(
client
,
song
);
if
(
song
.
tag
!=
nullptr
&&
song
.
tag
->
has_playlist
)
if
(
song
.
tag
!=
nullptr
&&
song
.
tag
->
has_playlist
)
/* this song file has an embedded CUE sheet */
/* this song file has an embedded CUE sheet */
...
@@ -81,11 +81,11 @@ PrintSongBrief(Client *client, Song &song)
...
@@ -81,11 +81,11 @@ PrintSongBrief(Client *client, Song &song)
}
}
static
bool
static
bool
PrintSongFull
(
Client
*
client
,
Song
&
song
)
PrintSongFull
(
Client
&
client
,
const
Song
&
song
)
{
{
assert
(
song
.
parent
!=
nullptr
);
assert
(
song
.
parent
!=
nullptr
);
song_print_info
(
client
,
&
song
);
song_print_info
(
client
,
song
);
if
(
song
.
tag
!=
nullptr
&&
song
.
tag
->
has_playlist
)
if
(
song
.
tag
!=
nullptr
&&
song
.
tag
->
has_playlist
)
/* this song file has an embedded CUE sheet */
/* this song file has an embedded CUE sheet */
...
@@ -95,7 +95,7 @@ PrintSongFull(Client *client, Song &song)
...
@@ -95,7 +95,7 @@ PrintSongFull(Client *client, Song &song)
}
}
static
bool
static
bool
PrintPlaylistBrief
(
Client
*
client
,
PrintPlaylistBrief
(
Client
&
client
,
const
PlaylistInfo
&
playlist
,
const
PlaylistInfo
&
playlist
,
const
Directory
&
directory
)
const
Directory
&
directory
)
{
{
...
@@ -104,7 +104,7 @@ PrintPlaylistBrief(Client *client,
...
@@ -104,7 +104,7 @@ PrintPlaylistBrief(Client *client,
}
}
static
bool
static
bool
PrintPlaylistFull
(
Client
*
client
,
PrintPlaylistFull
(
Client
&
client
,
const
PlaylistInfo
&
playlist
,
const
PlaylistInfo
&
playlist
,
const
Directory
&
directory
)
const
Directory
&
directory
)
{
{
...
@@ -117,7 +117,7 @@ PrintPlaylistFull(Client *client,
...
@@ -117,7 +117,7 @@ PrintPlaylistFull(Client *client,
}
}
bool
bool
db_selection_print
(
Client
*
client
,
const
DatabaseSelection
&
selection
,
db_selection_print
(
Client
&
client
,
const
DatabaseSelection
&
selection
,
bool
full
,
Error
&
error
)
bool
full
,
Error
&
error
)
{
{
const
Database
*
db
=
GetDatabase
(
error
);
const
Database
*
db
=
GetDatabase
(
error
);
...
@@ -127,13 +127,13 @@ db_selection_print(Client *client, const DatabaseSelection &selection,
...
@@ -127,13 +127,13 @@ db_selection_print(Client *client, const DatabaseSelection &selection,
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
d
=
selection
.
filter
==
nullptr
const
auto
d
=
selection
.
filter
==
nullptr
?
std
::
bind
(
full
?
PrintDirectoryFull
:
PrintDirectoryBrief
,
?
std
::
bind
(
full
?
PrintDirectoryFull
:
PrintDirectoryBrief
,
client
,
_1
)
std
::
ref
(
client
)
,
_1
)
:
VisitDirectory
();
:
VisitDirectory
();
const
auto
s
=
std
::
bind
(
full
?
PrintSongFull
:
PrintSongBrief
,
const
auto
s
=
std
::
bind
(
full
?
PrintSongFull
:
PrintSongBrief
,
client
,
_1
);
std
::
ref
(
client
)
,
_1
);
const
auto
p
=
selection
.
filter
==
nullptr
const
auto
p
=
selection
.
filter
==
nullptr
?
std
::
bind
(
full
?
PrintPlaylistFull
:
PrintPlaylistBrief
,
?
std
::
bind
(
full
?
PrintPlaylistFull
:
PrintPlaylistBrief
,
client
,
_1
,
_2
)
std
::
ref
(
client
)
,
_1
,
_2
)
:
VisitPlaylist
();
:
VisitPlaylist
();
return
db
->
Visit
(
selection
,
d
,
s
,
p
,
error
);
return
db
->
Visit
(
selection
,
d
,
s
,
p
,
error
);
...
@@ -144,7 +144,7 @@ struct SearchStats {
...
@@ -144,7 +144,7 @@ struct SearchStats {
unsigned
long
playTime
;
unsigned
long
playTime
;
};
};
static
void
printSearchStats
(
Client
*
client
,
SearchStats
*
stats
)
static
void
printSearchStats
(
Client
&
client
,
SearchStats
*
stats
)
{
{
client_printf
(
client
,
"songs: %i
\n
"
,
stats
->
numberOfSongs
);
client_printf
(
client
,
"songs: %i
\n
"
,
stats
->
numberOfSongs
);
client_printf
(
client
,
"playtime: %li
\n
"
,
stats
->
playTime
);
client_printf
(
client
,
"playtime: %li
\n
"
,
stats
->
playTime
);
...
@@ -160,7 +160,7 @@ stats_visitor_song(SearchStats &stats, Song &song)
...
@@ -160,7 +160,7 @@ stats_visitor_song(SearchStats &stats, Song &song)
}
}
bool
bool
searchStatsForSongsIn
(
Client
*
client
,
const
char
*
name
,
searchStatsForSongsIn
(
Client
&
client
,
const
char
*
name
,
const
SongFilter
*
filter
,
const
SongFilter
*
filter
,
Error
&
error
)
Error
&
error
)
{
{
...
@@ -185,14 +185,14 @@ searchStatsForSongsIn(Client *client, const char *name,
...
@@ -185,14 +185,14 @@ searchStatsForSongsIn(Client *client, const char *name,
}
}
bool
bool
printAllIn
(
Client
*
client
,
const
char
*
uri_utf8
,
Error
&
error
)
printAllIn
(
Client
&
client
,
const
char
*
uri_utf8
,
Error
&
error
)
{
{
const
DatabaseSelection
selection
(
uri_utf8
,
true
);
const
DatabaseSelection
selection
(
uri_utf8
,
true
);
return
db_selection_print
(
client
,
selection
,
false
,
error
);
return
db_selection_print
(
client
,
selection
,
false
,
error
);
}
}
bool
bool
printInfoForAllIn
(
Client
*
client
,
const
char
*
uri_utf8
,
printInfoForAllIn
(
Client
&
client
,
const
char
*
uri_utf8
,
Error
&
error
)
Error
&
error
)
{
{
const
DatabaseSelection
selection
(
uri_utf8
,
true
);
const
DatabaseSelection
selection
(
uri_utf8
,
true
);
...
@@ -200,15 +200,15 @@ printInfoForAllIn(Client *client, const char *uri_utf8,
...
@@ -200,15 +200,15 @@ printInfoForAllIn(Client *client, const char *uri_utf8,
}
}
static
bool
static
bool
PrintSongURIVisitor
(
Client
*
client
,
Song
&
song
)
PrintSongURIVisitor
(
Client
&
client
,
Song
&
song
)
{
{
song_print_uri
(
client
,
&
song
);
song_print_uri
(
client
,
song
);
return
true
;
return
true
;
}
}
static
bool
static
bool
PrintUniqueTag
(
Client
*
client
,
enum
tag_type
tag_type
,
PrintUniqueTag
(
Client
&
client
,
enum
tag_type
tag_type
,
const
char
*
value
)
const
char
*
value
)
{
{
client_printf
(
client
,
"%s: %s
\n
"
,
tag_item_names
[
tag_type
],
value
);
client_printf
(
client
,
"%s: %s
\n
"
,
tag_item_names
[
tag_type
],
value
);
...
@@ -216,7 +216,7 @@ PrintUniqueTag(Client *client, enum tag_type tag_type,
...
@@ -216,7 +216,7 @@ PrintUniqueTag(Client *client, enum tag_type tag_type,
}
}
bool
bool
listAllUniqueTags
(
Client
*
client
,
int
type
,
listAllUniqueTags
(
Client
&
client
,
int
type
,
const
SongFilter
*
filter
,
const
SongFilter
*
filter
,
Error
&
error
)
Error
&
error
)
{
{
...
@@ -228,11 +228,12 @@ listAllUniqueTags(Client *client, int type,
...
@@ -228,11 +228,12 @@ listAllUniqueTags(Client *client, int type,
if
(
type
==
LOCATE_TAG_FILE_TYPE
)
{
if
(
type
==
LOCATE_TAG_FILE_TYPE
)
{
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
PrintSongURIVisitor
,
client
,
_1
);
const
auto
f
=
std
::
bind
(
PrintSongURIVisitor
,
std
::
ref
(
client
),
_1
);
return
db
->
Visit
(
selection
,
f
,
error
);
return
db
->
Visit
(
selection
,
f
,
error
);
}
else
{
}
else
{
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
PrintUniqueTag
,
client
,
const
auto
f
=
std
::
bind
(
PrintUniqueTag
,
std
::
ref
(
client
)
,
(
enum
tag_type
)
type
,
_1
);
(
enum
tag_type
)
type
,
_1
);
return
db
->
VisitUniqueTags
(
selection
,
(
enum
tag_type
)
type
,
return
db
->
VisitUniqueTags
(
selection
,
(
enum
tag_type
)
type
,
f
,
error
);
f
,
error
);
...
...
src/DatabasePrint.hxx
View file @
ff626ac7
...
@@ -28,29 +28,27 @@ struct db_visitor;
...
@@ -28,29 +28,27 @@ struct db_visitor;
class
Client
;
class
Client
;
class
Error
;
class
Error
;
gcc_nonnull
(
1
)
bool
bool
db_selection_print
(
Client
*
client
,
const
DatabaseSelection
&
selection
,
db_selection_print
(
Client
&
client
,
const
DatabaseSelection
&
selection
,
bool
full
,
Error
&
error
);
bool
full
,
Error
&
error
);
gcc_nonnull
(
1
,
2
)
gcc_nonnull
(
2
)
bool
bool
printAllIn
(
Client
*
client
,
const
char
*
uri_utf8
,
Error
&
error
);
printAllIn
(
Client
&
client
,
const
char
*
uri_utf8
,
Error
&
error
);
gcc_nonnull
(
1
,
2
)
gcc_nonnull
(
2
)
bool
bool
printInfoForAllIn
(
Client
*
client
,
const
char
*
uri_utf8
,
printInfoForAllIn
(
Client
&
client
,
const
char
*
uri_utf8
,
Error
&
error
);
Error
&
error
);
gcc_nonnull
(
1
,
2
)
gcc_nonnull
(
2
)
bool
bool
searchStatsForSongsIn
(
Client
*
client
,
const
char
*
name
,
searchStatsForSongsIn
(
Client
&
client
,
const
char
*
name
,
const
SongFilter
*
filter
,
const
SongFilter
*
filter
,
Error
&
error
);
Error
&
error
);
gcc_nonnull
(
1
)
bool
bool
listAllUniqueTags
(
Client
*
client
,
int
type
,
listAllUniqueTags
(
Client
&
client
,
int
type
,
const
SongFilter
*
filter
,
const
SongFilter
*
filter
,
Error
&
error
);
Error
&
error
);
...
...
src/DatabaseSave.cxx
View file @
ff626ac7
...
@@ -49,10 +49,8 @@ enum {
...
@@ -49,10 +49,8 @@ enum {
};
};
void
void
db_save_internal
(
FILE
*
fp
,
const
Directory
*
music_root
)
db_save_internal
(
FILE
*
fp
,
const
Directory
&
music_root
)
{
{
assert
(
music_root
!=
nullptr
);
fprintf
(
fp
,
"%s
\n
"
,
DIRECTORY_INFO_BEGIN
);
fprintf
(
fp
,
"%s
\n
"
,
DIRECTORY_INFO_BEGIN
);
fprintf
(
fp
,
DB_FORMAT_PREFIX
"%u
\n
"
,
DB_FORMAT
);
fprintf
(
fp
,
DB_FORMAT_PREFIX
"%u
\n
"
,
DB_FORMAT
);
fprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_MPD_VERSION
,
VERSION
);
fprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_MPD_VERSION
,
VERSION
);
...
@@ -68,7 +66,7 @@ db_save_internal(FILE *fp, const Directory *music_root)
...
@@ -68,7 +66,7 @@ db_save_internal(FILE *fp, const Directory *music_root)
}
}
bool
bool
db_load_internal
(
TextFile
&
file
,
Directory
*
music_root
,
Error
&
error
)
db_load_internal
(
TextFile
&
file
,
Directory
&
music_root
,
Error
&
error
)
{
{
char
*
line
;
char
*
line
;
int
format
=
0
;
int
format
=
0
;
...
@@ -76,8 +74,6 @@ db_load_internal(TextFile &file, Directory *music_root, Error &error)
...
@@ -76,8 +74,6 @@ db_load_internal(TextFile &file, Directory *music_root, Error &error)
bool
success
;
bool
success
;
bool
tags
[
TAG_NUM_OF_ITEM_TYPES
];
bool
tags
[
TAG_NUM_OF_ITEM_TYPES
];
assert
(
music_root
!=
nullptr
);
/* get initial info */
/* get initial info */
line
=
file
.
ReadLine
();
line
=
file
.
ReadLine
();
if
(
line
==
nullptr
||
strcmp
(
DIRECTORY_INFO_BEGIN
,
line
)
!=
0
)
{
if
(
line
==
nullptr
||
strcmp
(
DIRECTORY_INFO_BEGIN
,
line
)
!=
0
)
{
...
...
src/DatabaseSave.hxx
View file @
ff626ac7
...
@@ -27,9 +27,9 @@ class TextFile;
...
@@ -27,9 +27,9 @@ class TextFile;
class
Error
;
class
Error
;
void
void
db_save_internal
(
FILE
*
file
,
const
Directory
*
root
);
db_save_internal
(
FILE
*
file
,
const
Directory
&
root
);
bool
bool
db_load_internal
(
TextFile
&
file
,
Directory
*
root
,
Error
&
error
);
db_load_internal
(
TextFile
&
file
,
Directory
&
root
,
Error
&
error
);
#endif
#endif
src/DecoderAPI.cxx
View file @
ff626ac7
...
@@ -41,11 +41,11 @@ decoder_initialized(struct decoder *decoder,
...
@@ -41,11 +41,11 @@ decoder_initialized(struct decoder *decoder,
const
AudioFormat
audio_format
,
const
AudioFormat
audio_format
,
bool
seekable
,
float
total_time
)
bool
seekable
,
float
total_time
)
{
{
struct
decoder_control
*
dc
=
decoder
->
dc
;
decoder_control
&
dc
=
decoder
->
dc
;
struct
audio_format_string
af_string
;
struct
audio_format_string
af_string
;
assert
(
dc
->
state
==
DecoderState
::
START
);
assert
(
dc
.
state
==
DecoderState
::
START
);
assert
(
dc
->
pipe
!=
nullptr
);
assert
(
dc
.
pipe
!=
nullptr
);
assert
(
decoder
!=
nullptr
);
assert
(
decoder
!=
nullptr
);
assert
(
decoder
->
stream_tag
==
nullptr
);
assert
(
decoder
->
stream_tag
==
nullptr
);
assert
(
decoder
->
decoder_tag
==
nullptr
);
assert
(
decoder
->
decoder_tag
==
nullptr
);
...
@@ -53,24 +53,24 @@ decoder_initialized(struct decoder *decoder,
...
@@ -53,24 +53,24 @@ decoder_initialized(struct decoder *decoder,
assert
(
audio_format
.
IsDefined
());
assert
(
audio_format
.
IsDefined
());
assert
(
audio_format
.
IsValid
());
assert
(
audio_format
.
IsValid
());
dc
->
in_audio_format
=
audio_format
;
dc
.
in_audio_format
=
audio_format
;
dc
->
out_audio_format
=
getOutputAudioFormat
(
audio_format
);
dc
.
out_audio_format
=
getOutputAudioFormat
(
audio_format
);
dc
->
seekable
=
seekable
;
dc
.
seekable
=
seekable
;
dc
->
total_time
=
total_time
;
dc
.
total_time
=
total_time
;
dc
->
Lock
();
dc
.
Lock
();
dc
->
state
=
DecoderState
::
DECODE
;
dc
.
state
=
DecoderState
::
DECODE
;
dc
->
client_cond
.
signal
();
dc
.
client_cond
.
signal
();
dc
->
Unlock
();
dc
.
Unlock
();
FormatDebug
(
decoder_domain
,
"audio_format=%s, seekable=%s"
,
FormatDebug
(
decoder_domain
,
"audio_format=%s, seekable=%s"
,
audio_format_to_string
(
dc
->
in_audio_format
,
&
af_string
),
audio_format_to_string
(
dc
.
in_audio_format
,
&
af_string
),
seekable
?
"true"
:
"false"
);
seekable
?
"true"
:
"false"
);
if
(
dc
->
in_audio_format
!=
dc
->
out_audio_format
)
if
(
dc
.
in_audio_format
!=
dc
.
out_audio_format
)
FormatDebug
(
decoder_domain
,
"converting to %s"
,
FormatDebug
(
decoder_domain
,
"converting to %s"
,
audio_format_to_string
(
dc
->
out_audio_format
,
audio_format_to_string
(
dc
.
out_audio_format
,
&
af_string
));
&
af_string
));
}
}
...
@@ -82,10 +82,10 @@ gcc_pure
...
@@ -82,10 +82,10 @@ gcc_pure
static
bool
static
bool
decoder_prepare_initial_seek
(
struct
decoder
*
decoder
)
decoder_prepare_initial_seek
(
struct
decoder
*
decoder
)
{
{
const
struct
decoder_control
*
dc
=
decoder
->
dc
;
const
decoder_control
&
dc
=
decoder
->
dc
;
assert
(
dc
->
pipe
!=
nullptr
);
assert
(
dc
.
pipe
!=
nullptr
);
if
(
dc
->
state
!=
DecoderState
::
DECODE
)
if
(
dc
.
state
!=
DecoderState
::
DECODE
)
/* wait until the decoder has finished initialisation
/* wait until the decoder has finished initialisation
(reading file headers etc.) before emitting the
(reading file headers etc.) before emitting the
virtual "SEEK" command */
virtual "SEEK" command */
...
@@ -97,13 +97,13 @@ decoder_prepare_initial_seek(struct decoder *decoder)
...
@@ -97,13 +97,13 @@ decoder_prepare_initial_seek(struct decoder *decoder)
return
true
;
return
true
;
if
(
decoder
->
initial_seek_pending
)
{
if
(
decoder
->
initial_seek_pending
)
{
if
(
!
dc
->
seekable
)
{
if
(
!
dc
.
seekable
)
{
/* seeking is not possible */
/* seeking is not possible */
decoder
->
initial_seek_pending
=
false
;
decoder
->
initial_seek_pending
=
false
;
return
false
;
return
false
;
}
}
if
(
dc
->
command
==
DecoderCommand
::
NONE
)
{
if
(
dc
.
command
==
DecoderCommand
::
NONE
)
{
/* begin initial seek */
/* begin initial seek */
decoder
->
initial_seek_pending
=
false
;
decoder
->
initial_seek_pending
=
false
;
...
@@ -129,13 +129,13 @@ gcc_pure
...
@@ -129,13 +129,13 @@ gcc_pure
static
DecoderCommand
static
DecoderCommand
decoder_get_virtual_command
(
struct
decoder
*
decoder
)
decoder_get_virtual_command
(
struct
decoder
*
decoder
)
{
{
const
struct
decoder_control
*
dc
=
decoder
->
dc
;
const
decoder_control
&
dc
=
decoder
->
dc
;
assert
(
dc
->
pipe
!=
nullptr
);
assert
(
dc
.
pipe
!=
nullptr
);
if
(
decoder_prepare_initial_seek
(
decoder
))
if
(
decoder_prepare_initial_seek
(
decoder
))
return
DecoderCommand
::
SEEK
;
return
DecoderCommand
::
SEEK
;
return
dc
->
command
;
return
dc
.
command
;
}
}
DecoderCommand
DecoderCommand
...
@@ -147,25 +147,25 @@ decoder_get_command(struct decoder *decoder)
...
@@ -147,25 +147,25 @@ decoder_get_command(struct decoder *decoder)
void
void
decoder_command_finished
(
struct
decoder
*
decoder
)
decoder_command_finished
(
struct
decoder
*
decoder
)
{
{
struct
decoder_control
*
dc
=
decoder
->
dc
;
decoder_control
&
dc
=
decoder
->
dc
;
dc
->
Lock
();
dc
.
Lock
();
assert
(
dc
->
command
!=
DecoderCommand
::
NONE
||
assert
(
dc
.
command
!=
DecoderCommand
::
NONE
||
decoder
->
initial_seek_running
);
decoder
->
initial_seek_running
);
assert
(
dc
->
command
!=
DecoderCommand
::
SEEK
||
assert
(
dc
.
command
!=
DecoderCommand
::
SEEK
||
decoder
->
initial_seek_running
||
decoder
->
initial_seek_running
||
dc
->
seek_error
||
decoder
->
seeking
);
dc
.
seek_error
||
decoder
->
seeking
);
assert
(
dc
->
pipe
!=
nullptr
);
assert
(
dc
.
pipe
!=
nullptr
);
if
(
decoder
->
initial_seek_running
)
{
if
(
decoder
->
initial_seek_running
)
{
assert
(
!
decoder
->
seeking
);
assert
(
!
decoder
->
seeking
);
assert
(
decoder
->
chunk
==
nullptr
);
assert
(
decoder
->
chunk
==
nullptr
);
assert
(
dc
->
pipe
->
IsEmpty
());
assert
(
dc
.
pipe
->
IsEmpty
());
decoder
->
initial_seek_running
=
false
;
decoder
->
initial_seek_running
=
false
;
decoder
->
timestamp
=
dc
->
start_ms
/
1000.
;
decoder
->
timestamp
=
dc
.
start_ms
/
1000.
;
dc
->
Unlock
();
dc
.
Unlock
();
return
;
return
;
}
}
...
@@ -175,41 +175,41 @@ decoder_command_finished(struct decoder *decoder)
...
@@ -175,41 +175,41 @@ decoder_command_finished(struct decoder *decoder)
/* delete frames from the old song position */
/* delete frames from the old song position */
if
(
decoder
->
chunk
!=
nullptr
)
{
if
(
decoder
->
chunk
!=
nullptr
)
{
dc
->
buffer
->
Return
(
decoder
->
chunk
);
dc
.
buffer
->
Return
(
decoder
->
chunk
);
decoder
->
chunk
=
nullptr
;
decoder
->
chunk
=
nullptr
;
}
}
dc
->
pipe
->
Clear
(
*
dc
->
buffer
);
dc
.
pipe
->
Clear
(
*
dc
.
buffer
);
decoder
->
timestamp
=
dc
->
seek_where
;
decoder
->
timestamp
=
dc
.
seek_where
;
}
}
dc
->
command
=
DecoderCommand
::
NONE
;
dc
.
command
=
DecoderCommand
::
NONE
;
dc
->
client_cond
.
signal
();
dc
.
client_cond
.
signal
();
dc
->
Unlock
();
dc
.
Unlock
();
}
}
double
decoder_seek_where
(
gcc_unused
struct
decoder
*
decoder
)
double
decoder_seek_where
(
gcc_unused
struct
decoder
*
decoder
)
{
{
const
struct
decoder_control
*
dc
=
decoder
->
dc
;
const
decoder_control
&
dc
=
decoder
->
dc
;
assert
(
dc
->
pipe
!=
nullptr
);
assert
(
dc
.
pipe
!=
nullptr
);
if
(
decoder
->
initial_seek_running
)
if
(
decoder
->
initial_seek_running
)
return
dc
->
start_ms
/
1000.
;
return
dc
.
start_ms
/
1000.
;
assert
(
dc
->
command
==
DecoderCommand
::
SEEK
);
assert
(
dc
.
command
==
DecoderCommand
::
SEEK
);
decoder
->
seeking
=
true
;
decoder
->
seeking
=
true
;
return
dc
->
seek_where
;
return
dc
.
seek_where
;
}
}
void
decoder_seek_error
(
struct
decoder
*
decoder
)
void
decoder_seek_error
(
struct
decoder
*
decoder
)
{
{
struct
decoder_control
*
dc
=
decoder
->
dc
;
decoder_control
&
dc
=
decoder
->
dc
;
assert
(
dc
->
pipe
!=
nullptr
);
assert
(
dc
.
pipe
!=
nullptr
);
if
(
decoder
->
initial_seek_running
)
{
if
(
decoder
->
initial_seek_running
)
{
/* d'oh, we can't seek to the sub-song start position,
/* d'oh, we can't seek to the sub-song start position,
...
@@ -218,9 +218,9 @@ void decoder_seek_error(struct decoder * decoder)
...
@@ -218,9 +218,9 @@ void decoder_seek_error(struct decoder * decoder)
return
;
return
;
}
}
assert
(
dc
->
command
==
DecoderCommand
::
SEEK
);
assert
(
dc
.
command
==
DecoderCommand
::
SEEK
);
dc
->
seek_error
=
true
;
dc
.
seek_error
=
true
;
decoder
->
seeking
=
false
;
decoder
->
seeking
=
false
;
decoder_command_finished
(
decoder
);
decoder_command_finished
(
decoder
);
...
@@ -237,14 +237,14 @@ decoder_check_cancel_read(const struct decoder *decoder)
...
@@ -237,14 +237,14 @@ decoder_check_cancel_read(const struct decoder *decoder)
if
(
decoder
==
nullptr
)
if
(
decoder
==
nullptr
)
return
false
;
return
false
;
const
struct
decoder_control
*
dc
=
decoder
->
dc
;
const
decoder_control
&
dc
=
decoder
->
dc
;
if
(
dc
->
command
==
DecoderCommand
::
NONE
)
if
(
dc
.
command
==
DecoderCommand
::
NONE
)
return
false
;
return
false
;
/* ignore the SEEK command during initialization, the plugin
/* ignore the SEEK command during initialization, the plugin
should handle that after it has initialized successfully */
should handle that after it has initialized successfully */
if
(
dc
->
command
==
DecoderCommand
::
SEEK
&&
if
(
dc
.
command
==
DecoderCommand
::
SEEK
&&
(
dc
->
state
==
DecoderState
::
START
||
decoder
->
seeking
))
(
dc
.
state
==
DecoderState
::
START
||
decoder
->
seeking
))
return
false
;
return
false
;
return
true
;
return
true
;
...
@@ -257,8 +257,8 @@ size_t decoder_read(struct decoder *decoder,
...
@@ -257,8 +257,8 @@ size_t decoder_read(struct decoder *decoder,
/* XXX don't allow decoder==nullptr */
/* XXX don't allow decoder==nullptr */
assert
(
decoder
==
nullptr
||
assert
(
decoder
==
nullptr
||
decoder
->
dc
->
state
==
DecoderState
::
START
||
decoder
->
dc
.
state
==
DecoderState
::
START
||
decoder
->
dc
->
state
==
DecoderState
::
DECODE
);
decoder
->
dc
.
state
==
DecoderState
::
DECODE
);
assert
(
is
!=
nullptr
);
assert
(
is
!=
nullptr
);
assert
(
buffer
!=
nullptr
);
assert
(
buffer
!=
nullptr
);
...
@@ -314,15 +314,15 @@ do_send_tag(struct decoder *decoder, const Tag &tag)
...
@@ -314,15 +314,15 @@ do_send_tag(struct decoder *decoder, const Tag &tag)
/* there is a partial chunk - flush it, we want the
/* there is a partial chunk - flush it, we want the
tag in a new chunk */
tag in a new chunk */
decoder_flush_chunk
(
decoder
);
decoder_flush_chunk
(
decoder
);
decoder
->
dc
->
client_cond
.
signal
();
decoder
->
dc
.
client_cond
.
signal
();
}
}
assert
(
decoder
->
chunk
==
nullptr
);
assert
(
decoder
->
chunk
==
nullptr
);
chunk
=
decoder_get_chunk
(
decoder
);
chunk
=
decoder_get_chunk
(
decoder
);
if
(
chunk
==
nullptr
)
{
if
(
chunk
==
nullptr
)
{
assert
(
decoder
->
dc
->
command
!=
DecoderCommand
::
NONE
);
assert
(
decoder
->
dc
.
command
!=
DecoderCommand
::
NONE
);
return
decoder
->
dc
->
command
;
return
decoder
->
dc
.
command
;
}
}
chunk
->
tag
=
new
Tag
(
tag
);
chunk
->
tag
=
new
Tag
(
tag
);
...
@@ -358,16 +358,16 @@ decoder_data(struct decoder *decoder,
...
@@ -358,16 +358,16 @@ decoder_data(struct decoder *decoder,
const
void
*
data
,
size_t
length
,
const
void
*
data
,
size_t
length
,
uint16_t
kbit_rate
)
uint16_t
kbit_rate
)
{
{
struct
decoder_control
*
dc
=
decoder
->
dc
;
decoder_control
&
dc
=
decoder
->
dc
;
DecoderCommand
cmd
;
DecoderCommand
cmd
;
assert
(
dc
->
state
==
DecoderState
::
DECODE
);
assert
(
dc
.
state
==
DecoderState
::
DECODE
);
assert
(
dc
->
pipe
!=
nullptr
);
assert
(
dc
.
pipe
!=
nullptr
);
assert
(
length
%
dc
->
in_audio_format
.
GetFrameSize
()
==
0
);
assert
(
length
%
dc
.
in_audio_format
.
GetFrameSize
()
==
0
);
dc
->
Lock
();
dc
.
Lock
();
cmd
=
decoder_get_virtual_command
(
decoder
);
cmd
=
decoder_get_virtual_command
(
decoder
);
dc
->
Unlock
();
dc
.
Unlock
();
if
(
cmd
==
DecoderCommand
::
STOP
||
cmd
==
DecoderCommand
::
SEEK
||
if
(
cmd
==
DecoderCommand
::
STOP
||
cmd
==
DecoderCommand
::
SEEK
||
length
==
0
)
length
==
0
)
...
@@ -390,11 +390,11 @@ decoder_data(struct decoder *decoder,
...
@@ -390,11 +390,11 @@ decoder_data(struct decoder *decoder,
return
cmd
;
return
cmd
;
}
}
if
(
dc
->
in_audio_format
!=
dc
->
out_audio_format
)
{
if
(
dc
.
in_audio_format
!=
dc
.
out_audio_format
)
{
Error
error
;
Error
error
;
data
=
decoder
->
conv_state
.
Convert
(
dc
->
in_audio_format
,
data
=
decoder
->
conv_state
.
Convert
(
dc
.
in_audio_format
,
data
,
length
,
data
,
length
,
dc
->
out_audio_format
,
dc
.
out_audio_format
,
&
length
,
&
length
,
error
);
error
);
if
(
data
==
nullptr
)
{
if
(
data
==
nullptr
)
{
...
@@ -413,18 +413,18 @@ decoder_data(struct decoder *decoder,
...
@@ -413,18 +413,18 @@ decoder_data(struct decoder *decoder,
chunk
=
decoder_get_chunk
(
decoder
);
chunk
=
decoder_get_chunk
(
decoder
);
if
(
chunk
==
nullptr
)
{
if
(
chunk
==
nullptr
)
{
assert
(
dc
->
command
!=
DecoderCommand
::
NONE
);
assert
(
dc
.
command
!=
DecoderCommand
::
NONE
);
return
dc
->
command
;
return
dc
.
command
;
}
}
void
*
dest
=
chunk
->
Write
(
dc
->
out_audio_format
,
void
*
dest
=
chunk
->
Write
(
dc
.
out_audio_format
,
decoder
->
timestamp
-
decoder
->
timestamp
-
dc
->
song
->
start_ms
/
1000.0
,
dc
.
song
->
start_ms
/
1000.0
,
kbit_rate
,
&
nbytes
);
kbit_rate
,
&
nbytes
);
if
(
dest
==
nullptr
)
{
if
(
dest
==
nullptr
)
{
/* the chunk is full, flush it */
/* the chunk is full, flush it */
decoder_flush_chunk
(
decoder
);
decoder_flush_chunk
(
decoder
);
dc
->
client_cond
.
signal
();
dc
.
client_cond
.
signal
();
continue
;
continue
;
}
}
...
@@ -439,21 +439,21 @@ decoder_data(struct decoder *decoder,
...
@@ -439,21 +439,21 @@ decoder_data(struct decoder *decoder,
/* expand the music pipe chunk */
/* expand the music pipe chunk */
full
=
chunk
->
Expand
(
dc
->
out_audio_format
,
nbytes
);
full
=
chunk
->
Expand
(
dc
.
out_audio_format
,
nbytes
);
if
(
full
)
{
if
(
full
)
{
/* the chunk is full, flush it */
/* the chunk is full, flush it */
decoder_flush_chunk
(
decoder
);
decoder_flush_chunk
(
decoder
);
dc
->
client_cond
.
signal
();
dc
.
client_cond
.
signal
();
}
}
data
=
(
const
uint8_t
*
)
data
+
nbytes
;
data
=
(
const
uint8_t
*
)
data
+
nbytes
;
length
-=
nbytes
;
length
-=
nbytes
;
decoder
->
timestamp
+=
(
double
)
nbytes
/
decoder
->
timestamp
+=
(
double
)
nbytes
/
dc
->
out_audio_format
.
GetTimeToSize
();
dc
.
out_audio_format
.
GetTimeToSize
();
if
(
dc
->
end_ms
>
0
&&
if
(
dc
.
end_ms
>
0
&&
decoder
->
timestamp
>=
dc
->
end_ms
/
1000.0
)
decoder
->
timestamp
>=
dc
.
end_ms
/
1000.0
)
/* the end of this range has been reached:
/* the end of this range has been reached:
stop decoding */
stop decoding */
return
DecoderCommand
::
STOP
;
return
DecoderCommand
::
STOP
;
...
@@ -466,11 +466,11 @@ DecoderCommand
...
@@ -466,11 +466,11 @@ DecoderCommand
decoder_tag
(
gcc_unused
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
decoder_tag
(
gcc_unused
struct
decoder
*
decoder
,
struct
input_stream
*
is
,
Tag
&&
tag
)
Tag
&&
tag
)
{
{
gcc_unused
const
struct
decoder_control
*
dc
=
decoder
->
dc
;
gcc_unused
const
decoder_control
&
dc
=
decoder
->
dc
;
DecoderCommand
cmd
;
DecoderCommand
cmd
;
assert
(
dc
->
state
==
DecoderState
::
DECODE
);
assert
(
dc
.
state
==
DecoderState
::
DECODE
);
assert
(
dc
->
pipe
!=
nullptr
);
assert
(
dc
.
pipe
!=
nullptr
);
/* save the tag */
/* save the tag */
...
@@ -522,7 +522,7 @@ decoder_replay_gain(struct decoder *decoder,
...
@@ -522,7 +522,7 @@ decoder_replay_gain(struct decoder *decoder,
if
(
rgm
!=
REPLAY_GAIN_ALBUM
)
if
(
rgm
!=
REPLAY_GAIN_ALBUM
)
rgm
=
REPLAY_GAIN_TRACK
;
rgm
=
REPLAY_GAIN_TRACK
;
decoder
->
dc
->
replay_gain_db
=
20.0
*
log10f
(
decoder
->
dc
.
replay_gain_db
=
20.0
*
log10f
(
replay_gain_tuple_scale
(
replay_gain_tuple_scale
(
&
replay_gain_info
->
tuples
[
rgm
],
&
replay_gain_info
->
tuples
[
rgm
],
replay_gain_preamp
,
replay_gain_missing_preamp
,
replay_gain_preamp
,
replay_gain_missing_preamp
,
...
@@ -537,7 +537,7 @@ decoder_replay_gain(struct decoder *decoder,
...
@@ -537,7 +537,7 @@ decoder_replay_gain(struct decoder *decoder,
replay gain values affect the following
replay gain values affect the following
samples */
samples */
decoder_flush_chunk
(
decoder
);
decoder_flush_chunk
(
decoder
);
decoder
->
dc
->
client_cond
.
signal
();
decoder
->
dc
.
client_cond
.
signal
();
}
}
}
else
}
else
decoder
->
replay_gain_serial
=
0
;
decoder
->
replay_gain_serial
=
0
;
...
@@ -548,9 +548,8 @@ decoder_mixramp(struct decoder *decoder,
...
@@ -548,9 +548,8 @@ decoder_mixramp(struct decoder *decoder,
char
*
mixramp_start
,
char
*
mixramp_end
)
char
*
mixramp_start
,
char
*
mixramp_end
)
{
{
assert
(
decoder
!=
nullptr
);
assert
(
decoder
!=
nullptr
);
struct
decoder_control
*
dc
=
decoder
->
dc
;
decoder_control
&
dc
=
decoder
->
dc
;
assert
(
dc
!=
nullptr
);
dc
->
MixRampStart
(
mixramp_start
);
dc
.
MixRampStart
(
mixramp_start
);
dc
->
MixRampEnd
(
mixramp_end
);
dc
.
MixRampEnd
(
mixramp_end
);
}
}
src/DecoderInternal.cxx
View file @
ff626ac7
...
@@ -42,17 +42,17 @@ decoder::~decoder()
...
@@ -42,17 +42,17 @@ decoder::~decoder()
* one.
* one.
*/
*/
static
DecoderCommand
static
DecoderCommand
need_chunks
(
struct
decoder_control
*
dc
,
bool
do_wait
)
need_chunks
(
decoder_control
&
dc
,
bool
do_wait
)
{
{
if
(
dc
->
command
==
DecoderCommand
::
STOP
||
if
(
dc
.
command
==
DecoderCommand
::
STOP
||
dc
->
command
==
DecoderCommand
::
SEEK
)
dc
.
command
==
DecoderCommand
::
SEEK
)
return
dc
->
command
;
return
dc
.
command
;
if
(
do_wait
)
{
if
(
do_wait
)
{
dc
->
Wait
();
dc
.
Wait
();
dc
->
client_cond
.
signal
();
dc
.
client_cond
.
signal
();
return
dc
->
command
;
return
dc
.
command
;
}
}
return
DecoderCommand
::
NONE
;
return
DecoderCommand
::
NONE
;
...
@@ -61,7 +61,7 @@ need_chunks(struct decoder_control *dc, bool do_wait)
...
@@ -61,7 +61,7 @@ need_chunks(struct decoder_control *dc, bool do_wait)
struct
music_chunk
*
struct
music_chunk
*
decoder_get_chunk
(
struct
decoder
*
decoder
)
decoder_get_chunk
(
struct
decoder
*
decoder
)
{
{
struct
decoder_control
*
dc
=
decoder
->
dc
;
decoder_control
&
dc
=
decoder
->
dc
;
DecoderCommand
cmd
;
DecoderCommand
cmd
;
assert
(
decoder
!=
nullptr
);
assert
(
decoder
!=
nullptr
);
...
@@ -70,7 +70,7 @@ decoder_get_chunk(struct decoder *decoder)
...
@@ -70,7 +70,7 @@ decoder_get_chunk(struct decoder *decoder)
return
decoder
->
chunk
;
return
decoder
->
chunk
;
do
{
do
{
decoder
->
chunk
=
dc
->
buffer
->
Allocate
();
decoder
->
chunk
=
dc
.
buffer
->
Allocate
();
if
(
decoder
->
chunk
!=
nullptr
)
{
if
(
decoder
->
chunk
!=
nullptr
)
{
decoder
->
chunk
->
replay_gain_serial
=
decoder
->
chunk
->
replay_gain_serial
=
decoder
->
replay_gain_serial
;
decoder
->
replay_gain_serial
;
...
@@ -81,9 +81,9 @@ decoder_get_chunk(struct decoder *decoder)
...
@@ -81,9 +81,9 @@ decoder_get_chunk(struct decoder *decoder)
return
decoder
->
chunk
;
return
decoder
->
chunk
;
}
}
dc
->
Lock
();
dc
.
Lock
();
cmd
=
need_chunks
(
dc
,
true
);
cmd
=
need_chunks
(
dc
,
true
);
dc
->
Unlock
();
dc
.
Unlock
();
}
while
(
cmd
==
DecoderCommand
::
NONE
);
}
while
(
cmd
==
DecoderCommand
::
NONE
);
return
nullptr
;
return
nullptr
;
...
@@ -92,15 +92,15 @@ decoder_get_chunk(struct decoder *decoder)
...
@@ -92,15 +92,15 @@ decoder_get_chunk(struct decoder *decoder)
void
void
decoder_flush_chunk
(
struct
decoder
*
decoder
)
decoder_flush_chunk
(
struct
decoder
*
decoder
)
{
{
struct
decoder_control
*
dc
=
decoder
->
dc
;
decoder_control
&
dc
=
decoder
->
dc
;
assert
(
decoder
!=
nullptr
);
assert
(
decoder
!=
nullptr
);
assert
(
decoder
->
chunk
!=
nullptr
);
assert
(
decoder
->
chunk
!=
nullptr
);
if
(
decoder
->
chunk
->
IsEmpty
())
if
(
decoder
->
chunk
->
IsEmpty
())
dc
->
buffer
->
Return
(
decoder
->
chunk
);
dc
.
buffer
->
Return
(
decoder
->
chunk
);
else
else
dc
->
pipe
->
Push
(
decoder
->
chunk
);
dc
.
pipe
->
Push
(
decoder
->
chunk
);
decoder
->
chunk
=
nullptr
;
decoder
->
chunk
=
nullptr
;
}
}
src/DecoderInternal.hxx
View file @
ff626ac7
...
@@ -24,11 +24,12 @@
...
@@ -24,11 +24,12 @@
#include "pcm/PcmConvert.hxx"
#include "pcm/PcmConvert.hxx"
#include "ReplayGainInfo.hxx"
#include "ReplayGainInfo.hxx"
struct
decoder_control
;
struct
input_stream
;
struct
input_stream
;
struct
Tag
;
struct
Tag
;
struct
decoder
{
struct
decoder
{
struct
decoder_control
*
dc
;
decoder_control
&
dc
;
PcmConvert
conv_state
;
PcmConvert
conv_state
;
...
@@ -82,7 +83,7 @@ struct decoder {
...
@@ -82,7 +83,7 @@ struct decoder {
*/
*/
unsigned
replay_gain_serial
;
unsigned
replay_gain_serial
;
decoder
(
decoder_control
*
_dc
,
bool
_initial_seek_pending
,
Tag
*
_tag
)
decoder
(
decoder_control
&
_dc
,
bool
_initial_seek_pending
,
Tag
*
_tag
)
:
dc
(
_dc
),
:
dc
(
_dc
),
timestamp
(
0
),
timestamp
(
0
),
initial_seek_pending
(
_initial_seek_pending
),
initial_seek_pending
(
_initial_seek_pending
),
...
...
src/DecoderList.cxx
View file @
ff626ac7
...
@@ -149,7 +149,7 @@ decoder_plugin_from_suffix(const char *suffix,
...
@@ -149,7 +149,7 @@ decoder_plugin_from_suffix(const char *suffix,
decoder_plugins
[
i
]
!=
nullptr
;
++
i
)
{
decoder_plugins
[
i
]
!=
nullptr
;
++
i
)
{
plugin
=
decoder_plugins
[
i
];
plugin
=
decoder_plugins
[
i
];
if
(
decoder_plugins_enabled
[
i
]
&&
if
(
decoder_plugins_enabled
[
i
]
&&
decoder_plugin_supports_suffix
(
plugin
,
suffix
))
decoder_plugin_supports_suffix
(
*
plugin
,
suffix
))
return
plugin
;
return
plugin
;
}
}
...
@@ -169,7 +169,7 @@ decoder_plugin_from_mime_type(const char *mimeType, unsigned int next)
...
@@ -169,7 +169,7 @@ decoder_plugin_from_mime_type(const char *mimeType, unsigned int next)
for
(;
decoder_plugins
[
i
]
!=
nullptr
;
++
i
)
{
for
(;
decoder_plugins
[
i
]
!=
nullptr
;
++
i
)
{
const
struct
decoder_plugin
*
plugin
=
decoder_plugins
[
i
];
const
struct
decoder_plugin
*
plugin
=
decoder_plugins
[
i
];
if
(
decoder_plugins_enabled
[
i
]
&&
if
(
decoder_plugins_enabled
[
i
]
&&
decoder_plugin_supports_mime_type
(
plugin
,
mimeType
))
{
decoder_plugin_supports_mime_type
(
*
plugin
,
mimeType
))
{
++
i
;
++
i
;
return
plugin
;
return
plugin
;
}
}
...
@@ -217,9 +217,9 @@ void decoder_plugin_init_all(void)
...
@@ -217,9 +217,9 @@ void decoder_plugin_init_all(void)
struct
config_param
empty
;
struct
config_param
empty
;
for
(
unsigned
i
=
0
;
decoder_plugins
[
i
]
!=
nullptr
;
++
i
)
{
for
(
unsigned
i
=
0
;
decoder_plugins
[
i
]
!=
nullptr
;
++
i
)
{
const
struct
decoder_plugin
*
plugin
=
decoder_plugins
[
i
];
const
decoder_plugin
&
plugin
=
*
decoder_plugins
[
i
];
const
struct
config_param
*
param
=
const
struct
config_param
*
param
=
decoder_plugin_config
(
plugin
->
name
);
decoder_plugin_config
(
plugin
.
name
);
if
(
param
==
nullptr
)
if
(
param
==
nullptr
)
param
=
&
empty
;
param
=
&
empty
;
...
@@ -235,5 +235,5 @@ void decoder_plugin_init_all(void)
...
@@ -235,5 +235,5 @@ void decoder_plugin_init_all(void)
void
decoder_plugin_deinit_all
(
void
)
void
decoder_plugin_deinit_all
(
void
)
{
{
decoder_plugins_for_each_enabled
(
plugin
)
decoder_plugins_for_each_enabled
(
plugin
)
decoder_plugin_finish
(
plugin
);
decoder_plugin_finish
(
*
plugin
);
}
}
src/DecoderPlugin.cxx
View file @
ff626ac7
...
@@ -24,24 +24,22 @@
...
@@ -24,24 +24,22 @@
#include <assert.h>
#include <assert.h>
bool
bool
decoder_plugin_supports_suffix
(
const
struct
decoder_plugin
*
plugin
,
decoder_plugin_supports_suffix
(
const
decoder_plugin
&
plugin
,
const
char
*
suffix
)
const
char
*
suffix
)
{
{
assert
(
plugin
!=
nullptr
);
assert
(
suffix
!=
nullptr
);
assert
(
suffix
!=
nullptr
);
return
plugin
->
suffixes
!=
nullptr
&&
return
plugin
.
suffixes
!=
nullptr
&&
string_array_contains
(
plugin
->
suffixes
,
suffix
);
string_array_contains
(
plugin
.
suffixes
,
suffix
);
}
}
bool
bool
decoder_plugin_supports_mime_type
(
const
struct
decoder_plugin
*
plugin
,
decoder_plugin_supports_mime_type
(
const
decoder_plugin
&
plugin
,
const
char
*
mime_type
)
const
char
*
mime_type
)
{
{
assert
(
plugin
!=
nullptr
);
assert
(
mime_type
!=
nullptr
);
assert
(
mime_type
!=
nullptr
);
return
plugin
->
mime_types
!=
nullptr
&&
return
plugin
.
mime_types
!=
nullptr
&&
string_array_contains
(
plugin
->
mime_types
,
mime_type
);
string_array_contains
(
plugin
.
mime_types
,
mime_type
);
}
}
src/DecoderPlugin.hxx
View file @
ff626ac7
...
@@ -111,11 +111,11 @@ struct decoder_plugin {
...
@@ -111,11 +111,11 @@ struct decoder_plugin {
* the plugin is not available
* the plugin is not available
*/
*/
static
inline
bool
static
inline
bool
decoder_plugin_init
(
const
struct
decoder_plugin
*
plugin
,
decoder_plugin_init
(
const
decoder_plugin
&
plugin
,
const
config_param
&
param
)
const
config_param
&
param
)
{
{
return
plugin
->
init
!=
nullptr
return
plugin
.
init
!=
nullptr
?
plugin
->
init
(
param
)
?
plugin
.
init
(
param
)
:
true
;
:
true
;
}
}
...
@@ -123,42 +123,42 @@ decoder_plugin_init(const struct decoder_plugin *plugin,
...
@@ -123,42 +123,42 @@ decoder_plugin_init(const struct decoder_plugin *plugin,
* Deinitialize a decoder plugin which was initialized successfully.
* Deinitialize a decoder plugin which was initialized successfully.
*/
*/
static
inline
void
static
inline
void
decoder_plugin_finish
(
const
struct
decoder_plugin
*
plugin
)
decoder_plugin_finish
(
const
decoder_plugin
&
plugin
)
{
{
if
(
plugin
->
finish
!=
nullptr
)
if
(
plugin
.
finish
!=
nullptr
)
plugin
->
finish
();
plugin
.
finish
();
}
}
/**
/**
* Decode a stream.
* Decode a stream.
*/
*/
static
inline
void
static
inline
void
decoder_plugin_stream_decode
(
const
struct
decoder_plugin
*
plugin
,
decoder_plugin_stream_decode
(
const
decoder_plugin
&
plugin
,
struct
decoder
*
decoder
,
struct
input_stream
*
is
)
struct
decoder
*
decoder
,
struct
input_stream
*
is
)
{
{
plugin
->
stream_decode
(
decoder
,
is
);
plugin
.
stream_decode
(
decoder
,
is
);
}
}
/**
/**
* Decode a file.
* Decode a file.
*/
*/
static
inline
void
static
inline
void
decoder_plugin_file_decode
(
const
struct
decoder_plugin
*
plugin
,
decoder_plugin_file_decode
(
const
decoder_plugin
&
plugin
,
struct
decoder
*
decoder
,
const
char
*
path_fs
)
struct
decoder
*
decoder
,
const
char
*
path_fs
)
{
{
plugin
->
file_decode
(
decoder
,
path_fs
);
plugin
.
file_decode
(
decoder
,
path_fs
);
}
}
/**
/**
* Read the tag of a file.
* Read the tag of a file.
*/
*/
static
inline
bool
static
inline
bool
decoder_plugin_scan_file
(
const
struct
decoder_plugin
*
plugin
,
decoder_plugin_scan_file
(
const
decoder_plugin
&
plugin
,
const
char
*
path_fs
,
const
char
*
path_fs
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
{
return
plugin
->
scan_file
!=
nullptr
return
plugin
.
scan_file
!=
nullptr
?
plugin
->
scan_file
(
path_fs
,
handler
,
handler_ctx
)
?
plugin
.
scan_file
(
path_fs
,
handler
,
handler_ctx
)
:
false
;
:
false
;
}
}
...
@@ -166,13 +166,13 @@ decoder_plugin_scan_file(const struct decoder_plugin *plugin,
...
@@ -166,13 +166,13 @@ decoder_plugin_scan_file(const struct decoder_plugin *plugin,
* Read the tag of a stream.
* Read the tag of a stream.
*/
*/
static
inline
bool
static
inline
bool
decoder_plugin_scan_stream
(
const
struct
decoder_plugin
*
plugin
,
decoder_plugin_scan_stream
(
const
decoder_plugin
&
plugin
,
struct
input_stream
*
is
,
struct
input_stream
*
is
,
const
struct
tag_handler
*
handler
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
void
*
handler_ctx
)
{
{
return
plugin
->
scan_stream
!=
nullptr
return
plugin
.
scan_stream
!=
nullptr
?
plugin
->
scan_stream
(
is
,
handler
,
handler_ctx
)
?
plugin
.
scan_stream
(
is
,
handler
,
handler_ctx
)
:
false
;
:
false
;
}
}
...
@@ -180,25 +180,25 @@ decoder_plugin_scan_stream(const struct decoder_plugin *plugin,
...
@@ -180,25 +180,25 @@ decoder_plugin_scan_stream(const struct decoder_plugin *plugin,
* return "virtual" tracks in a container
* return "virtual" tracks in a container
*/
*/
static
inline
char
*
static
inline
char
*
decoder_plugin_container_scan
(
const
struct
decoder_plugin
*
plugin
,
decoder_plugin_container_scan
(
const
decoder_plugin
&
plugin
,
const
char
*
pathname
,
const
char
*
pathname
,
const
unsigned
int
tnum
)
const
unsigned
int
tnum
)
{
{
return
plugin
->
container_scan
(
pathname
,
tnum
);
return
plugin
.
container_scan
(
pathname
,
tnum
);
}
}
/**
/**
* Does the plugin announce the specified file name suffix?
* Does the plugin announce the specified file name suffix?
*/
*/
bool
bool
decoder_plugin_supports_suffix
(
const
struct
decoder_plugin
*
plugin
,
decoder_plugin_supports_suffix
(
const
decoder_plugin
&
plugin
,
const
char
*
suffix
);
const
char
*
suffix
);
/**
/**
* Does the plugin announce the specified MIME type?
* Does the plugin announce the specified MIME type?
*/
*/
bool
bool
decoder_plugin_supports_mime_type
(
const
struct
decoder_plugin
*
plugin
,
decoder_plugin_supports_mime_type
(
const
decoder_plugin
&
plugin
,
const
char
*
mime_type
);
const
char
*
mime_type
);
#endif
#endif
src/DecoderPrint.cxx
View file @
ff626ac7
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include <assert.h>
#include <assert.h>
static
void
static
void
decoder_plugin_print
(
Client
*
client
,
decoder_plugin_print
(
Client
&
client
,
const
struct
decoder_plugin
*
plugin
)
const
struct
decoder_plugin
*
plugin
)
{
{
const
char
*
const
*
p
;
const
char
*
const
*
p
;
...
@@ -46,7 +46,7 @@ decoder_plugin_print(Client *client,
...
@@ -46,7 +46,7 @@ decoder_plugin_print(Client *client,
}
}
void
void
decoder_list_print
(
Client
*
client
)
decoder_list_print
(
Client
&
client
)
{
{
decoder_plugins_for_each_enabled
(
plugin
)
decoder_plugins_for_each_enabled
(
plugin
)
decoder_plugin_print
(
client
,
plugin
);
decoder_plugin_print
(
client
,
plugin
);
...
...
src/DecoderPrint.hxx
View file @
ff626ac7
...
@@ -23,6 +23,6 @@
...
@@ -23,6 +23,6 @@
class
Client
;
class
Client
;
void
void
decoder_list_print
(
Client
*
client
);
decoder_list_print
(
Client
&
client
);
#endif
#endif
src/DecoderThread.cxx
View file @
ff626ac7
...
@@ -52,13 +52,13 @@ static constexpr Domain decoder_thread_domain("decoder_thread");
...
@@ -52,13 +52,13 @@ static constexpr Domain decoder_thread_domain("decoder_thread");
* @param dc the #decoder_control object; must be locked
* @param dc the #decoder_control object; must be locked
*/
*/
static
void
static
void
decoder_command_finished_locked
(
struct
decoder_control
*
dc
)
decoder_command_finished_locked
(
decoder_control
&
dc
)
{
{
assert
(
dc
->
command
!=
DecoderCommand
::
NONE
);
assert
(
dc
.
command
!=
DecoderCommand
::
NONE
);
dc
->
command
=
DecoderCommand
::
NONE
;
dc
.
command
=
DecoderCommand
::
NONE
;
dc
->
client_cond
.
signal
();
dc
.
client_cond
.
signal
();
}
}
/**
/**
...
@@ -73,11 +73,11 @@ decoder_command_finished_locked(struct decoder_control *dc)
...
@@ -73,11 +73,11 @@ decoder_command_finished_locked(struct decoder_control *dc)
* received, nullptr on error
* received, nullptr on error
*/
*/
static
struct
input_stream
*
static
struct
input_stream
*
decoder_input_stream_open
(
struct
decoder_control
*
dc
,
const
char
*
uri
)
decoder_input_stream_open
(
decoder_control
&
dc
,
const
char
*
uri
)
{
{
Error
error
;
Error
error
;
input_stream
*
is
=
input_stream
::
Open
(
uri
,
dc
->
mutex
,
dc
->
cond
,
error
);
input_stream
*
is
=
input_stream
::
Open
(
uri
,
dc
.
mutex
,
dc
.
cond
,
error
);
if
(
is
==
nullptr
)
{
if
(
is
==
nullptr
)
{
if
(
error
.
IsDefined
())
if
(
error
.
IsDefined
())
LogError
(
error
);
LogError
(
error
);
...
@@ -88,90 +88,88 @@ decoder_input_stream_open(struct decoder_control *dc, const char *uri)
...
@@ -88,90 +88,88 @@ decoder_input_stream_open(struct decoder_control *dc, const char *uri)
/* wait for the input stream to become ready; its metadata
/* wait for the input stream to become ready; its metadata
will be available then */
will be available then */
dc
->
Lock
();
dc
.
Lock
();
is
->
Update
();
is
->
Update
();
while
(
!
is
->
ready
&&
while
(
!
is
->
ready
&&
dc
->
command
!=
DecoderCommand
::
STOP
)
{
dc
.
command
!=
DecoderCommand
::
STOP
)
{
dc
->
Wait
();
dc
.
Wait
();
is
->
Update
();
is
->
Update
();
}
}
if
(
!
is
->
Check
(
error
))
{
if
(
!
is
->
Check
(
error
))
{
dc
->
Unlock
();
dc
.
Unlock
();
LogError
(
error
);
LogError
(
error
);
return
nullptr
;
return
nullptr
;
}
}
dc
->
Unlock
();
dc
.
Unlock
();
return
is
;
return
is
;
}
}
static
bool
static
bool
decoder_stream_decode
(
const
struct
decoder_plugin
*
plugin
,
decoder_stream_decode
(
const
decoder_plugin
&
plugin
,
struct
decoder
*
decoder
,
struct
decoder
*
decoder
,
struct
input_stream
*
input_stream
)
struct
input_stream
*
input_stream
)
{
{
assert
(
plugin
!=
nullptr
);
assert
(
plugin
.
stream_decode
!=
nullptr
);
assert
(
plugin
->
stream_decode
!=
nullptr
);
assert
(
decoder
!=
nullptr
);
assert
(
decoder
!=
nullptr
);
assert
(
decoder
->
stream_tag
==
nullptr
);
assert
(
decoder
->
stream_tag
==
nullptr
);
assert
(
decoder
->
decoder_tag
==
nullptr
);
assert
(
decoder
->
decoder_tag
==
nullptr
);
assert
(
input_stream
!=
nullptr
);
assert
(
input_stream
!=
nullptr
);
assert
(
input_stream
->
ready
);
assert
(
input_stream
->
ready
);
assert
(
decoder
->
dc
->
state
==
DecoderState
::
START
);
assert
(
decoder
->
dc
.
state
==
DecoderState
::
START
);
FormatDebug
(
decoder_thread_domain
,
"probing plugin %s"
,
plugin
->
name
);
FormatDebug
(
decoder_thread_domain
,
"probing plugin %s"
,
plugin
.
name
);
if
(
decoder
->
dc
->
command
==
DecoderCommand
::
STOP
)
if
(
decoder
->
dc
.
command
==
DecoderCommand
::
STOP
)
return
true
;
return
true
;
/* rewind the stream, so each plugin gets a fresh start */
/* rewind the stream, so each plugin gets a fresh start */
input_stream
->
Seek
(
0
,
SEEK_SET
,
IgnoreError
());
input_stream
->
Seek
(
0
,
SEEK_SET
,
IgnoreError
());
decoder
->
dc
->
Unlock
();
decoder
->
dc
.
Unlock
();
decoder_plugin_stream_decode
(
plugin
,
decoder
,
input_stream
);
decoder_plugin_stream_decode
(
plugin
,
decoder
,
input_stream
);
decoder
->
dc
->
Lock
();
decoder
->
dc
.
Lock
();
assert
(
decoder
->
dc
->
state
==
DecoderState
::
START
||
assert
(
decoder
->
dc
.
state
==
DecoderState
::
START
||
decoder
->
dc
->
state
==
DecoderState
::
DECODE
);
decoder
->
dc
.
state
==
DecoderState
::
DECODE
);
return
decoder
->
dc
->
state
!=
DecoderState
::
START
;
return
decoder
->
dc
.
state
!=
DecoderState
::
START
;
}
}
static
bool
static
bool
decoder_file_decode
(
const
struct
decoder_plugin
*
plugin
,
decoder_file_decode
(
const
decoder_plugin
&
plugin
,
struct
decoder
*
decoder
,
const
char
*
path
)
struct
decoder
*
decoder
,
const
char
*
path
)
{
{
assert
(
plugin
!=
nullptr
);
assert
(
plugin
.
file_decode
!=
nullptr
);
assert
(
plugin
->
file_decode
!=
nullptr
);
assert
(
decoder
!=
nullptr
);
assert
(
decoder
!=
nullptr
);
assert
(
decoder
->
stream_tag
==
nullptr
);
assert
(
decoder
->
stream_tag
==
nullptr
);
assert
(
decoder
->
decoder_tag
==
nullptr
);
assert
(
decoder
->
decoder_tag
==
nullptr
);
assert
(
path
!=
nullptr
);
assert
(
path
!=
nullptr
);
assert
(
PathTraits
::
IsAbsoluteFS
(
path
));
assert
(
PathTraits
::
IsAbsoluteFS
(
path
));
assert
(
decoder
->
dc
->
state
==
DecoderState
::
START
);
assert
(
decoder
->
dc
.
state
==
DecoderState
::
START
);
FormatDebug
(
decoder_thread_domain
,
"probing plugin %s"
,
plugin
->
name
);
FormatDebug
(
decoder_thread_domain
,
"probing plugin %s"
,
plugin
.
name
);
if
(
decoder
->
dc
->
command
==
DecoderCommand
::
STOP
)
if
(
decoder
->
dc
.
command
==
DecoderCommand
::
STOP
)
return
true
;
return
true
;
decoder
->
dc
->
Unlock
();
decoder
->
dc
.
Unlock
();
decoder_plugin_file_decode
(
plugin
,
decoder
,
path
);
decoder_plugin_file_decode
(
plugin
,
decoder
,
path
);
decoder
->
dc
->
Lock
();
decoder
->
dc
.
Lock
();
assert
(
decoder
->
dc
->
state
==
DecoderState
::
START
||
assert
(
decoder
->
dc
.
state
==
DecoderState
::
START
||
decoder
->
dc
->
state
==
DecoderState
::
DECODE
);
decoder
->
dc
.
state
==
DecoderState
::
DECODE
);
return
decoder
->
dc
->
state
!=
DecoderState
::
START
;
return
decoder
->
dc
.
state
!=
DecoderState
::
START
;
}
}
/**
/**
...
@@ -209,7 +207,7 @@ decoder_run_stream_mime_type(struct decoder *decoder, struct input_stream *is,
...
@@ -209,7 +207,7 @@ decoder_run_stream_mime_type(struct decoder *decoder, struct input_stream *is,
/* don't try a plugin twice */
/* don't try a plugin twice */
continue
;
continue
;
if
(
decoder_stream_decode
(
plugin
,
decoder
,
is
))
if
(
decoder_stream_decode
(
*
plugin
,
decoder
,
is
))
return
true
;
return
true
;
*
tried_r
=
g_slist_prepend
(
*
tried_r
,
deconst_plugin
(
plugin
));
*
tried_r
=
g_slist_prepend
(
*
tried_r
,
deconst_plugin
(
plugin
));
...
@@ -244,7 +242,7 @@ decoder_run_stream_suffix(struct decoder *decoder, struct input_stream *is,
...
@@ -244,7 +242,7 @@ decoder_run_stream_suffix(struct decoder *decoder, struct input_stream *is,
/* don't try a plugin twice */
/* don't try a plugin twice */
continue
;
continue
;
if
(
decoder_stream_decode
(
plugin
,
decoder
,
is
))
if
(
decoder_stream_decode
(
*
plugin
,
decoder
,
is
))
return
true
;
return
true
;
*
tried_r
=
g_slist_prepend
(
*
tried_r
,
deconst_plugin
(
plugin
));
*
tried_r
=
g_slist_prepend
(
*
tried_r
,
deconst_plugin
(
plugin
));
...
@@ -263,7 +261,7 @@ decoder_run_stream_fallback(struct decoder *decoder, struct input_stream *is)
...
@@ -263,7 +261,7 @@ decoder_run_stream_fallback(struct decoder *decoder, struct input_stream *is)
plugin
=
decoder_plugin_from_name
(
"mad"
);
plugin
=
decoder_plugin_from_name
(
"mad"
);
return
plugin
!=
nullptr
&&
plugin
->
stream_decode
!=
nullptr
&&
return
plugin
!=
nullptr
&&
plugin
->
stream_decode
!=
nullptr
&&
decoder_stream_decode
(
plugin
,
decoder
,
is
);
decoder_stream_decode
(
*
plugin
,
decoder
,
is
);
}
}
/**
/**
...
@@ -272,23 +270,23 @@ decoder_run_stream_fallback(struct decoder *decoder, struct input_stream *is)
...
@@ -272,23 +270,23 @@ decoder_run_stream_fallback(struct decoder *decoder, struct input_stream *is)
static
bool
static
bool
decoder_run_stream
(
struct
decoder
*
decoder
,
const
char
*
uri
)
decoder_run_stream
(
struct
decoder
*
decoder
,
const
char
*
uri
)
{
{
struct
decoder_control
*
dc
=
decoder
->
dc
;
decoder_control
&
dc
=
decoder
->
dc
;
struct
input_stream
*
input_stream
;
struct
input_stream
*
input_stream
;
bool
success
;
bool
success
;
dc
->
Unlock
();
dc
.
Unlock
();
input_stream
=
decoder_input_stream_open
(
dc
,
uri
);
input_stream
=
decoder_input_stream_open
(
dc
,
uri
);
if
(
input_stream
==
nullptr
)
{
if
(
input_stream
==
nullptr
)
{
dc
->
Lock
();
dc
.
Lock
();
return
false
;
return
false
;
}
}
dc
->
Lock
();
dc
.
Lock
();
GSList
*
tried
=
nullptr
;
GSList
*
tried
=
nullptr
;
success
=
dc
->
command
==
DecoderCommand
::
STOP
||
success
=
dc
.
command
==
DecoderCommand
::
STOP
||
/* first we try mime types: */
/* first we try mime types: */
decoder_run_stream_mime_type
(
decoder
,
input_stream
,
&
tried
)
||
decoder_run_stream_mime_type
(
decoder
,
input_stream
,
&
tried
)
||
/* if that fails, try suffix matching the URL: */
/* if that fails, try suffix matching the URL: */
...
@@ -301,9 +299,9 @@ decoder_run_stream(struct decoder *decoder, const char *uri)
...
@@ -301,9 +299,9 @@ decoder_run_stream(struct decoder *decoder, const char *uri)
g_slist_free
(
tried
);
g_slist_free
(
tried
);
dc
->
Unlock
();
dc
.
Unlock
();
input_stream
->
Close
();
input_stream
->
Close
();
dc
->
Lock
();
dc
.
Lock
();
return
success
;
return
success
;
}
}
...
@@ -326,25 +324,25 @@ decoder_load_replay_gain(struct decoder *decoder, const char *path_fs)
...
@@ -326,25 +324,25 @@ decoder_load_replay_gain(struct decoder *decoder, const char *path_fs)
static
bool
static
bool
decoder_run_file
(
struct
decoder
*
decoder
,
const
char
*
path_fs
)
decoder_run_file
(
struct
decoder
*
decoder
,
const
char
*
path_fs
)
{
{
struct
decoder_control
*
dc
=
decoder
->
dc
;
decoder_control
&
dc
=
decoder
->
dc
;
const
char
*
suffix
=
uri_get_suffix
(
path_fs
);
const
char
*
suffix
=
uri_get_suffix
(
path_fs
);
const
struct
decoder_plugin
*
plugin
=
nullptr
;
const
struct
decoder_plugin
*
plugin
=
nullptr
;
if
(
suffix
==
nullptr
)
if
(
suffix
==
nullptr
)
return
false
;
return
false
;
dc
->
Unlock
();
dc
.
Unlock
();
decoder_load_replay_gain
(
decoder
,
path_fs
);
decoder_load_replay_gain
(
decoder
,
path_fs
);
while
((
plugin
=
decoder_plugin_from_suffix
(
suffix
,
plugin
))
!=
nullptr
)
{
while
((
plugin
=
decoder_plugin_from_suffix
(
suffix
,
plugin
))
!=
nullptr
)
{
if
(
plugin
->
file_decode
!=
nullptr
)
{
if
(
plugin
->
file_decode
!=
nullptr
)
{
dc
->
Lock
();
dc
.
Lock
();
if
(
decoder_file_decode
(
plugin
,
decoder
,
path_fs
))
if
(
decoder_file_decode
(
*
plugin
,
decoder
,
path_fs
))
return
true
;
return
true
;
dc
->
Unlock
();
dc
.
Unlock
();
}
else
if
(
plugin
->
stream_decode
!=
nullptr
)
{
}
else
if
(
plugin
->
stream_decode
!=
nullptr
)
{
struct
input_stream
*
input_stream
;
struct
input_stream
*
input_stream
;
bool
success
;
bool
success
;
...
@@ -353,36 +351,36 @@ decoder_run_file(struct decoder *decoder, const char *path_fs)
...
@@ -353,36 +351,36 @@ decoder_run_file(struct decoder *decoder, const char *path_fs)
if
(
input_stream
==
nullptr
)
if
(
input_stream
==
nullptr
)
continue
;
continue
;
dc
->
Lock
();
dc
.
Lock
();
success
=
decoder_stream_decode
(
plugin
,
decoder
,
success
=
decoder_stream_decode
(
*
plugin
,
decoder
,
input_stream
);
input_stream
);
dc
->
Unlock
();
dc
.
Unlock
();
input_stream
->
Close
();
input_stream
->
Close
();
if
(
success
)
{
if
(
success
)
{
dc
->
Lock
();
dc
.
Lock
();
return
true
;
return
true
;
}
}
}
}
}
}
dc
->
Lock
();
dc
.
Lock
();
return
false
;
return
false
;
}
}
static
void
static
void
decoder_run_song
(
struct
decoder_control
*
dc
,
decoder_run_song
(
decoder_control
&
dc
,
const
Song
*
song
,
const
char
*
uri
)
const
Song
*
song
,
const
char
*
uri
)
{
{
decoder
decoder
(
dc
,
dc
->
start_ms
>
0
,
decoder
decoder
(
dc
,
dc
.
start_ms
>
0
,
song
->
tag
!=
nullptr
&&
song
->
IsFile
()
song
->
tag
!=
nullptr
&&
song
->
IsFile
()
?
new
Tag
(
*
song
->
tag
)
:
nullptr
);
?
new
Tag
(
*
song
->
tag
)
:
nullptr
);
int
ret
;
int
ret
;
dc
->
state
=
DecoderState
::
START
;
dc
.
state
=
DecoderState
::
START
;
decoder_command_finished_locked
(
dc
);
decoder_command_finished_locked
(
dc
);
...
@@ -390,48 +388,48 @@ decoder_run_song(struct decoder_control *dc,
...
@@ -390,48 +388,48 @@ decoder_run_song(struct decoder_control *dc,
?
decoder_run_file
(
&
decoder
,
uri
)
?
decoder_run_file
(
&
decoder
,
uri
)
:
decoder_run_stream
(
&
decoder
,
uri
);
:
decoder_run_stream
(
&
decoder
,
uri
);
dc
->
Unlock
();
dc
.
Unlock
();
/* flush the last chunk */
/* flush the last chunk */
if
(
decoder
.
chunk
!=
nullptr
)
if
(
decoder
.
chunk
!=
nullptr
)
decoder_flush_chunk
(
&
decoder
);
decoder_flush_chunk
(
&
decoder
);
dc
->
Lock
();
dc
.
Lock
();
if
(
ret
)
if
(
ret
)
dc
->
state
=
DecoderState
::
STOP
;
dc
.
state
=
DecoderState
::
STOP
;
else
{
else
{
dc
->
state
=
DecoderState
::
ERROR
;
dc
.
state
=
DecoderState
::
ERROR
;
const
char
*
error_uri
=
song
->
uri
;
const
char
*
error_uri
=
song
->
uri
;
char
*
allocated
=
uri_remove_auth
(
error_uri
);
char
*
allocated
=
uri_remove_auth
(
error_uri
);
if
(
allocated
!=
nullptr
)
if
(
allocated
!=
nullptr
)
error_uri
=
allocated
;
error_uri
=
allocated
;
dc
->
error
.
Format
(
decoder_domain
,
dc
.
error
.
Format
(
decoder_domain
,
"Failed to decode %s"
,
error_uri
);
"Failed to decode %s"
,
error_uri
);
g_free
(
allocated
);
g_free
(
allocated
);
}
}
dc
->
client_cond
.
signal
();
dc
.
client_cond
.
signal
();
}
}
static
void
static
void
decoder_run
(
struct
decoder_control
*
dc
)
decoder_run
(
decoder_control
&
dc
)
{
{
dc
->
ClearError
();
dc
.
ClearError
();
const
Song
*
song
=
dc
->
song
;
const
Song
*
song
=
dc
.
song
;
assert
(
song
!=
nullptr
);
assert
(
song
!=
nullptr
);
const
std
::
string
uri
=
song
->
IsFile
()
const
std
::
string
uri
=
song
->
IsFile
()
?
std
::
string
(
map_song_fs
(
song
).
c_str
())
?
std
::
string
(
map_song_fs
(
*
song
).
c_str
())
:
song
->
GetURI
();
:
song
->
GetURI
();
if
(
uri
.
empty
())
{
if
(
uri
.
empty
())
{
dc
->
state
=
DecoderState
::
ERROR
;
dc
.
state
=
DecoderState
::
ERROR
;
dc
->
error
.
Set
(
decoder_domain
,
"Failed to map song"
);
dc
.
error
.
Set
(
decoder_domain
,
"Failed to map song"
);
decoder_command_finished_locked
(
dc
);
decoder_command_finished_locked
(
dc
);
return
;
return
;
...
@@ -444,21 +442,21 @@ decoder_run(struct decoder_control *dc)
...
@@ -444,21 +442,21 @@ decoder_run(struct decoder_control *dc)
static
void
static
void
decoder_task
(
void
*
arg
)
decoder_task
(
void
*
arg
)
{
{
struct
decoder_control
*
dc
=
(
struct
decoder_control
*
)
arg
;
decoder_control
&
dc
=
*
(
decoder_control
*
)
arg
;
dc
->
Lock
();
dc
.
Lock
();
do
{
do
{
assert
(
dc
->
state
==
DecoderState
::
STOP
||
assert
(
dc
.
state
==
DecoderState
::
STOP
||
dc
->
state
==
DecoderState
::
ERROR
);
dc
.
state
==
DecoderState
::
ERROR
);
switch
(
dc
->
command
)
{
switch
(
dc
.
command
)
{
case
DecoderCommand
:
:
START
:
case
DecoderCommand
:
:
START
:
dc
->
MixRampStart
(
nullptr
);
dc
.
MixRampStart
(
nullptr
);
dc
->
MixRampPrevEnd
(
dc
->
mixramp_end
);
dc
.
MixRampPrevEnd
(
dc
.
mixramp_end
);
dc
->
mixramp_end
=
nullptr
;
/* Don't free, it's copied above. */
dc
.
mixramp_end
=
nullptr
;
/* Don't free, it's copied above. */
dc
->
replay_gain_prev_db
=
dc
->
replay_gain_db
;
dc
.
replay_gain_prev_db
=
dc
.
replay_gain_db
;
dc
->
replay_gain_db
=
0
;
dc
.
replay_gain_db
=
0
;
/* fall through */
/* fall through */
...
@@ -471,22 +469,22 @@ decoder_task(void *arg)
...
@@ -471,22 +469,22 @@ decoder_task(void *arg)
break
;
break
;
case
DecoderCommand
:
:
NONE
:
case
DecoderCommand
:
:
NONE
:
dc
->
Wait
();
dc
.
Wait
();
break
;
break
;
}
}
}
while
(
dc
->
command
!=
DecoderCommand
::
NONE
||
!
dc
->
quit
);
}
while
(
dc
.
command
!=
DecoderCommand
::
NONE
||
!
dc
.
quit
);
dc
->
Unlock
();
dc
.
Unlock
();
}
}
void
void
decoder_thread_start
(
struct
decoder_control
*
dc
)
decoder_thread_start
(
decoder_control
&
dc
)
{
{
assert
(
!
dc
->
thread
.
IsDefined
());
assert
(
!
dc
.
thread
.
IsDefined
());
dc
->
quit
=
false
;
dc
.
quit
=
false
;
Error
error
;
Error
error
;
if
(
!
dc
->
thread
.
Start
(
decoder_task
,
dc
,
error
))
if
(
!
dc
.
thread
.
Start
(
decoder_task
,
&
dc
,
error
))
FatalError
(
error
);
FatalError
(
error
);
}
}
src/DecoderThread.hxx
View file @
ff626ac7
...
@@ -23,6 +23,6 @@
...
@@ -23,6 +23,6 @@
struct
decoder_control
;
struct
decoder_control
;
void
void
decoder_thread_start
(
struct
decoder_control
*
dc
);
decoder_thread_start
(
decoder_control
&
dc
);
#endif
#endif
src/Directory.cxx
View file @
ff626ac7
...
@@ -70,11 +70,11 @@ Directory::Directory(const char *_path)
...
@@ -70,11 +70,11 @@ Directory::Directory(const char *_path)
Directory
::~
Directory
()
Directory
::~
Directory
()
{
{
Song
*
song
,
*
ns
;
Song
*
song
,
*
ns
;
directory_for_each_song_safe
(
song
,
ns
,
this
)
directory_for_each_song_safe
(
song
,
ns
,
*
this
)
song
->
Free
();
song
->
Free
();
Directory
*
child
,
*
n
;
Directory
*
child
,
*
n
;
directory_for_each_child_safe
(
child
,
n
,
this
)
directory_for_each_child_safe
(
child
,
n
,
*
this
)
child
->
Free
();
child
->
Free
();
}
}
...
@@ -153,7 +153,7 @@ Directory::FindChild(const char *name) const
...
@@ -153,7 +153,7 @@ Directory::FindChild(const char *name) const
assert
(
holding_db_lock
());
assert
(
holding_db_lock
());
const
Directory
*
child
;
const
Directory
*
child
;
directory_for_each_child
(
child
,
this
)
directory_for_each_child
(
child
,
*
this
)
if
(
strcmp
(
child
->
GetName
(),
name
)
==
0
)
if
(
strcmp
(
child
->
GetName
(),
name
)
==
0
)
return
child
;
return
child
;
...
@@ -166,7 +166,7 @@ Directory::PruneEmpty()
...
@@ -166,7 +166,7 @@ Directory::PruneEmpty()
assert
(
holding_db_lock
());
assert
(
holding_db_lock
());
Directory
*
child
,
*
n
;
Directory
*
child
,
*
n
;
directory_for_each_child_safe
(
child
,
n
,
this
)
{
directory_for_each_child_safe
(
child
,
n
,
*
this
)
{
child
->
PruneEmpty
();
child
->
PruneEmpty
();
if
(
child
->
IsEmpty
())
if
(
child
->
IsEmpty
())
...
@@ -235,7 +235,7 @@ Directory::FindSong(const char *name_utf8) const
...
@@ -235,7 +235,7 @@ Directory::FindSong(const char *name_utf8) const
assert
(
name_utf8
!=
nullptr
);
assert
(
name_utf8
!=
nullptr
);
Song
*
song
;
Song
*
song
;
directory_for_each_song
(
song
,
this
)
{
directory_for_each_song
(
song
,
*
this
)
{
assert
(
song
->
parent
==
this
);
assert
(
song
->
parent
==
this
);
if
(
strcmp
(
song
->
uri
,
name_utf8
)
==
0
)
if
(
strcmp
(
song
->
uri
,
name_utf8
)
==
0
)
...
@@ -293,7 +293,7 @@ Directory::Sort()
...
@@ -293,7 +293,7 @@ Directory::Sort()
song_list_sort
(
&
songs
);
song_list_sort
(
&
songs
);
Directory
*
child
;
Directory
*
child
;
directory_for_each_child
(
child
,
this
)
directory_for_each_child
(
child
,
*
this
)
child
->
Sort
();
child
->
Sort
();
}
}
...
@@ -307,7 +307,7 @@ Directory::Walk(bool recursive, const SongFilter *filter,
...
@@ -307,7 +307,7 @@ Directory::Walk(bool recursive, const SongFilter *filter,
if
(
visit_song
)
{
if
(
visit_song
)
{
Song
*
song
;
Song
*
song
;
directory_for_each_song
(
song
,
this
)
directory_for_each_song
(
song
,
*
this
)
if
((
filter
==
nullptr
||
filter
->
Match
(
*
song
))
&&
if
((
filter
==
nullptr
||
filter
->
Match
(
*
song
))
&&
!
visit_song
(
*
song
,
error
))
!
visit_song
(
*
song
,
error
))
return
false
;
return
false
;
...
@@ -320,7 +320,7 @@ Directory::Walk(bool recursive, const SongFilter *filter,
...
@@ -320,7 +320,7 @@ Directory::Walk(bool recursive, const SongFilter *filter,
}
}
Directory
*
child
;
Directory
*
child
;
directory_for_each_child
(
child
,
this
)
{
directory_for_each_child
(
child
,
*
this
)
{
if
(
visit_directory
&&
if
(
visit_directory
&&
!
visit_directory
(
*
child
,
error
))
!
visit_directory
(
*
child
,
error
))
return
false
;
return
false
;
...
...
src/Directory.hxx
View file @
ff626ac7
...
@@ -32,16 +32,16 @@
...
@@ -32,16 +32,16 @@
#define DEVICE_CONTAINER (dev_t)(-2)
#define DEVICE_CONTAINER (dev_t)(-2)
#define directory_for_each_child(pos, directory) \
#define directory_for_each_child(pos, directory) \
list_for_each_entry(pos, &
directory->
children, siblings)
list_for_each_entry(pos, &
(directory).
children, siblings)
#define directory_for_each_child_safe(pos, n, directory) \
#define directory_for_each_child_safe(pos, n, directory) \
list_for_each_entry_safe(pos, n, &
directory->
children, siblings)
list_for_each_entry_safe(pos, n, &
(directory).
children, siblings)
#define directory_for_each_song(pos, directory) \
#define directory_for_each_song(pos, directory) \
list_for_each_entry(pos, &
directory->
songs, siblings)
list_for_each_entry(pos, &
(directory).
songs, siblings)
#define directory_for_each_song_safe(pos, n, directory) \
#define directory_for_each_song_safe(pos, n, directory) \
list_for_each_entry_safe(pos, n, &
directory->
songs, siblings)
list_for_each_entry_safe(pos, n, &
(directory).
songs, siblings)
struct
Song
;
struct
Song
;
struct
db_visitor
;
struct
db_visitor
;
...
...
src/DirectorySave.cxx
View file @
ff626ac7
...
@@ -40,13 +40,13 @@
...
@@ -40,13 +40,13 @@
static
constexpr
Domain
directory_domain
(
"directory"
);
static
constexpr
Domain
directory_domain
(
"directory"
);
void
void
directory_save
(
FILE
*
fp
,
const
Directory
*
directory
)
directory_save
(
FILE
*
fp
,
const
Directory
&
directory
)
{
{
if
(
!
directory
->
IsRoot
())
{
if
(
!
directory
.
IsRoot
())
{
fprintf
(
fp
,
DIRECTORY_MTIME
"%lu
\n
"
,
fprintf
(
fp
,
DIRECTORY_MTIME
"%lu
\n
"
,
(
unsigned
long
)
directory
->
mtime
);
(
unsigned
long
)
directory
.
mtime
);
fprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_BEGIN
,
directory
->
GetPath
());
fprintf
(
fp
,
"%s%s
\n
"
,
DIRECTORY_BEGIN
,
directory
.
GetPath
());
}
}
Directory
*
cur
;
Directory
*
cur
;
...
@@ -56,7 +56,7 @@ directory_save(FILE *fp, const Directory *directory)
...
@@ -56,7 +56,7 @@ directory_save(FILE *fp, const Directory *directory)
fprintf
(
fp
,
DIRECTORY_DIR
"%s
\n
"
,
base
);
fprintf
(
fp
,
DIRECTORY_DIR
"%s
\n
"
,
base
);
g_free
(
base
);
g_free
(
base
);
directory_save
(
fp
,
cur
);
directory_save
(
fp
,
*
cur
);
if
(
ferror
(
fp
))
if
(
ferror
(
fp
))
return
;
return
;
...
@@ -64,27 +64,27 @@ directory_save(FILE *fp, const Directory *directory)
...
@@ -64,27 +64,27 @@ directory_save(FILE *fp, const Directory *directory)
Song
*
song
;
Song
*
song
;
directory_for_each_song
(
song
,
directory
)
directory_for_each_song
(
song
,
directory
)
song_save
(
fp
,
song
);
song_save
(
fp
,
*
song
);
playlist_vector_save
(
fp
,
directory
->
playlists
);
playlist_vector_save
(
fp
,
directory
.
playlists
);
if
(
!
directory
->
IsRoot
())
if
(
!
directory
.
IsRoot
())
fprintf
(
fp
,
DIRECTORY_END
"%s
\n
"
,
directory
->
GetPath
());
fprintf
(
fp
,
DIRECTORY_END
"%s
\n
"
,
directory
.
GetPath
());
}
}
static
Directory
*
static
Directory
*
directory_load_subdir
(
TextFile
&
file
,
Directory
*
parent
,
const
char
*
name
,
directory_load_subdir
(
TextFile
&
file
,
Directory
&
parent
,
const
char
*
name
,
Error
&
error
)
Error
&
error
)
{
{
bool
success
;
bool
success
;
if
(
parent
->
FindChild
(
name
)
!=
nullptr
)
{
if
(
parent
.
FindChild
(
name
)
!=
nullptr
)
{
error
.
Format
(
directory_domain
,
error
.
Format
(
directory_domain
,
"Duplicate subdirectory '%s'"
,
name
);
"Duplicate subdirectory '%s'"
,
name
);
return
nullptr
;
return
nullptr
;
}
}
Directory
*
directory
=
parent
->
CreateChild
(
name
);
Directory
*
directory
=
parent
.
CreateChild
(
name
);
const
char
*
line
=
file
.
ReadLine
();
const
char
*
line
=
file
.
ReadLine
();
if
(
line
==
nullptr
)
{
if
(
line
==
nullptr
)
{
...
@@ -112,7 +112,7 @@ directory_load_subdir(TextFile &file, Directory *parent, const char *name,
...
@@ -112,7 +112,7 @@ directory_load_subdir(TextFile &file, Directory *parent, const char *name,
return
nullptr
;
return
nullptr
;
}
}
success
=
directory_load
(
file
,
directory
,
error
);
success
=
directory_load
(
file
,
*
directory
,
error
);
if
(
!
success
)
{
if
(
!
success
)
{
directory
->
Delete
();
directory
->
Delete
();
return
nullptr
;
return
nullptr
;
...
@@ -122,7 +122,7 @@ directory_load_subdir(TextFile &file, Directory *parent, const char *name,
...
@@ -122,7 +122,7 @@ directory_load_subdir(TextFile &file, Directory *parent, const char *name,
}
}
bool
bool
directory_load
(
TextFile
&
file
,
Directory
*
directory
,
Error
&
error
)
directory_load
(
TextFile
&
file
,
Directory
&
directory
,
Error
&
error
)
{
{
const
char
*
line
;
const
char
*
line
;
...
@@ -139,24 +139,24 @@ directory_load(TextFile &file, Directory *directory, Error &error)
...
@@ -139,24 +139,24 @@ directory_load(TextFile &file, Directory *directory, Error &error)
const
char
*
name
=
line
+
sizeof
(
SONG_BEGIN
)
-
1
;
const
char
*
name
=
line
+
sizeof
(
SONG_BEGIN
)
-
1
;
Song
*
song
;
Song
*
song
;
if
(
directory
->
FindSong
(
name
)
!=
nullptr
)
{
if
(
directory
.
FindSong
(
name
)
!=
nullptr
)
{
error
.
Format
(
directory_domain
,
error
.
Format
(
directory_domain
,
"Duplicate song '%s'"
,
name
);
"Duplicate song '%s'"
,
name
);
return
false
;
return
false
;
}
}
song
=
song_load
(
file
,
directory
,
name
,
error
);
song
=
song_load
(
file
,
&
directory
,
name
,
error
);
if
(
song
==
nullptr
)
if
(
song
==
nullptr
)
return
false
;
return
false
;
directory
->
AddSong
(
song
);
directory
.
AddSong
(
song
);
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_META_BEGIN
))
{
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_META_BEGIN
))
{
/* duplicate the name, because
/* duplicate the name, because
playlist_metadata_load() will overwrite the
playlist_metadata_load() will overwrite the
buffer */
buffer */
char
*
name
=
g_strdup
(
line
+
sizeof
(
PLAYLIST_META_BEGIN
)
-
1
);
char
*
name
=
g_strdup
(
line
+
sizeof
(
PLAYLIST_META_BEGIN
)
-
1
);
if
(
!
playlist_metadata_load
(
file
,
directory
->
playlists
,
if
(
!
playlist_metadata_load
(
file
,
directory
.
playlists
,
name
,
error
))
{
name
,
error
))
{
g_free
(
name
);
g_free
(
name
);
return
false
;
return
false
;
...
...
src/DirectorySave.hxx
View file @
ff626ac7
...
@@ -27,9 +27,9 @@ class TextFile;
...
@@ -27,9 +27,9 @@ class TextFile;
class
Error
;
class
Error
;
void
void
directory_save
(
FILE
*
fp
,
const
Directory
*
directory
);
directory_save
(
FILE
*
fp
,
const
Directory
&
directory
);
bool
bool
directory_load
(
TextFile
&
file
,
Directory
*
directory
,
Error
&
error
);
directory_load
(
TextFile
&
file
,
Directory
&
directory
,
Error
&
error
);
#endif
#endif
src/Main.cxx
View file @
ff626ac7
...
@@ -446,7 +446,7 @@ int mpd_main(int argc, char *argv[])
...
@@ -446,7 +446,7 @@ int mpd_main(int argc, char *argv[])
initialize_decoder_and_player
();
initialize_decoder_and_player
();
volume_init
();
volume_init
();
initAudioConfig
();
initAudioConfig
();
audio_output_all_init
(
&
instance
->
partition
->
pc
);
audio_output_all_init
(
instance
->
partition
->
pc
);
client_manager_init
();
client_manager_init
();
replay_gain_global_init
();
replay_gain_global_init
();
...
...
src/Mapper.cxx
View file @
ff626ac7
...
@@ -170,18 +170,18 @@ map_uri_fs(const char *uri)
...
@@ -170,18 +170,18 @@ map_uri_fs(const char *uri)
}
}
AllocatedPath
AllocatedPath
map_directory_fs
(
const
Directory
*
directory
)
map_directory_fs
(
const
Directory
&
directory
)
{
{
assert
(
!
music_dir_fs
.
IsNull
());
assert
(
!
music_dir_fs
.
IsNull
());
if
(
directory
->
IsRoot
())
if
(
directory
.
IsRoot
())
return
music_dir_fs
;
return
music_dir_fs
;
return
map_uri_fs
(
directory
->
GetPath
());
return
map_uri_fs
(
directory
.
GetPath
());
}
}
AllocatedPath
AllocatedPath
map_directory_child_fs
(
const
Directory
*
directory
,
const
char
*
name
)
map_directory_child_fs
(
const
Directory
&
directory
,
const
char
*
name
)
{
{
assert
(
!
music_dir_fs
.
IsNull
());
assert
(
!
music_dir_fs
.
IsNull
());
...
@@ -217,16 +217,16 @@ map_detached_song_fs(const char *uri_utf8)
...
@@ -217,16 +217,16 @@ map_detached_song_fs(const char *uri_utf8)
}
}
AllocatedPath
AllocatedPath
map_song_fs
(
const
Song
*
song
)
map_song_fs
(
const
Song
&
song
)
{
{
assert
(
song
->
IsFile
());
assert
(
song
.
IsFile
());
if
(
song
->
IsInDatabase
())
if
(
song
.
IsInDatabase
())
return
song
->
IsDetached
()
return
song
.
IsDetached
()
?
map_detached_song_fs
(
song
->
uri
)
?
map_detached_song_fs
(
song
.
uri
)
:
map_directory_child_fs
(
song
->
parent
,
song
->
uri
);
:
map_directory_child_fs
(
*
song
.
parent
,
song
.
uri
);
else
else
return
AllocatedPath
::
FromUTF8
(
song
->
uri
);
return
AllocatedPath
::
FromUTF8
(
song
.
uri
);
}
}
std
::
string
std
::
string
...
...
src/Mapper.hxx
View file @
ff626ac7
...
@@ -91,7 +91,7 @@ map_uri_fs(const char *uri);
...
@@ -91,7 +91,7 @@ map_uri_fs(const char *uri);
*/
*/
gcc_pure
gcc_pure
AllocatedPath
AllocatedPath
map_directory_fs
(
const
Directory
*
directory
);
map_directory_fs
(
const
Directory
&
directory
);
/**
/**
* Determines the file system path of a directory's child (may be a
* Determines the file system path of a directory's child (may be a
...
@@ -103,7 +103,7 @@ map_directory_fs(const Directory *directory);
...
@@ -103,7 +103,7 @@ map_directory_fs(const Directory *directory);
*/
*/
gcc_pure
gcc_pure
AllocatedPath
AllocatedPath
map_directory_child_fs
(
const
Directory
*
directory
,
const
char
*
name
);
map_directory_child_fs
(
const
Directory
&
directory
,
const
char
*
name
);
/**
/**
* Determines the file system path of a song. This must not be a
* Determines the file system path of a song. This must not be a
...
@@ -114,7 +114,7 @@ map_directory_child_fs(const Directory *directory, const char *name);
...
@@ -114,7 +114,7 @@ map_directory_child_fs(const Directory *directory, const char *name);
*/
*/
gcc_pure
gcc_pure
AllocatedPath
AllocatedPath
map_song_fs
(
const
Song
*
song
);
map_song_fs
(
const
Song
&
song
);
/**
/**
* Maps a file system path (relative to the music directory or
* Maps a file system path (relative to the music directory or
...
...
src/MessageCommands.cxx
View file @
ff626ac7
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
#include <assert.h>
#include <assert.h>
enum
command_return
enum
command_return
handle_subscribe
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_subscribe
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
assert
(
argc
==
2
);
assert
(
argc
==
2
);
...
@@ -62,7 +62,7 @@ handle_subscribe(Client *client, gcc_unused int argc, char *argv[])
...
@@ -62,7 +62,7 @@ handle_subscribe(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_unsubscribe
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_unsubscribe
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
assert
(
argc
==
2
);
assert
(
argc
==
2
);
...
@@ -76,7 +76,7 @@ handle_unsubscribe(Client *client, gcc_unused int argc, char *argv[])
...
@@ -76,7 +76,7 @@ handle_unsubscribe(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_channels
(
Client
*
client
,
handle_channels
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
assert
(
argc
==
1
);
assert
(
argc
==
1
);
...
@@ -93,24 +93,24 @@ handle_channels(Client *client,
...
@@ -93,24 +93,24 @@ handle_channels(Client *client,
}
}
enum
command_return
enum
command_return
handle_read_messages
(
Client
*
client
,
handle_read_messages
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
assert
(
argc
==
1
);
assert
(
argc
==
1
);
while
(
!
client
->
messages
.
empty
())
{
while
(
!
client
.
messages
.
empty
())
{
const
ClientMessage
&
msg
=
client
->
messages
.
front
();
const
ClientMessage
&
msg
=
client
.
messages
.
front
();
client_printf
(
client
,
"channel: %s
\n
message: %s
\n
"
,
client_printf
(
client
,
"channel: %s
\n
message: %s
\n
"
,
msg
.
GetChannel
(),
msg
.
GetMessage
());
msg
.
GetChannel
(),
msg
.
GetMessage
());
client
->
messages
.
pop_front
();
client
.
messages
.
pop_front
();
}
}
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_send_message
(
Client
*
client
,
handle_send_message
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
assert
(
argc
==
3
);
assert
(
argc
==
3
);
...
@@ -124,7 +124,7 @@ handle_send_message(Client *client,
...
@@ -124,7 +124,7 @@ handle_send_message(Client *client,
bool
sent
=
false
;
bool
sent
=
false
;
const
ClientMessage
msg
(
argv
[
1
],
argv
[
2
]);
const
ClientMessage
msg
(
argv
[
1
],
argv
[
2
]);
for
(
const
auto
&
c
:
*
instance
->
client_list
)
for
(
const
auto
&
c
:
*
instance
->
client_list
)
if
(
client_push_message
(
c
,
msg
))
if
(
client_push_message
(
*
c
,
msg
))
sent
=
true
;
sent
=
true
;
if
(
sent
)
if
(
sent
)
...
...
src/MessageCommands.hxx
View file @
ff626ac7
...
@@ -25,18 +25,18 @@
...
@@ -25,18 +25,18 @@
class
Client
;
class
Client
;
enum
command_return
enum
command_return
handle_subscribe
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_subscribe
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_unsubscribe
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_unsubscribe
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_channels
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_channels
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_read_messages
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_read_messages
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_send_message
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_send_message
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/OtherCommands.cxx
View file @
ff626ac7
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
#include <string.h>
#include <string.h>
static
void
static
void
print_spl_list
(
Client
*
client
,
const
PlaylistVector
&
list
)
print_spl_list
(
Client
&
client
,
const
PlaylistVector
&
list
)
{
{
for
(
const
auto
&
i
:
list
)
{
for
(
const
auto
&
i
:
list
)
{
client_printf
(
client
,
"playlist: %s
\n
"
,
i
.
name
.
c_str
());
client_printf
(
client
,
"playlist: %s
\n
"
,
i
.
name
.
c_str
());
...
@@ -64,7 +64,7 @@ print_spl_list(Client *client, const PlaylistVector &list)
...
@@ -64,7 +64,7 @@ print_spl_list(Client *client, const PlaylistVector &list)
}
}
enum
command_return
enum
command_return
handle_urlhandlers
(
Client
*
client
,
handle_urlhandlers
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
if
(
client_is_local
(
client
))
if
(
client_is_local
(
client
))
...
@@ -74,7 +74,7 @@ handle_urlhandlers(Client *client,
...
@@ -74,7 +74,7 @@ handle_urlhandlers(Client *client,
}
}
enum
command_return
enum
command_return
handle_decoders
(
Client
*
client
,
handle_decoders
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
decoder_list_print
(
client
);
decoder_list_print
(
client
);
...
@@ -82,7 +82,7 @@ handle_decoders(Client *client,
...
@@ -82,7 +82,7 @@ handle_decoders(Client *client,
}
}
enum
command_return
enum
command_return
handle_tagtypes
(
Client
*
client
,
handle_tagtypes
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
tag_print_types
(
client
);
tag_print_types
(
client
);
...
@@ -90,21 +90,21 @@ handle_tagtypes(Client *client,
...
@@ -90,21 +90,21 @@ handle_tagtypes(Client *client,
}
}
enum
command_return
enum
command_return
handle_kill
(
gcc_unused
Client
*
client
,
handle_kill
(
gcc_unused
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
return
COMMAND_RETURN_KILL
;
return
COMMAND_RETURN_KILL
;
}
}
enum
command_return
enum
command_return
handle_close
(
gcc_unused
Client
*
client
,
handle_close
(
gcc_unused
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
return
COMMAND_RETURN_CLOSE
;
return
COMMAND_RETURN_CLOSE
;
}
}
enum
command_return
enum
command_return
handle_lsinfo
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_lsinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
const
char
*
uri
;
const
char
*
uri
;
...
@@ -136,7 +136,7 @@ handle_lsinfo(Client *client, int argc, char *argv[])
...
@@ -136,7 +136,7 @@ handle_lsinfo(Client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
}
}
song_print_info
(
client
,
song
);
song_print_info
(
client
,
*
song
);
song
->
Free
();
song
->
Free
();
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -155,7 +155,7 @@ handle_lsinfo(Client *client, int argc, char *argv[])
...
@@ -155,7 +155,7 @@ handle_lsinfo(Client *client, int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_update
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_update
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
const
char
*
path
=
""
;
const
char
*
path
=
""
;
unsigned
ret
;
unsigned
ret
;
...
@@ -186,7 +186,7 @@ handle_update(Client *client, gcc_unused int argc, char *argv[])
...
@@ -186,7 +186,7 @@ handle_update(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_rescan
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_rescan
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
const
char
*
path
=
""
;
const
char
*
path
=
""
;
unsigned
ret
;
unsigned
ret
;
...
@@ -214,7 +214,7 @@ handle_rescan(Client *client, gcc_unused int argc, char *argv[])
...
@@ -214,7 +214,7 @@ handle_rescan(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_setvol
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_setvol
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
level
;
unsigned
level
;
bool
success
;
bool
success
;
...
@@ -238,7 +238,7 @@ handle_setvol(Client *client, gcc_unused int argc, char *argv[])
...
@@ -238,7 +238,7 @@ handle_setvol(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_stats
(
Client
*
client
,
handle_stats
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
stats_print
(
client
);
stats_print
(
client
);
...
@@ -246,14 +246,14 @@ handle_stats(Client *client,
...
@@ -246,14 +246,14 @@ handle_stats(Client *client,
}
}
enum
command_return
enum
command_return
handle_ping
(
gcc_unused
Client
*
client
,
handle_ping
(
gcc_unused
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_password
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_password
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
permission
=
0
;
unsigned
permission
=
0
;
...
@@ -268,7 +268,7 @@ handle_password(Client *client, gcc_unused int argc, char *argv[])
...
@@ -268,7 +268,7 @@ handle_password(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_config
(
Client
*
client
,
handle_config
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
if
(
!
client_is_local
(
client
))
{
if
(
!
client_is_local
(
client
))
{
...
@@ -285,7 +285,7 @@ handle_config(Client *client,
...
@@ -285,7 +285,7 @@ handle_config(Client *client,
}
}
enum
command_return
enum
command_return
handle_idle
(
Client
*
client
,
handle_idle
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
unsigned
flags
=
0
,
j
;
unsigned
flags
=
0
,
j
;
...
@@ -309,7 +309,7 @@ handle_idle(Client *client,
...
@@ -309,7 +309,7 @@ handle_idle(Client *client,
flags
=
~
0
;
flags
=
~
0
;
/* enable "idle" mode on this client */
/* enable "idle" mode on this client */
client
->
IdleWait
(
flags
);
client
.
IdleWait
(
flags
);
return
COMMAND_RETURN_IDLE
;
return
COMMAND_RETURN_IDLE
;
}
}
src/OtherCommands.hxx
View file @
ff626ac7
...
@@ -25,45 +25,45 @@
...
@@ -25,45 +25,45 @@
class
Client
;
class
Client
;
enum
command_return
enum
command_return
handle_urlhandlers
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_urlhandlers
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_decoders
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_decoders
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_tagtypes
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_tagtypes
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_kill
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_kill
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_close
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_close
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_lsinfo
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_lsinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_update
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_update
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_rescan
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_rescan
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_setvol
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_setvol
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_stats
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_stats
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_ping
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_ping
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_password
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_password
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_config
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_config
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_idle
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_idle
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/OutputAll.cxx
View file @
ff626ac7
...
@@ -103,7 +103,7 @@ audio_output_config_count(void)
...
@@ -103,7 +103,7 @@ audio_output_config_count(void)
}
}
void
void
audio_output_all_init
(
struct
player_control
*
pc
)
audio_output_all_init
(
player_control
&
pc
)
{
{
const
struct
config_param
*
param
=
nullptr
;
const
struct
config_param
*
param
=
nullptr
;
unsigned
int
i
;
unsigned
int
i
;
...
@@ -469,17 +469,17 @@ audio_output_all_check(void)
...
@@ -469,17 +469,17 @@ audio_output_all_check(void)
}
}
bool
bool
audio_output_all_wait
(
struct
player_control
*
pc
,
unsigned
threshold
)
audio_output_all_wait
(
player_control
&
pc
,
unsigned
threshold
)
{
{
pc
->
Lock
();
pc
.
Lock
();
if
(
audio_output_all_check
()
<
threshold
)
{
if
(
audio_output_all_check
()
<
threshold
)
{
pc
->
Unlock
();
pc
.
Unlock
();
return
true
;
return
true
;
}
}
pc
->
Wait
();
pc
.
Wait
();
pc
->
Unlock
();
pc
.
Unlock
();
return
audio_output_all_check
()
<
threshold
;
return
audio_output_all_check
()
<
threshold
;
}
}
...
...
src/OutputAll.hxx
View file @
ff626ac7
...
@@ -40,7 +40,7 @@ class Error;
...
@@ -40,7 +40,7 @@ class Error;
* file and initialize them.
* file and initialize them.
*/
*/
void
void
audio_output_all_init
(
struct
player_control
*
pc
);
audio_output_all_init
(
player_control
&
pc
);
/**
/**
* Global finalization: free memory occupied by audio outputs. All
* Global finalization: free memory occupied by audio outputs. All
...
@@ -135,7 +135,7 @@ audio_output_all_check(void);
...
@@ -135,7 +135,7 @@ audio_output_all_check(void);
* @return true if there are less than #threshold chunks in the pipe
* @return true if there are less than #threshold chunks in the pipe
*/
*/
bool
bool
audio_output_all_wait
(
struct
player_control
*
pc
,
unsigned
threshold
);
audio_output_all_wait
(
player_control
&
pc
,
unsigned
threshold
);
/**
/**
* Puts all audio outputs into pause mode. Most implementations will
* Puts all audio outputs into pause mode. Most implementations will
...
...
src/OutputCommands.cxx
View file @
ff626ac7
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
#include <string.h>
#include <string.h>
enum
command_return
enum
command_return
handle_enableoutput
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_enableoutput
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
device
;
unsigned
device
;
bool
ret
;
bool
ret
;
...
@@ -46,7 +46,7 @@ handle_enableoutput(Client *client, gcc_unused int argc, char *argv[])
...
@@ -46,7 +46,7 @@ handle_enableoutput(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_disableoutput
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_disableoutput
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
device
;
unsigned
device
;
bool
ret
;
bool
ret
;
...
@@ -65,7 +65,7 @@ handle_disableoutput(Client *client, gcc_unused int argc, char *argv[])
...
@@ -65,7 +65,7 @@ handle_disableoutput(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_toggleoutput
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_toggleoutput
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
device
;
unsigned
device
;
if
(
!
check_unsigned
(
client
,
&
device
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
device
,
argv
[
1
]))
...
@@ -81,7 +81,7 @@ handle_toggleoutput(Client *client, gcc_unused int argc, char *argv[])
...
@@ -81,7 +81,7 @@ handle_toggleoutput(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_devices
(
Client
*
client
,
handle_devices
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
printAudioDevices
(
client
);
printAudioDevices
(
client
);
...
...
src/OutputCommands.hxx
View file @
ff626ac7
...
@@ -25,15 +25,15 @@
...
@@ -25,15 +25,15 @@
class
Client
;
class
Client
;
enum
command_return
enum
command_return
handle_enableoutput
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_enableoutput
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_disableoutput
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_disableoutput
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_toggleoutput
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_toggleoutput
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_devices
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_devices
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/OutputInit.cxx
View file @
ff626ac7
...
@@ -281,7 +281,7 @@ audio_output_setup(struct audio_output *ao, const config_param ¶m,
...
@@ -281,7 +281,7 @@ audio_output_setup(struct audio_output *ao, const config_param ¶m,
struct
audio_output
*
struct
audio_output
*
audio_output_new
(
const
config_param
&
param
,
audio_output_new
(
const
config_param
&
param
,
struct
player_control
*
pc
,
player_control
&
pc
,
Error
&
error
)
Error
&
error
)
{
{
const
struct
audio_output_plugin
*
plugin
;
const
struct
audio_output_plugin
*
plugin
;
...
@@ -324,6 +324,6 @@ audio_output_new(const config_param ¶m,
...
@@ -324,6 +324,6 @@ audio_output_new(const config_param ¶m,
return
nullptr
;
return
nullptr
;
}
}
ao
->
player_control
=
pc
;
ao
->
player_control
=
&
pc
;
return
ao
;
return
ao
;
}
}
src/OutputInternal.hxx
View file @
ff626ac7
...
@@ -264,7 +264,7 @@ audio_output_command_is_finished(const struct audio_output *ao)
...
@@ -264,7 +264,7 @@ audio_output_command_is_finished(const struct audio_output *ao)
struct
audio_output
*
struct
audio_output
*
audio_output_new
(
const
config_param
&
param
,
audio_output_new
(
const
config_param
&
param
,
struct
player_control
*
pc
,
player_control
&
pc
,
Error
&
error
);
Error
&
error
);
bool
bool
...
...
src/OutputPrint.cxx
View file @
ff626ac7
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#include "Client.hxx"
#include "Client.hxx"
void
void
printAudioDevices
(
Client
*
client
)
printAudioDevices
(
Client
&
client
)
{
{
const
unsigned
n
=
audio_output_count
();
const
unsigned
n
=
audio_output_count
();
...
...
src/OutputPrint.hxx
View file @
ff626ac7
/*
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
* http://www.musicpd.org
...
@@ -28,6 +29,6 @@
...
@@ -28,6 +29,6 @@
class
Client
;
class
Client
;
void
void
printAudioDevices
(
Client
*
client
);
printAudioDevices
(
Client
&
client
);
#endif
#endif
src/PlayerCommands.cxx
View file @
ff626ac7
...
@@ -53,46 +53,46 @@
...
@@ -53,46 +53,46 @@
#define COMMAND_STATUS_UPDATING_DB "updating_db"
#define COMMAND_STATUS_UPDATING_DB "updating_db"
enum
command_return
enum
command_return
handle_play
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_play
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
int
song
=
-
1
;
int
song
=
-
1
;
if
(
argc
==
2
&&
!
check_int
(
client
,
&
song
,
argv
[
1
]))
if
(
argc
==
2
&&
!
check_int
(
client
,
&
song
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
client
->
partition
.
PlayPosition
(
song
);
enum
playlist_result
result
=
client
.
partition
.
PlayPosition
(
song
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
enum
command_return
handle_playid
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_playid
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
int
id
=
-
1
;
int
id
=
-
1
;
if
(
argc
==
2
&&
!
check_int
(
client
,
&
id
,
argv
[
1
]))
if
(
argc
==
2
&&
!
check_int
(
client
,
&
id
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
client
->
partition
.
PlayId
(
id
);
enum
playlist_result
result
=
client
.
partition
.
PlayId
(
id
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
enum
command_return
handle_stop
(
Client
*
client
,
handle_stop
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
client
->
partition
.
Stop
();
client
.
partition
.
Stop
();
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_currentsong
(
Client
*
client
,
handle_currentsong
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
playlist_print_current
(
client
,
&
client
->
playlist
);
playlist_print_current
(
client
,
client
.
playlist
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_pause
(
Client
*
client
,
handle_pause
(
Client
&
client
,
int
argc
,
char
*
argv
[])
int
argc
,
char
*
argv
[])
{
{
if
(
argc
==
2
)
{
if
(
argc
==
2
)
{
...
@@ -100,22 +100,22 @@ handle_pause(Client *client,
...
@@ -100,22 +100,22 @@ handle_pause(Client *client,
if
(
!
check_bool
(
client
,
&
pause_flag
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
pause_flag
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
client
->
player_control
->
SetPause
(
pause_flag
);
client
.
player_control
.
SetPause
(
pause_flag
);
}
else
}
else
client
->
player_control
->
Pause
();
client
.
player_control
.
Pause
();
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_status
(
Client
*
client
,
handle_status
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
const
char
*
state
=
NULL
;
const
char
*
state
=
NULL
;
int
updateJobId
;
int
updateJobId
;
int
song
;
int
song
;
const
auto
player_status
=
client
->
player_control
->
GetStatus
();
const
auto
player_status
=
client
.
player_control
.
GetStatus
();
switch
(
player_status
.
state
)
{
switch
(
player_status
.
state
)
{
case
PlayerState
:
:
STOP
:
case
PlayerState
:
:
STOP
:
...
@@ -129,7 +129,7 @@ handle_status(Client *client,
...
@@ -129,7 +129,7 @@ handle_status(Client *client,
break
;
break
;
}
}
const
playlist
&
playlist
=
client
->
playlist
;
const
playlist
&
playlist
=
client
.
playlist
;
client_printf
(
client
,
client_printf
(
client
,
"volume: %i
\n
"
"volume: %i
\n
"
COMMAND_STATUS_REPEAT
": %i
\n
"
COMMAND_STATUS_REPEAT
": %i
\n
"
...
@@ -149,9 +149,9 @@ handle_status(Client *client,
...
@@ -149,9 +149,9 @@ handle_status(Client *client,
playlist
.
GetConsume
(),
playlist
.
GetConsume
(),
(
unsigned
long
)
playlist
.
GetVersion
(),
(
unsigned
long
)
playlist
.
GetVersion
(),
playlist
.
GetLength
(),
playlist
.
GetLength
(),
(
int
)(
client
->
player_control
->
GetCrossFade
()
+
0.5
),
(
int
)(
client
.
player_control
.
GetCrossFade
()
+
0.5
),
client
->
player_control
->
GetMixRampDb
(),
client
.
player_control
.
GetMixRampDb
(),
client
->
player_control
->
GetMixRampDelay
(),
client
.
player_control
.
GetMixRampDelay
(),
state
);
state
);
song
=
playlist
.
GetCurrentPosition
();
song
=
playlist
.
GetCurrentPosition
();
...
@@ -188,7 +188,7 @@ handle_status(Client *client,
...
@@ -188,7 +188,7 @@ handle_status(Client *client,
updateJobId
);
updateJobId
);
}
}
Error
error
=
client
->
player_control
->
LockGetError
();
Error
error
=
client
.
player_control
.
LockGetError
();
if
(
error
.
IsDefined
())
if
(
error
.
IsDefined
())
client_printf
(
client
,
client_printf
(
client
,
COMMAND_STATUS_ERROR
": %s
\n
"
,
COMMAND_STATUS_ERROR
": %s
\n
"
,
...
@@ -206,85 +206,85 @@ handle_status(Client *client,
...
@@ -206,85 +206,85 @@ handle_status(Client *client,
}
}
enum
command_return
enum
command_return
handle_next
(
Client
*
client
,
handle_next
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
playlist
&
playlist
=
client
->
playlist
;
playlist
&
playlist
=
client
.
playlist
;
/* single mode is not considered when this is user who
/* single mode is not considered when this is user who
* wants to change song. */
* wants to change song. */
const
bool
single
=
playlist
.
queue
.
single
;
const
bool
single
=
playlist
.
queue
.
single
;
playlist
.
queue
.
single
=
false
;
playlist
.
queue
.
single
=
false
;
client
->
partition
.
PlayNext
();
client
.
partition
.
PlayNext
();
playlist
.
queue
.
single
=
single
;
playlist
.
queue
.
single
=
single
;
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_previous
(
Client
*
client
,
handle_previous
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
client
->
partition
.
PlayPrevious
();
client
.
partition
.
PlayPrevious
();
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_repeat
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_repeat
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
bool
status
;
bool
status
;
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
client
->
partition
.
SetRepeat
(
status
);
client
.
partition
.
SetRepeat
(
status
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_single
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_single
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
bool
status
;
bool
status
;
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
client
->
partition
.
SetSingle
(
status
);
client
.
partition
.
SetSingle
(
status
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_consume
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_consume
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
bool
status
;
bool
status
;
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
client
->
partition
.
SetConsume
(
status
);
client
.
partition
.
SetConsume
(
status
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_random
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_random
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
bool
status
;
bool
status
;
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
if
(
!
check_bool
(
client
,
&
status
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
client
->
partition
.
SetRandom
(
status
);
client
.
partition
.
SetRandom
(
status
);
audio_output_all_set_replay_gain_mode
(
replay_gain_get_real_mode
(
client
->
partition
.
GetRandom
()));
audio_output_all_set_replay_gain_mode
(
replay_gain_get_real_mode
(
client
.
partition
.
GetRandom
()));
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_clearerror
(
gcc_unused
Client
*
client
,
handle_clearerror
(
gcc_unused
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
client
->
player_control
->
ClearError
();
client
.
player_control
.
ClearError
();
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_seek
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_seek
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
song
,
seek_time
;
unsigned
song
,
seek_time
;
...
@@ -294,12 +294,12 @@ handle_seek(Client *client, gcc_unused int argc, char *argv[])
...
@@ -294,12 +294,12 @@ handle_seek(Client *client, gcc_unused int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
enum
playlist_result
result
=
client
->
partition
.
SeekSongPosition
(
song
,
seek_time
);
client
.
partition
.
SeekSongPosition
(
song
,
seek_time
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
enum
command_return
handle_seekid
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_seekid
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
id
,
seek_time
;
unsigned
id
,
seek_time
;
...
@@ -309,12 +309,12 @@ handle_seekid(Client *client, gcc_unused int argc, char *argv[])
...
@@ -309,12 +309,12 @@ handle_seekid(Client *client, gcc_unused int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
enum
playlist_result
result
=
client
->
partition
.
SeekSongId
(
id
,
seek_time
);
client
.
partition
.
SeekSongId
(
id
,
seek_time
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
enum
command_return
handle_seekcur
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_seekcur
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
const
char
*
p
=
argv
[
1
];
const
char
*
p
=
argv
[
1
];
bool
relative
=
*
p
==
'+'
||
*
p
==
'-'
;
bool
relative
=
*
p
==
'+'
||
*
p
==
'-'
;
...
@@ -323,48 +323,48 @@ handle_seekcur(Client *client, gcc_unused int argc, char *argv[])
...
@@ -323,48 +323,48 @@ handle_seekcur(Client *client, gcc_unused int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
enum
playlist_result
result
=
client
->
partition
.
SeekCurrent
(
seek_time
,
relative
);
client
.
partition
.
SeekCurrent
(
seek_time
,
relative
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
enum
command_return
handle_crossfade
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_crossfade
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
xfade_time
;
unsigned
xfade_time
;
if
(
!
check_unsigned
(
client
,
&
xfade_time
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
xfade_time
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
client
->
player_control
->
SetCrossFade
(
xfade_time
);
client
.
player_control
.
SetCrossFade
(
xfade_time
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_mixrampdb
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_mixrampdb
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
float
db
;
float
db
;
if
(
!
check_float
(
client
,
&
db
,
argv
[
1
]))
if
(
!
check_float
(
client
,
&
db
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
client
->
player_control
->
SetMixRampDb
(
db
);
client
.
player_control
.
SetMixRampDb
(
db
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_mixrampdelay
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_mixrampdelay
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
float
delay_secs
;
float
delay_secs
;
if
(
!
check_float
(
client
,
&
delay_secs
,
argv
[
1
]))
if
(
!
check_float
(
client
,
&
delay_secs
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
client
->
player_control
->
SetMixRampDelay
(
delay_secs
);
client
.
player_control
.
SetMixRampDelay
(
delay_secs
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_replay_gain_mode
(
Client
*
client
,
handle_replay_gain_mode
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
gcc_unused
int
argc
,
char
*
argv
[])
{
{
if
(
!
replay_gain_set_mode_string
(
argv
[
1
]))
{
if
(
!
replay_gain_set_mode_string
(
argv
[
1
]))
{
...
@@ -373,13 +373,13 @@ handle_replay_gain_mode(Client *client,
...
@@ -373,13 +373,13 @@ handle_replay_gain_mode(Client *client,
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
}
}
audio_output_all_set_replay_gain_mode
(
replay_gain_get_real_mode
(
client
->
playlist
.
queue
.
random
));
audio_output_all_set_replay_gain_mode
(
replay_gain_get_real_mode
(
client
.
playlist
.
queue
.
random
));
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_replay_gain_status
(
Client
*
client
,
handle_replay_gain_status
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
client_printf
(
client
,
"replay_gain_mode: %s
\n
"
,
client_printf
(
client
,
"replay_gain_mode: %s
\n
"
,
...
...
src/PlayerCommands.hxx
View file @
ff626ac7
...
@@ -25,66 +25,66 @@
...
@@ -25,66 +25,66 @@
class
Client
;
class
Client
;
enum
command_return
enum
command_return
handle_play
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_play
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_playid
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_playid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_stop
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_stop
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_currentsong
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_currentsong
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_pause
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_pause
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_status
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_status
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_next
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_next
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_previous
(
Client
*
client
,
int
argc
,
char
*
avg
[]);
handle_previous
(
Client
&
client
,
int
argc
,
char
*
avg
[]);
enum
command_return
enum
command_return
handle_repeat
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_repeat
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_single
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_single
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_consume
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_consume
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_random
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_random
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_clearerror
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_clearerror
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_seek
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_seek
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_seekid
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_seekid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_seekcur
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_seekcur
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_crossfade
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_crossfade
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_mixrampdb
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_mixrampdb
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_mixrampdelay
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_mixrampdelay
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_replay_gain_mode
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_replay_gain_mode
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_replay_gain_status
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_replay_gain_status
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/PlayerThread.cxx
View file @
ff626ac7
...
@@ -445,7 +445,7 @@ Player::CheckDecoderStartup()
...
@@ -445,7 +445,7 @@ Player::CheckDecoderStartup()
dc
.
Unlock
();
dc
.
Unlock
();
if
(
output_open
&&
if
(
output_open
&&
!
audio_output_all_wait
(
&
pc
,
1
))
!
audio_output_all_wait
(
pc
,
1
))
/* the output devices havn't finished playing
/* the output devices havn't finished playing
all chunks yet - wait for that */
all chunks yet - wait for that */
return
true
;
return
true
;
...
@@ -746,7 +746,7 @@ play_chunk(player_control &pc,
...
@@ -746,7 +746,7 @@ play_chunk(player_control &pc,
inline
bool
inline
bool
Player
::
PlayNextChunk
()
Player
::
PlayNextChunk
()
{
{
if
(
!
audio_output_all_wait
(
&
pc
,
64
))
if
(
!
audio_output_all_wait
(
pc
,
64
))
/* the output pipe is still large enough, don't send
/* the output pipe is still large enough, don't send
another chunk */
another chunk */
return
true
;
return
true
;
...
@@ -1102,7 +1102,7 @@ player_task(void *arg)
...
@@ -1102,7 +1102,7 @@ player_task(void *arg)
player_control
&
pc
=
*
(
player_control
*
)
arg
;
player_control
&
pc
=
*
(
player_control
*
)
arg
;
decoder_control
dc
;
decoder_control
dc
;
decoder_thread_start
(
&
dc
);
decoder_thread_start
(
dc
);
MusicBuffer
buffer
(
pc
.
buffer_chunks
);
MusicBuffer
buffer
(
pc
.
buffer_chunks
);
...
...
src/Playlist.cxx
View file @
ff626ac7
...
@@ -50,42 +50,42 @@ playlist::TagChanged()
...
@@ -50,42 +50,42 @@ playlist::TagChanged()
* Queue a song, addressed by its order number.
* Queue a song, addressed by its order number.
*/
*/
static
void
static
void
playlist_queue_song_order
(
struct
playlist
*
playlist
,
struct
player_control
*
pc
,
playlist_queue_song_order
(
playlist
&
playlist
,
player_control
&
pc
,
unsigned
order
)
unsigned
order
)
{
{
assert
(
playlist
->
queue
.
IsValidOrder
(
order
));
assert
(
playlist
.
queue
.
IsValidOrder
(
order
));
playlist
->
queued
=
order
;
playlist
.
queued
=
order
;
Song
*
song
=
playlist
->
queue
.
GetOrder
(
order
)
->
DupDetached
();
Song
*
song
=
playlist
.
queue
.
GetOrder
(
order
).
DupDetached
();
{
{
const
auto
uri
=
song
->
GetURI
();
const
auto
uri
=
song
->
GetURI
();
FormatDebug
(
playlist_domain
,
"queue song %i:
\"
%s
\"
"
,
FormatDebug
(
playlist_domain
,
"queue song %i:
\"
%s
\"
"
,
playlist
->
queued
,
uri
.
c_str
());
playlist
.
queued
,
uri
.
c_str
());
}
}
pc
->
EnqueueSong
(
song
);
pc
.
EnqueueSong
(
song
);
}
}
/**
/**
* Called if the player thread has started playing the "queued" song.
* Called if the player thread has started playing the "queued" song.
*/
*/
static
void
static
void
playlist_song_started
(
struct
playlist
*
playlist
,
struct
player_control
*
pc
)
playlist_song_started
(
playlist
&
playlist
,
player_control
&
pc
)
{
{
assert
(
pc
->
next_song
==
nullptr
);
assert
(
pc
.
next_song
==
nullptr
);
assert
(
playlist
->
queued
>=
-
1
);
assert
(
playlist
.
queued
>=
-
1
);
/* queued song has started: copy queued to current,
/* queued song has started: copy queued to current,
and notify the clients */
and notify the clients */
int
current
=
playlist
->
current
;
int
current
=
playlist
.
current
;
playlist
->
current
=
playlist
->
queued
;
playlist
.
current
=
playlist
.
queued
;
playlist
->
queued
=
-
1
;
playlist
.
queued
=
-
1
;
if
(
playlist
->
queue
.
consume
)
if
(
playlist
.
queue
.
consume
)
playlist
->
DeleteOrder
(
*
pc
,
current
);
playlist
.
DeleteOrder
(
pc
,
current
);
idle_add
(
IDLE_PLAYER
);
idle_add
(
IDLE_PLAYER
);
}
}
...
@@ -94,7 +94,7 @@ const Song *
...
@@ -94,7 +94,7 @@ const Song *
playlist
::
GetQueuedSong
()
const
playlist
::
GetQueuedSong
()
const
{
{
return
playing
&&
queued
>=
0
return
playing
&&
queued
>=
0
?
queue
.
GetOrder
(
queued
)
?
&
queue
.
GetOrder
(
queued
)
:
nullptr
;
:
nullptr
;
}
}
...
@@ -127,7 +127,7 @@ playlist::UpdateQueuedSong(player_control &pc, const Song *prev)
...
@@ -127,7 +127,7 @@ playlist::UpdateQueuedSong(player_control &pc, const Song *prev)
}
}
const
Song
*
const
next_song
=
next_order
>=
0
const
Song
*
const
next_song
=
next_order
>=
0
?
queue
.
GetOrder
(
next_order
)
?
&
queue
.
GetOrder
(
next_order
)
:
nullptr
;
:
nullptr
;
if
(
prev
!=
nullptr
&&
next_song
!=
prev
)
{
if
(
prev
!=
nullptr
&&
next_song
!=
prev
)
{
...
@@ -138,7 +138,7 @@ playlist::UpdateQueuedSong(player_control &pc, const Song *prev)
...
@@ -138,7 +138,7 @@ playlist::UpdateQueuedSong(player_control &pc, const Song *prev)
if
(
next_order
>=
0
)
{
if
(
next_order
>=
0
)
{
if
(
next_song
!=
prev
)
if
(
next_song
!=
prev
)
playlist_queue_song_order
(
this
,
&
pc
,
next_order
);
playlist_queue_song_order
(
*
this
,
pc
,
next_order
);
else
else
queued
=
next_order
;
queued
=
next_order
;
}
}
...
@@ -150,7 +150,7 @@ playlist::PlayOrder(player_control &pc, int order)
...
@@ -150,7 +150,7 @@ playlist::PlayOrder(player_control &pc, int order)
playing
=
true
;
playing
=
true
;
queued
=
-
1
;
queued
=
-
1
;
Song
*
song
=
queue
.
GetOrder
(
order
)
->
DupDetached
();
Song
*
song
=
queue
.
GetOrder
(
order
)
.
DupDetached
();
{
{
const
auto
uri
=
song
->
GetURI
();
const
auto
uri
=
song
->
GetURI
();
...
@@ -163,7 +163,7 @@ playlist::PlayOrder(player_control &pc, int order)
...
@@ -163,7 +163,7 @@ playlist::PlayOrder(player_control &pc, int order)
}
}
static
void
static
void
playlist_resume_playback
(
struct
playlist
*
playlist
,
struct
player_control
*
pc
);
playlist_resume_playback
(
playlist
&
playlist
,
player_control
&
pc
);
void
void
playlist
::
SyncWithPlayer
(
player_control
&
pc
)
playlist
::
SyncWithPlayer
(
player_control
&
pc
)
...
@@ -183,12 +183,12 @@ playlist::SyncWithPlayer(player_control &pc)
...
@@ -183,12 +183,12 @@ playlist::SyncWithPlayer(player_control &pc)
should be restarted with the next song. That can
should be restarted with the next song. That can
happen if the playlist isn't filling the queue fast
happen if the playlist isn't filling the queue fast
enough */
enough */
playlist_resume_playback
(
this
,
&
pc
);
playlist_resume_playback
(
*
this
,
pc
);
else
{
else
{
/* check if the player thread has already started
/* check if the player thread has already started
playing the queued song */
playing the queued song */
if
(
pc_next_song
==
nullptr
&&
queued
!=
-
1
)
if
(
pc_next_song
==
nullptr
&&
queued
!=
-
1
)
playlist_song_started
(
this
,
&
pc
);
playlist_song_started
(
*
this
,
pc
);
pc
.
Lock
();
pc
.
Lock
();
pc_next_song
=
pc
.
next_song
;
pc_next_song
=
pc
.
next_song
;
...
@@ -206,26 +206,26 @@ playlist::SyncWithPlayer(player_control &pc)
...
@@ -206,26 +206,26 @@ playlist::SyncWithPlayer(player_control &pc)
* decide whether to re-start playback
* decide whether to re-start playback
*/
*/
static
void
static
void
playlist_resume_playback
(
struct
playlist
*
playlist
,
struct
player_control
*
pc
)
playlist_resume_playback
(
playlist
&
playlist
,
player_control
&
pc
)
{
{
assert
(
playlist
->
playing
);
assert
(
playlist
.
playing
);
assert
(
pc
->
GetState
()
==
PlayerState
::
STOP
);
assert
(
pc
.
GetState
()
==
PlayerState
::
STOP
);
const
auto
error
=
pc
->
GetErrorType
();
const
auto
error
=
pc
.
GetErrorType
();
if
(
error
==
PlayerError
::
NONE
)
if
(
error
==
PlayerError
::
NONE
)
playlist
->
error_count
=
0
;
playlist
.
error_count
=
0
;
else
else
++
playlist
->
error_count
;
++
playlist
.
error_count
;
if
((
playlist
->
stop_on_error
&&
error
!=
PlayerError
::
NONE
)
||
if
((
playlist
.
stop_on_error
&&
error
!=
PlayerError
::
NONE
)
||
error
==
PlayerError
::
OUTPUT
||
error
==
PlayerError
::
OUTPUT
||
playlist
->
error_count
>=
playlist
->
queue
.
GetLength
())
playlist
.
error_count
>=
playlist
.
queue
.
GetLength
())
/* too many errors, or critical error: stop
/* too many errors, or critical error: stop
playback */
playback */
playlist
->
Stop
(
*
pc
);
playlist
.
Stop
(
pc
);
else
else
/* continue playback at the next song */
/* continue playback at the next song */
playlist
->
PlayNext
(
*
pc
);
playlist
.
PlayNext
(
pc
);
}
}
void
void
...
@@ -246,13 +246,13 @@ playlist::SetRepeat(player_control &pc, bool status)
...
@@ -246,13 +246,13 @@ playlist::SetRepeat(player_control &pc, bool status)
}
}
static
void
static
void
playlist_order
(
struct
playlist
*
playlist
)
playlist_order
(
playlist
&
playlist
)
{
{
if
(
playlist
->
current
>=
0
)
if
(
playlist
.
current
>=
0
)
/* update playlist.current, order==position now */
/* update playlist.current, order==position now */
playlist
->
current
=
playlist
->
queue
.
OrderToPosition
(
playlist
->
current
);
playlist
.
current
=
playlist
.
queue
.
OrderToPosition
(
playlist
.
current
);
playlist
->
queue
.
RestoreOrder
();
playlist
.
queue
.
RestoreOrder
();
}
}
void
void
...
@@ -310,7 +310,7 @@ playlist::SetRandom(player_control &pc, bool status)
...
@@ -310,7 +310,7 @@ playlist::SetRandom(player_control &pc, bool status)
}
else
}
else
current
=
-
1
;
current
=
-
1
;
}
else
}
else
playlist_order
(
this
);
playlist_order
(
*
this
);
UpdateQueuedSong
(
pc
,
queued_song
);
UpdateQueuedSong
(
pc
,
queued_song
);
...
...
src/PlaylistCommands.cxx
View file @
ff626ac7
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
#include <stdlib.h>
#include <stdlib.h>
static
void
static
void
print_spl_list
(
Client
*
client
,
const
PlaylistVector
&
list
)
print_spl_list
(
Client
&
client
,
const
PlaylistVector
&
list
)
{
{
for
(
const
auto
&
i
:
list
)
{
for
(
const
auto
&
i
:
list
)
{
client_printf
(
client
,
"playlist: %s
\n
"
,
i
.
name
.
c_str
());
client_printf
(
client
,
"playlist: %s
\n
"
,
i
.
name
.
c_str
());
...
@@ -50,16 +50,16 @@ print_spl_list(Client *client, const PlaylistVector &list)
...
@@ -50,16 +50,16 @@ print_spl_list(Client *client, const PlaylistVector &list)
}
}
enum
command_return
enum
command_return
handle_save
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_save
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
enum
playlist_result
result
;
enum
playlist_result
result
;
result
=
spl_save_playlist
(
argv
[
1
],
&
client
->
playlist
);
result
=
spl_save_playlist
(
argv
[
1
],
client
.
playlist
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
enum
command_return
handle_load
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_load
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
unsigned
start_index
,
end_index
;
unsigned
start_index
,
end_index
;
...
@@ -73,13 +73,13 @@ handle_load(Client *client, int argc, char *argv[])
...
@@ -73,13 +73,13 @@ handle_load(Client *client, int argc, char *argv[])
result
=
playlist_open_into_queue
(
argv
[
1
],
result
=
playlist_open_into_queue
(
argv
[
1
],
start_index
,
end_index
,
start_index
,
end_index
,
&
client
->
playlist
,
client
.
playlist
,
client
->
player_control
,
true
);
client
.
player_control
,
true
);
if
(
result
!=
PLAYLIST_RESULT_NO_SUCH_LIST
)
if
(
result
!=
PLAYLIST_RESULT_NO_SUCH_LIST
)
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
Error
error
;
Error
error
;
if
(
playlist_load_spl
(
&
client
->
playlist
,
client
->
player_control
,
if
(
playlist_load_spl
(
client
.
playlist
,
client
.
player_control
,
argv
[
1
],
start_index
,
end_index
,
argv
[
1
],
start_index
,
end_index
,
error
))
error
))
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
...
@@ -99,7 +99,7 @@ handle_load(Client *client, int argc, char *argv[])
...
@@ -99,7 +99,7 @@ handle_load(Client *client, int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_listplaylist
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_listplaylist
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
if
(
playlist_file_print
(
client
,
argv
[
1
],
false
))
if
(
playlist_file_print
(
client
,
argv
[
1
],
false
))
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
...
@@ -111,7 +111,7 @@ handle_listplaylist(Client *client, gcc_unused int argc, char *argv[])
...
@@ -111,7 +111,7 @@ handle_listplaylist(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_listplaylistinfo
(
Client
*
client
,
handle_listplaylistinfo
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
gcc_unused
int
argc
,
char
*
argv
[])
{
{
if
(
playlist_file_print
(
client
,
argv
[
1
],
true
))
if
(
playlist_file_print
(
client
,
argv
[
1
],
true
))
...
@@ -124,7 +124,7 @@ handle_listplaylistinfo(Client *client,
...
@@ -124,7 +124,7 @@ handle_listplaylistinfo(Client *client,
}
}
enum
command_return
enum
command_return
handle_rm
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_rm
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
Error
error
;
Error
error
;
return
spl_delete
(
argv
[
1
],
error
)
return
spl_delete
(
argv
[
1
],
error
)
...
@@ -133,7 +133,7 @@ handle_rm(Client *client, gcc_unused int argc, char *argv[])
...
@@ -133,7 +133,7 @@ handle_rm(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_rename
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_rename
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
Error
error
;
Error
error
;
return
spl_rename
(
argv
[
1
],
argv
[
2
],
error
)
return
spl_rename
(
argv
[
1
],
argv
[
2
],
error
)
...
@@ -142,7 +142,7 @@ handle_rename(Client *client, gcc_unused int argc, char *argv[])
...
@@ -142,7 +142,7 @@ handle_rename(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_playlistdelete
(
Client
*
client
,
handle_playlistdelete
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
gcc_unused
int
argc
,
char
*
argv
[])
{
char
*
playlist
=
argv
[
1
];
char
*
playlist
=
argv
[
1
];
unsigned
from
;
unsigned
from
;
...
@@ -157,7 +157,7 @@ handle_playlistdelete(Client *client,
...
@@ -157,7 +157,7 @@ handle_playlistdelete(Client *client,
}
}
enum
command_return
enum
command_return
handle_playlistmove
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_playlistmove
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
char
*
playlist
=
argv
[
1
];
char
*
playlist
=
argv
[
1
];
unsigned
from
,
to
;
unsigned
from
,
to
;
...
@@ -174,7 +174,7 @@ handle_playlistmove(Client *client, gcc_unused int argc, char *argv[])
...
@@ -174,7 +174,7 @@ handle_playlistmove(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_playlistclear
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_playlistclear
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
Error
error
;
Error
error
;
return
spl_clear
(
argv
[
1
],
error
)
return
spl_clear
(
argv
[
1
],
error
)
...
@@ -183,7 +183,7 @@ handle_playlistclear(Client *client, gcc_unused int argc, char *argv[])
...
@@ -183,7 +183,7 @@ handle_playlistclear(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_playlistadd
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_playlistadd
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
char
*
playlist
=
argv
[
1
];
char
*
playlist
=
argv
[
1
];
char
*
uri
=
argv
[
2
];
char
*
uri
=
argv
[
2
];
...
@@ -212,7 +212,7 @@ handle_playlistadd(Client *client, gcc_unused int argc, char *argv[])
...
@@ -212,7 +212,7 @@ handle_playlistadd(Client *client, gcc_unused int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_listplaylists
(
Client
*
client
,
handle_listplaylists
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
Error
error
;
Error
error
;
...
...
src/PlaylistCommands.hxx
View file @
ff626ac7
...
@@ -25,36 +25,36 @@
...
@@ -25,36 +25,36 @@
class
Client
;
class
Client
;
enum
command_return
enum
command_return
handle_save
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_save
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_load
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_load
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_listplaylist
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_listplaylist
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_listplaylistinfo
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_listplaylistinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_rm
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_rm
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_rename
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_rename
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_playlistdelete
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_playlistdelete
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_playlistmove
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_playlistmove
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_playlistclear
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_playlistclear
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_playlistadd
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_playlistadd
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_listplaylists
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_listplaylists
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/PlaylistControl.cxx
View file @
ff626ac7
...
@@ -215,7 +215,7 @@ playlist::SeekSongPosition(player_control &pc, unsigned song, float seek_time)
...
@@ -215,7 +215,7 @@ playlist::SeekSongPosition(player_control &pc, unsigned song, float seek_time)
queued_song
=
nullptr
;
queued_song
=
nullptr
;
}
}
Song
*
the_song
=
queue
.
GetOrder
(
i
)
->
DupDetached
();
Song
*
the_song
=
queue
.
GetOrder
(
i
)
.
DupDetached
();
if
(
!
pc
.
Seek
(
the_song
,
seek_time
))
{
if
(
!
pc
.
Seek
(
the_song
,
seek_time
))
{
UpdateQueuedSong
(
pc
,
queued_song
);
UpdateQueuedSong
(
pc
,
queued_song
);
...
...
src/PlaylistEdit.cxx
View file @
ff626ac7
...
@@ -324,7 +324,7 @@ playlist::DeleteSong(struct player_control &pc, const struct Song &song)
...
@@ -324,7 +324,7 @@ playlist::DeleteSong(struct player_control &pc, const struct Song &song)
{
{
for
(
int
i
=
queue
.
GetLength
()
-
1
;
i
>=
0
;
--
i
)
for
(
int
i
=
queue
.
GetLength
()
-
1
;
i
>=
0
;
--
i
)
// TODO: compare URI instead of pointer
// TODO: compare URI instead of pointer
if
(
&
song
==
queue
.
Get
(
i
))
if
(
&
song
==
&
queue
.
Get
(
i
))
DeletePosition
(
pc
,
i
);
DeletePosition
(
pc
,
i
);
}
}
...
...
src/PlaylistFile.cxx
View file @
ff626ac7
...
@@ -365,7 +365,7 @@ spl_remove_index(const char *utf8path, unsigned pos, Error &error)
...
@@ -365,7 +365,7 @@ spl_remove_index(const char *utf8path, unsigned pos, Error &error)
}
}
bool
bool
spl_append_song
(
const
char
*
utf8path
,
Song
*
song
,
Error
&
error
)
spl_append_song
(
const
char
*
utf8path
,
const
Song
&
song
,
Error
&
error
)
{
{
if
(
spl_map
(
error
).
IsNull
())
if
(
spl_map
(
error
).
IsNull
())
return
false
;
return
false
;
...
@@ -407,7 +407,7 @@ spl_append_uri(const char *url, const char *utf8file, Error &error)
...
@@ -407,7 +407,7 @@ spl_append_uri(const char *url, const char *utf8file, Error &error)
{
{
if
(
uri_has_scheme
(
url
))
{
if
(
uri_has_scheme
(
url
))
{
Song
*
song
=
Song
::
NewRemote
(
url
);
Song
*
song
=
Song
::
NewRemote
(
url
);
bool
success
=
spl_append_song
(
utf8file
,
song
,
error
);
bool
success
=
spl_append_song
(
utf8file
,
*
song
,
error
);
song
->
Free
();
song
->
Free
();
return
success
;
return
success
;
}
else
{
}
else
{
...
@@ -419,7 +419,7 @@ spl_append_uri(const char *url, const char *utf8file, Error &error)
...
@@ -419,7 +419,7 @@ spl_append_uri(const char *url, const char *utf8file, Error &error)
if
(
song
==
nullptr
)
if
(
song
==
nullptr
)
return
false
;
return
false
;
bool
success
=
spl_append_song
(
utf8file
,
song
,
error
);
bool
success
=
spl_append_song
(
utf8file
,
*
song
,
error
);
db
->
ReturnSong
(
song
);
db
->
ReturnSong
(
song
);
return
success
;
return
success
;
}
}
...
...
src/PlaylistFile.hxx
View file @
ff626ac7
...
@@ -69,7 +69,7 @@ bool
...
@@ -69,7 +69,7 @@ bool
spl_remove_index
(
const
char
*
utf8path
,
unsigned
pos
,
Error
&
error
);
spl_remove_index
(
const
char
*
utf8path
,
unsigned
pos
,
Error
&
error
);
bool
bool
spl_append_song
(
const
char
*
utf8path
,
Song
*
song
,
Error
&
error
);
spl_append_song
(
const
char
*
utf8path
,
const
Song
&
song
,
Error
&
error
);
bool
bool
spl_append_uri
(
const
char
*
file
,
const
char
*
utf8file
,
Error
&
error
);
spl_append_uri
(
const
char
*
file
,
const
char
*
utf8file
,
Error
&
error
);
...
...
src/PlaylistPrint.cxx
View file @
ff626ac7
...
@@ -39,22 +39,22 @@
...
@@ -39,22 +39,22 @@
#include <glib.h>
#include <glib.h>
void
void
playlist_print_uris
(
Client
*
client
,
const
struct
playlist
*
playlist
)
playlist_print_uris
(
Client
&
client
,
const
playlist
&
playlist
)
{
{
const
struct
queue
*
queue
=
&
playlist
->
queue
;
const
queue
&
queue
=
playlist
.
queue
;
queue_print_uris
(
client
,
queue
,
0
,
queue
->
GetLength
());
queue_print_uris
(
client
,
queue
,
0
,
queue
.
GetLength
());
}
}
bool
bool
playlist_print_info
(
Client
*
client
,
const
struct
playlist
*
playlist
,
playlist_print_info
(
Client
&
client
,
const
playlist
&
playlist
,
unsigned
start
,
unsigned
end
)
unsigned
start
,
unsigned
end
)
{
{
const
struct
queue
*
queue
=
&
playlist
->
queue
;
const
queue
&
queue
=
playlist
.
queue
;
if
(
end
>
queue
->
GetLength
())
if
(
end
>
queue
.
GetLength
())
/* correct the "end" offset */
/* correct the "end" offset */
end
=
queue
->
GetLength
();
end
=
queue
.
GetLength
();
if
(
start
>
end
)
if
(
start
>
end
)
/* an invalid "start" offset is fatal */
/* an invalid "start" offset is fatal */
...
@@ -65,13 +65,12 @@ playlist_print_info(Client *client, const struct playlist *playlist,
...
@@ -65,13 +65,12 @@ playlist_print_info(Client *client, const struct playlist *playlist,
}
}
bool
bool
playlist_print_id
(
Client
*
client
,
const
struct
playlist
*
playlist
,
playlist_print_id
(
Client
&
client
,
const
playlist
&
playlist
,
unsigned
id
)
unsigned
id
)
{
{
const
struct
queue
*
queue
=
&
playlist
->
queue
;
int
position
;
int
position
;
position
=
queue
->
IdToPosition
(
id
);
position
=
playlist
.
queue
.
IdToPosition
(
id
);
if
(
position
<
0
)
if
(
position
<
0
)
/* no such song */
/* no such song */
return
false
;
return
false
;
...
@@ -80,42 +79,42 @@ playlist_print_id(Client *client, const struct playlist *playlist,
...
@@ -80,42 +79,42 @@ playlist_print_id(Client *client, const struct playlist *playlist,
}
}
bool
bool
playlist_print_current
(
Client
*
client
,
const
struct
playlist
*
playlist
)
playlist_print_current
(
Client
&
client
,
const
playlist
&
playlist
)
{
{
int
current_position
=
playlist
->
GetCurrentPosition
();
int
current_position
=
playlist
.
GetCurrentPosition
();
if
(
current_position
<
0
)
if
(
current_position
<
0
)
return
false
;
return
false
;
queue_print_info
(
client
,
&
playlist
->
queue
,
queue_print_info
(
client
,
playlist
.
queue
,
current_position
,
current_position
+
1
);
current_position
,
current_position
+
1
);
return
true
;
return
true
;
}
}
void
void
playlist_print_find
(
Client
*
client
,
const
struct
playlist
*
playlist
,
playlist_print_find
(
Client
&
client
,
const
playlist
&
playlist
,
const
SongFilter
&
filter
)
const
SongFilter
&
filter
)
{
{
queue_find
(
client
,
&
playlist
->
queue
,
filter
);
queue_find
(
client
,
playlist
.
queue
,
filter
);
}
}
void
void
playlist_print_changes_info
(
Client
*
client
,
playlist_print_changes_info
(
Client
&
client
,
const
struct
playlist
*
playlist
,
const
playlist
&
playlist
,
uint32_t
version
)
uint32_t
version
)
{
{
queue_print_changes_info
(
client
,
&
playlist
->
queue
,
version
);
queue_print_changes_info
(
client
,
playlist
.
queue
,
version
);
}
}
void
void
playlist_print_changes_position
(
Client
*
client
,
playlist_print_changes_position
(
Client
&
client
,
const
struct
playlist
*
playlist
,
const
playlist
&
playlist
,
uint32_t
version
)
uint32_t
version
)
{
{
queue_print_changes_position
(
client
,
&
playlist
->
queue
,
version
);
queue_print_changes_position
(
client
,
playlist
.
queue
,
version
);
}
}
static
bool
static
bool
PrintSongDetails
(
Client
*
client
,
const
char
*
uri_utf8
)
PrintSongDetails
(
Client
&
client
,
const
char
*
uri_utf8
)
{
{
const
Database
*
db
=
GetDatabase
(
IgnoreError
());
const
Database
*
db
=
GetDatabase
(
IgnoreError
());
if
(
db
==
nullptr
)
if
(
db
==
nullptr
)
...
@@ -125,13 +124,13 @@ PrintSongDetails(Client *client, const char *uri_utf8)
...
@@ -125,13 +124,13 @@ PrintSongDetails(Client *client, const char *uri_utf8)
if
(
song
==
nullptr
)
if
(
song
==
nullptr
)
return
false
;
return
false
;
song_print_info
(
client
,
song
);
song_print_info
(
client
,
*
song
);
db
->
ReturnSong
(
song
);
db
->
ReturnSong
(
song
);
return
true
;
return
true
;
}
}
bool
bool
spl_print
(
Client
*
client
,
const
char
*
name_utf8
,
bool
detail
,
spl_print
(
Client
&
client
,
const
char
*
name_utf8
,
bool
detail
,
Error
&
error
)
Error
&
error
)
{
{
PlaylistFileContents
contents
=
LoadPlaylistFile
(
name_utf8
,
error
);
PlaylistFileContents
contents
=
LoadPlaylistFile
(
name_utf8
,
error
);
...
@@ -148,7 +147,7 @@ spl_print(Client *client, const char *name_utf8, bool detail,
...
@@ -148,7 +147,7 @@ spl_print(Client *client, const char *name_utf8, bool detail,
}
}
static
void
static
void
playlist_provider_print
(
Client
*
client
,
const
char
*
uri
,
playlist_provider_print
(
Client
&
client
,
const
char
*
uri
,
SongEnumerator
&
e
,
bool
detail
)
SongEnumerator
&
e
,
bool
detail
)
{
{
Song
*
song
;
Song
*
song
;
...
@@ -160,9 +159,9 @@ playlist_provider_print(Client *client, const char *uri,
...
@@ -160,9 +159,9 @@ playlist_provider_print(Client *client, const char *uri,
continue
;
continue
;
if
(
detail
)
if
(
detail
)
song_print_info
(
client
,
song
);
song_print_info
(
client
,
*
song
);
else
else
song_print_uri
(
client
,
song
);
song_print_uri
(
client
,
*
song
);
song
->
Free
();
song
->
Free
();
}
}
...
@@ -171,7 +170,7 @@ playlist_provider_print(Client *client, const char *uri,
...
@@ -171,7 +170,7 @@ playlist_provider_print(Client *client, const char *uri,
}
}
bool
bool
playlist_file_print
(
Client
*
client
,
const
char
*
uri
,
bool
detail
)
playlist_file_print
(
Client
&
client
,
const
char
*
uri
,
bool
detail
)
{
{
Mutex
mutex
;
Mutex
mutex
;
Cond
cond
;
Cond
cond
;
...
...
src/PlaylistPrint.hxx
View file @
ff626ac7
/*
/*
* Copyright (C) 2003-2012 The Music Player Daemon Project
* Copyright (C) 2003-2012 The Music Player Daemon Project
* http://www.musicpd.org
* http://www.musicpd.org
...
@@ -31,7 +32,7 @@ class Error;
...
@@ -31,7 +32,7 @@ class Error;
* Sends the whole playlist to the client, song URIs only.
* Sends the whole playlist to the client, song URIs only.
*/
*/
void
void
playlist_print_uris
(
Client
*
client
,
const
struct
playlist
*
playlist
);
playlist_print_uris
(
Client
&
client
,
const
playlist
&
playlist
);
/**
/**
* Sends a range of the playlist to the client, including all known
* Sends a range of the playlist to the client, including all known
...
@@ -40,7 +41,7 @@ playlist_print_uris(Client *client, const struct playlist *playlist);
...
@@ -40,7 +41,7 @@ playlist_print_uris(Client *client, const struct playlist *playlist);
* This function however fails when the start offset is invalid.
* This function however fails when the start offset is invalid.
*/
*/
bool
bool
playlist_print_info
(
Client
*
client
,
const
struct
playlist
*
playlist
,
playlist_print_info
(
Client
&
client
,
const
playlist
&
playlist
,
unsigned
start
,
unsigned
end
);
unsigned
start
,
unsigned
end
);
/**
/**
...
@@ -49,7 +50,7 @@ playlist_print_info(Client *client, const struct playlist *playlist,
...
@@ -49,7 +50,7 @@ playlist_print_info(Client *client, const struct playlist *playlist,
* @return true on suite, false if there is no such song
* @return true on suite, false if there is no such song
*/
*/
bool
bool
playlist_print_id
(
Client
*
client
,
const
struct
playlist
*
playlist
,
playlist_print_id
(
Client
&
client
,
const
playlist
&
playlist
,
unsigned
id
);
unsigned
id
);
/**
/**
...
@@ -58,29 +59,29 @@ playlist_print_id(Client *client, const struct playlist *playlist,
...
@@ -58,29 +59,29 @@ playlist_print_id(Client *client, const struct playlist *playlist,
* @return true on success, false if there is no current song
* @return true on success, false if there is no current song
*/
*/
bool
bool
playlist_print_current
(
Client
*
client
,
const
struct
playlist
*
playlist
);
playlist_print_current
(
Client
&
client
,
const
playlist
&
playlist
);
/**
/**
* Find songs in the playlist.
* Find songs in the playlist.
*/
*/
void
void
playlist_print_find
(
Client
*
client
,
const
struct
playlist
*
playlist
,
playlist_print_find
(
Client
&
client
,
const
playlist
&
playlist
,
const
SongFilter
&
filter
);
const
SongFilter
&
filter
);
/**
/**
* Print detailed changes since the specified playlist version.
* Print detailed changes since the specified playlist version.
*/
*/
void
void
playlist_print_changes_info
(
Client
*
client
,
playlist_print_changes_info
(
Client
&
client
,
const
struct
playlist
*
playlist
,
const
playlist
&
playlist
,
uint32_t
version
);
uint32_t
version
);
/**
/**
* Print changes since the specified playlist version, position only.
* Print changes since the specified playlist version, position only.
*/
*/
void
void
playlist_print_changes_position
(
Client
*
client
,
playlist_print_changes_position
(
Client
&
client
,
const
struct
playlist
*
playlist
,
const
playlist
&
playlist
,
uint32_t
version
);
uint32_t
version
);
/**
/**
...
@@ -92,7 +93,7 @@ playlist_print_changes_position(Client *client,
...
@@ -92,7 +93,7 @@ playlist_print_changes_position(Client *client,
* @return true on success, false if the playlist does not exist
* @return true on success, false if the playlist does not exist
*/
*/
bool
bool
spl_print
(
Client
*
client
,
const
char
*
name_utf8
,
bool
detail
,
spl_print
(
Client
&
client
,
const
char
*
name_utf8
,
bool
detail
,
Error
&
error
);
Error
&
error
);
/**
/**
...
@@ -104,6 +105,6 @@ spl_print(Client *client, const char *name_utf8, bool detail,
...
@@ -104,6 +105,6 @@ spl_print(Client *client, const char *name_utf8, bool detail,
* @return true on success, false if the playlist does not exist
* @return true on success, false if the playlist does not exist
*/
*/
bool
bool
playlist_file_print
(
Client
*
client
,
const
char
*
uri
,
bool
detail
);
playlist_file_print
(
Client
&
client
,
const
char
*
uri
,
bool
detail
);
#endif
#endif
src/PlaylistQueue.cxx
View file @
ff626ac7
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
enum
playlist_result
enum
playlist_result
playlist_load_into_queue
(
const
char
*
uri
,
SongEnumerator
&
e
,
playlist_load_into_queue
(
const
char
*
uri
,
SongEnumerator
&
e
,
unsigned
start_index
,
unsigned
end_index
,
unsigned
start_index
,
unsigned
end_index
,
struct
playlist
*
dest
,
struct
player_control
*
pc
,
playlist
&
dest
,
player_control
&
pc
,
bool
secure
)
bool
secure
)
{
{
enum
playlist_result
result
;
enum
playlist_result
result
;
...
@@ -53,7 +53,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
...
@@ -53,7 +53,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
if
(
song
==
nullptr
)
if
(
song
==
nullptr
)
continue
;
continue
;
result
=
dest
->
AppendSong
(
*
pc
,
song
);
result
=
dest
.
AppendSong
(
pc
,
song
);
song
->
Free
();
song
->
Free
();
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
{
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
{
g_free
(
base_uri
);
g_free
(
base_uri
);
...
@@ -69,7 +69,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
...
@@ -69,7 +69,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
enum
playlist_result
enum
playlist_result
playlist_open_into_queue
(
const
char
*
uri
,
playlist_open_into_queue
(
const
char
*
uri
,
unsigned
start_index
,
unsigned
end_index
,
unsigned
start_index
,
unsigned
end_index
,
struct
playlist
*
dest
,
struct
player_control
*
pc
,
playlist
&
dest
,
player_control
&
pc
,
bool
secure
)
bool
secure
)
{
{
Mutex
mutex
;
Mutex
mutex
;
...
...
src/PlaylistQueue.hxx
View file @
ff626ac7
...
@@ -42,7 +42,7 @@ struct player_control;
...
@@ -42,7 +42,7 @@ struct player_control;
enum
playlist_result
enum
playlist_result
playlist_load_into_queue
(
const
char
*
uri
,
SongEnumerator
&
e
,
playlist_load_into_queue
(
const
char
*
uri
,
SongEnumerator
&
e
,
unsigned
start_index
,
unsigned
end_index
,
unsigned
start_index
,
unsigned
end_index
,
struct
playlist
*
dest
,
struct
player_control
*
pc
,
playlist
&
dest
,
player_control
&
pc
,
bool
secure
);
bool
secure
);
/**
/**
...
@@ -52,7 +52,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
...
@@ -52,7 +52,7 @@ playlist_load_into_queue(const char *uri, SongEnumerator &e,
enum
playlist_result
enum
playlist_result
playlist_open_into_queue
(
const
char
*
uri
,
playlist_open_into_queue
(
const
char
*
uri
,
unsigned
start_index
,
unsigned
end_index
,
unsigned
start_index
,
unsigned
end_index
,
struct
playlist
*
dest
,
struct
player_control
*
pc
,
playlist
&
dest
,
player_control
&
pc
,
bool
secure
);
bool
secure
);
#endif
#endif
...
...
src/PlaylistSave.cxx
View file @
ff626ac7
...
@@ -37,14 +37,14 @@
...
@@ -37,14 +37,14 @@
#include <string.h>
#include <string.h>
void
void
playlist_print_song
(
FILE
*
file
,
const
Song
*
song
)
playlist_print_song
(
FILE
*
file
,
const
Song
&
song
)
{
{
if
(
playlist_saveAbsolutePaths
&&
song
->
IsInDatabase
())
{
if
(
playlist_saveAbsolutePaths
&&
song
.
IsInDatabase
())
{
const
auto
path
=
map_song_fs
(
song
);
const
auto
path
=
map_song_fs
(
song
);
if
(
!
path
.
IsNull
())
if
(
!
path
.
IsNull
())
fprintf
(
file
,
"%s
\n
"
,
path
.
c_str
());
fprintf
(
file
,
"%s
\n
"
,
path
.
c_str
());
}
else
{
}
else
{
const
auto
uri_utf8
=
song
->
GetURI
();
const
auto
uri_utf8
=
song
.
GetURI
();
const
auto
uri_fs
=
AllocatedPath
::
FromUTF8
(
uri_utf8
.
c_str
());
const
auto
uri_fs
=
AllocatedPath
::
FromUTF8
(
uri_utf8
.
c_str
());
if
(
!
uri_fs
.
IsNull
())
if
(
!
uri_fs
.
IsNull
())
...
@@ -65,7 +65,7 @@ playlist_print_uri(FILE *file, const char *uri)
...
@@ -65,7 +65,7 @@ playlist_print_uri(FILE *file, const char *uri)
}
}
enum
playlist_result
enum
playlist_result
spl_save_queue
(
const
char
*
name_utf8
,
const
struct
queue
*
queue
)
spl_save_queue
(
const
char
*
name_utf8
,
const
queue
&
queue
)
{
{
if
(
map_spl_path
().
IsNull
())
if
(
map_spl_path
().
IsNull
())
return
PLAYLIST_RESULT_DISABLED
;
return
PLAYLIST_RESULT_DISABLED
;
...
@@ -85,8 +85,8 @@ spl_save_queue(const char *name_utf8, const struct queue *queue)
...
@@ -85,8 +85,8 @@ spl_save_queue(const char *name_utf8, const struct queue *queue)
if
(
file
==
nullptr
)
if
(
file
==
nullptr
)
return
PLAYLIST_RESULT_ERRNO
;
return
PLAYLIST_RESULT_ERRNO
;
for
(
unsigned
i
=
0
;
i
<
queue
->
GetLength
();
i
++
)
for
(
unsigned
i
=
0
;
i
<
queue
.
GetLength
();
i
++
)
playlist_print_song
(
file
,
queue
->
Get
(
i
));
playlist_print_song
(
file
,
queue
.
Get
(
i
));
fclose
(
file
);
fclose
(
file
);
...
@@ -95,13 +95,13 @@ spl_save_queue(const char *name_utf8, const struct queue *queue)
...
@@ -95,13 +95,13 @@ spl_save_queue(const char *name_utf8, const struct queue *queue)
}
}
enum
playlist_result
enum
playlist_result
spl_save_playlist
(
const
char
*
name_utf8
,
const
struct
playlist
*
playlist
)
spl_save_playlist
(
const
char
*
name_utf8
,
const
playlist
&
playlist
)
{
{
return
spl_save_queue
(
name_utf8
,
&
playlist
->
queue
);
return
spl_save_queue
(
name_utf8
,
playlist
.
queue
);
}
}
bool
bool
playlist_load_spl
(
struct
playlist
*
playlist
,
struct
player_control
*
pc
,
playlist_load_spl
(
struct
playlist
&
playlist
,
player_control
&
pc
,
const
char
*
name_utf8
,
const
char
*
name_utf8
,
unsigned
start_index
,
unsigned
end_index
,
unsigned
start_index
,
unsigned
end_index
,
Error
&
error
)
Error
&
error
)
...
@@ -119,13 +119,13 @@ playlist_load_spl(struct playlist *playlist, struct player_control *pc,
...
@@ -119,13 +119,13 @@ playlist_load_spl(struct playlist *playlist, struct player_control *pc,
if
(
memcmp
(
uri_utf8
.
c_str
(),
"file:///"
,
8
)
==
0
)
{
if
(
memcmp
(
uri_utf8
.
c_str
(),
"file:///"
,
8
)
==
0
)
{
const
char
*
path_utf8
=
uri_utf8
.
c_str
()
+
7
;
const
char
*
path_utf8
=
uri_utf8
.
c_str
()
+
7
;
if
(
playlist
->
AppendFile
(
*
pc
,
path_utf8
)
!=
PLAYLIST_RESULT_SUCCESS
)
if
(
playlist
.
AppendFile
(
pc
,
path_utf8
)
!=
PLAYLIST_RESULT_SUCCESS
)
FormatError
(
playlist_domain
,
FormatError
(
playlist_domain
,
"can't add file
\"
%s
\"
"
,
path_utf8
);
"can't add file
\"
%s
\"
"
,
path_utf8
);
continue
;
continue
;
}
}
if
((
playlist
->
AppendURI
(
*
pc
,
uri_utf8
.
c_str
()))
!=
PLAYLIST_RESULT_SUCCESS
)
{
if
((
playlist
.
AppendURI
(
pc
,
uri_utf8
.
c_str
()))
!=
PLAYLIST_RESULT_SUCCESS
)
{
/* for windows compatibility, convert slashes */
/* for windows compatibility, convert slashes */
char
*
temp2
=
g_strdup
(
uri_utf8
.
c_str
());
char
*
temp2
=
g_strdup
(
uri_utf8
.
c_str
());
char
*
p
=
temp2
;
char
*
p
=
temp2
;
...
@@ -135,7 +135,7 @@ playlist_load_spl(struct playlist *playlist, struct player_control *pc,
...
@@ -135,7 +135,7 @@ playlist_load_spl(struct playlist *playlist, struct player_control *pc,
p
++
;
p
++
;
}
}
if
(
playlist
->
AppendURI
(
*
pc
,
temp2
)
!=
PLAYLIST_RESULT_SUCCESS
)
if
(
playlist
.
AppendURI
(
pc
,
temp2
)
!=
PLAYLIST_RESULT_SUCCESS
)
FormatError
(
playlist_domain
,
FormatError
(
playlist_domain
,
"can't add file
\"
%s
\"
"
,
temp2
);
"can't add file
\"
%s
\"
"
,
temp2
);
...
...
src/PlaylistSave.hxx
View file @
ff626ac7
...
@@ -31,7 +31,7 @@ struct player_control;
...
@@ -31,7 +31,7 @@ struct player_control;
class
Error
;
class
Error
;
void
void
playlist_print_song
(
FILE
*
fp
,
const
Song
*
song
);
playlist_print_song
(
FILE
*
fp
,
const
Song
&
song
);
void
void
playlist_print_uri
(
FILE
*
fp
,
const
char
*
uri
);
playlist_print_uri
(
FILE
*
fp
,
const
char
*
uri
);
...
@@ -40,20 +40,20 @@ playlist_print_uri(FILE *fp, const char *uri);
...
@@ -40,20 +40,20 @@ playlist_print_uri(FILE *fp, const char *uri);
* Saves a queue object into a stored playlist file.
* Saves a queue object into a stored playlist file.
*/
*/
enum
playlist_result
enum
playlist_result
spl_save_queue
(
const
char
*
name_utf8
,
const
struct
queue
*
queue
);
spl_save_queue
(
const
char
*
name_utf8
,
const
queue
&
queue
);
/**
/**
* Saves a playlist object into a stored playlist file.
* Saves a playlist object into a stored playlist file.
*/
*/
enum
playlist_result
enum
playlist_result
spl_save_playlist
(
const
char
*
name_utf8
,
const
struct
playlist
*
playlist
);
spl_save_playlist
(
const
char
*
name_utf8
,
const
playlist
&
playlist
);
/**
/**
* Loads a stored playlist file, and append all songs to the global
* Loads a stored playlist file, and append all songs to the global
* playlist.
* playlist.
*/
*/
bool
bool
playlist_load_spl
(
struct
playlist
*
playlist
,
struct
player_control
*
pc
,
playlist_load_spl
(
struct
playlist
&
playlist
,
player_control
&
pc
,
const
char
*
name_utf8
,
const
char
*
name_utf8
,
unsigned
start_index
,
unsigned
end_index
,
unsigned
start_index
,
unsigned
end_index
,
Error
&
error
);
Error
&
error
);
...
...
src/PlaylistSong.cxx
View file @
ff626ac7
...
@@ -64,7 +64,7 @@ apply_song_metadata(Song *dest, const Song *src)
...
@@ -64,7 +64,7 @@ apply_song_metadata(Song *dest, const Song *src)
return
dest
;
return
dest
;
if
(
dest
->
IsInDatabase
())
{
if
(
dest
->
IsInDatabase
())
{
const
auto
path_fs
=
map_song_fs
(
dest
);
const
auto
path_fs
=
map_song_fs
(
*
dest
);
if
(
path_fs
.
IsNull
())
if
(
path_fs
.
IsNull
())
return
dest
;
return
dest
;
...
...
src/PlaylistState.cxx
View file @
ff626ac7
...
@@ -59,14 +59,14 @@
...
@@ -59,14 +59,14 @@
#define PLAYLIST_BUFFER_SIZE 2*MPD_PATH_MAX
#define PLAYLIST_BUFFER_SIZE 2*MPD_PATH_MAX
void
void
playlist_state_save
(
FILE
*
fp
,
const
struct
playlist
*
playlist
,
playlist_state_save
(
FILE
*
fp
,
const
struct
playlist
&
playlist
,
struct
player_control
*
pc
)
player_control
&
pc
)
{
{
const
auto
player_status
=
pc
->
GetStatus
();
const
auto
player_status
=
pc
.
GetStatus
();
fputs
(
PLAYLIST_STATE_FILE_STATE
,
fp
);
fputs
(
PLAYLIST_STATE_FILE_STATE
,
fp
);
if
(
playlist
->
playing
)
{
if
(
playlist
.
playing
)
{
switch
(
player_status
.
state
)
{
switch
(
player_status
.
state
)
{
case
PlayerState
:
:
PAUSE
:
case
PlayerState
:
:
PAUSE
:
fputs
(
PLAYLIST_STATE_FILE_STATE_PAUSE
"
\n
"
,
fp
);
fputs
(
PLAYLIST_STATE_FILE_STATE_PAUSE
"
\n
"
,
fp
);
...
@@ -75,35 +75,35 @@ playlist_state_save(FILE *fp, const struct playlist *playlist,
...
@@ -75,35 +75,35 @@ playlist_state_save(FILE *fp, const struct playlist *playlist,
fputs
(
PLAYLIST_STATE_FILE_STATE_PLAY
"
\n
"
,
fp
);
fputs
(
PLAYLIST_STATE_FILE_STATE_PLAY
"
\n
"
,
fp
);
}
}
fprintf
(
fp
,
PLAYLIST_STATE_FILE_CURRENT
"%i
\n
"
,
fprintf
(
fp
,
PLAYLIST_STATE_FILE_CURRENT
"%i
\n
"
,
playlist
->
queue
.
OrderToPosition
(
playlist
->
current
));
playlist
.
queue
.
OrderToPosition
(
playlist
.
current
));
fprintf
(
fp
,
PLAYLIST_STATE_FILE_TIME
"%i
\n
"
,
fprintf
(
fp
,
PLAYLIST_STATE_FILE_TIME
"%i
\n
"
,
(
int
)
player_status
.
elapsed_time
);
(
int
)
player_status
.
elapsed_time
);
}
else
{
}
else
{
fputs
(
PLAYLIST_STATE_FILE_STATE_STOP
"
\n
"
,
fp
);
fputs
(
PLAYLIST_STATE_FILE_STATE_STOP
"
\n
"
,
fp
);
if
(
playlist
->
current
>=
0
)
if
(
playlist
.
current
>=
0
)
fprintf
(
fp
,
PLAYLIST_STATE_FILE_CURRENT
"%i
\n
"
,
fprintf
(
fp
,
PLAYLIST_STATE_FILE_CURRENT
"%i
\n
"
,
playlist
->
queue
.
OrderToPosition
(
playlist
->
current
));
playlist
.
queue
.
OrderToPosition
(
playlist
.
current
));
}
}
fprintf
(
fp
,
PLAYLIST_STATE_FILE_RANDOM
"%i
\n
"
,
playlist
->
queue
.
random
);
fprintf
(
fp
,
PLAYLIST_STATE_FILE_RANDOM
"%i
\n
"
,
playlist
.
queue
.
random
);
fprintf
(
fp
,
PLAYLIST_STATE_FILE_REPEAT
"%i
\n
"
,
playlist
->
queue
.
repeat
);
fprintf
(
fp
,
PLAYLIST_STATE_FILE_REPEAT
"%i
\n
"
,
playlist
.
queue
.
repeat
);
fprintf
(
fp
,
PLAYLIST_STATE_FILE_SINGLE
"%i
\n
"
,
playlist
->
queue
.
single
);
fprintf
(
fp
,
PLAYLIST_STATE_FILE_SINGLE
"%i
\n
"
,
playlist
.
queue
.
single
);
fprintf
(
fp
,
PLAYLIST_STATE_FILE_CONSUME
"%i
\n
"
,
fprintf
(
fp
,
PLAYLIST_STATE_FILE_CONSUME
"%i
\n
"
,
playlist
->
queue
.
consume
);
playlist
.
queue
.
consume
);
fprintf
(
fp
,
PLAYLIST_STATE_FILE_CROSSFADE
"%i
\n
"
,
fprintf
(
fp
,
PLAYLIST_STATE_FILE_CROSSFADE
"%i
\n
"
,
(
int
)
pc
->
GetCrossFade
());
(
int
)
pc
.
GetCrossFade
());
fprintf
(
fp
,
PLAYLIST_STATE_FILE_MIXRAMPDB
"%f
\n
"
,
fprintf
(
fp
,
PLAYLIST_STATE_FILE_MIXRAMPDB
"%f
\n
"
,
pc
->
GetMixRampDb
());
pc
.
GetMixRampDb
());
fprintf
(
fp
,
PLAYLIST_STATE_FILE_MIXRAMPDELAY
"%f
\n
"
,
fprintf
(
fp
,
PLAYLIST_STATE_FILE_MIXRAMPDELAY
"%f
\n
"
,
pc
->
GetMixRampDelay
());
pc
.
GetMixRampDelay
());
fputs
(
PLAYLIST_STATE_FILE_PLAYLIST_BEGIN
"
\n
"
,
fp
);
fputs
(
PLAYLIST_STATE_FILE_PLAYLIST_BEGIN
"
\n
"
,
fp
);
queue_save
(
fp
,
&
playlist
->
queue
);
queue_save
(
fp
,
playlist
.
queue
);
fputs
(
PLAYLIST_STATE_FILE_PLAYLIST_END
"
\n
"
,
fp
);
fputs
(
PLAYLIST_STATE_FILE_PLAYLIST_END
"
\n
"
,
fp
);
}
}
static
void
static
void
playlist_state_load
(
TextFile
&
file
,
struct
playlist
*
playlist
)
playlist_state_load
(
TextFile
&
file
,
struct
playlist
&
playlist
)
{
{
const
char
*
line
=
file
.
ReadLine
();
const
char
*
line
=
file
.
ReadLine
();
if
(
line
==
nullptr
)
{
if
(
line
==
nullptr
)
{
...
@@ -112,7 +112,7 @@ playlist_state_load(TextFile &file, struct playlist *playlist)
...
@@ -112,7 +112,7 @@ playlist_state_load(TextFile &file, struct playlist *playlist)
}
}
while
(
!
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_PLAYLIST_END
))
{
while
(
!
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_PLAYLIST_END
))
{
queue_load_song
(
file
,
line
,
&
playlist
->
queue
);
queue_load_song
(
file
,
line
,
playlist
.
queue
);
line
=
file
.
ReadLine
();
line
=
file
.
ReadLine
();
if
(
line
==
nullptr
)
{
if
(
line
==
nullptr
)
{
...
@@ -123,12 +123,12 @@ playlist_state_load(TextFile &file, struct playlist *playlist)
...
@@ -123,12 +123,12 @@ playlist_state_load(TextFile &file, struct playlist *playlist)
}
}
}
}
playlist
->
queue
.
IncrementVersion
();
playlist
.
queue
.
IncrementVersion
();
}
}
bool
bool
playlist_state_restore
(
const
char
*
line
,
TextFile
&
file
,
playlist_state_restore
(
const
char
*
line
,
TextFile
&
file
,
struct
playlist
*
playlist
,
struct
player_control
*
pc
)
struct
playlist
&
playlist
,
player_control
&
pc
)
{
{
int
current
=
-
1
;
int
current
=
-
1
;
int
seek_time
=
0
;
int
seek_time
=
0
;
...
@@ -150,24 +150,24 @@ playlist_state_restore(const char *line, TextFile &file,
...
@@ -150,24 +150,24 @@ playlist_state_restore(const char *line, TextFile &file,
while
((
line
=
file
.
ReadLine
())
!=
nullptr
)
{
while
((
line
=
file
.
ReadLine
())
!=
nullptr
)
{
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_TIME
))
{
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_TIME
))
{
seek_time
=
seek_time
=
atoi
(
&
(
line
[
strlen
(
PLAYLIST_STATE_FILE_TIME
)]));
atoi
(
&
(
line
[
strlen
(
PLAYLIST_STATE_FILE_TIME
)]));
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_REPEAT
))
{
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_REPEAT
))
{
playlist
->
SetRepeat
(
*
pc
,
playlist
.
SetRepeat
(
pc
,
strcmp
(
&
(
line
[
strlen
(
PLAYLIST_STATE_FILE_REPEAT
)]),
strcmp
(
&
(
line
[
strlen
(
PLAYLIST_STATE_FILE_REPEAT
)]),
"1"
)
==
0
);
"1"
)
==
0
);
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_SINGLE
))
{
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_SINGLE
))
{
playlist
->
SetSingle
(
*
pc
,
playlist
.
SetSingle
(
pc
,
strcmp
(
&
(
line
[
strlen
(
PLAYLIST_STATE_FILE_SINGLE
)]),
strcmp
(
&
(
line
[
strlen
(
PLAYLIST_STATE_FILE_SINGLE
)]),
"1"
)
==
0
);
"1"
)
==
0
);
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_CONSUME
))
{
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_CONSUME
))
{
playlist
->
SetConsume
(
strcmp
(
&
(
line
[
strlen
(
PLAYLIST_STATE_FILE_CONSUME
)]),
playlist
.
SetConsume
(
strcmp
(
&
(
line
[
strlen
(
PLAYLIST_STATE_FILE_CONSUME
)]),
"1"
)
==
0
);
"1"
)
==
0
);
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_CROSSFADE
))
{
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_CROSSFADE
))
{
pc
->
SetCrossFade
(
atoi
(
line
+
strlen
(
PLAYLIST_STATE_FILE_CROSSFADE
)));
pc
.
SetCrossFade
(
atoi
(
line
+
strlen
(
PLAYLIST_STATE_FILE_CROSSFADE
)));
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_MIXRAMPDB
))
{
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_MIXRAMPDB
))
{
pc
->
SetMixRampDb
(
atof
(
line
+
strlen
(
PLAYLIST_STATE_FILE_MIXRAMPDB
)));
pc
.
SetMixRampDb
(
atof
(
line
+
strlen
(
PLAYLIST_STATE_FILE_MIXRAMPDB
)));
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_MIXRAMPDELAY
))
{
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_MIXRAMPDELAY
))
{
pc
->
SetMixRampDelay
(
atof
(
line
+
strlen
(
PLAYLIST_STATE_FILE_MIXRAMPDELAY
)));
pc
.
SetMixRampDelay
(
atof
(
line
+
strlen
(
PLAYLIST_STATE_FILE_MIXRAMPDELAY
)));
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_RANDOM
))
{
}
else
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_RANDOM
))
{
random_mode
=
random_mode
=
strcmp
(
line
+
strlen
(
PLAYLIST_STATE_FILE_RANDOM
),
strcmp
(
line
+
strlen
(
PLAYLIST_STATE_FILE_RANDOM
),
...
@@ -182,10 +182,10 @@ playlist_state_restore(const char *line, TextFile &file,
...
@@ -182,10 +182,10 @@ playlist_state_restore(const char *line, TextFile &file,
}
}
}
}
playlist
->
SetRandom
(
*
pc
,
random_mode
);
playlist
.
SetRandom
(
pc
,
random_mode
);
if
(
!
playlist
->
queue
.
IsEmpty
())
{
if
(
!
playlist
.
queue
.
IsEmpty
())
{
if
(
!
playlist
->
queue
.
IsValidPosition
(
current
))
if
(
!
playlist
.
queue
.
IsValidPosition
(
current
))
current
=
0
;
current
=
0
;
if
(
state
==
PlayerState
::
PLAY
&&
if
(
state
==
PlayerState
::
PLAY
&&
...
@@ -199,40 +199,40 @@ playlist_state_restore(const char *line, TextFile &file,
...
@@ -199,40 +199,40 @@ playlist_state_restore(const char *line, TextFile &file,
called here, after the audio output states were
called here, after the audio output states were
restored, before playback begins */
restored, before playback begins */
if
(
state
!=
PlayerState
::
STOP
)
if
(
state
!=
PlayerState
::
STOP
)
pc
->
UpdateAudio
();
pc
.
UpdateAudio
();
if
(
state
==
PlayerState
::
STOP
/* && config_option */
)
if
(
state
==
PlayerState
::
STOP
/* && config_option */
)
playlist
->
current
=
current
;
playlist
.
current
=
current
;
else
if
(
seek_time
==
0
)
else
if
(
seek_time
==
0
)
playlist
->
PlayPosition
(
*
pc
,
current
);
playlist
.
PlayPosition
(
pc
,
current
);
else
else
playlist
->
SeekSongPosition
(
*
pc
,
current
,
seek_time
);
playlist
.
SeekSongPosition
(
pc
,
current
,
seek_time
);
if
(
state
==
PlayerState
::
PAUSE
)
if
(
state
==
PlayerState
::
PAUSE
)
pc
->
Pause
();
pc
.
Pause
();
}
}
return
true
;
return
true
;
}
}
unsigned
unsigned
playlist_state_get_hash
(
const
struct
playlist
*
playlist
,
playlist_state_get_hash
(
const
playlist
&
playlist
,
struct
player_control
*
pc
)
player_control
&
pc
)
{
{
const
auto
player_status
=
pc
->
GetStatus
();
const
auto
player_status
=
pc
.
GetStatus
();
return
playlist
->
queue
.
version
^
return
playlist
.
queue
.
version
^
(
player_status
.
state
!=
PlayerState
::
STOP
(
player_status
.
state
!=
PlayerState
::
STOP
?
((
int
)
player_status
.
elapsed_time
<<
8
)
?
((
int
)
player_status
.
elapsed_time
<<
8
)
:
0
)
^
:
0
)
^
(
playlist
->
current
>=
0
(
playlist
.
current
>=
0
?
(
playlist
->
queue
.
OrderToPosition
(
playlist
->
current
)
<<
16
)
?
(
playlist
.
queue
.
OrderToPosition
(
playlist
.
current
)
<<
16
)
:
0
)
^
:
0
)
^
((
int
)
pc
->
GetCrossFade
()
<<
20
)
^
((
int
)
pc
.
GetCrossFade
()
<<
20
)
^
(
unsigned
(
player_status
.
state
)
<<
24
)
^
(
unsigned
(
player_status
.
state
)
<<
24
)
^
(
playlist
->
queue
.
random
<<
27
)
^
(
playlist
.
queue
.
random
<<
27
)
^
(
playlist
->
queue
.
repeat
<<
28
)
^
(
playlist
.
queue
.
repeat
<<
28
)
^
(
playlist
->
queue
.
single
<<
29
)
^
(
playlist
.
queue
.
single
<<
29
)
^
(
playlist
->
queue
.
consume
<<
30
)
^
(
playlist
.
queue
.
consume
<<
30
)
^
(
playlist
->
queue
.
random
<<
31
);
(
playlist
.
queue
.
random
<<
31
);
}
}
src/PlaylistState.hxx
View file @
ff626ac7
...
@@ -32,12 +32,12 @@ struct player_control;
...
@@ -32,12 +32,12 @@ struct player_control;
class
TextFile
;
class
TextFile
;
void
void
playlist_state_save
(
FILE
*
fp
,
const
struct
playlist
*
playlist
,
playlist_state_save
(
FILE
*
fp
,
const
struct
playlist
&
playlist
,
struct
player_control
*
pc
);
player_control
&
pc
);
bool
bool
playlist_state_restore
(
const
char
*
line
,
TextFile
&
file
,
playlist_state_restore
(
const
char
*
line
,
TextFile
&
file
,
struct
playlist
*
playlist
,
struct
player_control
*
pc
);
struct
playlist
&
playlist
,
player_control
&
pc
);
/**
/**
* Generates a hash number for the current state of the playlist and
* Generates a hash number for the current state of the playlist and
...
@@ -46,7 +46,7 @@ playlist_state_restore(const char *line, TextFile &file,
...
@@ -46,7 +46,7 @@ playlist_state_restore(const char *line, TextFile &file,
* be saved.
* be saved.
*/
*/
unsigned
unsigned
playlist_state_get_hash
(
const
struct
playlist
*
playlist
,
playlist_state_get_hash
(
const
struct
playlist
&
playlist
,
struct
player_control
*
p
c
);
player_control
&
c
);
#endif
#endif
src/Queue.cxx
View file @
ff626ac7
...
@@ -232,9 +232,11 @@ queue::DeletePosition(unsigned position)
...
@@ -232,9 +232,11 @@ queue::DeletePosition(unsigned position)
{
{
assert
(
position
<
length
);
assert
(
position
<
length
);
Song
*
song
=
Get
(
position
);
{
assert
(
!
song
->
IsInDatabase
()
||
song
->
IsDetached
());
Song
&
song
=
Get
(
position
);
song
->
Free
();
assert
(
!
song
.
IsInDatabase
()
||
song
.
IsDetached
());
song
.
Free
();
}
const
unsigned
id
=
PositionToId
(
position
);
const
unsigned
id
=
PositionToId
(
position
);
const
unsigned
_order
=
PositionToOrder
(
position
);
const
unsigned
_order
=
PositionToOrder
(
position
);
...
...
src/Queue.hxx
View file @
ff626ac7
...
@@ -200,16 +200,16 @@ struct queue {
...
@@ -200,16 +200,16 @@ struct queue {
/**
/**
* Returns the song at the specified position.
* Returns the song at the specified position.
*/
*/
Song
*
Get
(
unsigned
position
)
const
{
Song
&
Get
(
unsigned
position
)
const
{
assert
(
position
<
length
);
assert
(
position
<
length
);
return
items
[
position
].
song
;
return
*
items
[
position
].
song
;
}
}
/**
/**
* Returns the song at the specified order number.
* Returns the song at the specified order number.
*/
*/
Song
*
GetOrder
(
unsigned
_order
)
const
{
Song
&
GetOrder
(
unsigned
_order
)
const
{
return
Get
(
OrderToPosition
(
_order
));
return
Get
(
OrderToPosition
(
_order
));
}
}
...
...
src/QueueCommands.cxx
View file @
ff626ac7
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
#include <string.h>
#include <string.h>
enum
command_return
enum
command_return
handle_add
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_add
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
char
*
uri
=
argv
[
1
];
char
*
uri
=
argv
[
1
];
enum
playlist_result
result
;
enum
playlist_result
result
;
...
@@ -59,7 +59,7 @@ handle_add(Client *client, gcc_unused int argc, char *argv[])
...
@@ -59,7 +59,7 @@ handle_add(Client *client, gcc_unused int argc, char *argv[])
if
(
!
client_allow_file
(
client
,
path_fs
,
error
))
if
(
!
client_allow_file
(
client
,
path_fs
,
error
))
return
print_error
(
client
,
error
);
return
print_error
(
client
,
error
);
result
=
client
->
partition
.
AppendFile
(
path_utf8
);
result
=
client
.
partition
.
AppendFile
(
path_utf8
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -70,19 +70,19 @@ handle_add(Client *client, gcc_unused int argc, char *argv[])
...
@@ -70,19 +70,19 @@ handle_add(Client *client, gcc_unused int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
}
}
result
=
client
->
partition
.
AppendURI
(
uri
);
result
=
client
.
partition
.
AppendURI
(
uri
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
const
DatabaseSelection
selection
(
uri
,
true
);
const
DatabaseSelection
selection
(
uri
,
true
);
Error
error
;
Error
error
;
return
AddFromDatabase
(
client
->
partition
,
selection
,
error
)
return
AddFromDatabase
(
client
.
partition
,
selection
,
error
)
?
COMMAND_RETURN_OK
?
COMMAND_RETURN_OK
:
print_error
(
client
,
error
);
:
print_error
(
client
,
error
);
}
}
enum
command_return
enum
command_return
handle_addid
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_addid
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
char
*
uri
=
argv
[
1
];
char
*
uri
=
argv
[
1
];
unsigned
added_id
;
unsigned
added_id
;
...
@@ -102,7 +102,7 @@ handle_addid(Client *client, int argc, char *argv[])
...
@@ -102,7 +102,7 @@ handle_addid(Client *client, int argc, char *argv[])
if
(
!
client_allow_file
(
client
,
path_fs
,
error
))
if
(
!
client_allow_file
(
client
,
path_fs
,
error
))
return
print_error
(
client
,
error
);
return
print_error
(
client
,
error
);
result
=
client
->
partition
.
AppendFile
(
path_utf8
,
&
added_id
);
result
=
client
.
partition
.
AppendFile
(
path_utf8
,
&
added_id
);
}
else
{
}
else
{
if
(
uri_has_scheme
(
uri
)
&&
!
uri_supported_scheme
(
uri
))
{
if
(
uri_has_scheme
(
uri
)
&&
!
uri_supported_scheme
(
uri
))
{
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
command_error
(
client
,
ACK_ERROR_NO_EXIST
,
...
@@ -110,7 +110,7 @@ handle_addid(Client *client, int argc, char *argv[])
...
@@ -110,7 +110,7 @@ handle_addid(Client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
}
}
result
=
client
->
partition
.
AppendURI
(
uri
,
&
added_id
);
result
=
client
.
partition
.
AppendURI
(
uri
,
&
added_id
);
}
}
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
...
@@ -120,11 +120,11 @@ handle_addid(Client *client, int argc, char *argv[])
...
@@ -120,11 +120,11 @@ handle_addid(Client *client, int argc, char *argv[])
unsigned
to
;
unsigned
to
;
if
(
!
check_unsigned
(
client
,
&
to
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
to
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
result
=
client
->
partition
.
MoveId
(
added_id
,
to
);
result
=
client
.
partition
.
MoveId
(
added_id
,
to
);
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
{
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
{
enum
command_return
ret
=
enum
command_return
ret
=
print_playlist_result
(
client
,
result
);
print_playlist_result
(
client
,
result
);
client
->
partition
.
DeleteId
(
added_id
);
client
.
partition
.
DeleteId
(
added_id
);
return
ret
;
return
ret
;
}
}
}
}
...
@@ -134,83 +134,83 @@ handle_addid(Client *client, int argc, char *argv[])
...
@@ -134,83 +134,83 @@ handle_addid(Client *client, int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_delete
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_delete
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
start
,
end
;
unsigned
start
,
end
;
if
(
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
]))
if
(
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
client
->
partition
.
DeleteRange
(
start
,
end
);
enum
playlist_result
result
=
client
.
partition
.
DeleteRange
(
start
,
end
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
enum
command_return
handle_deleteid
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_deleteid
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
id
;
unsigned
id
;
if
(
!
check_unsigned
(
client
,
&
id
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
id
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
client
->
partition
.
DeleteId
(
id
);
enum
playlist_result
result
=
client
.
partition
.
DeleteId
(
id
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
enum
command_return
handle_playlist
(
Client
*
client
,
handle_playlist
(
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
playlist_print_uris
(
client
,
&
client
->
playlist
);
playlist_print_uris
(
client
,
client
.
playlist
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_shuffle
(
gcc_unused
Client
*
client
,
handle_shuffle
(
gcc_unused
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
unsigned
start
=
0
,
end
=
client
->
playlist
.
queue
.
GetLength
();
unsigned
start
=
0
,
end
=
client
.
playlist
.
queue
.
GetLength
();
if
(
argc
==
2
&&
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
]))
if
(
argc
==
2
&&
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
client
->
partition
.
Shuffle
(
start
,
end
);
client
.
partition
.
Shuffle
(
start
,
end
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_clear
(
gcc_unused
Client
*
client
,
handle_clear
(
gcc_unused
Client
&
client
,
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
gcc_unused
int
argc
,
gcc_unused
char
*
argv
[])
{
{
client
->
partition
.
ClearQueue
();
client
.
partition
.
ClearQueue
();
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_plchanges
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_plchanges
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
uint32_t
version
;
uint32_t
version
;
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
]))
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
playlist_print_changes_info
(
client
,
&
client
->
playlist
,
version
);
playlist_print_changes_info
(
client
,
client
.
playlist
,
version
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_plchangesposid
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_plchangesposid
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
uint32_t
version
;
uint32_t
version
;
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
]))
if
(
!
check_uint32
(
client
,
&
version
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
playlist_print_changes_position
(
client
,
&
client
->
playlist
,
version
);
playlist_print_changes_position
(
client
,
client
.
playlist
,
version
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_playlistinfo
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_playlistinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
unsigned
start
=
0
,
end
=
std
::
numeric_limits
<
unsigned
>::
max
();
unsigned
start
=
0
,
end
=
std
::
numeric_limits
<
unsigned
>::
max
();
bool
ret
;
bool
ret
;
...
@@ -218,7 +218,7 @@ handle_playlistinfo(Client *client, int argc, char *argv[])
...
@@ -218,7 +218,7 @@ handle_playlistinfo(Client *client, int argc, char *argv[])
if
(
argc
==
2
&&
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
]))
if
(
argc
==
2
&&
!
check_range
(
client
,
&
start
,
&
end
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
ret
=
playlist_print_info
(
client
,
&
client
->
playlist
,
start
,
end
);
ret
=
playlist_print_info
(
client
,
client
.
playlist
,
start
,
end
);
if
(
!
ret
)
if
(
!
ret
)
return
print_playlist_result
(
client
,
return
print_playlist_result
(
client
,
PLAYLIST_RESULT_BAD_RANGE
);
PLAYLIST_RESULT_BAD_RANGE
);
...
@@ -227,19 +227,19 @@ handle_playlistinfo(Client *client, int argc, char *argv[])
...
@@ -227,19 +227,19 @@ handle_playlistinfo(Client *client, int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_playlistid
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_playlistid
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
if
(
argc
>=
2
)
{
if
(
argc
>=
2
)
{
unsigned
id
;
unsigned
id
;
if
(
!
check_unsigned
(
client
,
&
id
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
id
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
bool
ret
=
playlist_print_id
(
client
,
&
client
->
playlist
,
id
);
bool
ret
=
playlist_print_id
(
client
,
client
.
playlist
,
id
);
if
(
!
ret
)
if
(
!
ret
)
return
print_playlist_result
(
client
,
return
print_playlist_result
(
client
,
PLAYLIST_RESULT_NO_SUCH_SONG
);
PLAYLIST_RESULT_NO_SUCH_SONG
);
}
else
{
}
else
{
playlist_print_info
(
client
,
&
client
->
playlist
,
playlist_print_info
(
client
,
client
.
playlist
,
0
,
std
::
numeric_limits
<
unsigned
>::
max
());
0
,
std
::
numeric_limits
<
unsigned
>::
max
());
}
}
...
@@ -247,7 +247,7 @@ handle_playlistid(Client *client, int argc, char *argv[])
...
@@ -247,7 +247,7 @@ handle_playlistid(Client *client, int argc, char *argv[])
}
}
static
enum
command_return
static
enum
command_return
handle_playlist_match
(
Client
*
client
,
int
argc
,
char
*
argv
[],
handle_playlist_match
(
Client
&
client
,
int
argc
,
char
*
argv
[],
bool
fold_case
)
bool
fold_case
)
{
{
SongFilter
filter
;
SongFilter
filter
;
...
@@ -256,24 +256,24 @@ handle_playlist_match(Client *client, int argc, char *argv[],
...
@@ -256,24 +256,24 @@ handle_playlist_match(Client *client, int argc, char *argv[],
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
}
}
playlist_print_find
(
client
,
&
client
->
playlist
,
filter
);
playlist_print_find
(
client
,
client
.
playlist
,
filter
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
enum
command_return
enum
command_return
handle_playlistfind
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_playlistfind
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
return
handle_playlist_match
(
client
,
argc
,
argv
,
false
);
return
handle_playlist_match
(
client
,
argc
,
argv
,
false
);
}
}
enum
command_return
enum
command_return
handle_playlistsearch
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_playlistsearch
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
return
handle_playlist_match
(
client
,
argc
,
argv
,
true
);
return
handle_playlist_match
(
client
,
argc
,
argv
,
true
);
}
}
enum
command_return
enum
command_return
handle_prio
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_prio
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
unsigned
priority
;
unsigned
priority
;
...
@@ -293,7 +293,7 @@ handle_prio(Client *client, int argc, char *argv[])
...
@@ -293,7 +293,7 @@ handle_prio(Client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
enum
playlist_result
result
=
client
->
partition
.
SetPriorityRange
(
start_position
,
client
.
partition
.
SetPriorityRange
(
start_position
,
end_position
,
end_position
,
priority
);
priority
);
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
...
@@ -304,7 +304,7 @@ handle_prio(Client *client, int argc, char *argv[])
...
@@ -304,7 +304,7 @@ handle_prio(Client *client, int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_prioid
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_prioid
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
unsigned
priority
;
unsigned
priority
;
...
@@ -323,7 +323,7 @@ handle_prioid(Client *client, int argc, char *argv[])
...
@@ -323,7 +323,7 @@ handle_prioid(Client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
enum
playlist_result
result
=
client
->
partition
.
SetPriorityId
(
song_id
,
priority
);
client
.
partition
.
SetPriorityId
(
song_id
,
priority
);
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
...
@@ -332,7 +332,7 @@ handle_prioid(Client *client, int argc, char *argv[])
...
@@ -332,7 +332,7 @@ handle_prioid(Client *client, int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_move
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_move
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
start
,
end
;
unsigned
start
,
end
;
int
to
;
int
to
;
...
@@ -343,12 +343,12 @@ handle_move(Client *client, gcc_unused int argc, char *argv[])
...
@@ -343,12 +343,12 @@ handle_move(Client *client, gcc_unused int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
enum
playlist_result
result
=
client
->
partition
.
MoveRange
(
start
,
end
,
to
);
client
.
partition
.
MoveRange
(
start
,
end
,
to
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
enum
command_return
handle_moveid
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_moveid
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
id
;
unsigned
id
;
int
to
;
int
to
;
...
@@ -357,12 +357,12 @@ handle_moveid(Client *client, gcc_unused int argc, char *argv[])
...
@@ -357,12 +357,12 @@ handle_moveid(Client *client, gcc_unused int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
if
(
!
check_int
(
client
,
&
to
,
argv
[
2
]))
if
(
!
check_int
(
client
,
&
to
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
client
->
partition
.
MoveId
(
id
,
to
);
enum
playlist_result
result
=
client
.
partition
.
MoveId
(
id
,
to
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
enum
command_return
handle_swap
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_swap
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
song1
,
song2
;
unsigned
song1
,
song2
;
...
@@ -372,12 +372,12 @@ handle_swap(Client *client, gcc_unused int argc, char *argv[])
...
@@ -372,12 +372,12 @@ handle_swap(Client *client, gcc_unused int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
enum
playlist_result
result
=
client
->
partition
.
SwapPositions
(
song1
,
song2
);
client
.
partition
.
SwapPositions
(
song1
,
song2
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
enum
command_return
enum
command_return
handle_swapid
(
Client
*
client
,
gcc_unused
int
argc
,
char
*
argv
[])
handle_swapid
(
Client
&
client
,
gcc_unused
int
argc
,
char
*
argv
[])
{
{
unsigned
id1
,
id2
;
unsigned
id1
,
id2
;
...
@@ -386,6 +386,6 @@ handle_swapid(Client *client, gcc_unused int argc, char *argv[])
...
@@ -386,6 +386,6 @@ handle_swapid(Client *client, gcc_unused int argc, char *argv[])
if
(
!
check_unsigned
(
client
,
&
id2
,
argv
[
2
]))
if
(
!
check_unsigned
(
client
,
&
id2
,
argv
[
2
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
enum
playlist_result
result
=
client
->
partition
.
SwapIds
(
id1
,
id2
);
enum
playlist_result
result
=
client
.
partition
.
SwapIds
(
id1
,
id2
);
return
print_playlist_result
(
client
,
result
);
return
print_playlist_result
(
client
,
result
);
}
}
src/QueueCommands.hxx
View file @
ff626ac7
...
@@ -25,60 +25,60 @@
...
@@ -25,60 +25,60 @@
class
Client
;
class
Client
;
enum
command_return
enum
command_return
handle_add
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_add
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_addid
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_addid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_delete
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_delete
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_deleteid
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_deleteid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_playlist
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_playlist
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_shuffle
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_shuffle
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_clear
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_clear
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_plchanges
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_plchanges
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_plchangesposid
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_plchangesposid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_playlistinfo
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_playlistinfo
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_playlistid
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_playlistid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_playlistfind
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_playlistfind
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_playlistsearch
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_playlistsearch
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_prio
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_prio
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_prioid
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_prioid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_move
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_move
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_moveid
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_moveid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_swap
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_swap
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
enum
command_return
enum
command_return
handle_swapid
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_swapid
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/QueuePrint.cxx
View file @
ff626ac7
...
@@ -38,70 +38,70 @@ extern "C" {
...
@@ -38,70 +38,70 @@ extern "C" {
* @param end the index of the last song (excluding)
* @param end the index of the last song (excluding)
*/
*/
static
void
static
void
queue_print_song_info
(
Client
*
client
,
const
struct
queue
*
queue
,
queue_print_song_info
(
Client
&
client
,
const
queue
&
queue
,
unsigned
position
)
unsigned
position
)
{
{
song_print_info
(
client
,
queue
->
Get
(
position
));
song_print_info
(
client
,
queue
.
Get
(
position
));
client_printf
(
client
,
"Pos: %u
\n
Id: %u
\n
"
,
client_printf
(
client
,
"Pos: %u
\n
Id: %u
\n
"
,
position
,
queue
->
PositionToId
(
position
));
position
,
queue
.
PositionToId
(
position
));
uint8_t
priority
=
queue
->
GetPriorityAtPosition
(
position
);
uint8_t
priority
=
queue
.
GetPriorityAtPosition
(
position
);
if
(
priority
!=
0
)
if
(
priority
!=
0
)
client_printf
(
client
,
"Prio: %u
\n
"
,
priority
);
client_printf
(
client
,
"Prio: %u
\n
"
,
priority
);
}
}
void
void
queue_print_info
(
Client
*
client
,
const
struct
queue
*
queue
,
queue_print_info
(
Client
&
client
,
const
queue
&
queue
,
unsigned
start
,
unsigned
end
)
unsigned
start
,
unsigned
end
)
{
{
assert
(
start
<=
end
);
assert
(
start
<=
end
);
assert
(
end
<=
queue
->
GetLength
());
assert
(
end
<=
queue
.
GetLength
());
for
(
unsigned
i
=
start
;
i
<
end
;
++
i
)
for
(
unsigned
i
=
start
;
i
<
end
;
++
i
)
queue_print_song_info
(
client
,
queue
,
i
);
queue_print_song_info
(
client
,
queue
,
i
);
}
}
void
void
queue_print_uris
(
Client
*
client
,
const
struct
queue
*
queue
,
queue_print_uris
(
Client
&
client
,
const
queue
&
queue
,
unsigned
start
,
unsigned
end
)
unsigned
start
,
unsigned
end
)
{
{
assert
(
start
<=
end
);
assert
(
start
<=
end
);
assert
(
end
<=
queue
->
GetLength
());
assert
(
end
<=
queue
.
GetLength
());
for
(
unsigned
i
=
start
;
i
<
end
;
++
i
)
{
for
(
unsigned
i
=
start
;
i
<
end
;
++
i
)
{
client_printf
(
client
,
"%i:"
,
i
);
client_printf
(
client
,
"%i:"
,
i
);
song_print_uri
(
client
,
queue
->
Get
(
i
));
song_print_uri
(
client
,
queue
.
Get
(
i
));
}
}
}
}
void
void
queue_print_changes_info
(
Client
*
client
,
const
struct
queue
*
queue
,
queue_print_changes_info
(
Client
&
client
,
const
queue
&
queue
,
uint32_t
version
)
uint32_t
version
)
{
{
for
(
unsigned
i
=
0
;
i
<
queue
->
GetLength
();
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
queue
.
GetLength
();
i
++
)
{
if
(
queue
->
IsNewerAtPosition
(
i
,
version
))
if
(
queue
.
IsNewerAtPosition
(
i
,
version
))
queue_print_song_info
(
client
,
queue
,
i
);
queue_print_song_info
(
client
,
queue
,
i
);
}
}
}
}
void
void
queue_print_changes_position
(
Client
*
client
,
const
struct
queue
*
queue
,
queue_print_changes_position
(
Client
&
client
,
const
queue
&
queue
,
uint32_t
version
)
uint32_t
version
)
{
{
for
(
unsigned
i
=
0
;
i
<
queue
->
GetLength
();
i
++
)
for
(
unsigned
i
=
0
;
i
<
queue
.
GetLength
();
i
++
)
if
(
queue
->
IsNewerAtPosition
(
i
,
version
))
if
(
queue
.
IsNewerAtPosition
(
i
,
version
))
client_printf
(
client
,
"cpos: %i
\n
Id: %i
\n
"
,
client_printf
(
client
,
"cpos: %i
\n
Id: %i
\n
"
,
i
,
queue
->
PositionToId
(
i
));
i
,
queue
.
PositionToId
(
i
));
}
}
void
void
queue_find
(
Client
*
client
,
const
struct
queue
*
queue
,
queue_find
(
Client
&
client
,
const
queue
&
queue
,
const
SongFilter
&
filter
)
const
SongFilter
&
filter
)
{
{
for
(
unsigned
i
=
0
;
i
<
queue
->
GetLength
();
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
queue
.
GetLength
();
i
++
)
{
const
Song
*
song
=
queue
->
Get
(
i
);
const
Song
&
song
=
queue
.
Get
(
i
);
if
(
filter
.
Match
(
*
song
))
if
(
filter
.
Match
(
song
))
queue_print_song_info
(
client
,
queue
,
i
);
queue_print_song_info
(
client
,
queue
,
i
);
}
}
}
}
src/QueuePrint.hxx
View file @
ff626ac7
...
@@ -32,23 +32,23 @@ class SongFilter;
...
@@ -32,23 +32,23 @@ class SongFilter;
class
Client
;
class
Client
;
void
void
queue_print_info
(
Client
*
client
,
const
struct
queue
*
queue
,
queue_print_info
(
Client
&
client
,
const
queue
&
queue
,
unsigned
start
,
unsigned
end
);
unsigned
start
,
unsigned
end
);
void
void
queue_print_uris
(
Client
*
client
,
const
struct
queue
*
queue
,
queue_print_uris
(
Client
&
client
,
const
queue
&
queue
,
unsigned
start
,
unsigned
end
);
unsigned
start
,
unsigned
end
);
void
void
queue_print_changes_info
(
Client
*
client
,
const
struct
queue
*
queue
,
queue_print_changes_info
(
Client
&
client
,
const
queue
&
queue
,
uint32_t
version
);
uint32_t
version
);
void
void
queue_print_changes_position
(
Client
*
client
,
const
struct
queue
*
queue
,
queue_print_changes_position
(
Client
&
client
,
const
queue
&
queue
,
uint32_t
version
);
uint32_t
version
);
void
void
queue_find
(
Client
*
client
,
const
struct
queue
*
queue
,
queue_find
(
Client
&
client
,
const
queue
&
queue
,
const
SongFilter
&
filter
);
const
SongFilter
&
filter
);
#endif
#endif
src/QueueSave.cxx
View file @
ff626ac7
...
@@ -38,43 +38,43 @@
...
@@ -38,43 +38,43 @@
#define PRIO_LABEL "Prio: "
#define PRIO_LABEL "Prio: "
static
void
static
void
queue_save_database_song
(
FILE
*
fp
,
int
idx
,
const
Song
*
song
)
queue_save_database_song
(
FILE
*
fp
,
int
idx
,
const
Song
&
song
)
{
{
const
auto
uri
=
song
->
GetURI
();
const
auto
uri
=
song
.
GetURI
();
fprintf
(
fp
,
"%i:%s
\n
"
,
idx
,
uri
.
c_str
());
fprintf
(
fp
,
"%i:%s
\n
"
,
idx
,
uri
.
c_str
());
}
}
static
void
static
void
queue_save_full_song
(
FILE
*
fp
,
const
Song
*
song
)
queue_save_full_song
(
FILE
*
fp
,
const
Song
&
song
)
{
{
song_save
(
fp
,
song
);
song_save
(
fp
,
song
);
}
}
static
void
static
void
queue_save_song
(
FILE
*
fp
,
int
idx
,
const
Song
*
song
)
queue_save_song
(
FILE
*
fp
,
int
idx
,
const
Song
&
song
)
{
{
if
(
song
->
IsInDatabase
())
if
(
song
.
IsInDatabase
())
queue_save_database_song
(
fp
,
idx
,
song
);
queue_save_database_song
(
fp
,
idx
,
song
);
else
else
queue_save_full_song
(
fp
,
song
);
queue_save_full_song
(
fp
,
song
);
}
}
void
void
queue_save
(
FILE
*
fp
,
const
struct
queue
*
queue
)
queue_save
(
FILE
*
fp
,
const
queue
&
queue
)
{
{
for
(
unsigned
i
=
0
;
i
<
queue
->
GetLength
();
i
++
)
{
for
(
unsigned
i
=
0
;
i
<
queue
.
GetLength
();
i
++
)
{
uint8_t
prio
=
queue
->
GetPriorityAtPosition
(
i
);
uint8_t
prio
=
queue
.
GetPriorityAtPosition
(
i
);
if
(
prio
!=
0
)
if
(
prio
!=
0
)
fprintf
(
fp
,
PRIO_LABEL
"%u
\n
"
,
prio
);
fprintf
(
fp
,
PRIO_LABEL
"%u
\n
"
,
prio
);
queue_save_song
(
fp
,
i
,
queue
->
Get
(
i
));
queue_save_song
(
fp
,
i
,
queue
.
Get
(
i
));
}
}
}
}
void
void
queue_load_song
(
TextFile
&
file
,
const
char
*
line
,
queue
*
queue
)
queue_load_song
(
TextFile
&
file
,
const
char
*
line
,
queue
&
queue
)
{
{
if
(
queue
->
IsFull
())
if
(
queue
.
IsFull
())
return
;
return
;
uint8_t
priority
=
0
;
uint8_t
priority
=
0
;
...
@@ -124,7 +124,7 @@ queue_load_song(TextFile &file, const char *line, queue *queue)
...
@@ -124,7 +124,7 @@ queue_load_song(TextFile &file, const char *line, queue *queue)
}
}
}
}
queue
->
Append
(
song
,
priority
);
queue
.
Append
(
song
,
priority
);
if
(
db
!=
nullptr
)
if
(
db
!=
nullptr
)
db
->
ReturnSong
(
song
);
db
->
ReturnSong
(
song
);
...
...
src/QueueSave.hxx
View file @
ff626ac7
...
@@ -31,12 +31,12 @@ struct queue;
...
@@ -31,12 +31,12 @@ struct queue;
class
TextFile
;
class
TextFile
;
void
void
queue_save
(
FILE
*
fp
,
const
struct
queue
*
queue
);
queue_save
(
FILE
*
fp
,
const
queue
&
queue
);
/**
/**
* Loads one song from the state file and appends it to the queue.
* Loads one song from the state file and appends it to the queue.
*/
*/
void
void
queue_load_song
(
TextFile
&
file
,
const
char
*
line
,
queue
*
queue
);
queue_load_song
(
TextFile
&
file
,
const
char
*
line
,
queue
&
queue
);
#endif
#endif
src/Song.hxx
View file @
ff626ac7
...
@@ -83,6 +83,10 @@ struct Song {
...
@@ -83,6 +83,10 @@ struct Song {
gcc_malloc
gcc_malloc
static
Song
*
LoadFile
(
const
char
*
path_utf8
,
Directory
*
parent
);
static
Song
*
LoadFile
(
const
char
*
path_utf8
,
Directory
*
parent
);
static
Song
*
LoadFile
(
const
char
*
path_utf8
,
Directory
&
parent
)
{
return
LoadFile
(
path_utf8
,
&
parent
);
}
/**
/**
* Replaces the URI of a song object. The given song object
* Replaces the URI of a song object. The given song object
* is destroyed, and a newly allocated one is returned. It
* is destroyed, and a newly allocated one is returned. It
...
...
src/SongPrint.cxx
View file @
ff626ac7
...
@@ -30,18 +30,18 @@
...
@@ -30,18 +30,18 @@
#include <glib.h>
#include <glib.h>
void
void
song_print_uri
(
Client
*
client
,
Song
*
song
)
song_print_uri
(
Client
&
client
,
const
Song
&
song
)
{
{
if
(
song
->
IsInDatabase
()
&&
!
song
->
parent
->
IsRoot
())
{
if
(
song
.
IsInDatabase
()
&&
!
song
.
parent
->
IsRoot
())
{
client_printf
(
client
,
"%s%s/%s
\n
"
,
SONG_FILE
,
client_printf
(
client
,
"%s%s/%s
\n
"
,
SONG_FILE
,
song
->
parent
->
GetPath
(),
song
->
uri
);
song
.
parent
->
GetPath
(),
song
.
uri
);
}
else
{
}
else
{
char
*
allocated
;
char
*
allocated
;
const
char
*
uri
;
const
char
*
uri
;
uri
=
allocated
=
uri_remove_auth
(
song
->
uri
);
uri
=
allocated
=
uri_remove_auth
(
song
.
uri
);
if
(
uri
==
NULL
)
if
(
uri
==
NULL
)
uri
=
song
->
uri
;
uri
=
song
.
uri
;
client_printf
(
client
,
"%s%s
\n
"
,
SONG_FILE
,
client_printf
(
client
,
"%s%s
\n
"
,
SONG_FILE
,
map_to_relative_path
(
uri
));
map_to_relative_path
(
uri
));
...
@@ -51,24 +51,24 @@ song_print_uri(Client *client, Song *song)
...
@@ -51,24 +51,24 @@ song_print_uri(Client *client, Song *song)
}
}
void
void
song_print_info
(
Client
*
client
,
Song
*
song
)
song_print_info
(
Client
&
client
,
const
Song
&
song
)
{
{
song_print_uri
(
client
,
song
);
song_print_uri
(
client
,
song
);
if
(
song
->
end_ms
>
0
)
if
(
song
.
end_ms
>
0
)
client_printf
(
client
,
"Range: %u.%03u-%u.%03u
\n
"
,
client_printf
(
client
,
"Range: %u.%03u-%u.%03u
\n
"
,
song
->
start_ms
/
1000
,
song
.
start_ms
/
1000
,
song
->
start_ms
%
1000
,
song
.
start_ms
%
1000
,
song
->
end_ms
/
1000
,
song
.
end_ms
/
1000
,
song
->
end_ms
%
1000
);
song
.
end_ms
%
1000
);
else
if
(
song
->
start_ms
>
0
)
else
if
(
song
.
start_ms
>
0
)
client_printf
(
client
,
"Range: %u.%03u-
\n
"
,
client_printf
(
client
,
"Range: %u.%03u-
\n
"
,
song
->
start_ms
/
1000
,
song
.
start_ms
/
1000
,
song
->
start_ms
%
1000
);
song
.
start_ms
%
1000
);
if
(
song
->
mtime
>
0
)
if
(
song
.
mtime
>
0
)
time_print
(
client
,
"Last-Modified"
,
song
->
mtime
);
time_print
(
client
,
"Last-Modified"
,
song
.
mtime
);
if
(
song
->
tag
!=
nullptr
)
if
(
song
.
tag
!=
nullptr
)
tag_print
(
client
,
*
song
->
tag
);
tag_print
(
client
,
*
song
.
tag
);
}
}
src/SongPrint.hxx
View file @
ff626ac7
...
@@ -24,9 +24,9 @@ struct Song;
...
@@ -24,9 +24,9 @@ struct Song;
class
Client
;
class
Client
;
void
void
song_print_info
(
Client
*
client
,
Song
*
song
);
song_print_info
(
Client
&
client
,
const
Song
&
song
);
void
void
song_print_uri
(
Client
*
client
,
Song
*
song
);
song_print_uri
(
Client
&
client
,
const
Song
&
song
);
#endif
#endif
src/SongSave.cxx
View file @
ff626ac7
...
@@ -37,19 +37,19 @@
...
@@ -37,19 +37,19 @@
static
constexpr
Domain
song_save_domain
(
"song_save"
);
static
constexpr
Domain
song_save_domain
(
"song_save"
);
void
void
song_save
(
FILE
*
fp
,
const
Song
*
song
)
song_save
(
FILE
*
fp
,
const
Song
&
song
)
{
{
fprintf
(
fp
,
SONG_BEGIN
"%s
\n
"
,
song
->
uri
);
fprintf
(
fp
,
SONG_BEGIN
"%s
\n
"
,
song
.
uri
);
if
(
song
->
end_ms
>
0
)
if
(
song
.
end_ms
>
0
)
fprintf
(
fp
,
"Range: %u-%u
\n
"
,
song
->
start_ms
,
song
->
end_ms
);
fprintf
(
fp
,
"Range: %u-%u
\n
"
,
song
.
start_ms
,
song
.
end_ms
);
else
if
(
song
->
start_ms
>
0
)
else
if
(
song
.
start_ms
>
0
)
fprintf
(
fp
,
"Range: %u-
\n
"
,
song
->
start_ms
);
fprintf
(
fp
,
"Range: %u-
\n
"
,
song
.
start_ms
);
if
(
song
->
tag
!=
nullptr
)
if
(
song
.
tag
!=
nullptr
)
tag_save
(
fp
,
*
song
->
tag
);
tag_save
(
fp
,
*
song
.
tag
);
fprintf
(
fp
,
SONG_MTIME
": %li
\n
"
,
(
long
)
song
->
mtime
);
fprintf
(
fp
,
SONG_MTIME
": %li
\n
"
,
(
long
)
song
.
mtime
);
fprintf
(
fp
,
SONG_END
"
\n
"
);
fprintf
(
fp
,
SONG_END
"
\n
"
);
}
}
...
...
src/SongSave.hxx
View file @
ff626ac7
...
@@ -30,7 +30,7 @@ class TextFile;
...
@@ -30,7 +30,7 @@ class TextFile;
class
Error
;
class
Error
;
void
void
song_save
(
FILE
*
fp
,
const
Song
*
song
);
song_save
(
FILE
*
fp
,
const
Song
&
song
);
/**
/**
* Loads a song from the input file. Reading stops after the
* Loads a song from the input file. Reading stops after the
...
...
src/SongSticker.cxx
View file @
ff626ac7
...
@@ -84,7 +84,7 @@ struct sticker_song_find_data {
...
@@ -84,7 +84,7 @@ struct sticker_song_find_data {
const
char
*
base_uri
;
const
char
*
base_uri
;
size_t
base_uri_length
;
size_t
base_uri_length
;
void
(
*
func
)(
Song
*
song
,
const
char
*
value
,
void
(
*
func
)(
Song
&
song
,
const
char
*
value
,
void
*
user_data
);
void
*
user_data
);
void
*
user_data
;
void
*
user_data
;
};
};
...
@@ -101,22 +101,22 @@ sticker_song_find_cb(const char *uri, const char *value, void *user_data)
...
@@ -101,22 +101,22 @@ sticker_song_find_cb(const char *uri, const char *value, void *user_data)
Song
*
song
=
data
->
directory
->
LookupSong
(
uri
+
data
->
base_uri_length
);
Song
*
song
=
data
->
directory
->
LookupSong
(
uri
+
data
->
base_uri_length
);
if
(
song
!=
nullptr
)
if
(
song
!=
nullptr
)
data
->
func
(
song
,
value
,
data
->
user_data
);
data
->
func
(
*
song
,
value
,
data
->
user_data
);
}
}
bool
bool
sticker_song_find
(
Directory
*
directory
,
const
char
*
name
,
sticker_song_find
(
Directory
&
directory
,
const
char
*
name
,
void
(
*
func
)(
Song
*
song
,
const
char
*
value
,
void
(
*
func
)(
Song
&
song
,
const
char
*
value
,
void
*
user_data
),
void
*
user_data
),
void
*
user_data
)
void
*
user_data
)
{
{
struct
sticker_song_find_data
data
;
struct
sticker_song_find_data
data
;
data
.
directory
=
directory
;
data
.
directory
=
&
directory
;
data
.
func
=
func
;
data
.
func
=
func
;
data
.
user_data
=
user_data
;
data
.
user_data
=
user_data
;
char
*
allocated
;
char
*
allocated
;
data
.
base_uri
=
directory
->
GetPath
();
data
.
base_uri
=
directory
.
GetPath
();
if
(
*
data
.
base_uri
!=
0
)
if
(
*
data
.
base_uri
!=
0
)
/* append slash to base_uri */
/* append slash to base_uri */
data
.
base_uri
=
allocated
=
data
.
base_uri
=
allocated
=
...
...
src/SongSticker.hxx
View file @
ff626ac7
...
@@ -78,8 +78,8 @@ sticker_song_get(const Song *song);
...
@@ -78,8 +78,8 @@ sticker_song_get(const Song *song);
* failure
* failure
*/
*/
bool
bool
sticker_song_find
(
Directory
*
directory
,
const
char
*
name
,
sticker_song_find
(
Directory
&
directory
,
const
char
*
name
,
void
(
*
func
)(
Song
*
song
,
const
char
*
value
,
void
(
*
func
)(
Song
&
song
,
const
char
*
value
,
void
*
user_data
),
void
*
user_data
),
void
*
user_data
);
void
*
user_data
);
...
...
src/SongUpdate.cxx
View file @
ff626ac7
...
@@ -99,7 +99,7 @@ Song::UpdateFile()
...
@@ -99,7 +99,7 @@ Song::UpdateFile()
if
(
plugin
==
nullptr
)
if
(
plugin
==
nullptr
)
return
false
;
return
false
;
const
auto
path_fs
=
map_song_fs
(
this
);
const
auto
path_fs
=
map_song_fs
(
*
this
);
if
(
path_fs
.
IsNull
())
if
(
path_fs
.
IsNull
())
return
false
;
return
false
;
...
@@ -119,7 +119,7 @@ Song::UpdateFile()
...
@@ -119,7 +119,7 @@ Song::UpdateFile()
do
{
do
{
/* load file tag */
/* load file tag */
if
(
decoder_plugin_scan_file
(
plugin
,
path_fs
.
c_str
(),
if
(
decoder_plugin_scan_file
(
*
plugin
,
path_fs
.
c_str
(),
&
full_tag_handler
,
&
tag_builder
))
&
full_tag_handler
,
&
tag_builder
))
break
;
break
;
...
@@ -136,7 +136,7 @@ Song::UpdateFile()
...
@@ -136,7 +136,7 @@ Song::UpdateFile()
/* now try the stream_tag() method */
/* now try the stream_tag() method */
if
(
is
!=
nullptr
)
{
if
(
is
!=
nullptr
)
{
if
(
decoder_plugin_scan_stream
(
plugin
,
is
,
if
(
decoder_plugin_scan_stream
(
*
plugin
,
is
,
&
full_tag_handler
,
&
full_tag_handler
,
&
tag_builder
))
&
tag_builder
))
break
;
break
;
...
...
src/StateFile.cxx
View file @
ff626ac7
...
@@ -48,8 +48,8 @@ StateFile::RememberVersions()
...
@@ -48,8 +48,8 @@ StateFile::RememberVersions()
{
{
prev_volume_version
=
sw_volume_state_get_hash
();
prev_volume_version
=
sw_volume_state_get_hash
();
prev_output_version
=
audio_output_state_get_version
();
prev_output_version
=
audio_output_state_get_version
();
prev_playlist_version
=
playlist_state_get_hash
(
&
partition
.
playlist
,
prev_playlist_version
=
playlist_state_get_hash
(
partition
.
playlist
,
&
partition
.
pc
);
partition
.
pc
);
}
}
bool
bool
...
@@ -57,8 +57,8 @@ StateFile::IsModified() const
...
@@ -57,8 +57,8 @@ StateFile::IsModified() const
{
{
return
prev_volume_version
!=
sw_volume_state_get_hash
()
||
return
prev_volume_version
!=
sw_volume_state_get_hash
()
||
prev_output_version
!=
audio_output_state_get_version
()
||
prev_output_version
!=
audio_output_state_get_version
()
||
prev_playlist_version
!=
playlist_state_get_hash
(
&
partition
.
playlist
,
prev_playlist_version
!=
playlist_state_get_hash
(
partition
.
playlist
,
&
partition
.
pc
);
partition
.
pc
);
}
}
void
void
...
@@ -76,7 +76,7 @@ StateFile::Write()
...
@@ -76,7 +76,7 @@ StateFile::Write()
save_sw_volume_state
(
fp
);
save_sw_volume_state
(
fp
);
audio_output_state_save
(
fp
);
audio_output_state_save
(
fp
);
playlist_state_save
(
fp
,
&
partition
.
playlist
,
&
partition
.
pc
);
playlist_state_save
(
fp
,
partition
.
playlist
,
partition
.
pc
);
fclose
(
fp
);
fclose
(
fp
);
...
@@ -101,8 +101,8 @@ StateFile::Read()
...
@@ -101,8 +101,8 @@ StateFile::Read()
while
((
line
=
file
.
ReadLine
())
!=
NULL
)
{
while
((
line
=
file
.
ReadLine
())
!=
NULL
)
{
success
=
read_sw_volume_state
(
line
)
||
success
=
read_sw_volume_state
(
line
)
||
audio_output_state_read
(
line
)
||
audio_output_state_read
(
line
)
||
playlist_state_restore
(
line
,
file
,
&
partition
.
playlist
,
playlist_state_restore
(
line
,
file
,
partition
.
playlist
,
&
partition
.
pc
);
partition
.
pc
);
if
(
!
success
)
if
(
!
success
)
FormatError
(
state_file_domain
,
FormatError
(
state_file_domain
,
"Unrecognized line in state file: %s"
,
"Unrecognized line in state file: %s"
,
...
...
src/Stats.cxx
View file @
ff626ac7
...
@@ -65,7 +65,7 @@ void stats_update(void)
...
@@ -65,7 +65,7 @@ void stats_update(void)
}
}
void
void
stats_print
(
Client
*
client
)
stats_print
(
Client
&
client
)
{
{
client_printf
(
client
,
client_printf
(
client
,
"artists: %u
\n
"
"artists: %u
\n
"
...
@@ -78,7 +78,7 @@ stats_print(Client *client)
...
@@ -78,7 +78,7 @@ stats_print(Client *client)
stats
.
album_count
,
stats
.
album_count
,
stats
.
song_count
,
stats
.
song_count
,
(
long
)
g_timer_elapsed
(
stats
.
timer
,
NULL
),
(
long
)
g_timer_elapsed
(
stats
.
timer
,
NULL
),
(
long
)(
client
->
player_control
->
GetTotalPlayTime
()
+
0.5
),
(
long
)(
client
.
player_control
.
GetTotalPlayTime
()
+
0.5
),
stats
.
song_duration
);
stats
.
song_duration
);
if
(
db_is_simple
())
if
(
db_is_simple
())
...
...
src/Stats.hxx
View file @
ff626ac7
...
@@ -49,6 +49,6 @@ void stats_global_finish(void);
...
@@ -49,6 +49,6 @@ void stats_global_finish(void);
void
stats_update
(
void
);
void
stats_update
(
void
);
void
void
stats_print
(
Client
*
client
);
stats_print
(
Client
&
client
);
#endif
#endif
src/StickerCommands.cxx
View file @
ff626ac7
...
@@ -36,12 +36,12 @@
...
@@ -36,12 +36,12 @@
#include <string.h>
#include <string.h>
struct
sticker_song_find_data
{
struct
sticker_song_find_data
{
Client
*
client
;
Client
&
client
;
const
char
*
name
;
const
char
*
name
;
};
};
static
void
static
void
sticker_song_find_print_cb
(
Song
*
song
,
const
char
*
value
,
sticker_song_find_print_cb
(
Song
&
song
,
const
char
*
value
,
void
*
user_data
)
void
*
user_data
)
{
{
struct
sticker_song_find_data
*
data
=
struct
sticker_song_find_data
*
data
=
...
@@ -52,7 +52,7 @@ sticker_song_find_print_cb(Song *song, const char *value,
...
@@ -52,7 +52,7 @@ sticker_song_find_print_cb(Song *song, const char *value,
}
}
static
enum
command_return
static
enum
command_return
handle_sticker_song
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_sticker_song
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
Error
error
;
Error
error
;
const
Database
*
db
=
GetDatabase
(
error
);
const
Database
*
db
=
GetDatabase
(
error
);
...
@@ -85,7 +85,7 @@ handle_sticker_song(Client *client, int argc, char *argv[])
...
@@ -85,7 +85,7 @@ handle_sticker_song(Client *client, int argc, char *argv[])
sticker
*
sticker
=
sticker_song_get
(
song
);
sticker
*
sticker
=
sticker_song_get
(
song
);
db
->
ReturnSong
(
song
);
db
->
ReturnSong
(
song
);
if
(
sticker
)
{
if
(
sticker
)
{
sticker_print
(
client
,
sticker
);
sticker_print
(
client
,
*
sticker
);
sticker_free
(
sticker
);
sticker_free
(
sticker
);
}
}
...
@@ -141,7 +141,7 @@ handle_sticker_song(Client *client, int argc, char *argv[])
...
@@ -141,7 +141,7 @@ handle_sticker_song(Client *client, int argc, char *argv[])
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
}
}
success
=
sticker_song_find
(
directory
,
data
.
name
,
success
=
sticker_song_find
(
*
directory
,
data
.
name
,
sticker_song_find_print_cb
,
&
data
);
sticker_song_find_print_cb
,
&
data
);
db_unlock
();
db_unlock
();
if
(
!
success
)
{
if
(
!
success
)
{
...
@@ -158,7 +158,7 @@ handle_sticker_song(Client *client, int argc, char *argv[])
...
@@ -158,7 +158,7 @@ handle_sticker_song(Client *client, int argc, char *argv[])
}
}
enum
command_return
enum
command_return
handle_sticker
(
Client
*
client
,
int
argc
,
char
*
argv
[])
handle_sticker
(
Client
&
client
,
int
argc
,
char
*
argv
[])
{
{
assert
(
argc
>=
4
);
assert
(
argc
>=
4
);
...
...
src/StickerCommands.hxx
View file @
ff626ac7
...
@@ -25,6 +25,6 @@
...
@@ -25,6 +25,6 @@
class
Client
;
class
Client
;
enum
command_return
enum
command_return
handle_sticker
(
Client
*
client
,
int
argc
,
char
*
argv
[]);
handle_sticker
(
Client
&
client
,
int
argc
,
char
*
argv
[]);
#endif
#endif
src/StickerDatabase.cxx
View file @
ff626ac7
...
@@ -507,22 +507,22 @@ sticker_free(struct sticker *sticker)
...
@@ -507,22 +507,22 @@ sticker_free(struct sticker *sticker)
}
}
const
char
*
const
char
*
sticker_get_value
(
const
struct
sticker
*
sticker
,
const
char
*
name
)
sticker_get_value
(
const
struct
sticker
&
sticker
,
const
char
*
name
)
{
{
auto
i
=
sticker
->
table
.
find
(
name
);
auto
i
=
sticker
.
table
.
find
(
name
);
if
(
i
==
sticker
->
table
.
end
())
if
(
i
==
sticker
.
table
.
end
())
return
nullptr
;
return
nullptr
;
return
i
->
second
.
c_str
();
return
i
->
second
.
c_str
();
}
}
void
void
sticker_foreach
(
const
st
ruct
sticker
*
sticker
,
sticker_foreach
(
const
st
icker
&
sticker
,
void
(
*
func
)(
const
char
*
name
,
const
char
*
value
,
void
(
*
func
)(
const
char
*
name
,
const
char
*
value
,
void
*
user_data
),
void
*
user_data
),
void
*
user_data
)
void
*
user_data
)
{
{
for
(
const
auto
&
i
:
sticker
->
table
)
for
(
const
auto
&
i
:
sticker
.
table
)
func
(
i
.
first
.
c_str
(),
i
.
second
.
c_str
(),
user_data
);
func
(
i
.
first
.
c_str
(),
i
.
second
.
c_str
(),
user_data
);
}
}
...
...
src/StickerDatabase.hxx
View file @
ff626ac7
...
@@ -117,7 +117,7 @@ sticker_free(struct sticker *sticker);
...
@@ -117,7 +117,7 @@ sticker_free(struct sticker *sticker);
*/
*/
gcc_pure
gcc_pure
const
char
*
const
char
*
sticker_get_value
(
const
struct
sticker
*
sticker
,
const
char
*
name
);
sticker_get_value
(
const
struct
sticker
&
sticker
,
const
char
*
name
);
/**
/**
* Iterates over all sticker items in a sticker.
* Iterates over all sticker items in a sticker.
...
@@ -127,7 +127,7 @@ sticker_get_value(const struct sticker *sticker, const char *name);
...
@@ -127,7 +127,7 @@ sticker_get_value(const struct sticker *sticker, const char *name);
* @param user_data an opaque pointer for the callback function
* @param user_data an opaque pointer for the callback function
*/
*/
void
void
sticker_foreach
(
const
struct
sticker
*
sticker
,
sticker_foreach
(
const
struct
sticker
&
sticker
,
void
(
*
func
)(
const
char
*
name
,
const
char
*
value
,
void
(
*
func
)(
const
char
*
name
,
const
char
*
value
,
void
*
user_data
),
void
*
user_data
),
void
*
user_data
);
void
*
user_data
);
...
...
src/StickerPrint.cxx
View file @
ff626ac7
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
#include "Client.hxx"
#include "Client.hxx"
void
void
sticker_print_value
(
Client
*
client
,
sticker_print_value
(
Client
&
client
,
const
char
*
name
,
const
char
*
value
)
const
char
*
name
,
const
char
*
value
)
{
{
client_printf
(
client
,
"sticker: %s=%s
\n
"
,
name
,
value
);
client_printf
(
client
,
"sticker: %s=%s
\n
"
,
name
,
value
);
...
@@ -32,13 +32,13 @@ sticker_print_value(Client *client,
...
@@ -32,13 +32,13 @@ sticker_print_value(Client *client,
static
void
static
void
print_sticker_cb
(
const
char
*
name
,
const
char
*
value
,
void
*
data
)
print_sticker_cb
(
const
char
*
name
,
const
char
*
value
,
void
*
data
)
{
{
Client
*
client
=
(
Client
*
)
data
;
Client
&
client
=
*
(
Client
*
)
data
;
sticker_print_value
(
client
,
name
,
value
);
sticker_print_value
(
client
,
name
,
value
);
}
}
void
void
sticker_print
(
Client
*
client
,
const
struct
sticker
*
sticker
)
sticker_print
(
Client
&
client
,
const
sticker
&
sticker
)
{
{
sticker_foreach
(
sticker
,
print_sticker_cb
,
client
);
sticker_foreach
(
sticker
,
print_sticker_cb
,
&
client
);
}
}
src/StickerPrint.hxx
View file @
ff626ac7
...
@@ -27,12 +27,12 @@ class Client;
...
@@ -27,12 +27,12 @@ class Client;
* Sends one sticker value to the client.
* Sends one sticker value to the client.
*/
*/
void
void
sticker_print_value
(
Client
*
client
,
const
char
*
name
,
const
char
*
value
);
sticker_print_value
(
Client
&
client
,
const
char
*
name
,
const
char
*
value
);
/**
/**
* Sends all sticker values to the client.
* Sends all sticker values to the client.
*/
*/
void
void
sticker_print
(
Client
*
client
,
const
struct
sticker
*
sticker
);
sticker_print
(
Client
&
client
,
const
sticker
&
sticker
);
#endif
#endif
src/TagFile.cxx
View file @
ff626ac7
...
@@ -53,7 +53,7 @@ tag_file_scan(const char *path_fs,
...
@@ -53,7 +53,7 @@ tag_file_scan(const char *path_fs,
do
{
do
{
/* load file tag */
/* load file tag */
if
(
decoder_plugin_scan_file
(
plugin
,
path_fs
,
if
(
decoder_plugin_scan_file
(
*
plugin
,
path_fs
,
handler
,
handler_ctx
))
handler
,
handler_ctx
))
break
;
break
;
...
@@ -69,7 +69,7 @@ tag_file_scan(const char *path_fs,
...
@@ -69,7 +69,7 @@ tag_file_scan(const char *path_fs,
/* now try the stream_tag() method */
/* now try the stream_tag() method */
if
(
is
!=
nullptr
)
{
if
(
is
!=
nullptr
)
{
if
(
decoder_plugin_scan_stream
(
plugin
,
is
,
if
(
decoder_plugin_scan_stream
(
*
plugin
,
is
,
handler
,
handler
,
handler_ctx
))
handler_ctx
))
break
;
break
;
...
...
src/TagPrint.cxx
View file @
ff626ac7
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#include "Song.hxx"
#include "Song.hxx"
#include "Client.hxx"
#include "Client.hxx"
void
tag_print_types
(
Client
*
client
)
void
tag_print_types
(
Client
&
client
)
{
{
int
i
;
int
i
;
...
@@ -35,7 +35,7 @@ void tag_print_types(Client *client)
...
@@ -35,7 +35,7 @@ void tag_print_types(Client *client)
}
}
}
}
void
tag_print
(
Client
*
client
,
const
Tag
&
tag
)
void
tag_print
(
Client
&
client
,
const
Tag
&
tag
)
{
{
if
(
tag
.
time
>=
0
)
if
(
tag
.
time
>=
0
)
client_printf
(
client
,
SONG_TIME
"%i
\n
"
,
tag
.
time
);
client_printf
(
client
,
SONG_TIME
"%i
\n
"
,
tag
.
time
);
...
...
src/TagPrint.hxx
View file @
ff626ac7
...
@@ -23,9 +23,9 @@
...
@@ -23,9 +23,9 @@
struct
Tag
;
struct
Tag
;
class
Client
;
class
Client
;
void
tag_print_types
(
Client
*
client
);
void
tag_print_types
(
Client
&
client
);
void
void
tag_print
(
Client
*
client
,
const
Tag
&
tag
);
tag_print
(
Client
&
client
,
const
Tag
&
tag
);
#endif
#endif
src/TimePrint.cxx
View file @
ff626ac7
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
#include "Client.hxx"
#include "Client.hxx"
void
void
time_print
(
Client
*
client
,
const
char
*
name
,
time_t
t
)
time_print
(
Client
&
client
,
const
char
*
name
,
time_t
t
)
{
{
#ifdef WIN32
#ifdef WIN32
const
struct
tm
*
tm2
=
gmtime
(
&
t
);
const
struct
tm
*
tm2
=
gmtime
(
&
t
);
...
...
src/TimePrint.hxx
View file @
ff626ac7
...
@@ -28,6 +28,6 @@ class Client;
...
@@ -28,6 +28,6 @@ class Client;
* Write a line with a time stamp to the client.
* Write a line with a time stamp to the client.
*/
*/
void
void
time_print
(
Client
*
client
,
const
char
*
name
,
time_t
t
);
time_print
(
Client
&
client
,
const
char
*
name
,
time_t
t
);
#endif
#endif
src/UpdateArchive.cxx
View file @
ff626ac7
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
#include <string.h>
#include <string.h>
static
void
static
void
update_archive_tree
(
Directory
*
directory
,
const
char
*
name
)
update_archive_tree
(
Directory
&
directory
,
const
char
*
name
)
{
{
const
char
*
tmp
=
strchr
(
name
,
'/'
);
const
char
*
tmp
=
strchr
(
name
,
'/'
);
if
(
tmp
)
{
if
(
tmp
)
{
...
@@ -46,12 +46,12 @@ update_archive_tree(Directory *directory, const char *name)
...
@@ -46,12 +46,12 @@ update_archive_tree(Directory *directory, const char *name)
//add dir is not there already
//add dir is not there already
db_lock
();
db_lock
();
Directory
*
subdir
=
Directory
*
subdir
=
directory
->
MakeChild
(
child_name
.
c_str
());
directory
.
MakeChild
(
child_name
.
c_str
());
subdir
->
device
=
DEVICE_INARCHIVE
;
subdir
->
device
=
DEVICE_INARCHIVE
;
db_unlock
();
db_unlock
();
//create directories first
//create directories first
update_archive_tree
(
subdir
,
tmp
+
1
);
update_archive_tree
(
*
subdir
,
tmp
+
1
);
}
else
{
}
else
{
if
(
strlen
(
name
)
==
0
)
{
if
(
strlen
(
name
)
==
0
)
{
LogWarning
(
update_domain
,
LogWarning
(
update_domain
,
...
@@ -61,18 +61,18 @@ update_archive_tree(Directory *directory, const char *name)
...
@@ -61,18 +61,18 @@ update_archive_tree(Directory *directory, const char *name)
//add file
//add file
db_lock
();
db_lock
();
Song
*
song
=
directory
->
FindSong
(
name
);
Song
*
song
=
directory
.
FindSong
(
name
);
db_unlock
();
db_unlock
();
if
(
song
==
nullptr
)
{
if
(
song
==
nullptr
)
{
song
=
Song
::
LoadFile
(
name
,
directory
);
song
=
Song
::
LoadFile
(
name
,
directory
);
if
(
song
!=
nullptr
)
{
if
(
song
!=
nullptr
)
{
db_lock
();
db_lock
();
directory
->
AddSong
(
song
);
directory
.
AddSong
(
song
);
db_unlock
();
db_unlock
();
modified
=
true
;
modified
=
true
;
FormatInfo
(
update_domain
,
"added %s/%s"
,
FormatInfo
(
update_domain
,
"added %s/%s"
,
directory
->
GetPath
(),
name
);
directory
.
GetPath
(),
name
);
}
}
}
}
}
}
...
@@ -87,12 +87,12 @@ update_archive_tree(Directory *directory, const char *name)
...
@@ -87,12 +87,12 @@ update_archive_tree(Directory *directory, const char *name)
* @param plugin the archive plugin which fits this archive type
* @param plugin the archive plugin which fits this archive type
*/
*/
static
void
static
void
update_archive_file2
(
Directory
*
parent
,
const
char
*
name
,
update_archive_file2
(
Directory
&
parent
,
const
char
*
name
,
const
struct
stat
*
st
,
const
struct
stat
*
st
,
const
struct
archive_plugin
*
plugin
)
const
struct
archive_plugin
*
plugin
)
{
{
db_lock
();
db_lock
();
Directory
*
directory
=
parent
->
FindChild
(
name
);
Directory
*
directory
=
parent
.
FindChild
(
name
);
db_unlock
();
db_unlock
();
if
(
directory
!=
nullptr
&&
directory
->
mtime
==
st
->
st_mtime
&&
if
(
directory
!=
nullptr
&&
directory
->
mtime
==
st
->
st_mtime
&&
...
@@ -117,7 +117,7 @@ update_archive_file2(Directory *parent, const char *name,
...
@@ -117,7 +117,7 @@ update_archive_file2(Directory *parent, const char *name,
FormatDebug
(
update_domain
,
FormatDebug
(
update_domain
,
"creating archive directory: %s"
,
name
);
"creating archive directory: %s"
,
name
);
db_lock
();
db_lock
();
directory
=
parent
->
CreateChild
(
name
);
directory
=
parent
.
CreateChild
(
name
);
/* mark this directory as archive (we use device for
/* mark this directory as archive (we use device for
this) */
this) */
directory
->
device
=
DEVICE_INARCHIVE
;
directory
->
device
=
DEVICE_INARCHIVE
;
...
@@ -136,7 +136,7 @@ update_archive_file2(Directory *parent, const char *name,
...
@@ -136,7 +136,7 @@ update_archive_file2(Directory *parent, const char *name,
virtual
void
VisitArchiveEntry
(
const
char
*
path_utf8
)
override
{
virtual
void
VisitArchiveEntry
(
const
char
*
path_utf8
)
override
{
FormatDebug
(
update_domain
,
FormatDebug
(
update_domain
,
"adding archive file: %s"
,
path_utf8
);
"adding archive file: %s"
,
path_utf8
);
update_archive_tree
(
directory
,
path_utf8
);
update_archive_tree
(
*
directory
,
path_utf8
);
}
}
};
};
...
@@ -146,7 +146,7 @@ update_archive_file2(Directory *parent, const char *name,
...
@@ -146,7 +146,7 @@ update_archive_file2(Directory *parent, const char *name,
}
}
bool
bool
update_archive_file
(
Directory
*
directory
,
update_archive_file
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
suffix
,
const
char
*
name
,
const
char
*
suffix
,
const
struct
stat
*
st
)
const
struct
stat
*
st
)
{
{
...
...
src/UpdateArchive.hxx
View file @
ff626ac7
...
@@ -31,14 +31,14 @@ struct archive_plugin;
...
@@ -31,14 +31,14 @@ struct archive_plugin;
#ifdef ENABLE_ARCHIVE
#ifdef ENABLE_ARCHIVE
bool
bool
update_archive_file
(
Directory
*
directory
,
update_archive_file
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
suffix
,
const
char
*
name
,
const
char
*
suffix
,
const
struct
stat
*
st
);
const
struct
stat
*
st
);
#else
#else
static
inline
bool
static
inline
bool
update_archive_file
(
gcc_unused
Directory
*
directory
,
update_archive_file
(
gcc_unused
Directory
&
directory
,
gcc_unused
const
char
*
name
,
gcc_unused
const
char
*
name
,
gcc_unused
const
char
*
suffix
,
gcc_unused
const
char
*
suffix
,
gcc_unused
const
struct
stat
*
st
)
gcc_unused
const
struct
stat
*
st
)
...
...
src/UpdateContainer.cxx
View file @
ff626ac7
...
@@ -43,10 +43,10 @@
...
@@ -43,10 +43,10 @@
* The caller must lock the database.
* The caller must lock the database.
*/
*/
static
Directory
*
static
Directory
*
make_directory_if_modified
(
Directory
*
parent
,
const
char
*
name
,
make_directory_if_modified
(
Directory
&
parent
,
const
char
*
name
,
const
struct
stat
*
st
)
const
struct
stat
*
st
)
{
{
Directory
*
directory
=
parent
->
FindChild
(
name
);
Directory
*
directory
=
parent
.
FindChild
(
name
);
// directory exists already
// directory exists already
if
(
directory
!=
nullptr
)
{
if
(
directory
!=
nullptr
)
{
...
@@ -59,18 +59,18 @@ make_directory_if_modified(Directory *parent, const char *name,
...
@@ -59,18 +59,18 @@ make_directory_if_modified(Directory *parent, const char *name,
modified
=
true
;
modified
=
true
;
}
}
directory
=
parent
->
MakeChild
(
name
);
directory
=
parent
.
MakeChild
(
name
);
directory
->
mtime
=
st
->
st_mtime
;
directory
->
mtime
=
st
->
st_mtime
;
return
directory
;
return
directory
;
}
}
bool
bool
update_container_file
(
Directory
*
directory
,
update_container_file
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
name
,
const
struct
stat
*
st
,
const
struct
stat
*
st
,
const
struct
decoder_plugin
*
plugin
)
const
decoder_plugin
&
plugin
)
{
{
if
(
plugin
->
container_scan
==
nullptr
)
if
(
plugin
.
container_scan
==
nullptr
)
return
false
;
return
false
;
db_lock
();
db_lock
();
...
@@ -89,14 +89,14 @@ update_container_file(Directory *directory,
...
@@ -89,14 +89,14 @@ update_container_file(Directory *directory,
char
*
vtrack
;
char
*
vtrack
;
unsigned
int
tnum
=
0
;
unsigned
int
tnum
=
0
;
TagBuilder
tag_builder
;
TagBuilder
tag_builder
;
while
((
vtrack
=
plugin
->
container_scan
(
pathname
.
c_str
(),
++
tnum
))
!=
nullptr
)
{
while
((
vtrack
=
plugin
.
container_scan
(
pathname
.
c_str
(),
++
tnum
))
!=
nullptr
)
{
Song
*
song
=
Song
::
NewFile
(
vtrack
,
contdir
);
Song
*
song
=
Song
::
NewFile
(
vtrack
,
contdir
);
// shouldn't be necessary but it's there..
// shouldn't be necessary but it's there..
song
->
mtime
=
st
->
st_mtime
;
song
->
mtime
=
st
->
st_mtime
;
const
auto
child_path_fs
=
const
auto
child_path_fs
=
map_directory_child_fs
(
contdir
,
vtrack
);
map_directory_child_fs
(
*
contdir
,
vtrack
);
decoder_plugin_scan_file
(
plugin
,
child_path_fs
.
c_str
(),
decoder_plugin_scan_file
(
plugin
,
child_path_fs
.
c_str
(),
&
add_tag_handler
,
&
tag_builder
);
&
add_tag_handler
,
&
tag_builder
);
...
@@ -113,7 +113,7 @@ update_container_file(Directory *directory,
...
@@ -113,7 +113,7 @@ update_container_file(Directory *directory,
modified
=
true
;
modified
=
true
;
FormatInfo
(
update_domain
,
"added %s/%s"
,
FormatInfo
(
update_domain
,
"added %s/%s"
,
directory
->
GetPath
(),
vtrack
);
directory
.
GetPath
(),
vtrack
);
g_free
(
vtrack
);
g_free
(
vtrack
);
}
}
...
...
src/UpdateContainer.hxx
View file @
ff626ac7
...
@@ -28,9 +28,9 @@ struct Directory;
...
@@ -28,9 +28,9 @@ struct Directory;
struct
decoder_plugin
;
struct
decoder_plugin
;
bool
bool
update_container_file
(
Directory
*
directory
,
update_container_file
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
name
,
const
struct
stat
*
st
,
const
struct
stat
*
st
,
const
struct
decoder_plugin
*
plugin
);
const
decoder_plugin
&
plugin
);
#endif
#endif
src/UpdateDatabase.cxx
View file @
ff626ac7
...
@@ -29,12 +29,12 @@
...
@@ -29,12 +29,12 @@
#include <stddef.h>
#include <stddef.h>
void
void
delete_song
(
Directory
*
dir
,
Song
*
del
)
delete_song
(
Directory
&
dir
,
Song
*
del
)
{
{
assert
(
del
->
parent
==
dir
);
assert
(
del
->
parent
==
&
dir
);
/* first, prevent traversers in main task from getting this */
/* first, prevent traversers in main task from getting this */
dir
->
RemoveSong
(
del
);
dir
.
RemoveSong
(
del
);
db_unlock
();
/* temporary unlock, because update_remove_song() blocks */
db_unlock
();
/* temporary unlock, because update_remove_song() blocks */
...
@@ -54,7 +54,7 @@ delete_song(Directory *dir, Song *del)
...
@@ -54,7 +54,7 @@ delete_song(Directory *dir, Song *del)
* Caller must lock the #db_mutex.
* Caller must lock the #db_mutex.
*/
*/
static
void
static
void
clear_directory
(
Directory
*
directory
)
clear_directory
(
Directory
&
directory
)
{
{
Directory
*
child
,
*
n
;
Directory
*
child
,
*
n
;
directory_for_each_child_safe
(
child
,
n
,
directory
)
directory_for_each_child_safe
(
child
,
n
,
directory
)
...
@@ -62,7 +62,7 @@ clear_directory(Directory *directory)
...
@@ -62,7 +62,7 @@ clear_directory(Directory *directory)
Song
*
song
,
*
ns
;
Song
*
song
,
*
ns
;
directory_for_each_song_safe
(
song
,
ns
,
directory
)
{
directory_for_each_song_safe
(
song
,
ns
,
directory
)
{
assert
(
song
->
parent
==
directory
);
assert
(
song
->
parent
==
&
directory
);
delete_song
(
directory
,
song
);
delete_song
(
directory
,
song
);
}
}
}
}
...
@@ -72,31 +72,31 @@ delete_directory(Directory *directory)
...
@@ -72,31 +72,31 @@ delete_directory(Directory *directory)
{
{
assert
(
directory
->
parent
!=
nullptr
);
assert
(
directory
->
parent
!=
nullptr
);
clear_directory
(
directory
);
clear_directory
(
*
directory
);
directory
->
Delete
();
directory
->
Delete
();
}
}
bool
bool
delete_name_in
(
Directory
*
parent
,
const
char
*
name
)
delete_name_in
(
Directory
&
parent
,
const
char
*
name
)
{
{
bool
modified
=
false
;
bool
modified
=
false
;
db_lock
();
db_lock
();
Directory
*
directory
=
parent
->
FindChild
(
name
);
Directory
*
directory
=
parent
.
FindChild
(
name
);
if
(
directory
!=
nullptr
)
{
if
(
directory
!=
nullptr
)
{
delete_directory
(
directory
);
delete_directory
(
directory
);
modified
=
true
;
modified
=
true
;
}
}
Song
*
song
=
parent
->
FindSong
(
name
);
Song
*
song
=
parent
.
FindSong
(
name
);
if
(
song
!=
nullptr
)
{
if
(
song
!=
nullptr
)
{
delete_song
(
parent
,
song
);
delete_song
(
parent
,
song
);
modified
=
true
;
modified
=
true
;
}
}
parent
->
playlists
.
erase
(
name
);
parent
.
playlists
.
erase
(
name
);
db_unlock
();
db_unlock
();
...
...
src/UpdateDatabase.hxx
View file @
ff626ac7
...
@@ -29,7 +29,7 @@ struct Song;
...
@@ -29,7 +29,7 @@ struct Song;
* Caller must lock the #db_mutex.
* Caller must lock the #db_mutex.
*/
*/
void
void
delete_song
(
Directory
*
parent
,
Song
*
song
);
delete_song
(
Directory
&
parent
,
Song
*
song
);
/**
/**
* Recursively free a directory and all its contents.
* Recursively free a directory and all its contents.
...
@@ -45,6 +45,6 @@ delete_directory(Directory *directory);
...
@@ -45,6 +45,6 @@ delete_directory(Directory *directory);
* @return true if the database was modified
* @return true if the database was modified
*/
*/
bool
bool
delete_name_in
(
Directory
*
parent
,
const
char
*
name
);
delete_name_in
(
Directory
&
parent
,
const
char
*
name
);
#endif
#endif
src/UpdateIO.cxx
View file @
ff626ac7
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
#include <unistd.h>
#include <unistd.h>
int
int
stat_directory
(
const
Directory
*
directory
,
struct
stat
*
st
)
stat_directory
(
const
Directory
&
directory
,
struct
stat
*
st
)
{
{
const
auto
path_fs
=
map_directory_fs
(
directory
);
const
auto
path_fs
=
map_directory_fs
(
directory
);
if
(
path_fs
.
IsNull
())
if
(
path_fs
.
IsNull
())
...
@@ -48,7 +48,7 @@ stat_directory(const Directory *directory, struct stat *st)
...
@@ -48,7 +48,7 @@ stat_directory(const Directory *directory, struct stat *st)
}
}
int
int
stat_directory_child
(
const
Directory
*
parent
,
const
char
*
name
,
stat_directory_child
(
const
Directory
&
parent
,
const
char
*
name
,
struct
stat
*
st
)
struct
stat
*
st
)
{
{
const
auto
path_fs
=
map_directory_child_fs
(
parent
,
name
);
const
auto
path_fs
=
map_directory_child_fs
(
parent
,
name
);
...
@@ -67,21 +67,21 @@ stat_directory_child(const Directory *parent, const char *name,
...
@@ -67,21 +67,21 @@ stat_directory_child(const Directory *parent, const char *name,
}
}
bool
bool
directory_exists
(
const
Directory
*
directory
)
directory_exists
(
const
Directory
&
directory
)
{
{
const
auto
path_fs
=
map_directory_fs
(
directory
);
const
auto
path_fs
=
map_directory_fs
(
directory
);
if
(
path_fs
.
IsNull
())
if
(
path_fs
.
IsNull
())
/* invalid path: cannot exist */
/* invalid path: cannot exist */
return
false
;
return
false
;
return
directory
->
device
==
DEVICE_INARCHIVE
||
return
directory
.
device
==
DEVICE_INARCHIVE
||
directory
->
device
==
DEVICE_CONTAINER
directory
.
device
==
DEVICE_CONTAINER
?
FileExists
(
path_fs
)
?
FileExists
(
path_fs
)
:
DirectoryExists
(
path_fs
);
:
DirectoryExists
(
path_fs
);
}
}
bool
bool
directory_child_is_regular
(
const
Directory
*
directory
,
directory_child_is_regular
(
const
Directory
&
directory
,
const
char
*
name_utf8
)
const
char
*
name_utf8
)
{
{
const
auto
path_fs
=
map_directory_child_fs
(
directory
,
name_utf8
);
const
auto
path_fs
=
map_directory_child_fs
(
directory
,
name_utf8
);
...
@@ -92,7 +92,7 @@ directory_child_is_regular(const Directory *directory,
...
@@ -92,7 +92,7 @@ directory_child_is_regular(const Directory *directory,
}
}
bool
bool
directory_child_access
(
const
Directory
*
directory
,
directory_child_access
(
const
Directory
&
directory
,
const
char
*
name
,
int
mode
)
const
char
*
name
,
int
mode
)
{
{
#ifdef WIN32
#ifdef WIN32
...
...
src/UpdateIO.hxx
View file @
ff626ac7
...
@@ -27,24 +27,24 @@
...
@@ -27,24 +27,24 @@
struct
Directory
;
struct
Directory
;
int
int
stat_directory
(
const
Directory
*
directory
,
struct
stat
*
st
);
stat_directory
(
const
Directory
&
directory
,
struct
stat
*
st
);
int
int
stat_directory_child
(
const
Directory
*
parent
,
const
char
*
name
,
stat_directory_child
(
const
Directory
&
parent
,
const
char
*
name
,
struct
stat
*
st
);
struct
stat
*
st
);
bool
bool
directory_exists
(
const
Directory
*
directory
);
directory_exists
(
const
Directory
&
directory
);
bool
bool
directory_child_is_regular
(
const
Directory
*
directory
,
directory_child_is_regular
(
const
Directory
&
directory
,
const
char
*
name_utf8
);
const
char
*
name_utf8
);
/**
/**
* Checks if the given permissions on the mapped file are given.
* Checks if the given permissions on the mapped file are given.
*/
*/
bool
bool
directory_child_access
(
const
Directory
*
directory
,
directory_child_access
(
const
Directory
&
directory
,
const
char
*
name
,
int
mode
);
const
char
*
name
,
int
mode
);
#endif
#endif
src/UpdateSong.cxx
View file @
ff626ac7
...
@@ -34,18 +34,18 @@
...
@@ -34,18 +34,18 @@
#include <unistd.h>
#include <unistd.h>
static
void
static
void
update_song_file2
(
Directory
*
directory
,
update_song_file2
(
Directory
&
directory
,
const
char
*
name
,
const
struct
stat
*
st
,
const
char
*
name
,
const
struct
stat
*
st
,
const
struct
decoder_plugin
*
plugin
)
const
decoder_plugin
&
plugin
)
{
{
db_lock
();
db_lock
();
Song
*
song
=
directory
->
FindSong
(
name
);
Song
*
song
=
directory
.
FindSong
(
name
);
db_unlock
();
db_unlock
();
if
(
!
directory_child_access
(
directory
,
name
,
R_OK
))
{
if
(
!
directory_child_access
(
directory
,
name
,
R_OK
))
{
FormatError
(
update_domain
,
FormatError
(
update_domain
,
"no read permissions on %s/%s"
,
"no read permissions on %s/%s"
,
directory
->
GetPath
(),
name
);
directory
.
GetPath
(),
name
);
if
(
song
!=
nullptr
)
{
if
(
song
!=
nullptr
)
{
db_lock
();
db_lock
();
delete_song
(
directory
,
song
);
delete_song
(
directory
,
song
);
...
@@ -69,29 +69,29 @@ update_song_file2(Directory *directory,
...
@@ -69,29 +69,29 @@ update_song_file2(Directory *directory,
if
(
song
==
nullptr
)
{
if
(
song
==
nullptr
)
{
FormatDebug
(
update_domain
,
"reading %s/%s"
,
FormatDebug
(
update_domain
,
"reading %s/%s"
,
directory
->
GetPath
(),
name
);
directory
.
GetPath
(),
name
);
song
=
Song
::
LoadFile
(
name
,
directory
);
song
=
Song
::
LoadFile
(
name
,
&
directory
);
if
(
song
==
nullptr
)
{
if
(
song
==
nullptr
)
{
FormatDebug
(
update_domain
,
FormatDebug
(
update_domain
,
"ignoring unrecognized file %s/%s"
,
"ignoring unrecognized file %s/%s"
,
directory
->
GetPath
(),
name
);
directory
.
GetPath
(),
name
);
return
;
return
;
}
}
db_lock
();
db_lock
();
directory
->
AddSong
(
song
);
directory
.
AddSong
(
song
);
db_unlock
();
db_unlock
();
modified
=
true
;
modified
=
true
;
FormatInfo
(
update_domain
,
"added %s/%s"
,
FormatInfo
(
update_domain
,
"added %s/%s"
,
directory
->
GetPath
(),
name
);
directory
.
GetPath
(),
name
);
}
else
if
(
st
->
st_mtime
!=
song
->
mtime
||
walk_discard
)
{
}
else
if
(
st
->
st_mtime
!=
song
->
mtime
||
walk_discard
)
{
FormatInfo
(
update_domain
,
"updating %s/%s"
,
FormatInfo
(
update_domain
,
"updating %s/%s"
,
directory
->
GetPath
(),
name
);
directory
.
GetPath
(),
name
);
if
(
!
song
->
UpdateFile
())
{
if
(
!
song
->
UpdateFile
())
{
FormatDebug
(
update_domain
,
FormatDebug
(
update_domain
,
"deleting unrecognized file %s/%s"
,
"deleting unrecognized file %s/%s"
,
directory
->
GetPath
(),
name
);
directory
.
GetPath
(),
name
);
db_lock
();
db_lock
();
delete_song
(
directory
,
song
);
delete_song
(
directory
,
song
);
db_unlock
();
db_unlock
();
...
@@ -102,7 +102,7 @@ update_song_file2(Directory *directory,
...
@@ -102,7 +102,7 @@ update_song_file2(Directory *directory,
}
}
bool
bool
update_song_file
(
Directory
*
directory
,
update_song_file
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
suffix
,
const
char
*
name
,
const
char
*
suffix
,
const
struct
stat
*
st
)
const
struct
stat
*
st
)
{
{
...
@@ -111,6 +111,6 @@ update_song_file(Directory *directory,
...
@@ -111,6 +111,6 @@ update_song_file(Directory *directory,
if
(
plugin
==
nullptr
)
if
(
plugin
==
nullptr
)
return
false
;
return
false
;
update_song_file2
(
directory
,
name
,
st
,
plugin
);
update_song_file2
(
directory
,
name
,
st
,
*
plugin
);
return
true
;
return
true
;
}
}
src/UpdateSong.hxx
View file @
ff626ac7
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
struct
Directory
;
struct
Directory
;
bool
bool
update_song_file
(
Directory
*
directory
,
update_song_file
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
suffix
,
const
char
*
name
,
const
char
*
suffix
,
const
struct
stat
*
st
);
const
struct
stat
*
st
);
...
...
src/UpdateWalk.cxx
View file @
ff626ac7
...
@@ -87,15 +87,15 @@ update_walk_global_finish(void)
...
@@ -87,15 +87,15 @@ update_walk_global_finish(void)
}
}
static
void
static
void
directory_set_stat
(
Directory
*
dir
,
const
struct
stat
*
st
)
directory_set_stat
(
Directory
&
dir
,
const
struct
stat
*
st
)
{
{
dir
->
inode
=
st
->
st_ino
;
dir
.
inode
=
st
->
st_ino
;
dir
->
device
=
st
->
st_dev
;
dir
.
device
=
st
->
st_dev
;
dir
->
have_stat
=
true
;
dir
.
have_stat
=
true
;
}
}
static
void
static
void
remove_excluded_from_directory
(
Directory
*
directory
,
remove_excluded_from_directory
(
Directory
&
directory
,
const
ExcludeList
&
exclude_list
)
const
ExcludeList
&
exclude_list
)
{
{
db_lock
();
db_lock
();
...
@@ -112,7 +112,7 @@ remove_excluded_from_directory(Directory *directory,
...
@@ -112,7 +112,7 @@ remove_excluded_from_directory(Directory *directory,
Song
*
song
,
*
ns
;
Song
*
song
,
*
ns
;
directory_for_each_song_safe
(
song
,
ns
,
directory
)
{
directory_for_each_song_safe
(
song
,
ns
,
directory
)
{
assert
(
song
->
parent
==
directory
);
assert
(
song
->
parent
==
&
directory
);
const
auto
name_fs
=
AllocatedPath
::
FromUTF8
(
song
->
uri
);
const
auto
name_fs
=
AllocatedPath
::
FromUTF8
(
song
->
uri
);
if
(
name_fs
.
IsNull
()
||
exclude_list
.
Check
(
name_fs
))
{
if
(
name_fs
.
IsNull
()
||
exclude_list
.
Check
(
name_fs
))
{
...
@@ -125,11 +125,11 @@ remove_excluded_from_directory(Directory *directory,
...
@@ -125,11 +125,11 @@ remove_excluded_from_directory(Directory *directory,
}
}
static
void
static
void
purge_deleted_from_directory
(
Directory
*
directory
)
purge_deleted_from_directory
(
Directory
&
directory
)
{
{
Directory
*
child
,
*
n
;
Directory
*
child
,
*
n
;
directory_for_each_child_safe
(
child
,
n
,
directory
)
{
directory_for_each_child_safe
(
child
,
n
,
directory
)
{
if
(
directory_exists
(
child
))
if
(
directory_exists
(
*
child
))
continue
;
continue
;
db_lock
();
db_lock
();
...
@@ -141,7 +141,7 @@ purge_deleted_from_directory(Directory *directory)
...
@@ -141,7 +141,7 @@ purge_deleted_from_directory(Directory *directory)
Song
*
song
,
*
ns
;
Song
*
song
,
*
ns
;
directory_for_each_song_safe
(
song
,
ns
,
directory
)
{
directory_for_each_song_safe
(
song
,
ns
,
directory
)
{
const
auto
path
=
map_song_fs
(
song
);
const
auto
path
=
map_song_fs
(
*
song
);
if
(
path
.
IsNull
()
||
!
FileExists
(
path
))
{
if
(
path
.
IsNull
()
||
!
FileExists
(
path
))
{
db_lock
();
db_lock
();
delete_song
(
directory
,
song
);
delete_song
(
directory
,
song
);
...
@@ -151,12 +151,12 @@ purge_deleted_from_directory(Directory *directory)
...
@@ -151,12 +151,12 @@ purge_deleted_from_directory(Directory *directory)
}
}
}
}
for
(
auto
i
=
directory
->
playlists
.
begin
(),
for
(
auto
i
=
directory
.
playlists
.
begin
(),
end
=
directory
->
playlists
.
end
();
end
=
directory
.
playlists
.
end
();
i
!=
end
;)
{
i
!=
end
;)
{
if
(
!
directory_child_is_regular
(
directory
,
i
->
name
.
c_str
()))
{
if
(
!
directory_child_is_regular
(
directory
,
i
->
name
.
c_str
()))
{
db_lock
();
db_lock
();
i
=
directory
->
playlists
.
erase
(
i
);
i
=
directory
.
playlists
.
erase
(
i
);
db_unlock
();
db_unlock
();
}
else
}
else
++
i
;
++
i
;
...
@@ -165,7 +165,7 @@ purge_deleted_from_directory(Directory *directory)
...
@@ -165,7 +165,7 @@ purge_deleted_from_directory(Directory *directory)
#ifndef WIN32
#ifndef WIN32
static
int
static
int
update_directory_stat
(
Directory
*
directory
)
update_directory_stat
(
Directory
&
directory
)
{
{
struct
stat
st
;
struct
stat
st
;
if
(
stat_directory
(
directory
,
&
st
)
<
0
)
if
(
stat_directory
(
directory
,
&
st
)
<
0
)
...
@@ -181,7 +181,7 @@ find_inode_ancestor(Directory *parent, ino_t inode, dev_t device)
...
@@ -181,7 +181,7 @@ find_inode_ancestor(Directory *parent, ino_t inode, dev_t device)
{
{
#ifndef WIN32
#ifndef WIN32
while
(
parent
)
{
while
(
parent
)
{
if
(
!
parent
->
have_stat
&&
update_directory_stat
(
parent
)
<
0
)
if
(
!
parent
->
have_stat
&&
update_directory_stat
(
*
parent
)
<
0
)
return
-
1
;
return
-
1
;
if
(
parent
->
inode
==
inode
&&
parent
->
device
==
device
)
{
if
(
parent
->
inode
==
inode
&&
parent
->
device
==
device
)
{
...
@@ -201,7 +201,7 @@ find_inode_ancestor(Directory *parent, ino_t inode, dev_t device)
...
@@ -201,7 +201,7 @@ find_inode_ancestor(Directory *parent, ino_t inode, dev_t device)
}
}
static
bool
static
bool
update_playlist_file2
(
Directory
*
directory
,
update_playlist_file2
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
suffix
,
const
char
*
name
,
const
char
*
suffix
,
const
struct
stat
*
st
)
const
struct
stat
*
st
)
{
{
...
@@ -211,14 +211,14 @@ update_playlist_file2(Directory *directory,
...
@@ -211,14 +211,14 @@ update_playlist_file2(Directory *directory,
PlaylistInfo
pi
(
name
,
st
->
st_mtime
);
PlaylistInfo
pi
(
name
,
st
->
st_mtime
);
db_lock
();
db_lock
();
if
(
directory
->
playlists
.
UpdateOrInsert
(
std
::
move
(
pi
)))
if
(
directory
.
playlists
.
UpdateOrInsert
(
std
::
move
(
pi
)))
modified
=
true
;
modified
=
true
;
db_unlock
();
db_unlock
();
return
true
;
return
true
;
}
}
static
bool
static
bool
update_regular_file
(
Directory
*
directory
,
update_regular_file
(
Directory
&
directory
,
const
char
*
name
,
const
struct
stat
*
st
)
const
char
*
name
,
const
struct
stat
*
st
)
{
{
const
char
*
suffix
=
uri_get_suffix
(
name
);
const
char
*
suffix
=
uri_get_suffix
(
name
);
...
@@ -231,10 +231,10 @@ update_regular_file(Directory *directory,
...
@@ -231,10 +231,10 @@ update_regular_file(Directory *directory,
}
}
static
bool
static
bool
update_directory
(
Directory
*
directory
,
const
struct
stat
*
st
);
update_directory
(
Directory
&
directory
,
const
struct
stat
*
st
);
static
void
static
void
update_directory_child
(
Directory
*
directory
,
update_directory_child
(
Directory
&
directory
,
const
char
*
name
,
const
struct
stat
*
st
)
const
char
*
name
,
const
struct
stat
*
st
)
{
{
assert
(
strchr
(
name
,
'/'
)
==
nullptr
);
assert
(
strchr
(
name
,
'/'
)
==
nullptr
);
...
@@ -242,16 +242,16 @@ update_directory_child(Directory *directory,
...
@@ -242,16 +242,16 @@ update_directory_child(Directory *directory,
if
(
S_ISREG
(
st
->
st_mode
))
{
if
(
S_ISREG
(
st
->
st_mode
))
{
update_regular_file
(
directory
,
name
,
st
);
update_regular_file
(
directory
,
name
,
st
);
}
else
if
(
S_ISDIR
(
st
->
st_mode
))
{
}
else
if
(
S_ISDIR
(
st
->
st_mode
))
{
if
(
find_inode_ancestor
(
directory
,
st
->
st_ino
,
st
->
st_dev
))
if
(
find_inode_ancestor
(
&
directory
,
st
->
st_ino
,
st
->
st_dev
))
return
;
return
;
db_lock
();
db_lock
();
Directory
*
subdir
=
directory
->
MakeChild
(
name
);
Directory
*
subdir
=
directory
.
MakeChild
(
name
);
db_unlock
();
db_unlock
();
assert
(
directory
==
subdir
->
parent
);
assert
(
&
directory
==
subdir
->
parent
);
if
(
!
update_directory
(
subdir
,
st
))
{
if
(
!
update_directory
(
*
subdir
,
st
))
{
db_lock
();
db_lock
();
delete_directory
(
subdir
);
delete_directory
(
subdir
);
db_unlock
();
db_unlock
();
...
@@ -277,7 +277,7 @@ static bool
...
@@ -277,7 +277,7 @@ static bool
skip_symlink
(
const
Directory
*
directory
,
const
char
*
utf8_name
)
skip_symlink
(
const
Directory
*
directory
,
const
char
*
utf8_name
)
{
{
#ifndef WIN32
#ifndef WIN32
const
auto
path_fs
=
map_directory_child_fs
(
directory
,
utf8_name
);
const
auto
path_fs
=
map_directory_child_fs
(
*
directory
,
utf8_name
);
if
(
path_fs
.
IsNull
())
if
(
path_fs
.
IsNull
())
return
true
;
return
true
;
...
@@ -339,7 +339,7 @@ skip_symlink(const Directory *directory, const char *utf8_name)
...
@@ -339,7 +339,7 @@ skip_symlink(const Directory *directory, const char *utf8_name)
}
}
static
bool
static
bool
update_directory
(
Directory
*
directory
,
const
struct
stat
*
st
)
update_directory
(
Directory
&
directory
,
const
struct
stat
*
st
)
{
{
assert
(
S_ISDIR
(
st
->
st_mode
));
assert
(
S_ISDIR
(
st
->
st_mode
));
...
@@ -380,7 +380,7 @@ update_directory(Directory *directory, const struct stat *st)
...
@@ -380,7 +380,7 @@ update_directory(Directory *directory, const struct stat *st)
if
(
utf8
.
empty
())
if
(
utf8
.
empty
())
continue
;
continue
;
if
(
skip_symlink
(
directory
,
utf8
.
c_str
()))
{
if
(
skip_symlink
(
&
directory
,
utf8
.
c_str
()))
{
modified
|=
delete_name_in
(
directory
,
utf8
.
c_str
());
modified
|=
delete_name_in
(
directory
,
utf8
.
c_str
());
continue
;
continue
;
}
}
...
@@ -391,16 +391,16 @@ update_directory(Directory *directory, const struct stat *st)
...
@@ -391,16 +391,16 @@ update_directory(Directory *directory, const struct stat *st)
modified
|=
delete_name_in
(
directory
,
utf8
.
c_str
());
modified
|=
delete_name_in
(
directory
,
utf8
.
c_str
());
}
}
directory
->
mtime
=
st
->
st_mtime
;
directory
.
mtime
=
st
->
st_mtime
;
return
true
;
return
true
;
}
}
static
Directory
*
static
Directory
*
directory_make_child_checked
(
Directory
*
parent
,
const
char
*
name_utf8
)
directory_make_child_checked
(
Directory
&
parent
,
const
char
*
name_utf8
)
{
{
db_lock
();
db_lock
();
Directory
*
directory
=
parent
->
FindChild
(
name_utf8
);
Directory
*
directory
=
parent
.
FindChild
(
name_utf8
);
db_unlock
();
db_unlock
();
if
(
directory
!=
nullptr
)
if
(
directory
!=
nullptr
)
...
@@ -408,23 +408,23 @@ directory_make_child_checked(Directory *parent, const char *name_utf8)
...
@@ -408,23 +408,23 @@ directory_make_child_checked(Directory *parent, const char *name_utf8)
struct
stat
st
;
struct
stat
st
;
if
(
stat_directory_child
(
parent
,
name_utf8
,
&
st
)
<
0
||
if
(
stat_directory_child
(
parent
,
name_utf8
,
&
st
)
<
0
||
find_inode_ancestor
(
parent
,
st
.
st_ino
,
st
.
st_dev
))
find_inode_ancestor
(
&
parent
,
st
.
st_ino
,
st
.
st_dev
))
return
nullptr
;
return
nullptr
;
if
(
skip_symlink
(
parent
,
name_utf8
))
if
(
skip_symlink
(
&
parent
,
name_utf8
))
return
nullptr
;
return
nullptr
;
/* if we're adding directory paths, make sure to delete filenames
/* if we're adding directory paths, make sure to delete filenames
with potentially the same name */
with potentially the same name */
db_lock
();
db_lock
();
Song
*
conflicting
=
parent
->
FindSong
(
name_utf8
);
Song
*
conflicting
=
parent
.
FindSong
(
name_utf8
);
if
(
conflicting
)
if
(
conflicting
)
delete_song
(
parent
,
conflicting
);
delete_song
(
parent
,
conflicting
);
directory
=
parent
->
CreateChild
(
name_utf8
);
directory
=
parent
.
CreateChild
(
name_utf8
);
db_unlock
();
db_unlock
();
directory_set_stat
(
directory
,
&
st
);
directory_set_stat
(
*
directory
,
&
st
);
return
directory
;
return
directory
;
}
}
...
@@ -441,7 +441,8 @@ directory_make_uri_parent_checked(const char *uri)
...
@@ -441,7 +441,8 @@ directory_make_uri_parent_checked(const char *uri)
if
(
*
name_utf8
==
0
)
if
(
*
name_utf8
==
0
)
continue
;
continue
;
directory
=
directory_make_child_checked
(
directory
,
name_utf8
);
directory
=
directory_make_child_checked
(
*
directory
,
name_utf8
);
if
(
directory
==
nullptr
)
if
(
directory
==
nullptr
)
break
;
break
;
...
@@ -463,10 +464,10 @@ update_uri(const char *uri)
...
@@ -463,10 +464,10 @@ update_uri(const char *uri)
struct
stat
st
;
struct
stat
st
;
if
(
!
skip_symlink
(
parent
,
name
)
&&
if
(
!
skip_symlink
(
parent
,
name
)
&&
stat_directory_child
(
parent
,
name
,
&
st
)
==
0
)
stat_directory_child
(
*
parent
,
name
,
&
st
)
==
0
)
update_directory_child
(
parent
,
name
,
&
st
);
update_directory_child
(
*
parent
,
name
,
&
st
);
else
else
modified
|=
delete_name_in
(
parent
,
name
);
modified
|=
delete_name_in
(
*
parent
,
name
);
g_free
(
name
);
g_free
(
name
);
}
}
...
@@ -483,8 +484,8 @@ update_walk(const char *path, bool discard)
...
@@ -483,8 +484,8 @@ update_walk(const char *path, bool discard)
Directory
*
directory
=
db_get_root
();
Directory
*
directory
=
db_get_root
();
struct
stat
st
;
struct
stat
st
;
if
(
stat_directory
(
directory
,
&
st
)
==
0
)
if
(
stat_directory
(
*
directory
,
&
st
)
==
0
)
update_directory
(
directory
,
&
st
);
update_directory
(
*
directory
,
&
st
);
}
}
return
modified
;
return
modified
;
...
...
src/db/SimpleDatabasePlugin.cxx
View file @
ff626ac7
...
@@ -145,7 +145,7 @@ SimpleDatabase::Load(Error &error)
...
@@ -145,7 +145,7 @@ SimpleDatabase::Load(Error &error)
return
false
;
return
false
;
}
}
if
(
!
db_load_internal
(
file
,
root
,
error
))
if
(
!
db_load_internal
(
file
,
*
root
,
error
))
return
false
;
return
false
;
struct
stat
st
;
struct
stat
st
;
...
@@ -300,7 +300,7 @@ SimpleDatabase::Save(Error &error)
...
@@ -300,7 +300,7 @@ SimpleDatabase::Save(Error &error)
return
false
;
return
false
;
}
}
db_save_internal
(
fp
,
root
);
db_save_internal
(
fp
,
*
root
);
if
(
ferror
(
fp
))
{
if
(
ferror
(
fp
))
{
error
.
SetErrno
(
"Failed to write to database file"
);
error
.
SetErrno
(
"Failed to write to database file"
);
...
...
src/ls.cxx
View file @
ff626ac7
...
@@ -75,7 +75,7 @@ void print_supported_uri_schemes_to_fp(FILE *fp)
...
@@ -75,7 +75,7 @@ void print_supported_uri_schemes_to_fp(FILE *fp)
fprintf
(
fp
,
"
\n
"
);
fprintf
(
fp
,
"
\n
"
);
}
}
void
print_supported_uri_schemes
(
Client
*
client
)
void
print_supported_uri_schemes
(
Client
&
client
)
{
{
const
char
**
prefixes
=
remoteUrlPrefixes
;
const
char
**
prefixes
=
remoteUrlPrefixes
;
...
...
src/ls.hxx
View file @
ff626ac7
...
@@ -35,7 +35,7 @@ bool uri_supported_scheme(const char *url);
...
@@ -35,7 +35,7 @@ bool uri_supported_scheme(const char *url);
* Send a list of supported URI schemes to the client. This is the
* Send a list of supported URI schemes to the client. This is the
* response to the "urlhandlers" command.
* response to the "urlhandlers" command.
*/
*/
void
print_supported_uri_schemes
(
Client
*
client
);
void
print_supported_uri_schemes
(
Client
&
client
);
/**
/**
* Send a list of supported URI schemes to a file pointer.
* Send a list of supported URI schemes to a file pointer.
...
...
src/protocol/ArgParser.cxx
View file @
ff626ac7
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <stdlib.h>
bool
bool
check_uint32
(
Client
*
client
,
uint32_t
*
dst
,
const
char
*
s
)
check_uint32
(
Client
&
client
,
uint32_t
*
dst
,
const
char
*
s
)
{
{
char
*
test
;
char
*
test
;
...
@@ -40,7 +40,7 @@ check_uint32(Client *client, uint32_t *dst, const char *s)
...
@@ -40,7 +40,7 @@ check_uint32(Client *client, uint32_t *dst, const char *s)
}
}
bool
bool
check_int
(
Client
*
client
,
int
*
value_r
,
const
char
*
s
)
check_int
(
Client
&
client
,
int
*
value_r
,
const
char
*
s
)
{
{
char
*
test
;
char
*
test
;
long
value
;
long
value
;
...
@@ -64,7 +64,7 @@ check_int(Client *client, int *value_r, const char *s)
...
@@ -64,7 +64,7 @@ check_int(Client *client, int *value_r, const char *s)
}
}
bool
bool
check_range
(
Client
*
client
,
unsigned
*
value_r1
,
unsigned
*
value_r2
,
check_range
(
Client
&
client
,
unsigned
*
value_r1
,
unsigned
*
value_r2
,
const
char
*
s
)
const
char
*
s
)
{
{
char
*
test
,
*
test2
;
char
*
test
,
*
test2
;
...
@@ -131,7 +131,7 @@ check_range(Client *client, unsigned *value_r1, unsigned *value_r2,
...
@@ -131,7 +131,7 @@ check_range(Client *client, unsigned *value_r1, unsigned *value_r2,
}
}
bool
bool
check_unsigned
(
Client
*
client
,
unsigned
*
value_r
,
const
char
*
s
)
check_unsigned
(
Client
&
client
,
unsigned
*
value_r
,
const
char
*
s
)
{
{
unsigned
long
value
;
unsigned
long
value
;
char
*
endptr
;
char
*
endptr
;
...
@@ -154,7 +154,7 @@ check_unsigned(Client *client, unsigned *value_r, const char *s)
...
@@ -154,7 +154,7 @@ check_unsigned(Client *client, unsigned *value_r, const char *s)
}
}
bool
bool
check_bool
(
Client
*
client
,
bool
*
value_r
,
const
char
*
s
)
check_bool
(
Client
&
client
,
bool
*
value_r
,
const
char
*
s
)
{
{
long
value
;
long
value
;
char
*
endptr
;
char
*
endptr
;
...
@@ -171,7 +171,7 @@ check_bool(Client *client, bool *value_r, const char *s)
...
@@ -171,7 +171,7 @@ check_bool(Client *client, bool *value_r, const char *s)
}
}
bool
bool
check_float
(
Client
*
client
,
float
*
value_r
,
const
char
*
s
)
check_float
(
Client
&
client
,
float
*
value_r
,
const
char
*
s
)
{
{
float
value
;
float
value
;
char
*
endptr
;
char
*
endptr
;
...
...
src/protocol/ArgParser.hxx
View file @
ff626ac7
...
@@ -27,22 +27,22 @@
...
@@ -27,22 +27,22 @@
class
Client
;
class
Client
;
bool
bool
check_uint32
(
Client
*
client
,
uint32_t
*
dst
,
const
char
*
s
);
check_uint32
(
Client
&
client
,
uint32_t
*
dst
,
const
char
*
s
);
bool
bool
check_int
(
Client
*
client
,
int
*
value_r
,
const
char
*
s
);
check_int
(
Client
&
client
,
int
*
value_r
,
const
char
*
s
);
bool
bool
check_range
(
Client
*
client
,
unsigned
*
value_r1
,
unsigned
*
value_r2
,
check_range
(
Client
&
client
,
unsigned
*
value_r1
,
unsigned
*
value_r2
,
const
char
*
s
);
const
char
*
s
);
bool
bool
check_unsigned
(
Client
*
client
,
unsigned
*
value_r
,
const
char
*
s
);
check_unsigned
(
Client
&
client
,
unsigned
*
value_r
,
const
char
*
s
);
bool
bool
check_bool
(
Client
*
client
,
bool
*
value_r
,
const
char
*
s
);
check_bool
(
Client
&
client
,
bool
*
value_r
,
const
char
*
s
);
bool
bool
check_float
(
Client
*
client
,
float
*
value_r
,
const
char
*
s
);
check_float
(
Client
&
client
,
float
*
value_r
,
const
char
*
s
);
#endif
#endif
src/protocol/Result.cxx
View file @
ff626ac7
...
@@ -27,16 +27,15 @@ const char *current_command;
...
@@ -27,16 +27,15 @@ const char *current_command;
int
command_list_num
;
int
command_list_num
;
void
void
command_success
(
Client
*
client
)
command_success
(
Client
&
client
)
{
{
client_puts
(
client
,
"OK
\n
"
);
client_puts
(
client
,
"OK
\n
"
);
}
}
void
void
command_error_v
(
Client
*
client
,
enum
ack
error
,
command_error_v
(
Client
&
client
,
enum
ack
error
,
const
char
*
fmt
,
va_list
args
)
const
char
*
fmt
,
va_list
args
)
{
{
assert
(
client
!=
NULL
);
assert
(
current_command
!=
NULL
);
assert
(
current_command
!=
NULL
);
client_printf
(
client
,
"ACK [%i@%i] {%s} "
,
client_printf
(
client
,
"ACK [%i@%i] {%s} "
,
...
@@ -48,7 +47,7 @@ command_error_v(Client *client, enum ack error,
...
@@ -48,7 +47,7 @@ command_error_v(Client *client, enum ack error,
}
}
void
void
command_error
(
Client
*
client
,
enum
ack
error
,
const
char
*
fmt
,
...)
command_error
(
Client
&
client
,
enum
ack
error
,
const
char
*
fmt
,
...)
{
{
va_list
args
;
va_list
args
;
va_start
(
args
,
fmt
);
va_start
(
args
,
fmt
);
...
...
src/protocol/Result.hxx
View file @
ff626ac7
...
@@ -32,14 +32,14 @@ extern const char *current_command;
...
@@ -32,14 +32,14 @@ extern const char *current_command;
extern
int
command_list_num
;
extern
int
command_list_num
;
void
void
command_success
(
Client
*
client
);
command_success
(
Client
&
client
);
void
void
command_error_v
(
Client
*
client
,
enum
ack
error
,
command_error_v
(
Client
&
client
,
enum
ack
error
,
const
char
*
fmt
,
va_list
args
);
const
char
*
fmt
,
va_list
args
);
gcc_printf
(
3
,
4
)
gcc_printf
(
3
,
4
)
void
void
command_error
(
Client
*
client
,
enum
ack
error
,
const
char
*
fmt
,
...);
command_error
(
Client
&
client
,
enum
ack
error
,
const
char
*
fmt
,
...);
#endif
#endif
test/read_tags.cxx
View file @
ff626ac7
...
@@ -181,7 +181,7 @@ int main(int argc, char **argv)
...
@@ -181,7 +181,7 @@ int main(int argc, char **argv)
return
1
;
return
1
;
}
}
bool
success
=
decoder_plugin_scan_file
(
plugin
,
path
,
bool
success
=
decoder_plugin_scan_file
(
*
plugin
,
path
,
&
print_handler
,
NULL
);
&
print_handler
,
NULL
);
if
(
!
success
&&
plugin
->
scan_stream
!=
NULL
)
{
if
(
!
success
&&
plugin
->
scan_stream
!=
NULL
)
{
Mutex
mutex
;
Mutex
mutex
;
...
@@ -209,7 +209,7 @@ int main(int argc, char **argv)
...
@@ -209,7 +209,7 @@ int main(int argc, char **argv)
mutex
.
unlock
();
mutex
.
unlock
();
success
=
decoder_plugin_scan_stream
(
plugin
,
is
,
success
=
decoder_plugin_scan_stream
(
*
plugin
,
is
,
&
print_handler
,
NULL
);
&
print_handler
,
NULL
);
is
->
Close
();
is
->
Close
();
}
}
...
...
test/run_decoder.cxx
View file @
ff626ac7
...
@@ -184,7 +184,7 @@ int main(int argc, char **argv)
...
@@ -184,7 +184,7 @@ int main(int argc, char **argv)
decoder
.
initialized
=
false
;
decoder
.
initialized
=
false
;
if
(
decoder
.
plugin
->
file_decode
!=
NULL
)
{
if
(
decoder
.
plugin
->
file_decode
!=
NULL
)
{
decoder_plugin_file_decode
(
decoder
.
plugin
,
&
decoder
,
decoder_plugin_file_decode
(
*
decoder
.
plugin
,
&
decoder
,
decoder
.
uri
);
decoder
.
uri
);
}
else
if
(
decoder
.
plugin
->
stream_decode
!=
NULL
)
{
}
else
if
(
decoder
.
plugin
->
stream_decode
!=
NULL
)
{
Mutex
mutex
;
Mutex
mutex
;
...
@@ -201,7 +201,7 @@ int main(int argc, char **argv)
...
@@ -201,7 +201,7 @@ int main(int argc, char **argv)
return
1
;
return
1
;
}
}
decoder_plugin_stream_decode
(
decoder
.
plugin
,
&
decoder
,
is
);
decoder_plugin_stream_decode
(
*
decoder
.
plugin
,
&
decoder
,
is
);
is
->
Close
();
is
->
Close
();
}
else
{
}
else
{
...
...
test/run_output.cxx
View file @
ff626ac7
...
@@ -91,7 +91,7 @@ load_audio_output(const char *name)
...
@@ -91,7 +91,7 @@ load_audio_output(const char *name)
Error
error
;
Error
error
;
struct
audio_output
*
ao
=
struct
audio_output
*
ao
=
audio_output_new
(
*
param
,
&
dummy_player_control
,
error
);
audio_output_new
(
*
param
,
dummy_player_control
,
error
);
if
(
ao
==
nullptr
)
if
(
ao
==
nullptr
)
g_printerr
(
"%s
\n
"
,
error
.
GetMessage
());
g_printerr
(
"%s
\n
"
,
error
.
GetMessage
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment