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
668724de
Commit
668724de
authored
Feb 20, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Client: replace playlist and player_control with getter methods
Prepare to convert "partition" to a mutable pointer.
parent
71ce1a25
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
33 deletions
+54
-33
Client.cxx
src/client/Client.cxx
+12
-0
Client.hxx
src/client/Client.hxx
+8
-2
ClientNew.cxx
src/client/ClientNew.cxx
+0
-1
PlayerCommands.cxx
src/command/PlayerCommands.cxx
+20
-16
PlaylistCommands.cxx
src/command/PlaylistCommands.cxx
+3
-3
QueueCommands.cxx
src/command/QueueCommands.cxx
+9
-9
TagCommands.cxx
src/command/TagCommands.cxx
+2
-2
No files found.
src/client/Client.cxx
View file @
668724de
...
...
@@ -25,6 +25,18 @@
const
Domain
client_domain
(
"client"
);
playlist
&
Client
::
GetPlaylist
()
{
return
partition
.
playlist
;
}
PlayerControl
&
Client
::
GetPlayerControl
()
{
return
partition
.
pc
;
}
#ifdef ENABLE_DATABASE
const
Database
*
...
...
src/client/Client.hxx
View file @
668724de
...
...
@@ -41,6 +41,8 @@ class SocketAddress;
class
EventLoop
;
class
Path
;
struct
Partition
;
struct
PlayerControl
;
struct
playlist
;
class
Database
;
class
Storage
;
...
...
@@ -49,8 +51,6 @@ class Client final
public
boost
::
intrusive
::
list_base_hook
<
boost
::
intrusive
::
link_mode
<
boost
::
intrusive
::
normal_link
>>
{
public
:
Partition
&
partition
;
struct
playlist
&
playlist
;
struct
PlayerControl
&
player_control
;
unsigned
permission
;
...
...
@@ -187,6 +187,12 @@ public:
*/
void
AllowFile
(
Path
path_fs
)
const
;
gcc_pure
playlist
&
GetPlaylist
();
gcc_pure
PlayerControl
&
GetPlayerControl
();
/**
* Wrapper for Instance::GetDatabase().
*/
...
...
src/client/ClientNew.cxx
View file @
668724de
...
...
@@ -46,7 +46,6 @@ Client::Client(EventLoop &_loop, Partition &_partition,
:
FullyBufferedSocket
(
_fd
,
_loop
,
16384
,
client_max_output_buffer_size
),
TimeoutMonitor
(
_loop
),
partition
(
_partition
),
playlist
(
partition
.
playlist
),
player_control
(
partition
.
pc
),
permission
(
getDefaultPermissions
()),
uid
(
_uid
),
num
(
_num
),
...
...
src/command/PlayerCommands.cxx
View file @
668724de
...
...
@@ -86,18 +86,20 @@ handle_stop(Client &client, gcc_unused Request args, gcc_unused Response &r)
CommandResult
handle_currentsong
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
{
playlist_print_current
(
r
,
client
.
playlist
);
playlist_print_current
(
r
,
client
.
GetPlaylist
()
);
return
CommandResult
::
OK
;
}
CommandResult
handle_pause
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
auto
&
pc
=
client
.
GetPlayerControl
();
if
(
!
args
.
IsEmpty
())
{
bool
pause_flag
=
args
.
ParseBool
(
0
);
client
.
player_control
.
LockSetPause
(
pause_flag
);
pc
.
LockSetPause
(
pause_flag
);
}
else
client
.
player_control
.
LockPause
();
pc
.
LockPause
();
return
CommandResult
::
OK
;
}
...
...
@@ -105,10 +107,12 @@ handle_pause(Client &client, Request args, gcc_unused Response &r)
CommandResult
handle_status
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
{
auto
&
pc
=
client
.
GetPlayerControl
();
const
char
*
state
=
nullptr
;
int
song
;
const
auto
player_status
=
client
.
player_control
.
LockGetStatus
();
const
auto
player_status
=
pc
.
LockGetStatus
();
switch
(
player_status
.
state
)
{
case
PlayerState
:
:
STOP
:
...
...
@@ -122,7 +126,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
break
;
}
const
playlist
&
playlist
=
client
.
playlist
;
const
playlist
&
playlist
=
client
.
GetPlaylist
()
;
r
.
Format
(
"volume: %i
\n
"
COMMAND_STATUS_REPEAT
": %i
\n
"
COMMAND_STATUS_RANDOM
": %i
\n
"
...
...
@@ -139,16 +143,16 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
playlist
.
GetConsume
(),
(
unsigned
long
)
playlist
.
GetVersion
(),
playlist
.
GetLength
(),
client
.
player_control
.
GetMixRampDb
(),
pc
.
GetMixRampDb
(),
state
);
if
(
client
.
player_control
.
GetCrossFade
()
>
0
)
if
(
pc
.
GetCrossFade
()
>
0
)
r
.
Format
(
COMMAND_STATUS_CROSSFADE
": %i
\n
"
,
int
(
client
.
player_control
.
GetCrossFade
()
+
0.5
));
int
(
pc
.
GetCrossFade
()
+
0.5
));
if
(
client
.
player_control
.
GetMixRampDelay
()
>
0
)
if
(
pc
.
GetMixRampDelay
()
>
0
)
r
.
Format
(
COMMAND_STATUS_MIXRAMPDELAY
": %f
\n
"
,
client
.
player_control
.
GetMixRampDelay
());
pc
.
GetMixRampDelay
());
song
=
playlist
.
GetCurrentPosition
();
if
(
song
>=
0
)
{
...
...
@@ -189,7 +193,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
#endif
try
{
client
.
player_control
.
LockCheckRethrowError
();
pc
.
LockCheckRethrowError
();
}
catch
(...)
{
r
.
Format
(
COMMAND_STATUS_ERROR
": %s
\n
"
,
FullMessage
(
std
::
current_exception
()).
c_str
());
...
...
@@ -207,7 +211,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
CommandResult
handle_next
(
Client
&
client
,
gcc_unused
Request
args
,
gcc_unused
Response
&
r
)
{
playlist
&
playlist
=
client
.
playlist
;
playlist
&
playlist
=
client
.
GetPlaylist
()
;
/* single mode is not considered when this is user who
* wants to change song. */
...
...
@@ -267,7 +271,7 @@ CommandResult
handle_clearerror
(
Client
&
client
,
gcc_unused
Request
args
,
gcc_unused
Response
&
r
)
{
client
.
player_control
.
LockClearError
();
client
.
GetPlayerControl
()
.
LockClearError
();
return
CommandResult
::
OK
;
}
...
...
@@ -306,7 +310,7 @@ CommandResult
handle_crossfade
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
unsigned
xfade_time
=
args
.
ParseUnsigned
(
0
);
client
.
player_control
.
SetCrossFade
(
xfade_time
);
client
.
GetPlayerControl
()
.
SetCrossFade
(
xfade_time
);
return
CommandResult
::
OK
;
}
...
...
@@ -314,7 +318,7 @@ CommandResult
handle_mixrampdb
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
float
db
=
args
.
ParseFloat
(
0
);
client
.
player_control
.
SetMixRampDb
(
db
);
client
.
GetPlayerControl
()
.
SetMixRampDb
(
db
);
return
CommandResult
::
OK
;
}
...
...
@@ -322,7 +326,7 @@ CommandResult
handle_mixrampdelay
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
float
delay_secs
=
args
.
ParseFloat
(
0
);
client
.
player_control
.
SetMixRampDelay
(
delay_secs
);
client
.
GetPlayerControl
()
.
SetMixRampDelay
(
delay_secs
);
return
CommandResult
::
OK
;
}
...
...
src/command/PlaylistCommands.cxx
View file @
668724de
...
...
@@ -58,7 +58,7 @@ print_spl_list(Response &r, const PlaylistVector &list)
CommandResult
handle_save
(
Client
&
client
,
Request
args
,
gcc_unused
Response
&
r
)
{
spl_save_playlist
(
args
.
front
(),
client
.
playlist
);
spl_save_playlist
(
args
.
front
(),
client
.
GetPlaylist
()
);
return
CommandResult
::
OK
;
}
...
...
@@ -72,8 +72,8 @@ handle_load(Client &client, Request args, gcc_unused Response &r)
const
SongLoader
loader
(
client
);
playlist_open_into_queue
(
args
.
front
(),
range
.
start
,
range
.
end
,
client
.
playlist
,
client
.
player_control
,
loader
);
client
.
GetPlaylist
()
,
client
.
GetPlayerControl
()
,
loader
);
return
CommandResult
::
OK
;
}
...
...
src/command/QueueCommands.cxx
View file @
668724de
...
...
@@ -164,8 +164,8 @@ handle_rangeid(Client &client, Request args, Response &r)
return
CommandResult
::
ERROR
;
}
client
.
partition
.
playlist
.
SetSongIdRange
(
client
.
partition
.
pc
,
id
,
start
,
end
);
client
.
GetPlaylist
().
SetSongIdRange
(
client
.
GetPlayerControl
()
,
id
,
start
,
end
);
return
CommandResult
::
OK
;
}
...
...
@@ -188,7 +188,7 @@ handle_deleteid(Client &client, Request args, gcc_unused Response &r)
CommandResult
handle_playlist
(
Client
&
client
,
gcc_unused
Request
args
,
Response
&
r
)
{
playlist_print_uris
(
r
,
client
.
playlist
);
playlist_print_uris
(
r
,
client
.
GetPlaylist
()
);
return
CommandResult
::
OK
;
}
...
...
@@ -212,7 +212,7 @@ handle_plchanges(Client &client, Request args, Response &r)
{
uint32_t
version
=
ParseCommandArgU32
(
args
.
front
());
RangeArg
range
=
args
.
ParseOptional
(
1
,
RangeArg
::
All
());
playlist_print_changes_info
(
r
,
client
.
playlist
,
version
,
playlist_print_changes_info
(
r
,
client
.
GetPlaylist
()
,
version
,
range
.
start
,
range
.
end
);
return
CommandResult
::
OK
;
}
...
...
@@ -222,7 +222,7 @@ handle_plchangesposid(Client &client, Request args, Response &r)
{
uint32_t
version
=
ParseCommandArgU32
(
args
.
front
());
RangeArg
range
=
args
.
ParseOptional
(
1
,
RangeArg
::
All
());
playlist_print_changes_position
(
r
,
client
.
playlist
,
version
,
playlist_print_changes_position
(
r
,
client
.
GetPlaylist
()
,
version
,
range
.
start
,
range
.
end
);
return
CommandResult
::
OK
;
}
...
...
@@ -232,7 +232,7 @@ handle_playlistinfo(Client &client, Request args, Response &r)
{
RangeArg
range
=
args
.
ParseOptional
(
0
,
RangeArg
::
All
());
playlist_print_info
(
r
,
client
.
playlist
,
playlist_print_info
(
r
,
client
.
GetPlaylist
()
,
range
.
start
,
range
.
end
);
return
CommandResult
::
OK
;
}
...
...
@@ -242,9 +242,9 @@ handle_playlistid(Client &client, Request args, Response &r)
{
if
(
!
args
.
IsEmpty
())
{
unsigned
id
=
args
.
ParseUnsigned
(
0
);
playlist_print_id
(
r
,
client
.
playlist
,
id
);
playlist_print_id
(
r
,
client
.
GetPlaylist
()
,
id
);
}
else
{
playlist_print_info
(
r
,
client
.
playlist
,
playlist_print_info
(
r
,
client
.
GetPlaylist
()
,
0
,
std
::
numeric_limits
<
unsigned
>::
max
());
}
...
...
@@ -261,7 +261,7 @@ handle_playlist_match(Client &client, Request args, Response &r,
return
CommandResult
::
ERROR
;
}
playlist_print_find
(
r
,
client
.
playlist
,
filter
);
playlist_print_find
(
r
,
client
.
GetPlaylist
()
,
filter
);
return
CommandResult
::
OK
;
}
...
...
src/command/TagCommands.cxx
View file @
668724de
...
...
@@ -40,7 +40,7 @@ handle_addtagid(Client &client, Request args, Response &r)
const
char
*
const
value
=
args
[
2
];
client
.
partition
.
playlist
.
AddSongIdTag
(
song_id
,
tag_type
,
value
);
client
.
GetPlaylist
()
.
AddSongIdTag
(
song_id
,
tag_type
,
value
);
return
CommandResult
::
OK
;
}
...
...
@@ -60,6 +60,6 @@ handle_cleartagid(Client &client, Request args, Response &r)
}
}
client
.
partition
.
playlist
.
ClearSongIdTag
(
song_id
,
tag_type
);
client
.
GetPlaylist
()
.
ClearSongIdTag
(
song_id
,
tag_type
);
return
CommandResult
::
OK
;
}
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