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
d05bb2a0
Commit
d05bb2a0
authored
Sep 27, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PlayerControl: use strictly typed enums
parent
67659016
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
129 additions
and
128 deletions
+129
-128
PlayerCommands.cxx
src/PlayerCommands.cxx
+4
-4
PlayerControl.cxx
src/PlayerControl.cxx
+22
-22
PlayerControl.hxx
src/PlayerControl.hxx
+37
-38
PlayerThread.cxx
src/PlayerThread.cxx
+44
-44
Playlist.cxx
src/Playlist.cxx
+6
-6
PlaylistControl.cxx
src/PlaylistControl.cxx
+2
-2
PlaylistEdit.cxx
src/PlaylistEdit.cxx
+1
-1
PlaylistState.cxx
src/PlaylistState.cxx
+13
-11
No files found.
src/PlayerCommands.cxx
View file @
d05bb2a0
...
...
@@ -124,13 +124,13 @@ handle_status(Client *client,
const
auto
player_status
=
client
->
player_control
->
GetStatus
();
switch
(
player_status
.
state
)
{
case
P
LAYER_STATE_
STOP
:
case
P
layerState
:
:
STOP
:
state
=
"stop"
;
break
;
case
P
LAYER_STATE_
PAUSE
:
case
P
layerState
:
:
PAUSE
:
state
=
"pause"
;
break
;
case
P
LAYER_STATE_
PLAY
:
case
P
layerState
:
:
PLAY
:
state
=
"play"
;
break
;
}
...
...
@@ -168,7 +168,7 @@ handle_status(Client *client,
song
,
playlist
.
PositionToId
(
song
));
}
if
(
player_status
.
state
!=
P
LAYER_STATE_
STOP
)
{
if
(
player_status
.
state
!=
P
layerState
::
STOP
)
{
client_printf
(
client
,
COMMAND_STATUS_TIME
": %i:%i
\n
"
"elapsed: %1.3f
\n
"
...
...
src/PlayerControl.cxx
View file @
d05bb2a0
...
...
@@ -32,9 +32,9 @@ player_control::player_control(unsigned _buffer_chunks,
:
buffer_chunks
(
_buffer_chunks
),
buffered_before_play
(
_buffered_before_play
),
thread
(
nullptr
),
command
(
P
LAYER_COMMAND_
NONE
),
state
(
P
LAYER_STATE_
STOP
),
error_type
(
P
LAYER_ERROR_
NONE
),
command
(
P
layerCommand
::
NONE
),
state
(
P
layerState
::
STOP
),
error_type
(
P
layerError
::
NONE
),
next_song
(
nullptr
),
cross_fade_seconds
(
0
),
mixramp_db
(
0
),
...
...
@@ -63,8 +63,8 @@ player_control::Play(Song *song)
Lock
();
if
(
state
!=
P
LAYER_STATE_
STOP
)
SynchronousCommand
(
P
LAYER_COMMAND_
STOP
);
if
(
state
!=
P
layerState
::
STOP
)
SynchronousCommand
(
P
layerCommand
::
STOP
);
assert
(
next_song
==
nullptr
);
...
...
@@ -78,14 +78,14 @@ player_control::Play(Song *song)
void
player_control
::
Cancel
()
{
LockSynchronousCommand
(
P
LAYER_COMMAND_
CANCEL
);
LockSynchronousCommand
(
P
layerCommand
::
CANCEL
);
assert
(
next_song
==
NULL
);
}
void
player_control
::
Stop
()
{
LockSynchronousCommand
(
P
LAYER_COMMAND_
CLOSE_AUDIO
);
LockSynchronousCommand
(
P
layerCommand
::
CLOSE_AUDIO
);
assert
(
next_song
==
nullptr
);
idle_add
(
IDLE_PLAYER
);
...
...
@@ -94,7 +94,7 @@ player_control::Stop()
void
player_control
::
UpdateAudio
()
{
LockSynchronousCommand
(
P
LAYER_COMMAND_
UPDATE_AUDIO
);
LockSynchronousCommand
(
P
layerCommand
::
UPDATE_AUDIO
);
}
void
...
...
@@ -102,7 +102,7 @@ player_control::Kill()
{
assert
(
thread
!=
NULL
);
LockSynchronousCommand
(
P
LAYER_COMMAND_
EXIT
);
LockSynchronousCommand
(
P
layerCommand
::
EXIT
);
g_thread_join
(
thread
);
thread
=
NULL
;
...
...
@@ -112,8 +112,8 @@ player_control::Kill()
void
player_control
::
PauseLocked
()
{
if
(
state
!=
P
LAYER_STATE_
STOP
)
{
SynchronousCommand
(
P
LAYER_COMMAND_
PAUSE
);
if
(
state
!=
P
layerState
::
STOP
)
{
SynchronousCommand
(
P
layerCommand
::
PAUSE
);
idle_add
(
IDLE_PLAYER
);
}
}
...
...
@@ -132,15 +132,15 @@ player_control::SetPause(bool pause_flag)
Lock
();
switch
(
state
)
{
case
P
LAYER_STATE_
STOP
:
case
P
layerState
:
:
STOP
:
break
;
case
P
LAYER_STATE_
PLAY
:
case
P
layerState
:
:
PLAY
:
if
(
pause_flag
)
PauseLocked
();
break
;
case
P
LAYER_STATE_
PAUSE
:
case
P
layerState
:
:
PAUSE
:
if
(
!
pause_flag
)
PauseLocked
();
break
;
...
...
@@ -163,11 +163,11 @@ player_control::GetStatus()
player_status
status
;
Lock
();
SynchronousCommand
(
P
LAYER_COMMAND_
REFRESH
);
SynchronousCommand
(
P
layerCommand
::
REFRESH
);
status
.
state
=
state
;
if
(
state
!=
P
LAYER_STATE_
STOP
)
{
if
(
state
!=
P
layerState
::
STOP
)
{
status
.
bit_rate
=
bit_rate
;
status
.
audio_format
=
audio_format
;
status
.
total_time
=
total_time
;
...
...
@@ -180,9 +180,9 @@ player_control::GetStatus()
}
void
player_control
::
SetError
(
player_e
rror
type
,
Error
&&
_error
)
player_control
::
SetError
(
PlayerE
rror
type
,
Error
&&
_error
)
{
assert
(
type
!=
P
LAYER_ERROR_
NONE
);
assert
(
type
!=
P
layerError
::
NONE
);
assert
(
_error
.
IsDefined
());
error_type
=
type
;
...
...
@@ -194,8 +194,8 @@ player_control::ClearError()
{
Lock
();
if
(
error_type
!=
P
LAYER_ERROR_
NONE
)
{
error_type
=
P
LAYER_ERROR_
NONE
;
if
(
error_type
!=
P
layerError
::
NONE
)
{
error_type
=
P
layerError
::
NONE
;
error
.
Clear
();
}
...
...
@@ -206,7 +206,7 @@ char *
player_control
::
GetErrorMessage
()
const
{
Lock
();
char
*
message
=
error_type
!=
P
LAYER_ERROR_
NONE
char
*
message
=
error_type
!=
P
layerError
::
NONE
?
g_strdup
(
error
.
GetMessage
())
:
NULL
;
Unlock
();
...
...
@@ -235,7 +235,7 @@ player_control::Seek(Song *song, float seek_time)
next_song
=
song
;
seek_where
=
seek_time
;
SynchronousCommand
(
P
LAYER_COMMAND_
SEEK
);
SynchronousCommand
(
P
layerCommand
::
SEEK
);
Unlock
();
assert
(
next_song
==
nullptr
);
...
...
src/PlayerControl.hxx
View file @
d05bb2a0
...
...
@@ -29,62 +29,61 @@
#include <stdint.h>
struct
decoder_control
;
struct
Song
;
enum
player_state
{
PLAYER_STATE_STOP
=
0
,
P
LAYER_STATE_P
AUSE
,
PLAY
ER_STATE_PLAY
enum
class
PlayerState
:
uint8_t
{
STOP
,
PAUSE
,
PLAY
};
enum
player_command
{
PLAYER_COMMAND_NONE
=
0
,
PLAYER_COMMAND_
EXIT
,
PLAYER_COMMAND_
STOP
,
P
LAYER_COMMAND_P
AUSE
,
PLAYER_COMMAND_
SEEK
,
PLAYER_COMMAND_
CLOSE_AUDIO
,
enum
class
PlayerCommand
:
uint8_t
{
NONE
,
EXIT
,
STOP
,
PAUSE
,
SEEK
,
CLOSE_AUDIO
,
/**
* At least one audio_output.enabled flag has been modified;
* commit those changes to the output threads.
*/
PLAYER_COMMAND_
UPDATE_AUDIO
,
UPDATE_AUDIO
,
/** player_control.next_song has been updated */
PLAYER_COMMAND_
QUEUE
,
QUEUE
,
/**
* cancel pre-decoding player_control.next_song; if the player
* has already started playing this song, it will completely
* stop
*/
PLAYER_COMMAND_
CANCEL
,
CANCEL
,
/**
* Refresh status information in the #player_control struct,
* e.g. elapsed_time.
*/
PLAYER_COMMAND_
REFRESH
,
REFRESH
,
};
enum
player_error
{
PLAYER_ERROR_NONE
=
0
,
enum
class
PlayerError
:
uint8_t
{
NONE
,
/**
* The decoder has failed to decode the song.
*/
PLAYER_ERROR_
DECODER
,
DECODER
,
/**
* The audio output has failed.
*/
PLAYER_ERROR_
OUTPUT
,
OUTPUT
,
};
struct
player_status
{
enum
player_s
tate
state
;
PlayerS
tate
state
;
uint16_t
bit_rate
;
AudioFormat
audio_format
;
float
total_time
;
...
...
@@ -117,16 +116,16 @@ struct player_control {
*/
Cond
client_cond
;
enum
player_c
ommand
command
;
enum
player_s
tate
state
;
PlayerC
ommand
command
;
PlayerS
tate
state
;
enum
player_e
rror
error_type
;
PlayerE
rror
error_type
;
/**
* The error that occurred in the player thread. This
* attribute is only valid if #error is not
* #P
LAYER_ERROR_
NONE. The object must be freed when this
* object transitions back to #P
LAYER_ERROR_
NONE.
* #P
layerError::
NONE. The object must be freed when this
* object transitions back to #P
layerError::
NONE.
*/
Error
error
;
...
...
@@ -236,9 +235,9 @@ struct player_control {
* object.
*/
void
CommandFinished
()
{
assert
(
command
!=
P
LAYER_COMMAND_
NONE
);
assert
(
command
!=
P
layerCommand
::
NONE
);
command
=
P
LAYER_COMMAND_
NONE
;
command
=
P
layerCommand
::
NONE
;
ClientSignal
();
}
...
...
@@ -250,7 +249,7 @@ private:
* object.
*/
void
WaitCommandLocked
()
{
while
(
command
!=
P
LAYER_COMMAND_
NONE
)
while
(
command
!=
P
layerCommand
::
NONE
)
ClientWait
();
}
...
...
@@ -261,8 +260,8 @@ private:
* To be called from the main thread. Caller must lock the
* object.
*/
void
SynchronousCommand
(
player_c
ommand
cmd
)
{
assert
(
command
==
P
LAYER_COMMAND_
NONE
);
void
SynchronousCommand
(
PlayerC
ommand
cmd
)
{
assert
(
command
==
P
layerCommand
::
NONE
);
command
=
cmd
;
Signal
();
...
...
@@ -276,7 +275,7 @@ private:
* To be called from the main thread. This method locks the
* object.
*/
void
LockSynchronousCommand
(
player_c
ommand
cmd
)
{
void
LockSynchronousCommand
(
PlayerC
ommand
cmd
)
{
Lock
();
SynchronousCommand
(
cmd
);
Unlock
();
...
...
@@ -290,7 +289,7 @@ public:
void
Play
(
Song
*
song
);
/**
* see P
LAYER_COMMAND_
CANCEL
* see P
layerCommand::
CANCEL
*/
void
Cancel
();
...
...
@@ -312,7 +311,7 @@ public:
gcc_pure
player_status
GetStatus
();
player_s
tate
GetState
()
const
{
PlayerS
tate
GetState
()
const
{
return
state
;
}
...
...
@@ -321,10 +320,10 @@ public:
*
* Caller must lock the object.
*
* @param type the error type; must not be #P
LAYER_ERROR_
NONE
* @param type the error type; must not be #P
layerError::
NONE
* @param error detailed error information; must be defined.
*/
void
SetError
(
player_e
rror
type
,
Error
&&
error
);
void
SetError
(
PlayerE
rror
type
,
Error
&&
error
);
void
ClearError
();
...
...
@@ -335,7 +334,7 @@ public:
*/
char
*
GetErrorMessage
()
const
;
player_e
rror
GetErrorType
()
const
{
PlayerE
rror
GetErrorType
()
const
{
return
error_type
;
}
...
...
@@ -349,7 +348,7 @@ private:
assert
(
next_song
==
nullptr
);
next_song
=
song
;
SynchronousCommand
(
P
LAYER_COMMAND_
QUEUE
);
SynchronousCommand
(
P
layerCommand
::
QUEUE
);
}
public
:
...
...
src/PlayerThread.cxx
View file @
d05bb2a0
...
...
@@ -205,7 +205,7 @@ struct player {
}
/**
* This is the handler for the #P
LAYER_COMMAND_
SEEK command.
* This is the handler for the #P
layerCommand::
SEEK command.
*
* The player lock is not held.
*/
...
...
@@ -281,11 +281,11 @@ player_command_finished(player_control &pc)
void
player
::
StartDecoder
(
MusicPipe
&
_pipe
)
{
assert
(
queued
||
pc
.
command
==
P
LAYER_COMMAND_
SEEK
);
assert
(
queued
||
pc
.
command
==
P
layerCommand
::
SEEK
);
assert
(
pc
.
next_song
!=
nullptr
);
unsigned
start_ms
=
pc
.
next_song
->
start_ms
;
if
(
pc
.
command
==
P
LAYER_COMMAND_
SEEK
)
if
(
pc
.
command
==
P
layerCommand
::
SEEK
)
start_ms
+=
(
unsigned
)(
pc
.
seek_where
*
1000
);
dc
.
Start
(
pc
.
next_song
->
DupDetached
(),
...
...
@@ -313,7 +313,7 @@ player::StopDecoder()
bool
player
::
WaitForDecoder
()
{
assert
(
queued
||
pc
.
command
==
P
LAYER_COMMAND_
SEEK
);
assert
(
queued
||
pc
.
command
==
P
layerCommand
::
SEEK
);
assert
(
pc
.
next_song
!=
nullptr
);
queued
=
false
;
...
...
@@ -321,7 +321,7 @@ player::WaitForDecoder()
Error
error
=
dc
.
LockGetError
();
if
(
error
.
IsDefined
())
{
pc
.
Lock
();
pc
.
SetError
(
P
LAYER_ERROR_
DECODER
,
std
::
move
(
error
));
pc
.
SetError
(
P
layerError
::
DECODER
,
std
::
move
(
error
));
pc
.
next_song
->
Free
();
pc
.
next_song
=
nullptr
;
...
...
@@ -383,8 +383,8 @@ bool
player
::
OpenOutput
()
{
assert
(
play_audio_format
.
IsDefined
());
assert
(
pc
.
state
==
P
LAYER_STATE_
PLAY
||
pc
.
state
==
P
LAYER_STATE_
PAUSE
);
assert
(
pc
.
state
==
P
layerState
::
PLAY
||
pc
.
state
==
P
layerState
::
PAUSE
);
Error
error
;
if
(
audio_output_all_open
(
play_audio_format
,
buffer
,
error
))
{
...
...
@@ -392,7 +392,7 @@ player::OpenOutput()
paused
=
false
;
pc
.
Lock
();
pc
.
state
=
P
LAYER_STATE_
PLAY
;
pc
.
state
=
P
layerState
::
PLAY
;
pc
.
Unlock
();
idle_add
(
IDLE_PLAYER
);
...
...
@@ -408,8 +408,8 @@ player::OpenOutput()
paused
=
true
;
pc
.
Lock
();
pc
.
SetError
(
P
LAYER_ERROR_
OUTPUT
,
std
::
move
(
error
));
pc
.
state
=
P
LAYER_STATE_
PAUSE
;
pc
.
SetError
(
P
layerError
::
OUTPUT
,
std
::
move
(
error
));
pc
.
state
=
P
layerState
::
PAUSE
;
pc
.
Unlock
();
idle_add
(
IDLE_PLAYER
);
...
...
@@ -431,7 +431,7 @@ player::CheckDecoderStartup()
dc
.
Unlock
();
pc
.
Lock
();
pc
.
SetError
(
P
LAYER_ERROR_
DECODER
,
std
::
move
(
error
));
pc
.
SetError
(
P
layerError
::
DECODER
,
std
::
move
(
error
));
pc
.
Unlock
();
return
false
;
...
...
@@ -589,20 +589,20 @@ inline void
player
::
ProcessCommand
()
{
switch
(
pc
.
command
)
{
case
P
LAYER_COMMAND_
NONE
:
case
P
LAYER_COMMAND_
STOP
:
case
P
LAYER_COMMAND_
EXIT
:
case
P
LAYER_COMMAND_
CLOSE_AUDIO
:
case
P
layerCommand
:
:
NONE
:
case
P
layerCommand
:
:
STOP
:
case
P
layerCommand
:
:
EXIT
:
case
P
layerCommand
:
:
CLOSE_AUDIO
:
break
;
case
P
LAYER_COMMAND_
UPDATE_AUDIO
:
case
P
layerCommand
:
:
UPDATE_AUDIO
:
pc
.
Unlock
();
audio_output_all_enable_disable
();
pc
.
Lock
();
pc
.
CommandFinished
();
break
;
case
P
LAYER_COMMAND_
QUEUE
:
case
P
layerCommand
:
:
QUEUE
:
assert
(
pc
.
next_song
!=
nullptr
);
assert
(
!
queued
);
assert
(
!
IsDecoderAtNextSong
());
...
...
@@ -611,7 +611,7 @@ player::ProcessCommand()
pc
.
CommandFinished
();
break
;
case
P
LAYER_COMMAND_
PAUSE
:
case
P
layerCommand
:
:
PAUSE
:
pc
.
Unlock
();
paused
=
!
paused
;
...
...
@@ -619,13 +619,13 @@ player::ProcessCommand()
audio_output_all_pause
();
pc
.
Lock
();
pc
.
state
=
P
LAYER_STATE_
PAUSE
;
pc
.
state
=
P
layerState
::
PAUSE
;
}
else
if
(
!
play_audio_format
.
IsDefined
())
{
/* the decoder hasn't provided an audio format
yet - don't open the audio device yet */
pc
.
Lock
();
pc
.
state
=
P
LAYER_STATE_
PLAY
;
pc
.
state
=
P
layerState
::
PLAY
;
}
else
{
OpenOutput
();
...
...
@@ -635,18 +635,18 @@ player::ProcessCommand()
pc
.
CommandFinished
();
break
;
case
P
LAYER_COMMAND_
SEEK
:
case
P
layerCommand
:
:
SEEK
:
pc
.
Unlock
();
SeekDecoder
();
pc
.
Lock
();
break
;
case
P
LAYER_COMMAND_
CANCEL
:
case
P
layerCommand
:
:
CANCEL
:
if
(
pc
.
next_song
==
nullptr
)
{
/* the cancel request arrived too late, we're
already playing the queued song... stop
everything now */
pc
.
command
=
P
LAYER_COMMAND_
STOP
;
pc
.
command
=
P
layerCommand
::
STOP
;
return
;
}
...
...
@@ -664,7 +664,7 @@ player::ProcessCommand()
pc
.
CommandFinished
();
break
;
case
P
LAYER_COMMAND_
REFRESH
:
case
P
layerCommand
:
:
REFRESH
:
if
(
output_open
&&
!
paused
)
{
pc
.
Unlock
();
audio_output_all_check
();
...
...
@@ -841,11 +841,11 @@ player::PlayNextChunk()
pc
.
Lock
();
pc
.
SetError
(
P
LAYER_ERROR_
OUTPUT
,
std
::
move
(
error
));
pc
.
SetError
(
P
layerError
::
OUTPUT
,
std
::
move
(
error
));
/* pause: the user may resume playback as soon as an
audio output becomes available */
pc
.
state
=
P
LAYER_STATE_
PAUSE
;
pc
.
state
=
P
layerState
::
PAUSE
;
paused
=
true
;
pc
.
Unlock
();
...
...
@@ -889,7 +889,7 @@ player::SongBorder()
const
bool
border_pause
=
pc
.
border_pause
;
if
(
border_pause
)
{
paused
=
true
;
pc
.
state
=
P
LAYER_STATE_
PAUSE
;
pc
.
state
=
P
layerState
::
PAUSE
;
}
pc
.
Unlock
();
...
...
@@ -916,18 +916,18 @@ player::Run()
}
pc
.
Lock
();
pc
.
state
=
P
LAYER_STATE_
PLAY
;
pc
.
state
=
P
layerState
::
PLAY
;
if
(
pc
.
command
==
P
LAYER_COMMAND_
SEEK
)
if
(
pc
.
command
==
P
layerCommand
::
SEEK
)
elapsed_time
=
pc
.
seek_where
;
pc
.
CommandFinished
();
while
(
true
)
{
ProcessCommand
();
if
(
pc
.
command
==
P
LAYER_COMMAND_
STOP
||
pc
.
command
==
P
LAYER_COMMAND_
EXIT
||
pc
.
command
==
P
LAYER_COMMAND_
CLOSE_AUDIO
)
{
if
(
pc
.
command
==
P
layerCommand
::
STOP
||
pc
.
command
==
P
layerCommand
::
EXIT
||
pc
.
command
==
P
layerCommand
::
CLOSE_AUDIO
)
{
pc
.
Unlock
();
audio_output_all_cancel
();
break
;
...
...
@@ -1021,7 +1021,7 @@ player::Run()
if
(
paused
)
{
pc
.
Lock
();
if
(
pc
.
command
==
P
LAYER_COMMAND_
NONE
)
if
(
pc
.
command
==
P
layerCommand
::
NONE
)
pc
.
Wait
();
continue
;
}
else
if
(
!
pipe
->
IsEmpty
())
{
...
...
@@ -1079,7 +1079,7 @@ player::Run()
pc
.
next_song
=
nullptr
;
}
pc
.
state
=
P
LAYER_STATE_
STOP
;
pc
.
state
=
P
layerState
::
STOP
;
pc
.
Unlock
();
}
...
...
@@ -1106,8 +1106,8 @@ player_task(gpointer arg)
while
(
1
)
{
switch
(
pc
.
command
)
{
case
P
LAYER_COMMAND_
SEEK
:
case
P
LAYER_COMMAND_
QUEUE
:
case
P
layerCommand
:
:
SEEK
:
case
P
layerCommand
:
:
QUEUE
:
assert
(
pc
.
next_song
!=
nullptr
);
pc
.
Unlock
();
...
...
@@ -1116,14 +1116,14 @@ player_task(gpointer arg)
pc
.
Lock
();
break
;
case
P
LAYER_COMMAND_
STOP
:
case
P
layerCommand
:
:
STOP
:
pc
.
Unlock
();
audio_output_all_cancel
();
pc
.
Lock
();
/* fall through */
case
P
LAYER_COMMAND_
PAUSE
:
case
P
layerCommand
:
:
PAUSE
:
if
(
pc
.
next_song
!=
nullptr
)
{
pc
.
next_song
->
Free
();
pc
.
next_song
=
nullptr
;
...
...
@@ -1132,7 +1132,7 @@ player_task(gpointer arg)
pc
.
CommandFinished
();
break
;
case
P
LAYER_COMMAND_
CLOSE_AUDIO
:
case
P
layerCommand
:
:
CLOSE_AUDIO
:
pc
.
Unlock
();
audio_output_all_release
();
...
...
@@ -1144,14 +1144,14 @@ player_task(gpointer arg)
break
;
case
P
LAYER_COMMAND_
UPDATE_AUDIO
:
case
P
layerCommand
:
:
UPDATE_AUDIO
:
pc
.
Unlock
();
audio_output_all_enable_disable
();
pc
.
Lock
();
pc
.
CommandFinished
();
break
;
case
P
LAYER_COMMAND_
EXIT
:
case
P
layerCommand
:
:
EXIT
:
pc
.
Unlock
();
dc
.
Quit
();
...
...
@@ -1161,7 +1161,7 @@ player_task(gpointer arg)
player_command_finished
(
pc
);
return
nullptr
;
case
P
LAYER_COMMAND_
CANCEL
:
case
P
layerCommand
:
:
CANCEL
:
if
(
pc
.
next_song
!=
nullptr
)
{
pc
.
next_song
->
Free
();
pc
.
next_song
=
nullptr
;
...
...
@@ -1170,12 +1170,12 @@ player_task(gpointer arg)
pc
.
CommandFinished
();
break
;
case
P
LAYER_COMMAND_
REFRESH
:
case
P
layerCommand
:
:
REFRESH
:
/* no-op when not playing */
pc
.
CommandFinished
();
break
;
case
P
LAYER_COMMAND_
NONE
:
case
P
layerCommand
:
:
NONE
:
pc
.
Wait
();
break
;
}
...
...
src/Playlist.cxx
View file @
d05bb2a0
...
...
@@ -175,11 +175,11 @@ playlist::SyncWithPlayer(player_control &pc)
return
;
pc
.
Lock
();
const
player_s
tate
pc_state
=
pc
.
GetState
();
const
PlayerS
tate
pc_state
=
pc
.
GetState
();
const
Song
*
pc_next_song
=
pc
.
next_song
;
pc
.
Unlock
();
if
(
pc_state
==
P
LAYER_STATE_
STOP
)
if
(
pc_state
==
P
layerState
::
STOP
)
/* the player thread has stopped: check if playback
should be restarted with the next song. That can
happen if the playlist isn't filling the queue fast
...
...
@@ -210,16 +210,16 @@ static void
playlist_resume_playback
(
struct
playlist
*
playlist
,
struct
player_control
*
pc
)
{
assert
(
playlist
->
playing
);
assert
(
pc
->
GetState
()
==
P
LAYER_STATE_
STOP
);
assert
(
pc
->
GetState
()
==
P
layerState
::
STOP
);
const
auto
error
=
pc
->
GetErrorType
();
if
(
error
==
P
LAYER_ERROR_
NONE
)
if
(
error
==
P
layerError
::
NONE
)
playlist
->
error_count
=
0
;
else
++
playlist
->
error_count
;
if
((
playlist
->
stop_on_error
&&
error
!=
P
LAYER_ERROR_
NONE
)
||
error
==
P
LAYER_ERROR_
OUTPUT
||
if
((
playlist
->
stop_on_error
&&
error
!=
P
layerError
::
NONE
)
||
error
==
P
layerError
::
OUTPUT
||
playlist
->
error_count
>=
playlist
->
queue
.
GetLength
())
/* too many errors, or critical error: stop
playback */
...
...
src/PlaylistControl.cxx
View file @
d05bb2a0
...
...
@@ -250,8 +250,8 @@ playlist::SeekCurrent(player_control &pc, float seek_time, bool relative)
if
(
relative
)
{
const
auto
status
=
pc
.
GetStatus
();
if
(
status
.
state
!=
P
LAYER_STATE_
PLAY
&&
status
.
state
!=
P
LAYER_STATE_
PAUSE
)
if
(
status
.
state
!=
P
layerState
::
PLAY
&&
status
.
state
!=
P
layerState
::
PAUSE
)
return
PLAYLIST_RESULT_NOT_PLAYING
;
seek_time
+=
(
int
)
status
.
elapsed_time
;
...
...
src/PlaylistEdit.cxx
View file @
d05bb2a0
...
...
@@ -226,7 +226,7 @@ playlist::DeleteInternal(player_control &pc,
unsigned
songOrder
=
queue
.
PositionToOrder
(
song
);
if
(
playing
&&
current
==
(
int
)
songOrder
)
{
const
bool
paused
=
pc
.
GetState
()
==
P
LAYER_STATE_
PAUSE
;
const
bool
paused
=
pc
.
GetState
()
==
P
layerState
::
PAUSE
;
/* the current song is going to be deleted: stop the player */
...
...
src/PlaylistState.cxx
View file @
d05bb2a0
...
...
@@ -63,7 +63,7 @@ playlist_state_save(FILE *fp, const struct playlist *playlist,
if
(
playlist
->
playing
)
{
switch
(
player_status
.
state
)
{
case
P
LAYER_STATE_
PAUSE
:
case
P
layerState
:
:
PAUSE
:
fputs
(
PLAYLIST_STATE_FILE_STATE_PAUSE
"
\n
"
,
fp
);
break
;
default:
...
...
@@ -126,7 +126,6 @@ playlist_state_restore(const char *line, TextFile &file,
{
int
current
=
-
1
;
int
seek_time
=
0
;
enum
player_state
state
=
PLAYER_STATE_STOP
;
bool
random_mode
=
false
;
if
(
!
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_STATE
))
...
...
@@ -134,10 +133,13 @@ playlist_state_restore(const char *line, TextFile &file,
line
+=
sizeof
(
PLAYLIST_STATE_FILE_STATE
)
-
1
;
PlayerState
state
;
if
(
strcmp
(
line
,
PLAYLIST_STATE_FILE_STATE_PLAY
)
==
0
)
state
=
P
LAYER_STATE_
PLAY
;
state
=
P
layerState
::
PLAY
;
else
if
(
strcmp
(
line
,
PLAYLIST_STATE_FILE_STATE_PAUSE
)
==
0
)
state
=
PLAYER_STATE_PAUSE
;
state
=
PlayerState
::
PAUSE
;
else
state
=
PlayerState
::
STOP
;
while
((
line
=
file
.
ReadLine
())
!=
NULL
)
{
if
(
g_str_has_prefix
(
line
,
PLAYLIST_STATE_FILE_TIME
))
{
...
...
@@ -180,27 +182,27 @@ playlist_state_restore(const char *line, TextFile &file,
if
(
!
playlist
->
queue
.
IsValidPosition
(
current
))
current
=
0
;
if
(
state
==
P
LAYER_STATE_
PLAY
&&
if
(
state
==
P
layerState
::
PLAY
&&
config_get_bool
(
CONF_RESTORE_PAUSED
,
false
))
/* the user doesn't want MPD to auto-start
playback after startup; fall back to
"pause" */
state
=
P
LAYER_STATE_
PAUSE
;
state
=
P
layerState
::
PAUSE
;
/* enable all devices for the first time; this must be
called here, after the audio output states were
restored, before playback begins */
if
(
state
!=
P
LAYER_STATE_
STOP
)
if
(
state
!=
P
layerState
::
STOP
)
pc
->
UpdateAudio
();
if
(
state
==
P
LAYER_STATE_
STOP
/* && config_option */
)
if
(
state
==
P
layerState
::
STOP
/* && config_option */
)
playlist
->
current
=
current
;
else
if
(
seek_time
==
0
)
playlist
->
PlayPosition
(
*
pc
,
current
);
else
playlist
->
SeekSongPosition
(
*
pc
,
current
,
seek_time
);
if
(
state
==
P
LAYER_STATE_
PAUSE
)
if
(
state
==
P
layerState
::
PAUSE
)
pc
->
Pause
();
}
...
...
@@ -214,14 +216,14 @@ playlist_state_get_hash(const struct playlist *playlist,
const
auto
player_status
=
pc
->
GetStatus
();
return
playlist
->
queue
.
version
^
(
player_status
.
state
!=
P
LAYER_STATE_
STOP
(
player_status
.
state
!=
P
layerState
::
STOP
?
((
int
)
player_status
.
elapsed_time
<<
8
)
:
0
)
^
(
playlist
->
current
>=
0
?
(
playlist
->
queue
.
OrderToPosition
(
playlist
->
current
)
<<
16
)
:
0
)
^
((
int
)
pc
->
GetCrossFade
()
<<
20
)
^
(
player_status
.
state
<<
24
)
^
(
unsigned
(
player_status
.
state
)
<<
24
)
^
(
playlist
->
queue
.
random
<<
27
)
^
(
playlist
->
queue
.
repeat
<<
28
)
^
(
playlist
->
queue
.
single
<<
29
)
^
...
...
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