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
e1b03b4a
Commit
e1b03b4a
authored
Jan 20, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PlayerControl: move functions into the class
parent
e6ed592b
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
335 additions
and
400 deletions
+335
-400
DecoderControl.hxx
src/DecoderControl.hxx
+9
-0
Main.cxx
src/Main.cxx
+2
-2
OutputAll.cxx
src/OutputAll.cxx
+4
-4
OutputCommand.cxx
src/OutputCommand.cxx
+2
-2
OutputThread.cxx
src/OutputThread.cxx
+1
-1
PlayerCommands.cxx
src/PlayerCommands.cxx
+11
-13
PlayerControl.cxx
src/PlayerControl.cxx
+92
-108
PlayerControl.hxx
src/PlayerControl.hxx
+121
-167
PlayerThread.cxx
src/PlayerThread.cxx
+61
-61
Playlist.cxx
src/Playlist.cxx
+12
-14
PlaylistControl.cxx
src/PlaylistControl.cxx
+6
-7
PlaylistEdit.cxx
src/PlaylistEdit.cxx
+2
-2
PlaylistState.cxx
src/PlaylistState.cxx
+11
-18
Stats.cxx
src/Stats.cxx
+1
-1
No files found.
src/DecoderControl.hxx
View file @
e1b03b4a
...
@@ -129,6 +129,15 @@ struct decoder_control {
...
@@ -129,6 +129,15 @@ struct decoder_control {
char
*
mixramp_start
;
char
*
mixramp_start
;
char
*
mixramp_end
;
char
*
mixramp_end
;
char
*
mixramp_prev_end
;
char
*
mixramp_prev_end
;
/**
* Waits for a signal from the decoder thread. This object
* must be locked prior to calling this function. This method
* is only valid in the player thread.
*/
void
WaitForDecoder
()
{
g_cond_wait
(
client_cond
,
mutex
);
}
};
};
G_GNUC_MALLOC
G_GNUC_MALLOC
...
...
src/Main.cxx
View file @
e1b03b4a
...
@@ -509,7 +509,7 @@ int mpd_main(int argc, char *argv[])
...
@@ -509,7 +509,7 @@ int mpd_main(int argc, char *argv[])
/* enable all audio outputs (if not already done by
/* enable all audio outputs (if not already done by
playlist_state_restore() */
playlist_state_restore() */
pc_update_audio
(
&
global_partition
->
pc
);
global_partition
->
pc
.
UpdateAudio
(
);
#ifdef WIN32
#ifdef WIN32
win32_app_started
();
win32_app_started
();
...
@@ -535,7 +535,7 @@ int mpd_main(int argc, char *argv[])
...
@@ -535,7 +535,7 @@ int mpd_main(int argc, char *argv[])
delete
state_file
;
delete
state_file
;
}
}
pc_kill
(
&
global_partition
->
pc
);
global_partition
->
pc
.
Kill
(
);
finishZeroconf
();
finishZeroconf
();
listen_global_finish
();
listen_global_finish
();
delete
client_list
;
delete
client_list
;
...
...
src/OutputAll.cxx
View file @
e1b03b4a
...
@@ -481,15 +481,15 @@ audio_output_all_check(void)
...
@@ -481,15 +481,15 @@ audio_output_all_check(void)
bool
bool
audio_output_all_wait
(
struct
player_control
*
pc
,
unsigned
threshold
)
audio_output_all_wait
(
struct
player_control
*
pc
,
unsigned
threshold
)
{
{
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
if
(
audio_output_all_check
()
<
threshold
)
{
if
(
audio_output_all_check
()
<
threshold
)
{
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
return
true
;
return
true
;
}
}
p
layer_wait
(
pc
);
p
c
->
Wait
(
);
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
return
audio_output_all_check
()
<
threshold
;
return
audio_output_all_check
()
<
threshold
;
}
}
...
...
src/OutputCommand.cxx
View file @
e1b03b4a
...
@@ -53,7 +53,7 @@ audio_output_enable_index(unsigned idx)
...
@@ -53,7 +53,7 @@ audio_output_enable_index(unsigned idx)
ao
->
enabled
=
true
;
ao
->
enabled
=
true
;
idle_add
(
IDLE_OUTPUT
);
idle_add
(
IDLE_OUTPUT
);
pc_update_audio
(
ao
->
player_control
);
ao
->
player_control
->
UpdateAudio
(
);
++
audio_output_state_version
;
++
audio_output_state_version
;
...
@@ -82,7 +82,7 @@ audio_output_disable_index(unsigned idx)
...
@@ -82,7 +82,7 @@ audio_output_disable_index(unsigned idx)
idle_add
(
IDLE_MIXER
);
idle_add
(
IDLE_MIXER
);
}
}
pc_update_audio
(
ao
->
player_control
);
ao
->
player_control
->
UpdateAudio
(
);
++
audio_output_state_version
;
++
audio_output_state_version
;
...
...
src/OutputThread.cxx
View file @
e1b03b4a
...
@@ -548,7 +548,7 @@ ao_play(struct audio_output *ao)
...
@@ -548,7 +548,7 @@ ao_play(struct audio_output *ao)
ao
->
chunk_finished
=
true
;
ao
->
chunk_finished
=
true
;
g_mutex_unlock
(
ao
->
mutex
);
g_mutex_unlock
(
ao
->
mutex
);
player_lock_signal
(
ao
->
player_control
);
ao
->
player_control
->
LockSignal
(
);
g_mutex_lock
(
ao
->
mutex
);
g_mutex_lock
(
ao
->
mutex
);
return
true
;
return
true
;
...
...
src/PlayerCommands.cxx
View file @
e1b03b4a
...
@@ -106,9 +106,9 @@ handle_pause(Client *client,
...
@@ -106,9 +106,9 @@ 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
;
pc_set_pause
(
client
->
player_control
,
pause_flag
);
client
->
player_control
->
SetPause
(
pause_flag
);
}
else
}
else
pc_pause
(
client
->
player_control
);
client
->
player_control
->
Pause
(
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -118,12 +118,10 @@ handle_status(Client *client,
...
@@ -118,12 +118,10 @@ handle_status(Client *client,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
{
const
char
*
state
=
NULL
;
const
char
*
state
=
NULL
;
struct
player_status
player_status
;
int
updateJobId
;
int
updateJobId
;
char
*
error
;
int
song
;
int
song
;
pc_get_status
(
client
->
player_control
,
&
player_status
);
const
auto
player_status
=
client
->
player_control
->
GetStatus
(
);
switch
(
player_status
.
state
)
{
switch
(
player_status
.
state
)
{
case
PLAYER_STATE_STOP
:
case
PLAYER_STATE_STOP
:
...
@@ -157,9 +155,9 @@ handle_status(Client *client,
...
@@ -157,9 +155,9 @@ handle_status(Client *client,
playlist
.
GetConsume
(),
playlist
.
GetConsume
(),
(
unsigned
long
)
playlist
.
GetVersion
(),
(
unsigned
long
)
playlist
.
GetVersion
(),
playlist
.
GetLength
(),
playlist
.
GetLength
(),
(
int
)(
pc_get_cross_fade
(
client
->
player_control
)
+
0.5
),
(
int
)(
client
->
player_control
->
GetCrossFade
(
)
+
0.5
),
pc_get_mixramp_db
(
client
->
player_control
),
client
->
player_control
->
GetMixRampDb
(
),
pc_get_mixramp_delay
(
client
->
player_control
),
client
->
player_control
->
GetMixRampDelay
(
),
state
);
state
);
song
=
playlist
.
GetCurrentPosition
();
song
=
playlist
.
GetCurrentPosition
();
...
@@ -192,7 +190,7 @@ handle_status(Client *client,
...
@@ -192,7 +190,7 @@ handle_status(Client *client,
updateJobId
);
updateJobId
);
}
}
error
=
pc_get_error_message
(
client
->
player_control
);
char
*
error
=
client
->
player_control
->
GetErrorMessage
(
);
if
(
error
!=
NULL
)
{
if
(
error
!=
NULL
)
{
client_printf
(
client
,
client_printf
(
client
,
COMMAND_STATUS_ERROR
": %s
\n
"
,
COMMAND_STATUS_ERROR
": %s
\n
"
,
...
@@ -285,7 +283,7 @@ enum command_return
...
@@ -285,7 +283,7 @@ enum command_return
handle_clearerror
(
G_GNUC_UNUSED
Client
*
client
,
handle_clearerror
(
G_GNUC_UNUSED
Client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
{
pc_clear_error
(
client
->
player_control
);
client
->
player_control
->
ClearError
(
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -340,7 +338,7 @@ handle_crossfade(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -340,7 +338,7 @@ handle_crossfade(Client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
check_unsigned
(
client
,
&
xfade_time
,
argv
[
1
]))
if
(
!
check_unsigned
(
client
,
&
xfade_time
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
pc_set_cross_fade
(
client
->
player_control
,
xfade_time
);
client
->
player_control
->
SetCrossFade
(
xfade_time
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -352,7 +350,7 @@ handle_mixrampdb(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -352,7 +350,7 @@ handle_mixrampdb(Client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
check_float
(
client
,
&
db
,
argv
[
1
]))
if
(
!
check_float
(
client
,
&
db
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
pc_set_mixramp_db
(
client
->
player_control
,
db
);
client
->
player_control
->
SetMixRampDb
(
db
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
@@ -364,7 +362,7 @@ handle_mixrampdelay(Client *client, G_GNUC_UNUSED int argc, char *argv[])
...
@@ -364,7 +362,7 @@ handle_mixrampdelay(Client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
check_float
(
client
,
&
delay_secs
,
argv
[
1
]))
if
(
!
check_float
(
client
,
&
delay_secs
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
return
COMMAND_RETURN_ERROR
;
pc_set_mixramp_delay
(
client
->
player_control
,
delay_secs
);
client
->
player_control
->
SetMixRampDelay
(
delay_secs
);
return
COMMAND_RETURN_OK
;
return
COMMAND_RETURN_OK
;
}
}
...
...
src/PlayerControl.cxx
View file @
e1b03b4a
...
@@ -56,18 +56,6 @@ player_control::~player_control()
...
@@ -56,18 +56,6 @@ player_control::~player_control()
song_free
(
next_song
);
song_free
(
next_song
);
}
}
void
player_wait_decoder
(
gcc_unused
struct
player_control
*
pc
,
struct
decoder_control
*
dc
)
{
assert
(
pc
!=
NULL
);
assert
(
dc
!=
NULL
);
/* during this function, the decoder lock is held, because
we're waiting for the decoder thread */
g_cond_wait
(
dc
->
client_cond
,
dc
->
mutex
);
}
static
void
static
void
player_command_wait_locked
(
struct
player_control
*
pc
)
player_command_wait_locked
(
struct
player_control
*
pc
)
{
{
...
@@ -81,84 +69,84 @@ player_command_locked(struct player_control *pc, enum player_command cmd)
...
@@ -81,84 +69,84 @@ player_command_locked(struct player_control *pc, enum player_command cmd)
assert
(
pc
->
command
==
PLAYER_COMMAND_NONE
);
assert
(
pc
->
command
==
PLAYER_COMMAND_NONE
);
pc
->
command
=
cmd
;
pc
->
command
=
cmd
;
p
layer_signal
(
pc
);
p
c
->
Signal
(
);
player_command_wait_locked
(
pc
);
player_command_wait_locked
(
pc
);
}
}
static
void
static
void
player_command
(
struct
player_control
*
pc
,
enum
player_command
cmd
)
player_command
(
struct
player_control
*
pc
,
enum
player_command
cmd
)
{
{
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
player_command_locked
(
pc
,
cmd
);
player_command_locked
(
pc
,
cmd
);
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
}
}
void
void
p
c_play
(
struct
player_control
*
pc
,
struct
song
*
song
)
p
layer_control
::
Play
(
struct
song
*
song
)
{
{
assert
(
song
!=
NULL
);
assert
(
song
!=
NULL
);
player_lock
(
pc
);
Lock
(
);
if
(
pc
->
state
!=
PLAYER_STATE_STOP
)
if
(
state
!=
PLAYER_STATE_STOP
)
player_command_locked
(
pc
,
PLAYER_COMMAND_STOP
);
player_command_locked
(
this
,
PLAYER_COMMAND_STOP
);
assert
(
pc
->
next_song
==
NULL
);
assert
(
next_song
==
nullptr
);
pc_enqueue_song_locked
(
pc
,
song
);
pc_enqueue_song_locked
(
this
,
song
);
assert
(
pc
->
next_song
==
NULL
);
assert
(
next_song
==
nullptr
);
player_unlock
(
pc
);
Unlock
(
);
idle_add
(
IDLE_PLAYER
);
idle_add
(
IDLE_PLAYER
);
}
}
void
void
p
c_cancel
(
struct
player_control
*
pc
)
p
layer_control
::
Cancel
(
)
{
{
player_command
(
pc
,
PLAYER_COMMAND_CANCEL
);
player_command
(
this
,
PLAYER_COMMAND_CANCEL
);
assert
(
pc
->
next_song
==
NULL
);
assert
(
next_song
==
NULL
);
}
}
void
void
p
c_stop
(
struct
player_control
*
pc
)
p
layer_control
::
Stop
(
)
{
{
player_command
(
pc
,
PLAYER_COMMAND_CLOSE_AUDIO
);
player_command
(
this
,
PLAYER_COMMAND_CLOSE_AUDIO
);
assert
(
pc
->
next_song
==
NULL
);
assert
(
next_song
==
nullptr
);
idle_add
(
IDLE_PLAYER
);
idle_add
(
IDLE_PLAYER
);
}
}
void
void
p
c_update_audio
(
struct
player_control
*
pc
)
p
layer_control
::
UpdateAudio
(
)
{
{
player_command
(
pc
,
PLAYER_COMMAND_UPDATE_AUDIO
);
player_command
(
this
,
PLAYER_COMMAND_UPDATE_AUDIO
);
}
}
void
void
p
c_kill
(
struct
player_control
*
pc
)
p
layer_control
::
Kill
(
)
{
{
assert
(
pc
->
thread
!=
NULL
);
assert
(
thread
!=
NULL
);
player_command
(
pc
,
PLAYER_COMMAND_EXIT
);
player_command
(
this
,
PLAYER_COMMAND_EXIT
);
g_thread_join
(
pc
->
thread
);
g_thread_join
(
thread
);
pc
->
thread
=
NULL
;
thread
=
NULL
;
idle_add
(
IDLE_PLAYER
);
idle_add
(
IDLE_PLAYER
);
}
}
void
void
p
c_pause
(
struct
player_control
*
pc
)
p
layer_control
::
Pause
(
)
{
{
player_lock
(
pc
);
Lock
(
);
if
(
pc
->
state
!=
PLAYER_STATE_STOP
)
{
if
(
state
!=
PLAYER_STATE_STOP
)
{
player_command_locked
(
pc
,
PLAYER_COMMAND_PAUSE
);
player_command_locked
(
this
,
PLAYER_COMMAND_PAUSE
);
idle_add
(
IDLE_PLAYER
);
idle_add
(
IDLE_PLAYER
);
}
}
player_unlock
(
pc
);
Unlock
(
);
}
}
static
void
static
void
...
@@ -171,90 +159,92 @@ pc_pause_locked(struct player_control *pc)
...
@@ -171,90 +159,92 @@ pc_pause_locked(struct player_control *pc)
}
}
void
void
p
c_set_pause
(
struct
player_control
*
pc
,
bool
pause_flag
)
p
layer_control
::
SetPause
(
bool
pause_flag
)
{
{
player_lock
(
pc
);
Lock
(
);
switch
(
pc
->
state
)
{
switch
(
state
)
{
case
PLAYER_STATE_STOP
:
case
PLAYER_STATE_STOP
:
break
;
break
;
case
PLAYER_STATE_PLAY
:
case
PLAYER_STATE_PLAY
:
if
(
pause_flag
)
if
(
pause_flag
)
pc_pause_locked
(
pc
);
pc_pause_locked
(
this
);
break
;
break
;
case
PLAYER_STATE_PAUSE
:
case
PLAYER_STATE_PAUSE
:
if
(
!
pause_flag
)
if
(
!
pause_flag
)
pc_pause_locked
(
pc
);
pc_pause_locked
(
this
);
break
;
break
;
}
}
player_unlock
(
pc
);
Unlock
(
);
}
}
void
void
p
c_set_border_pause
(
struct
player_control
*
pc
,
bool
border_pause
)
p
layer_control
::
SetBorderPause
(
bool
_
border_pause
)
{
{
player_lock
(
pc
);
Lock
(
);
pc
->
border_pause
=
border_pause
;
border_pause
=
_
border_pause
;
player_unlock
(
pc
);
Unlock
(
);
}
}
void
player_status
p
c_get_status
(
struct
player_control
*
pc
,
struct
player_status
*
status
)
p
layer_control
::
GetStatus
(
)
{
{
player_lock
(
pc
);
player_status
status
;
player_command_locked
(
pc
,
PLAYER_COMMAND_REFRESH
);
status
->
state
=
pc
->
state
;
Lock
();
player_command_locked
(
this
,
PLAYER_COMMAND_REFRESH
);
if
(
pc
->
state
!=
PLAYER_STATE_STOP
)
{
status
.
state
=
state
;
status
->
bit_rate
=
pc
->
bit_rate
;
status
->
audio_format
=
pc
->
audio_format
;
if
(
state
!=
PLAYER_STATE_STOP
)
{
status
->
total_time
=
pc
->
total_time
;
status
.
bit_rate
=
bit_rate
;
status
->
elapsed_time
=
pc
->
elapsed_time
;
status
.
audio_format
=
audio_format
;
status
.
total_time
=
total_time
;
status
.
elapsed_time
=
elapsed_time
;
}
}
player_unlock
(
pc
);
Unlock
();
return
status
;
}
}
void
void
pc_set_error
(
struct
player_control
*
pc
,
enum
player_error
type
,
player_control
::
SetError
(
player_error
type
,
GError
*
_error
)
GError
*
error
)
{
{
assert
(
pc
!=
NULL
);
assert
(
type
!=
PLAYER_ERROR_NONE
);
assert
(
type
!=
PLAYER_ERROR_NONE
);
assert
(
error
!=
NULL
);
assert
(
_
error
!=
NULL
);
if
(
pc
->
error_type
!=
PLAYER_ERROR_NONE
)
if
(
error_type
!=
PLAYER_ERROR_NONE
)
g_error_free
(
pc
->
error
);
g_error_free
(
error
);
pc
->
error_type
=
type
;
error_type
=
type
;
pc
->
error
=
error
;
error
=
_
error
;
}
}
void
void
p
c_clear_error
(
struct
player_control
*
pc
)
p
layer_control
::
ClearError
(
)
{
{
player_lock
(
pc
);
Lock
(
);
if
(
pc
->
error_type
!=
PLAYER_ERROR_NONE
)
{
if
(
error_type
!=
PLAYER_ERROR_NONE
)
{
pc
->
error_type
=
PLAYER_ERROR_NONE
;
error_type
=
PLAYER_ERROR_NONE
;
g_error_free
(
pc
->
error
);
g_error_free
(
error
);
}
}
player_unlock
(
pc
);
Unlock
(
);
}
}
char
*
char
*
p
c_get_error_message
(
struct
player_control
*
pc
)
p
layer_control
::
GetErrorMessage
()
const
{
{
player_lock
(
pc
);
Lock
(
);
char
*
message
=
pc
->
error_type
!=
PLAYER_ERROR_NONE
char
*
message
=
error_type
!=
PLAYER_ERROR_NONE
?
g_strdup
(
pc
->
error
->
message
)
?
g_strdup
(
error
->
message
)
:
NULL
;
:
NULL
;
player_unlock
(
pc
);
Unlock
(
);
return
message
;
return
message
;
}
}
...
@@ -269,65 +259,59 @@ pc_enqueue_song_locked(struct player_control *pc, struct song *song)
...
@@ -269,65 +259,59 @@ pc_enqueue_song_locked(struct player_control *pc, struct song *song)
}
}
void
void
p
c_enqueue_song
(
struct
player_control
*
pc
,
struct
song
*
song
)
p
layer_control
::
EnqueueSong
(
struct
song
*
song
)
{
{
assert
(
song
!=
NULL
);
assert
(
song
!=
NULL
);
player_lock
(
pc
);
Lock
(
);
pc_enqueue_song_locked
(
pc
,
song
);
pc_enqueue_song_locked
(
this
,
song
);
player_unlock
(
pc
);
Unlock
(
);
}
}
bool
bool
p
c_seek
(
struct
player_control
*
pc
,
struct
song
*
song
,
float
seek_time
)
p
layer_control
::
Seek
(
struct
song
*
song
,
float
seek_time
)
{
{
assert
(
song
!=
NULL
);
assert
(
song
!=
NULL
);
player_lock
(
pc
);
Lock
(
);
if
(
pc
->
next_song
!=
NULL
)
if
(
next_song
!=
nullptr
)
song_free
(
pc
->
next_song
);
song_free
(
next_song
);
pc
->
next_song
=
song
;
next_song
=
song
;
pc
->
seek_where
=
seek_time
;
seek_where
=
seek_time
;
player_command_locked
(
pc
,
PLAYER_COMMAND_SEEK
);
player_command_locked
(
this
,
PLAYER_COMMAND_SEEK
);
player_unlock
(
pc
);
Unlock
(
);
assert
(
pc
->
next_song
==
NULL
);
assert
(
next_song
==
nullptr
);
idle_add
(
IDLE_PLAYER
);
idle_add
(
IDLE_PLAYER
);
return
true
;
return
true
;
}
}
float
pc_get_cross_fade
(
const
struct
player_control
*
pc
)
{
return
pc
->
cross_fade_seconds
;
}
void
void
p
c_set_cross_fade
(
struct
player_control
*
pc
,
float
cross_fade_seconds
)
p
layer_control
::
SetCrossFade
(
float
_
cross_fade_seconds
)
{
{
if
(
cross_fade_seconds
<
0
)
if
(
_
cross_fade_seconds
<
0
)
cross_fade_seconds
=
0
;
_
cross_fade_seconds
=
0
;
pc
->
cross_fade_seconds
=
cross_fade_seconds
;
cross_fade_seconds
=
_
cross_fade_seconds
;
idle_add
(
IDLE_OPTIONS
);
idle_add
(
IDLE_OPTIONS
);
}
}
void
void
p
c_set_mixramp_db
(
struct
player_control
*
pc
,
float
mixramp_db
)
p
layer_control
::
SetMixRampDb
(
float
_
mixramp_db
)
{
{
pc
->
mixramp_db
=
mixramp_db
;
mixramp_db
=
_
mixramp_db
;
idle_add
(
IDLE_OPTIONS
);
idle_add
(
IDLE_OPTIONS
);
}
}
void
void
p
c_set_mixramp_delay
(
struct
player_control
*
pc
,
float
mixramp_delay_seconds
)
p
layer_control
::
SetMixRampDelay
(
float
_
mixramp_delay_seconds
)
{
{
pc
->
mixramp_delay_seconds
=
mixramp_delay_seconds
;
mixramp_delay_seconds
=
_
mixramp_delay_seconds
;
idle_add
(
IDLE_OPTIONS
);
idle_add
(
IDLE_OPTIONS
);
}
}
src/PlayerControl.hxx
View file @
e1b03b4a
...
@@ -101,7 +101,7 @@ struct player_control {
...
@@ -101,7 +101,7 @@ struct player_control {
/**
/**
* This lock protects #command, #state, #error.
* This lock protects #command, #state, #error.
*/
*/
Mutex
mutex
;
mutable
Mutex
mutex
;
/**
/**
* Trigger this object after you have modified #command.
* Trigger this object after you have modified #command.
...
@@ -152,188 +152,142 @@ struct player_control {
...
@@ -152,188 +152,142 @@ struct player_control {
player_control
(
unsigned
buffer_chunks
,
player_control
(
unsigned
buffer_chunks
,
unsigned
buffered_before_play
);
unsigned
buffered_before_play
);
~
player_control
();
~
player_control
();
};
/**
/**
* Locks the #player_control object.
* Locks the object.
*/
*/
static
inline
void
void
Lock
()
const
{
player_lock
(
struct
player_control
*
pc
)
mutex
.
lock
();
{
}
pc
->
mutex
.
lock
();
}
/**
* Unlocks the #player_control object.
*/
static
inline
void
player_unlock
(
struct
player_control
*
pc
)
{
pc
->
mutex
.
unlock
();
}
/**
* Waits for a signal on the #player_control object. This function is
* only valid in the player thread. The object must be locked prior
* to calling this function.
*/
static
inline
void
player_wait
(
struct
player_control
*
pc
)
{
pc
->
cond
.
wait
(
pc
->
mutex
);
}
/**
* Waits for a signal on the #player_control object. This function is
* only valid in the player thread. The #decoder_control object must
* be locked prior to calling this function.
*
* Note the small difference to the player_wait() function!
*/
void
player_wait_decoder
(
struct
player_control
*
pc
,
struct
decoder_control
*
dc
);
/**
/**
* Signals the #player_control object. The object should be locked
* Unlocks the object.
* prior to calling this function.
*/
*/
void
Unlock
()
const
{
static
inline
void
mutex
.
unlock
();
player_signal
(
struct
player_control
*
pc
)
}
{
pc
->
cond
.
signal
();
}
/**
* Signals the #player_control object. The object is temporarily
* locked by this function.
*/
static
inline
void
player_lock_signal
(
struct
player_control
*
pc
)
{
player_lock
(
pc
);
player_signal
(
pc
);
player_unlock
(
pc
);
}
/**
* @param song the song to be queued; the given instance will be owned
* and freed by the player
*/
void
pc_play
(
struct
player_control
*
pc
,
struct
song
*
song
);
/**
/**
* see PLAYER_COMMAND_CANCEL
* Signals the object. The object should be locked prior to
*/
* calling this function.
void
*/
pc_cancel
(
struct
player_control
*
pc
);
void
Signal
()
{
cond
.
signal
();
}
void
/**
pc_set_pause
(
struct
player_control
*
pc
,
bool
pause_flag
);
* Signals the object. The object is temporarily locked by
* this function.
*/
void
LockSignal
()
{
Lock
();
Signal
();
Unlock
();
}
void
/**
pc_pause
(
struct
player_control
*
pc
);
* Waits for a signal on the object. This function is only
* valid in the player thread. The object must be locked
* prior to calling this function.
*/
void
Wait
()
{
cond
.
wait
(
mutex
);
}
/**
/**
* Set the player's #border_pause flag.
* @param song the song to be queued; the given instance will
*/
* be owned and freed by the player
void
*/
pc_set_border_pause
(
struct
player_control
*
pc
,
bool
border_pause
);
void
Play
(
struct
song
*
song
);
void
/**
pc_kill
(
struct
player_control
*
pc
);
* see PLAYER_COMMAND_CANCEL
*/
void
Cancel
();
void
void
SetPause
(
bool
pause_flag
);
pc_get_status
(
struct
player_control
*
pc
,
struct
player_status
*
status
);
static
inline
enum
player_state
void
Pause
();
pc_get_state
(
struct
player_control
*
pc
)
{
return
pc
->
state
;
}
/**
/**
* Set the error. Discards any previous error condition.
* Set the player's #border_pause flag.
*
*/
* Caller must lock the object.
void
SetBorderPause
(
bool
border_pause
);
*
* @param type the error type; must not be #PLAYER_ERROR_NONE
* @param error detailed error information; must not be NULL; the
* #player_control takes over ownership of this #GError instance
*/
void
pc_set_error
(
struct
player_control
*
pc
,
enum
player_error
type
,
GError
*
error
);
void
void
Kill
();
pc_clear_error
(
struct
player_control
*
pc
);
/**
gcc_pure
* Returns the human-readable message describing the last error during
player_status
GetStatus
();
* playback, NULL if no error occurred. The caller has to free the
* returned string.
*/
char
*
pc_get_error_message
(
struct
player_control
*
pc
);
static
inline
enum
player_error
player_state
GetState
()
const
{
pc_get_error_type
(
struct
player_control
*
pc
)
return
state
;
{
}
return
pc
->
error_type
;
}
void
/**
pc_stop
(
struct
player_control
*
pc
);
* Set the error. Discards any previous error condition.
*
* Caller must lock the object.
*
* @param type the error type; must not be #PLAYER_ERROR_NONE
* @param error detailed error information; must not be NULL; the
* #player_control takes over ownership of this #GError instance
*/
void
SetError
(
player_error
type
,
GError
*
error
);
void
void
ClearError
();
pc_update_audio
(
struct
player_control
*
pc
);
/**
/**
* @param song the song to be queued; the given instance will be owned
* Returns the human-readable message describing the last
* and freed by the player
* error during playback, NULL if no error occurred. The
*/
* caller has to free the returned string.
void
*/
pc_enqueue_song
(
struct
player_control
*
pc
,
struct
song
*
song
)
;
char
*
GetErrorMessage
()
const
;
/**
player_error
GetErrorType
()
const
{
* Makes the player thread seek the specified song to a position.
return
error_type
;
*
}
* @param song the song to be queued; the given instance will be owned
* and freed by the player
void
Stop
();
* @return true on success, false on failure (e.g. if MPD isn't
* playing currently)
void
UpdateAudio
();
*/
bool
/**
pc_seek
(
struct
player_control
*
pc
,
struct
song
*
song
,
float
seek_time
);
* @param song the song to be queued; the given instance will be owned
* and freed by the player
void
*/
pc_set_cross_fade
(
struct
player_control
*
pc
,
float
cross_fade_seconds
);
void
EnqueueSong
(
struct
song
*
song
);
float
/**
pc_get_cross_fade
(
const
struct
player_control
*
pc
);
* Makes the player thread seek the specified song to a position.
*
void
* @param song the song to be queued; the given instance will be owned
pc_set_mixramp_db
(
struct
player_control
*
pc
,
float
mixramp_db
);
* and freed by the player
* @return true on success, false on failure (e.g. if MPD isn't
static
inline
float
* playing currently)
pc_get_mixramp_db
(
const
struct
player_control
*
pc
)
*/
{
bool
Seek
(
struct
song
*
song
,
float
seek_time
);
return
pc
->
mixramp_db
;
}
void
SetCrossFade
(
float
cross_fade_seconds
);
void
float
GetCrossFade
()
const
{
pc_set_mixramp_delay
(
struct
player_control
*
pc
,
float
mixramp_delay_seconds
);
return
cross_fade_seconds
;
}
static
inline
float
pc_get_mixramp_delay
(
const
struct
player_control
*
pc
)
void
SetMixRampDb
(
float
mixramp_db
);
{
return
pc
->
mixramp_delay_seconds
;
float
GetMixRampDb
()
const
{
}
return
mixramp_db
;
}
static
inline
double
pc_get_total_play_time
(
const
struct
player_control
*
pc
)
void
SetMixRampDelay
(
float
mixramp_delay_seconds
);
{
return
pc
->
total_play_time
;
float
GetMixRampDelay
()
const
{
}
return
mixramp_delay_seconds
;
}
double
GetTotalPlayTime
()
const
{
return
total_play_time
;
}
};
#endif
#endif
src/PlayerThread.cxx
View file @
e1b03b4a
...
@@ -153,9 +153,9 @@ player_command_finished_locked(struct player_control *pc)
...
@@ -153,9 +153,9 @@ player_command_finished_locked(struct player_control *pc)
static
void
static
void
player_command_finished
(
struct
player_control
*
pc
)
player_command_finished
(
struct
player_control
*
pc
)
{
{
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
player_command_finished_locked
(
pc
);
player_command_finished_locked
(
pc
);
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
}
}
/**
/**
...
@@ -251,13 +251,13 @@ player_wait_for_decoder(struct player *player)
...
@@ -251,13 +251,13 @@ player_wait_for_decoder(struct player *player)
GError
*
error
=
dc_lock_get_error
(
dc
);
GError
*
error
=
dc_lock_get_error
(
dc
);
if
(
error
!=
NULL
)
{
if
(
error
!=
NULL
)
{
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
pc
_set_error
(
pc
,
PLAYER_ERROR_DECODER
,
error
);
pc
->
SetError
(
PLAYER_ERROR_DECODER
,
error
);
song_free
(
pc
->
next_song
);
song_free
(
pc
->
next_song
);
pc
->
next_song
=
NULL
;
pc
->
next_song
=
NULL
;
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
return
false
;
return
false
;
}
}
...
@@ -272,7 +272,7 @@ player_wait_for_decoder(struct player *player)
...
@@ -272,7 +272,7 @@ player_wait_for_decoder(struct player *player)
player_check_decoder_startup() */
player_check_decoder_startup() */
player
->
decoder_starting
=
true
;
player
->
decoder_starting
=
true
;
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
/* update player_control's song information */
/* update player_control's song information */
pc
->
total_time
=
song_get_duration
(
pc
->
next_song
);
pc
->
total_time
=
song_get_duration
(
pc
->
next_song
);
...
@@ -282,7 +282,7 @@ player_wait_for_decoder(struct player *player)
...
@@ -282,7 +282,7 @@ player_wait_for_decoder(struct player *player)
/* clear the queued song */
/* clear the queued song */
pc
->
next_song
=
NULL
;
pc
->
next_song
=
NULL
;
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
/* call syncPlaylistWithQueue() in the main thread */
/* call syncPlaylistWithQueue() in the main thread */
GlobalEvents
::
Emit
(
GlobalEvents
::
PLAYLIST
);
GlobalEvents
::
Emit
(
GlobalEvents
::
PLAYLIST
);
...
@@ -331,9 +331,9 @@ player_open_output(struct player *player)
...
@@ -331,9 +331,9 @@ player_open_output(struct player *player)
player
->
output_open
=
true
;
player
->
output_open
=
true
;
player
->
paused
=
false
;
player
->
paused
=
false
;
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
pc
->
state
=
PLAYER_STATE_PLAY
;
pc
->
state
=
PLAYER_STATE_PLAY
;
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
return
true
;
return
true
;
}
else
{
}
else
{
...
@@ -345,10 +345,10 @@ player_open_output(struct player *player)
...
@@ -345,10 +345,10 @@ player_open_output(struct player *player)
audio output becomes available */
audio output becomes available */
player
->
paused
=
true
;
player
->
paused
=
true
;
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
pc
_set_error
(
pc
,
PLAYER_ERROR_OUTPUT
,
error
);
pc
->
SetError
(
PLAYER_ERROR_OUTPUT
,
error
);
pc
->
state
=
PLAYER_STATE_PAUSE
;
pc
->
state
=
PLAYER_STATE_PAUSE
;
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
return
false
;
return
false
;
}
}
...
@@ -376,9 +376,9 @@ player_check_decoder_startup(struct player *player)
...
@@ -376,9 +376,9 @@ player_check_decoder_startup(struct player *player)
/* the decoder failed */
/* the decoder failed */
decoder_unlock
(
dc
);
decoder_unlock
(
dc
);
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
pc
_set_error
(
pc
,
PLAYER_ERROR_DECODER
,
error
);
pc
->
SetError
(
PLAYER_ERROR_DECODER
,
error
);
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
return
false
;
return
false
;
}
else
if
(
!
decoder_is_starting
(
dc
))
{
}
else
if
(
!
decoder_is_starting
(
dc
))
{
...
@@ -392,10 +392,10 @@ player_check_decoder_startup(struct player *player)
...
@@ -392,10 +392,10 @@ player_check_decoder_startup(struct player *player)
all chunks yet - wait for that */
all chunks yet - wait for that */
return
true
;
return
true
;
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
pc
->
total_time
=
real_song_duration
(
dc
->
song
,
dc
->
total_time
);
pc
->
total_time
=
real_song_duration
(
dc
->
song
,
dc
->
total_time
);
pc
->
audio_format
=
dc
->
in_audio_format
;
pc
->
audio_format
=
dc
->
in_audio_format
;
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
player
->
play_audio_format
=
dc
->
out_audio_format
;
player
->
play_audio_format
=
dc
->
out_audio_format
;
player
->
decoder_starting
=
false
;
player
->
decoder_starting
=
false
;
...
@@ -413,7 +413,7 @@ player_check_decoder_startup(struct player *player)
...
@@ -413,7 +413,7 @@ player_check_decoder_startup(struct player *player)
}
else
{
}
else
{
/* the decoder is not yet ready; wait
/* the decoder is not yet ready; wait
some more */
some more */
player_wait_decoder
(
pc
,
dc
);
dc
->
WaitForDecoder
(
);
decoder_unlock
(
dc
);
decoder_unlock
(
dc
);
return
true
;
return
true
;
...
@@ -565,9 +565,9 @@ static void player_process_command(struct player *player)
...
@@ -565,9 +565,9 @@ static void player_process_command(struct player *player)
break
;
break
;
case
PLAYER_COMMAND_UPDATE_AUDIO
:
case
PLAYER_COMMAND_UPDATE_AUDIO
:
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
audio_output_all_enable_disable
();
audio_output_all_enable_disable
();
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
player_command_finished_locked
(
pc
);
player_command_finished_locked
(
pc
);
break
;
break
;
...
@@ -581,33 +581,33 @@ static void player_process_command(struct player *player)
...
@@ -581,33 +581,33 @@ static void player_process_command(struct player *player)
break
;
break
;
case
PLAYER_COMMAND_PAUSE
:
case
PLAYER_COMMAND_PAUSE
:
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
player
->
paused
=
!
player
->
paused
;
player
->
paused
=
!
player
->
paused
;
if
(
player
->
paused
)
{
if
(
player
->
paused
)
{
audio_output_all_pause
();
audio_output_all_pause
();
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
pc
->
state
=
PLAYER_STATE_PAUSE
;
pc
->
state
=
PLAYER_STATE_PAUSE
;
}
else
if
(
!
audio_format_defined
(
&
player
->
play_audio_format
))
{
}
else
if
(
!
audio_format_defined
(
&
player
->
play_audio_format
))
{
/* the decoder hasn't provided an audio format
/* the decoder hasn't provided an audio format
yet - don't open the audio device yet */
yet - don't open the audio device yet */
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
pc
->
state
=
PLAYER_STATE_PLAY
;
pc
->
state
=
PLAYER_STATE_PLAY
;
}
else
{
}
else
{
player_open_output
(
player
);
player_open_output
(
player
);
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
}
}
player_command_finished_locked
(
pc
);
player_command_finished_locked
(
pc
);
break
;
break
;
case
PLAYER_COMMAND_SEEK
:
case
PLAYER_COMMAND_SEEK
:
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
player_seek_decoder
(
player
);
player_seek_decoder
(
player
);
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
break
;
break
;
case
PLAYER_COMMAND_CANCEL
:
case
PLAYER_COMMAND_CANCEL
:
...
@@ -622,9 +622,9 @@ static void player_process_command(struct player *player)
...
@@ -622,9 +622,9 @@ static void player_process_command(struct player *player)
if
(
player_dc_at_next_song
(
player
))
{
if
(
player_dc_at_next_song
(
player
))
{
/* the decoder is already decoding the song -
/* the decoder is already decoding the song -
stop it and reset the position */
stop it and reset the position */
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
player_dc_stop
(
player
);
player_dc_stop
(
player
);
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
}
}
song_free
(
pc
->
next_song
);
song_free
(
pc
->
next_song
);
...
@@ -635,9 +635,9 @@ static void player_process_command(struct player *player)
...
@@ -635,9 +635,9 @@ static void player_process_command(struct player *player)
case
PLAYER_COMMAND_REFRESH
:
case
PLAYER_COMMAND_REFRESH
:
if
(
player
->
output_open
&&
!
player
->
paused
)
{
if
(
player
->
output_open
&&
!
player
->
paused
)
{
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
audio_output_all_check
();
audio_output_all_check
();
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
}
}
pc
->
elapsed_time
=
audio_output_all_get_elapsed_time
();
pc
->
elapsed_time
=
audio_output_all_get_elapsed_time
();
...
@@ -695,9 +695,9 @@ play_chunk(struct player_control *pc,
...
@@ -695,9 +695,9 @@ play_chunk(struct player_control *pc,
return
true
;
return
true
;
}
}
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
pc
->
bit_rate
=
chunk
->
bit_rate
;
pc
->
bit_rate
=
chunk
->
bit_rate
;
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
/* send the chunk to the audio outputs */
/* send the chunk to the audio outputs */
...
@@ -793,7 +793,7 @@ play_next_chunk(struct player *player)
...
@@ -793,7 +793,7 @@ play_next_chunk(struct player *player)
}
else
{
}
else
{
/* wait for the decoder */
/* wait for the decoder */
decoder_signal
(
dc
);
decoder_signal
(
dc
);
player_wait_decoder
(
pc
,
dc
);
dc
->
WaitForDecoder
(
);
decoder_unlock
(
dc
);
decoder_unlock
(
dc
);
return
true
;
return
true
;
...
@@ -823,16 +823,16 @@ play_next_chunk(struct player *player)
...
@@ -823,16 +823,16 @@ play_next_chunk(struct player *player)
music_buffer_return
(
player_buffer
,
chunk
);
music_buffer_return
(
player_buffer
,
chunk
);
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
pc
_set_error
(
pc
,
PLAYER_ERROR_OUTPUT
,
error
);
pc
->
SetError
(
PLAYER_ERROR_OUTPUT
,
error
);
/* pause: the user may resume playback as soon as an
/* pause: the user may resume playback as soon as an
audio output becomes available */
audio output becomes available */
pc
->
state
=
PLAYER_STATE_PAUSE
;
pc
->
state
=
PLAYER_STATE_PAUSE
;
player
->
paused
=
true
;
player
->
paused
=
true
;
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
return
false
;
return
false
;
}
}
...
@@ -877,14 +877,14 @@ player_song_border(struct player *player)
...
@@ -877,14 +877,14 @@ player_song_border(struct player *player)
return
false
;
return
false
;
struct
player_control
*
const
pc
=
player
->
pc
;
struct
player_control
*
const
pc
=
player
->
pc
;
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
if
(
pc
->
border_pause
)
{
if
(
pc
->
border_pause
)
{
player
->
paused
=
true
;
player
->
paused
=
true
;
pc
->
state
=
PLAYER_STATE_PAUSE
;
pc
->
state
=
PLAYER_STATE_PAUSE
;
}
}
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
return
true
;
return
true
;
}
}
...
@@ -898,7 +898,7 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
...
@@ -898,7 +898,7 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
{
{
player
player
(
pc
,
dc
);
player
player
(
pc
,
dc
);
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
player
.
pipe
=
music_pipe_new
();
player
.
pipe
=
music_pipe_new
();
...
@@ -910,11 +910,11 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
...
@@ -910,11 +910,11 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
player_command_finished
(
pc
);
player_command_finished
(
pc
);
music_pipe_free
(
player
.
pipe
);
music_pipe_free
(
player
.
pipe
);
GlobalEvents
::
Emit
(
GlobalEvents
::
PLAYLIST
);
GlobalEvents
::
Emit
(
GlobalEvents
::
PLAYLIST
);
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
return
;
return
;
}
}
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
pc
->
state
=
PLAYER_STATE_PLAY
;
pc
->
state
=
PLAYER_STATE_PLAY
;
if
(
pc
->
command
==
PLAYER_COMMAND_SEEK
)
if
(
pc
->
command
==
PLAYER_COMMAND_SEEK
)
...
@@ -927,12 +927,12 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
...
@@ -927,12 +927,12 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
if
(
pc
->
command
==
PLAYER_COMMAND_STOP
||
if
(
pc
->
command
==
PLAYER_COMMAND_STOP
||
pc
->
command
==
PLAYER_COMMAND_EXIT
||
pc
->
command
==
PLAYER_COMMAND_EXIT
||
pc
->
command
==
PLAYER_COMMAND_CLOSE_AUDIO
)
{
pc
->
command
==
PLAYER_COMMAND_CLOSE_AUDIO
)
{
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
audio_output_all_cancel
();
audio_output_all_cancel
();
break
;
break
;
}
}
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
if
(
player
.
buffering
)
{
if
(
player
.
buffering
)
{
/* buffering at the start of the song - wait
/* buffering at the start of the song - wait
...
@@ -951,9 +951,9 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
...
@@ -951,9 +951,9 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
decoder_lock
(
dc
);
decoder_lock
(
dc
);
/* XXX race condition: check decoder again */
/* XXX race condition: check decoder again */
player_wait_decoder
(
pc
,
dc
);
dc
->
WaitForDecoder
(
);
decoder_unlock
(
dc
);
decoder_unlock
(
dc
);
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
continue
;
continue
;
}
else
{
}
else
{
/* buffering is complete */
/* buffering is complete */
...
@@ -967,7 +967,7 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
...
@@ -967,7 +967,7 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
if
(
!
player_check_decoder_startup
(
&
player
))
if
(
!
player_check_decoder_startup
(
&
player
))
break
;
break
;
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
continue
;
continue
;
}
}
...
@@ -1020,10 +1020,10 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
...
@@ -1020,10 +1020,10 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
}
}
if
(
player
.
paused
)
{
if
(
player
.
paused
)
{
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
if
(
pc
->
command
==
PLAYER_COMMAND_NONE
)
if
(
pc
->
command
==
PLAYER_COMMAND_NONE
)
p
layer_wait
(
pc
);
p
c
->
Wait
(
);
continue
;
continue
;
}
else
if
(
!
music_pipe_empty
(
player
.
pipe
))
{
}
else
if
(
!
music_pipe_empty
(
player
.
pipe
))
{
/* at least one music chunk is ready - send it
/* at least one music chunk is ready - send it
...
@@ -1060,7 +1060,7 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
...
@@ -1060,7 +1060,7 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
break
;
break
;
}
}
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
}
}
player_dc_stop
(
&
player
);
player_dc_stop
(
&
player
);
...
@@ -1074,7 +1074,7 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
...
@@ -1074,7 +1074,7 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
if
(
player
.
song
!=
NULL
)
if
(
player
.
song
!=
NULL
)
song_free
(
player
.
song
);
song_free
(
player
.
song
);
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
if
(
player
.
queued
)
{
if
(
player
.
queued
)
{
assert
(
pc
->
next_song
!=
NULL
);
assert
(
pc
->
next_song
!=
NULL
);
...
@@ -1084,11 +1084,11 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
...
@@ -1084,11 +1084,11 @@ static void do_play(struct player_control *pc, struct decoder_control *dc)
pc
->
state
=
PLAYER_STATE_STOP
;
pc
->
state
=
PLAYER_STATE_STOP
;
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
GlobalEvents
::
Emit
(
GlobalEvents
::
PLAYLIST
);
GlobalEvents
::
Emit
(
GlobalEvents
::
PLAYLIST
);
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
}
}
static
gpointer
static
gpointer
...
@@ -1101,7 +1101,7 @@ player_task(gpointer arg)
...
@@ -1101,7 +1101,7 @@ player_task(gpointer arg)
player_buffer
=
music_buffer_new
(
pc
->
buffer_chunks
);
player_buffer
=
music_buffer_new
(
pc
->
buffer_chunks
);
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
while
(
1
)
{
while
(
1
)
{
switch
(
pc
->
command
)
{
switch
(
pc
->
command
)
{
...
@@ -1113,9 +1113,9 @@ player_task(gpointer arg)
...
@@ -1113,9 +1113,9 @@ player_task(gpointer arg)
break
;
break
;
case
PLAYER_COMMAND_STOP
:
case
PLAYER_COMMAND_STOP
:
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
audio_output_all_cancel
();
audio_output_all_cancel
();
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
/* fall through */
/* fall through */
...
@@ -1129,11 +1129,11 @@ player_task(gpointer arg)
...
@@ -1129,11 +1129,11 @@ player_task(gpointer arg)
break
;
break
;
case
PLAYER_COMMAND_CLOSE_AUDIO
:
case
PLAYER_COMMAND_CLOSE_AUDIO
:
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
audio_output_all_release
();
audio_output_all_release
();
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
player_command_finished_locked
(
pc
);
player_command_finished_locked
(
pc
);
#ifndef NDEBUG
#ifndef NDEBUG
...
@@ -1147,14 +1147,14 @@ player_task(gpointer arg)
...
@@ -1147,14 +1147,14 @@ player_task(gpointer arg)
break
;
break
;
case
PLAYER_COMMAND_UPDATE_AUDIO
:
case
PLAYER_COMMAND_UPDATE_AUDIO
:
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
audio_output_all_enable_disable
();
audio_output_all_enable_disable
();
p
layer_lock
(
pc
);
p
c
->
Lock
(
);
player_command_finished_locked
(
pc
);
player_command_finished_locked
(
pc
);
break
;
break
;
case
PLAYER_COMMAND_EXIT
:
case
PLAYER_COMMAND_EXIT
:
p
layer_unlock
(
pc
);
p
c
->
Unlock
(
);
dc_quit
(
dc
);
dc_quit
(
dc
);
dc_free
(
dc
);
dc_free
(
dc
);
...
@@ -1179,7 +1179,7 @@ player_task(gpointer arg)
...
@@ -1179,7 +1179,7 @@ player_task(gpointer arg)
break
;
break
;
case
PLAYER_COMMAND_NONE
:
case
PLAYER_COMMAND_NONE
:
p
layer_wait
(
pc
);
p
c
->
Wait
(
);
break
;
break
;
}
}
}
}
...
...
src/Playlist.cxx
View file @
e1b03b4a
...
@@ -69,7 +69,7 @@ playlist_queue_song_order(struct playlist *playlist, struct player_control *pc,
...
@@ -69,7 +69,7 @@ playlist_queue_song_order(struct playlist *playlist, struct player_control *pc,
g_debug
(
"queue song %i:
\"
%s
\"
"
,
playlist
->
queued
,
uri
);
g_debug
(
"queue song %i:
\"
%s
\"
"
,
playlist
->
queued
,
uri
);
g_free
(
uri
);
g_free
(
uri
);
pc
_enqueue_song
(
pc
,
song
);
pc
->
EnqueueSong
(
song
);
}
}
/**
/**
...
@@ -136,7 +136,7 @@ playlist::UpdateQueuedSong(player_control &pc, const song *prev)
...
@@ -136,7 +136,7 @@ playlist::UpdateQueuedSong(player_control &pc, const song *prev)
if
(
prev
!=
NULL
&&
next_song
!=
prev
)
{
if
(
prev
!=
NULL
&&
next_song
!=
prev
)
{
/* clear the currently queued song */
/* clear the currently queued song */
pc
_cancel
(
&
pc
);
pc
.
Cancel
(
);
queued
=
-
1
;
queued
=
-
1
;
}
}
...
@@ -160,7 +160,7 @@ playlist::PlayOrder(player_control &pc, int order)
...
@@ -160,7 +160,7 @@ playlist::PlayOrder(player_control &pc, int order)
g_debug
(
"play %i:
\"
%s
\"
"
,
order
,
uri
);
g_debug
(
"play %i:
\"
%s
\"
"
,
order
,
uri
);
g_free
(
uri
);
g_free
(
uri
);
pc
_play
(
&
pc
,
song
);
pc
.
Play
(
song
);
current
=
order
;
current
=
order
;
}
}
...
@@ -175,10 +175,10 @@ playlist::SyncWithPlayer(player_control &pc)
...
@@ -175,10 +175,10 @@ playlist::SyncWithPlayer(player_control &pc)
playing anymore; ignore the event */
playing anymore; ignore the event */
return
;
return
;
p
layer_lock
(
&
pc
);
p
c
.
Lock
(
);
const
enum
player_state
pc_state
=
pc_get_state
(
&
pc
);
const
player_state
pc_state
=
pc
.
GetState
(
);
const
song
*
pc_next_song
=
pc
.
next_song
;
const
song
*
pc_next_song
=
pc
.
next_song
;
p
layer_unlock
(
&
pc
);
p
c
.
Unlock
(
);
if
(
pc_state
==
PLAYER_STATE_STOP
)
if
(
pc_state
==
PLAYER_STATE_STOP
)
/* the player thread has stopped: check if playback
/* the player thread has stopped: check if playback
...
@@ -192,9 +192,9 @@ playlist::SyncWithPlayer(player_control &pc)
...
@@ -192,9 +192,9 @@ playlist::SyncWithPlayer(player_control &pc)
if
(
pc_next_song
==
nullptr
&&
queued
!=
-
1
)
if
(
pc_next_song
==
nullptr
&&
queued
!=
-
1
)
playlist_song_started
(
this
,
&
pc
);
playlist_song_started
(
this
,
&
pc
);
p
layer_lock
(
&
pc
);
p
c
.
Lock
(
);
pc_next_song
=
pc
.
next_song
;
pc_next_song
=
pc
.
next_song
;
p
layer_unlock
(
&
pc
);
p
c
.
Unlock
(
);
/* make sure the queued song is always set (if
/* make sure the queued song is always set (if
possible) */
possible) */
...
@@ -210,12 +210,10 @@ playlist::SyncWithPlayer(player_control &pc)
...
@@ -210,12 +210,10 @@ playlist::SyncWithPlayer(player_control &pc)
static
void
static
void
playlist_resume_playback
(
struct
playlist
*
playlist
,
struct
player_control
*
pc
)
playlist_resume_playback
(
struct
playlist
*
playlist
,
struct
player_control
*
pc
)
{
{
enum
player_error
error
;
assert
(
playlist
->
playing
);
assert
(
playlist
->
playing
);
assert
(
pc
_get_state
(
pc
)
==
PLAYER_STATE_STOP
);
assert
(
pc
->
GetState
(
)
==
PLAYER_STATE_STOP
);
error
=
pc_get_error_type
(
pc
);
const
auto
error
=
pc
->
GetErrorType
(
);
if
(
error
==
PLAYER_ERROR_NONE
)
if
(
error
==
PLAYER_ERROR_NONE
)
playlist
->
error_count
=
0
;
playlist
->
error_count
=
0
;
else
else
...
@@ -240,7 +238,7 @@ playlist::SetRepeat(player_control &pc, bool status)
...
@@ -240,7 +238,7 @@ playlist::SetRepeat(player_control &pc, bool status)
queue
.
repeat
=
status
;
queue
.
repeat
=
status
;
pc
_set_border_pause
(
&
pc
,
queue
.
single
&&
!
queue
.
repeat
);
pc
.
SetBorderPause
(
queue
.
single
&&
!
queue
.
repeat
);
/* if the last song is currently being played, the "next song"
/* if the last song is currently being played, the "next song"
might change when repeat mode is toggled */
might change when repeat mode is toggled */
...
@@ -267,7 +265,7 @@ playlist::SetSingle(player_control &pc, bool status)
...
@@ -267,7 +265,7 @@ playlist::SetSingle(player_control &pc, bool status)
queue
.
single
=
status
;
queue
.
single
=
status
;
pc
_set_border_pause
(
&
pc
,
queue
.
single
&&
!
queue
.
repeat
);
pc
.
SetBorderPause
(
queue
.
single
&&
!
queue
.
repeat
);
/* if the last song is currently being played, the "next song"
/* if the last song is currently being played, the "next song"
might change when single mode is toggled */
might change when single mode is toggled */
...
...
src/PlaylistControl.cxx
View file @
e1b03b4a
...
@@ -41,7 +41,7 @@ playlist::Stop(player_control &pc)
...
@@ -41,7 +41,7 @@ playlist::Stop(player_control &pc)
assert
(
current
>=
0
);
assert
(
current
>=
0
);
g_debug
(
"stop"
);
g_debug
(
"stop"
);
pc
_stop
(
&
pc
);
pc
.
Stop
(
);
queued
=
-
1
;
queued
=
-
1
;
playing
=
false
;
playing
=
false
;
...
@@ -62,7 +62,7 @@ playlist::Stop(player_control &pc)
...
@@ -62,7 +62,7 @@ playlist::Stop(player_control &pc)
enum
playlist_result
enum
playlist_result
playlist
::
PlayPosition
(
player_control
&
pc
,
int
song
)
playlist
::
PlayPosition
(
player_control
&
pc
,
int
song
)
{
{
pc
_clear_error
(
&
pc
);
pc
.
ClearError
(
);
unsigned
i
=
song
;
unsigned
i
=
song
;
if
(
song
==
-
1
)
{
if
(
song
==
-
1
)
{
...
@@ -74,7 +74,7 @@ playlist::PlayPosition(player_control &pc, int song)
...
@@ -74,7 +74,7 @@ playlist::PlayPosition(player_control &pc, int song)
if
(
playing
)
{
if
(
playing
)
{
/* already playing: unpause playback, just in
/* already playing: unpause playback, just in
case it was paused, and return */
case it was paused, and return */
pc
_set_pause
(
&
pc
,
false
);
pc
.
SetPause
(
false
);
return
PLAYLIST_RESULT_SUCCESS
;
return
PLAYLIST_RESULT_SUCCESS
;
}
}
...
@@ -204,7 +204,7 @@ playlist::SeekSongPosition(player_control &pc, unsigned song, float seek_time)
...
@@ -204,7 +204,7 @@ playlist::SeekSongPosition(player_control &pc, unsigned song, float seek_time)
?
queue
.
PositionToOrder
(
song
)
?
queue
.
PositionToOrder
(
song
)
:
song
;
:
song
;
pc
_clear_error
(
&
pc
);
pc
.
ClearError
(
);
stop_on_error
=
true
;
stop_on_error
=
true
;
error_count
=
0
;
error_count
=
0
;
...
@@ -219,7 +219,7 @@ playlist::SeekSongPosition(player_control &pc, unsigned song, float seek_time)
...
@@ -219,7 +219,7 @@ playlist::SeekSongPosition(player_control &pc, unsigned song, float seek_time)
}
}
struct
song
*
the_song
=
song_dup_detached
(
queue
.
GetOrder
(
i
));
struct
song
*
the_song
=
song_dup_detached
(
queue
.
GetOrder
(
i
));
if
(
!
pc
_seek
(
&
pc
,
the_song
,
seek_time
))
{
if
(
!
pc
.
Seek
(
the_song
,
seek_time
))
{
UpdateQueuedSong
(
pc
,
queued_song
);
UpdateQueuedSong
(
pc
,
queued_song
);
return
PLAYLIST_RESULT_NOT_PLAYING
;
return
PLAYLIST_RESULT_NOT_PLAYING
;
...
@@ -248,8 +248,7 @@ playlist::SeekCurrent(player_control &pc, float seek_time, bool relative)
...
@@ -248,8 +248,7 @@ playlist::SeekCurrent(player_control &pc, float seek_time, bool relative)
return
PLAYLIST_RESULT_NOT_PLAYING
;
return
PLAYLIST_RESULT_NOT_PLAYING
;
if
(
relative
)
{
if
(
relative
)
{
struct
player_status
status
;
const
auto
status
=
pc
.
GetStatus
();
pc_get_status
(
&
pc
,
&
status
);
if
(
status
.
state
!=
PLAYER_STATE_PLAY
&&
if
(
status
.
state
!=
PLAYER_STATE_PLAY
&&
status
.
state
!=
PLAYER_STATE_PAUSE
)
status
.
state
!=
PLAYER_STATE_PAUSE
)
...
...
src/PlaylistEdit.cxx
View file @
e1b03b4a
...
@@ -229,11 +229,11 @@ playlist::DeleteInternal(player_control &pc,
...
@@ -229,11 +229,11 @@ playlist::DeleteInternal(player_control &pc,
unsigned
songOrder
=
queue
.
PositionToOrder
(
song
);
unsigned
songOrder
=
queue
.
PositionToOrder
(
song
);
if
(
playing
&&
current
==
(
int
)
songOrder
)
{
if
(
playing
&&
current
==
(
int
)
songOrder
)
{
bool
paused
=
pc_get_state
(
&
pc
)
==
PLAYER_STATE_PAUSE
;
const
bool
paused
=
pc
.
GetState
(
)
==
PLAYER_STATE_PAUSE
;
/* the current song is going to be deleted: stop the player */
/* the current song is going to be deleted: stop the player */
pc
_stop
(
&
pc
);
pc
.
Stop
(
);
playing
=
false
;
playing
=
false
;
/* see which song is going to be played instead */
/* see which song is going to be played instead */
...
...
src/PlaylistState.cxx
View file @
e1b03b4a
...
@@ -56,9 +56,7 @@ void
...
@@ -56,9 +56,7 @@ void
playlist_state_save
(
FILE
*
fp
,
const
struct
playlist
*
playlist
,
playlist_state_save
(
FILE
*
fp
,
const
struct
playlist
*
playlist
,
struct
player_control
*
pc
)
struct
player_control
*
pc
)
{
{
struct
player_status
player_status
;
const
auto
player_status
=
pc
->
GetStatus
();
pc_get_status
(
pc
,
&
player_status
);
fputs
(
PLAYLIST_STATE_FILE_STATE
,
fp
);
fputs
(
PLAYLIST_STATE_FILE_STATE
,
fp
);
...
@@ -88,11 +86,11 @@ playlist_state_save(FILE *fp, const struct playlist *playlist,
...
@@ -88,11 +86,11 @@ playlist_state_save(FILE *fp, const struct playlist *playlist,
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_get_cross_fade
(
pc
)
));
(
int
)
pc
->
GetCrossFade
(
));
fprintf
(
fp
,
PLAYLIST_STATE_FILE_MIXRAMPDB
"%f
\n
"
,
fprintf
(
fp
,
PLAYLIST_STATE_FILE_MIXRAMPDB
"%f
\n
"
,
pc
_get_mixramp_db
(
pc
));
pc
->
GetMixRampDb
(
));
fprintf
(
fp
,
PLAYLIST_STATE_FILE_MIXRAMPDELAY
"%f
\n
"
,
fprintf
(
fp
,
PLAYLIST_STATE_FILE_MIXRAMPDELAY
"%f
\n
"
,
pc
_get_mixramp_delay
(
pc
));
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
);
...
@@ -156,14 +154,11 @@ playlist_state_restore(const char *line, TextFile &file,
...
@@ -156,14 +154,11 @@ playlist_state_restore(const char *line, TextFile &file,
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_set_cross_fade
(
pc
,
pc
->
SetCrossFade
(
atoi
(
line
+
strlen
(
PLAYLIST_STATE_FILE_CROSSFADE
)));
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_set_mixramp_db
(
pc
,
pc
->
SetMixRampDb
(
atof
(
line
+
strlen
(
PLAYLIST_STATE_FILE_MIXRAMPDB
)));
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_set_mixramp_delay
(
pc
,
pc
->
SetMixRampDelay
(
atof
(
line
+
strlen
(
PLAYLIST_STATE_FILE_MIXRAMPDELAY
)));
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
),
...
@@ -195,7 +190,7 @@ playlist_state_restore(const char *line, TextFile &file,
...
@@ -195,7 +190,7 @@ 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
!=
PLAYER_STATE_STOP
)
if
(
state
!=
PLAYER_STATE_STOP
)
pc
_update_audio
(
pc
);
pc
->
UpdateAudio
(
);
if
(
state
==
PLAYER_STATE_STOP
/* && config_option */
)
if
(
state
==
PLAYER_STATE_STOP
/* && config_option */
)
playlist
->
current
=
current
;
playlist
->
current
=
current
;
...
@@ -205,7 +200,7 @@ playlist_state_restore(const char *line, TextFile &file,
...
@@ -205,7 +200,7 @@ playlist_state_restore(const char *line, TextFile &file,
playlist
->
SeekSongPosition
(
*
pc
,
current
,
seek_time
);
playlist
->
SeekSongPosition
(
*
pc
,
current
,
seek_time
);
if
(
state
==
PLAYER_STATE_PAUSE
)
if
(
state
==
PLAYER_STATE_PAUSE
)
pc
_pause
(
pc
);
pc
->
Pause
(
);
}
}
return
true
;
return
true
;
...
@@ -215,9 +210,7 @@ unsigned
...
@@ -215,9 +210,7 @@ unsigned
playlist_state_get_hash
(
const
struct
playlist
*
playlist
,
playlist_state_get_hash
(
const
struct
playlist
*
playlist
,
struct
player_control
*
pc
)
struct
player_control
*
pc
)
{
{
struct
player_status
player_status
;
const
auto
player_status
=
pc
->
GetStatus
();
pc_get_status
(
pc
,
&
player_status
);
return
playlist
->
queue
.
version
^
return
playlist
->
queue
.
version
^
(
player_status
.
state
!=
PLAYER_STATE_STOP
(
player_status
.
state
!=
PLAYER_STATE_STOP
...
@@ -226,7 +219,7 @@ playlist_state_get_hash(const struct playlist *playlist,
...
@@ -226,7 +219,7 @@ playlist_state_get_hash(const struct playlist *playlist,
(
playlist
->
current
>=
0
(
playlist
->
current
>=
0
?
(
playlist
->
queue
.
OrderToPosition
(
playlist
->
current
)
<<
16
)
?
(
playlist
->
queue
.
OrderToPosition
(
playlist
->
current
)
<<
16
)
:
0
)
^
:
0
)
^
((
int
)
pc
_get_cross_fade
(
pc
)
<<
20
)
^
((
int
)
pc
->
GetCrossFade
(
)
<<
20
)
^
(
player_status
.
state
<<
24
)
^
(
player_status
.
state
<<
24
)
^
(
playlist
->
queue
.
random
<<
27
)
^
(
playlist
->
queue
.
random
<<
27
)
^
(
playlist
->
queue
.
repeat
<<
28
)
^
(
playlist
->
queue
.
repeat
<<
28
)
^
...
...
src/Stats.cxx
View file @
e1b03b4a
...
@@ -79,7 +79,7 @@ stats_print(Client *client)
...
@@ -79,7 +79,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
)(
pc_get_total_play_time
(
client
->
player_control
)
+
0.5
),
(
long
)(
client
->
player_control
->
GetTotalPlayTime
(
)
+
0.5
),
stats
.
song_duration
);
stats
.
song_duration
);
if
(
db_is_simple
())
if
(
db_is_simple
())
...
...
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