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
e5857cb7
Commit
e5857cb7
authored
Oct 08, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player_control: no CamelCase
parent
2ec89c63
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
79 additions
and
62 deletions
+79
-62
command.c
src/command.c
+8
-8
main.c
src/main.c
+1
-1
player_control.c
src/player_control.c
+30
-18
player_control.h
src/player_control.h
+24
-15
playlist.c
src/playlist.c
+5
-5
playlist_control.c
src/playlist_control.c
+4
-4
playlist_edit.c
src/playlist_edit.c
+2
-2
playlist_state.c
src/playlist_state.c
+4
-8
stats.c
src/stats.c
+1
-1
No files found.
src/command.c
View file @
e5857cb7
...
...
@@ -440,11 +440,11 @@ handle_pause(struct client *client,
bool
pause_flag
;
if
(
!
check_bool
(
client
,
&
pause_flag
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
playerSetPause
(
pause_flag
);
return
COMMAND_RETURN_OK
;
}
playerPause
();
pc_set_pause
(
pause_flag
);
}
else
pc_pause
();
return
COMMAND_RETURN_OK
;
}
...
...
@@ -489,7 +489,7 @@ handle_status(struct client *client,
playlist_get_consume
(
&
g_playlist
),
playlist_get_version
(
&
g_playlist
),
playlist_get_length
(
&
g_playlist
),
(
int
)(
getPlayerCrossF
ade
()
+
0
.
5
),
(
int
)(
pc_get_cross_f
ade
()
+
0
.
5
),
state
);
song
=
playlist_get_current_song
(
&
g_playlist
);
...
...
@@ -521,7 +521,7 @@ handle_status(struct client *client,
updateJobId
);
}
error
=
getPlayerErrorStr
();
error
=
pc_get_error_message
();
if
(
error
!=
NULL
)
{
client_printf
(
client
,
COMMAND_STATUS_ERROR
": %s
\n
"
,
...
...
@@ -1212,7 +1212,7 @@ static enum command_return
handle_clearerror
(
G_GNUC_UNUSED
struct
client
*
client
,
G_GNUC_UNUSED
int
argc
,
G_GNUC_UNUSED
char
*
argv
[])
{
clearPlayerE
rror
();
pc_clear_e
rror
();
return
COMMAND_RETURN_OK
;
}
...
...
@@ -1403,7 +1403,7 @@ handle_crossfade(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
if
(
!
check_unsigned
(
client
,
&
xfade_time
,
argv
[
1
]))
return
COMMAND_RETURN_ERROR
;
setPlayerCrossF
ade
(
xfade_time
);
pc_set_cross_f
ade
(
xfade_time
);
return
COMMAND_RETURN_OK
;
}
...
...
src/main.c
View file @
e5857cb7
...
...
@@ -386,7 +386,7 @@ int main(int argc, char *argv[])
mpd_inotify_finish
();
state_file_finish
();
p
layerK
ill
();
p
c_k
ill
();
finishZeroconf
();
client_manager_deinit
();
listen_global_finish
();
...
...
src/player_control.c
View file @
e5857cb7
...
...
@@ -68,7 +68,7 @@ static void player_command(enum player_command cmd)
}
void
p
layerP
lay
(
struct
song
*
song
)
p
c_p
lay
(
struct
song
*
song
)
{
assert
(
song
!=
NULL
);
...
...
@@ -86,14 +86,16 @@ void pc_cancel(void)
player_command
(
PLAYER_COMMAND_CANCEL
);
}
void
playerWait
(
void
)
void
pc_stop
(
void
)
{
player_command
(
PLAYER_COMMAND_CLOSE_AUDIO
);
idle_add
(
IDLE_PLAYER
);
}
void
playerKill
(
void
)
void
pc_kill
(
void
)
{
assert
(
pc
.
thread
!=
NULL
);
...
...
@@ -104,7 +106,8 @@ void playerKill(void)
idle_add
(
IDLE_PLAYER
);
}
void
playerPause
(
void
)
void
pc_pause
(
void
)
{
if
(
pc
.
state
!=
PLAYER_STATE_STOP
)
{
player_command
(
PLAYER_COMMAND_PAUSE
);
...
...
@@ -112,7 +115,8 @@ void playerPause(void)
}
}
void
playerSetPause
(
int
pause_flag
)
void
pc_set_pause
(
bool
pause_flag
)
{
switch
(
pc
.
state
)
{
case
PLAYER_STATE_STOP
:
...
...
@@ -120,11 +124,12 @@ void playerSetPause(int pause_flag)
case
PLAYER_STATE_PLAY
:
if
(
pause_flag
)
p
layerP
ause
();
p
c_p
ause
();
break
;
case
PLAYER_STATE_PAUSE
:
if
(
!
pause_flag
)
p
layerP
ause
();
p
c_p
ause
();
break
;
}
}
...
...
@@ -142,18 +147,21 @@ pc_get_status(struct player_status *status)
}
}
enum
player_state
getPlayerState
(
void
)
enum
player_state
pc_get_state
(
void
)
{
return
pc
.
state
;
}
void
clearPlayerError
(
void
)
void
pc_clear_error
(
void
)
{
pc
.
error
=
PLAYER_ERROR_NOERROR
;
pc
.
errored_song
=
NULL
;
}
enum
player_error
getPlayerError
(
void
)
enum
player_error
pc_get_error
(
void
)
{
return
pc
.
error
;
}
...
...
@@ -164,7 +172,8 @@ pc_errored_song_uri(void)
return
song_get_uri
(
pc
.
errored_song
);
}
char
*
getPlayerErrorStr
(
void
)
char
*
pc_get_error_message
(
void
)
{
char
*
error
;
char
*
uri
;
...
...
@@ -203,7 +212,7 @@ char *getPlayerErrorStr(void)
}
void
queueS
ong
(
struct
song
*
song
)
pc_enqueue_s
ong
(
struct
song
*
song
)
{
assert
(
song
!=
NULL
);
assert
(
pc
.
next_song
==
NULL
);
...
...
@@ -231,21 +240,24 @@ pc_seek(struct song *song, float seek_time)
return
true
;
}
float
getPlayerCrossFade
(
void
)
float
pc_get_cross_fade
(
void
)
{
return
pc
.
cross_fade_seconds
;
}
void
setPlayerCrossFade
(
float
crossFadeInSeconds
)
void
pc_set_cross_fade
(
float
cross_fade_seconds
)
{
if
(
cross
FadeInS
econds
<
0
)
cross
FadeInS
econds
=
0
;
pc
.
cross_fade_seconds
=
cross
FadeInS
econds
;
if
(
cross
_fade_s
econds
<
0
)
cross
_fade_s
econds
=
0
;
pc
.
cross_fade_seconds
=
cross
_fade_s
econds
;
idle_add
(
IDLE_OPTIONS
);
}
double
getPlayerTotalPlayTime
(
void
)
double
pc_get_total_play_time
(
void
)
{
return
pc
.
total_play_time
;
}
src/player_control.h
View file @
e5857cb7
...
...
@@ -107,39 +107,47 @@ void
pc_song_deleted
(
const
struct
song
*
song
);
void
p
layerP
lay
(
struct
song
*
song
);
p
c_p
lay
(
struct
song
*
song
);
/**
* see PLAYER_COMMAND_CANCEL
*/
void
pc_cancel
(
void
);
void
playerSetPause
(
int
pause_flag
);
void
pc_set_pause
(
bool
pause_flag
);
void
playerPause
(
void
);
void
pc_pause
(
void
);
void
playerKill
(
void
);
void
pc_kill
(
void
);
void
pc_get_status
(
struct
player_status
*
status
);
enum
player_state
getPlayerState
(
void
);
enum
player_state
pc_get_state
(
void
);
void
clearPlayerError
(
void
);
void
pc_clear_error
(
void
);
/**
* Returns the human-readable message describing the last error during
* playback, NULL if no error occurred. The caller has to free the
* returned string.
*/
char
*
getPlayerErrorStr
(
void
);
char
*
pc_get_error_message
(
void
);
enum
player_error
getPlayerError
(
void
);
enum
player_error
pc_get_error
(
void
);
void
playerWait
(
void
);
void
pc_stop
(
void
);
void
queueS
ong
(
struct
song
*
song
);
pc_enqueue_s
ong
(
struct
song
*
song
);
/**
* Makes the player thread seek the specified song to a position.
...
...
@@ -150,12 +158,13 @@ queueSong(struct song *song);
bool
pc_seek
(
struct
song
*
song
,
float
seek_time
);
void
setPlayerCrossFade
(
float
crossFadeInSeconds
);
float
getPlayerCrossFade
(
void
);
void
pc_set_cross_fade
(
float
cross_fade_seconds
);
double
getPlayerTotalPlayTime
(
void
);
float
pc_get_cross_fade
(
void
);
void
playerInit
(
void
);
double
pc_get_total_play_time
(
void
);
#endif
src/playlist.c
View file @
e5857cb7
...
...
@@ -88,7 +88,7 @@ playlist_queue_song_order(struct playlist *playlist, unsigned order)
g_debug
(
"queue song %i:
\"
%s
\"
"
,
playlist
->
queued
,
uri
);
g_free
(
uri
);
queueS
ong
(
song
);
pc_enqueue_s
ong
(
song
);
}
/**
...
...
@@ -190,7 +190,7 @@ playlist_play_order(struct playlist *playlist, int orderNum)
g_debug
(
"play %i:
\"
%s
\"
"
,
orderNum
,
uri
);
g_free
(
uri
);
p
layerP
lay
(
song
);
p
c_p
lay
(
song
);
playlist
->
current
=
orderNum
;
}
...
...
@@ -209,7 +209,7 @@ playlist_sync(struct playlist *playlist)
playing anymore; ignore the event */
return
;
if
(
getPlayerS
tate
()
==
PLAYER_STATE_STOP
)
if
(
pc_get_s
tate
()
==
PLAYER_STATE_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
...
...
@@ -237,9 +237,9 @@ playlist_resume_playback(struct playlist *playlist)
enum
player_error
error
;
assert
(
playlist
->
playing
);
assert
(
getPlayerS
tate
()
==
PLAYER_STATE_STOP
);
assert
(
pc_get_s
tate
()
==
PLAYER_STATE_STOP
);
error
=
getPlayerE
rror
();
error
=
pc_get_e
rror
();
if
(
error
==
PLAYER_ERROR_NOERROR
)
playlist
->
error_count
=
0
;
else
...
...
src/playlist_control.c
View file @
e5857cb7
...
...
@@ -38,7 +38,7 @@ void playlist_stop(struct playlist *playlist)
assert
(
playlist
->
current
>=
0
);
g_debug
(
"stop"
);
p
layerWait
();
p
c_stop
();
playlist
->
queued
=
-
1
;
playlist
->
playing
=
false
;
...
...
@@ -64,7 +64,7 @@ enum playlist_result playlist_play(struct playlist *playlist, int song)
{
unsigned
i
=
song
;
clearPlayerE
rror
();
pc_clear_e
rror
();
if
(
song
==
-
1
)
{
/* play any song ("current" song, or the first song */
...
...
@@ -75,7 +75,7 @@ enum playlist_result playlist_play(struct playlist *playlist, int song)
if
(
playlist
->
playing
)
{
/* already playing: unpause playback, just in
case it was paused, and return */
p
layerSetPause
(
0
);
p
c_set_pause
(
false
);
return
PLAYLIST_RESULT_SUCCESS
;
}
...
...
@@ -217,7 +217,7 @@ playlist_seek_song(struct playlist *playlist, unsigned song, float seek_time)
else
i
=
song
;
clearPlayerE
rror
();
pc_clear_e
rror
();
playlist
->
stop_on_error
=
true
;
playlist
->
error_count
=
0
;
...
...
src/playlist_edit.c
View file @
e5857cb7
...
...
@@ -219,11 +219,11 @@ playlist_delete_internal(struct playlist *playlist, unsigned song,
songOrder
=
queue_position_to_order
(
&
playlist
->
queue
,
song
);
if
(
playlist
->
playing
&&
playlist
->
current
==
(
int
)
songOrder
)
{
bool
paused
=
getPlayerS
tate
()
==
PLAYER_STATE_PAUSE
;
bool
paused
=
pc_get_s
tate
()
==
PLAYER_STATE_PAUSE
;
/* the current song is going to be deleted: stop the player */
p
layerWait
();
p
c_stop
();
playlist
->
playing
=
false
;
/* see which song is going to be played instead */
...
...
src/playlist_state.c
View file @
e5857cb7
...
...
@@ -88,7 +88,7 @@ playlist_state_save(FILE *fp, const struct playlist *playlist)
fprintf
(
fp
,
"%s%i
\n
"
,
PLAYLIST_STATE_FILE_CONSUME
,
playlist
->
queue
.
consume
);
fprintf
(
fp
,
"%s%i
\n
"
,
PLAYLIST_STATE_FILE_CROSSFADE
,
(
int
)(
getPlayerCrossF
ade
()));
(
int
)(
pc_get_cross_f
ade
()));
fprintf
(
fp
,
"%s
\n
"
,
PLAYLIST_STATE_FILE_PLAYLIST_BEGIN
);
queue_save
(
fp
,
&
playlist
->
queue
);
fprintf
(
fp
,
"%s
\n
"
,
PLAYLIST_STATE_FILE_PLAYLIST_END
);
...
...
@@ -166,11 +166,7 @@ playlist_state_restore(const char *line, FILE *fp, struct playlist *playlist)
}
else
playlist_set_consume
(
playlist
,
false
);
}
else
if
(
g_str_has_prefix
(
buffer
,
PLAYLIST_STATE_FILE_CROSSFADE
))
{
setPlayerCrossFade
(
atoi
(
&
(
buffer
[
strlen
(
PLAYLIST_STATE_FILE_CROSSFADE
)])));
pc_set_cross_fade
(
atoi
(
buffer
+
strlen
(
PLAYLIST_STATE_FILE_CROSSFADE
)));
}
else
if
(
g_str_has_prefix
(
buffer
,
PLAYLIST_STATE_FILE_RANDOM
))
{
random_mode
=
strcmp
(
buffer
+
strlen
(
PLAYLIST_STATE_FILE_RANDOM
),
...
...
@@ -199,7 +195,7 @@ playlist_state_restore(const char *line, FILE *fp, struct playlist *playlist)
playlist_seek_song
(
playlist
,
current
,
seek_time
);
if
(
state
==
PLAYER_STATE_PAUSE
)
p
layerP
ause
();
p
c_p
ause
();
}
return
true
;
...
...
@@ -220,7 +216,7 @@ playlist_state_get_hash(const struct playlist *playlist)
?
(
queue_order_to_position
(
&
playlist
->
queue
,
playlist
->
current
)
<<
16
)
:
0
)
^
((
int
)
getPlayerCrossF
ade
()
<<
20
)
^
((
int
)
pc_get_cross_f
ade
()
<<
20
)
^
(
player_status
.
state
<<
24
)
^
(
playlist
->
queue
.
random
<<
27
)
^
(
playlist
->
queue
.
repeat
<<
28
)
^
...
...
src/stats.c
View file @
e5857cb7
...
...
@@ -113,7 +113,7 @@ int stats_print(struct client *client)
stats
.
album_count
,
stats
.
song_count
,
(
long
)
g_timer_elapsed
(
stats
.
timer
,
NULL
),
(
long
)(
getPlayerTotalPlayT
ime
()
+
0
.
5
),
(
long
)(
pc_get_total_play_t
ime
()
+
0
.
5
),
stats
.
song_duration
,
db_get_mtime
());
return
0
;
...
...
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