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
5223261f
Commit
5223261f
authored
Nov 05, 2010
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player_thread: add helper function player_dc_at_next_song()
Some abstraction for decoder_control.pipe access.
parent
c594afee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
6 deletions
+33
-6
player_thread.c
src/player_thread.c
+33
-6
No files found.
src/player_thread.c
View file @
5223261f
...
@@ -119,6 +119,33 @@ static void player_command_finished(void)
...
@@ -119,6 +119,33 @@ static void player_command_finished(void)
}
}
/**
/**
* Is the decoder still busy on the same song as the player?
*
* Note: this function does not check if the decoder is already
* finished.
*/
static
bool
player_dc_at_current_song
(
const
struct
player
*
player
)
{
assert
(
player
!=
NULL
);
assert
(
player
->
pipe
!=
NULL
);
return
dc
.
pipe
==
player
->
pipe
;
}
/**
* Has the decoder already begun decoding the next song?
*
* Note: this function does not check if the decoder is already
* finished.
*/
static
bool
player_dc_at_next_song
(
const
struct
player
*
player
)
{
return
dc
.
pipe
!=
NULL
&&
!
player_dc_at_current_song
(
player
);
}
/**
* Stop the decoder and clears (and frees) its music pipe.
* Stop the decoder and clears (and frees) its music pipe.
*/
*/
static
void
static
void
...
@@ -364,7 +391,7 @@ static void player_process_command(struct player *player)
...
@@ -364,7 +391,7 @@ static void player_process_command(struct player *player)
case
PLAYER_COMMAND_QUEUE
:
case
PLAYER_COMMAND_QUEUE
:
assert
(
pc
.
next_song
!=
NULL
);
assert
(
pc
.
next_song
!=
NULL
);
assert
(
!
player
->
queued
);
assert
(
!
player
->
queued
);
assert
(
dc
.
pipe
==
NULL
||
dc
.
pipe
==
player
->
pipe
);
assert
(
!
player_dc_at_next_song
(
player
)
);
player
->
queued
=
true
;
player
->
queued
=
true
;
player_command_finished
();
player_command_finished
();
...
@@ -409,7 +436,7 @@ static void player_process_command(struct player *player)
...
@@ -409,7 +436,7 @@ static void player_process_command(struct player *player)
return
;
return
;
}
}
if
(
dc
.
pipe
!=
NULL
&&
dc
.
pipe
!=
player
->
pipe
)
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 */
player_dc_stop
(
player
);
player_dc_stop
(
player
);
...
@@ -505,7 +532,7 @@ play_next_chunk(struct player *player)
...
@@ -505,7 +532,7 @@ play_next_chunk(struct player *player)
return
true
;
return
true
;
if
(
player
->
xfade
==
XFADE_ENABLED
&&
if
(
player
->
xfade
==
XFADE_ENABLED
&&
dc
.
pipe
!=
NULL
&&
dc
.
pipe
!=
player
->
pipe
&&
player_dc_at_next_song
(
player
)
&&
(
cross_fade_position
=
music_pipe_size
(
player
->
pipe
))
(
cross_fade_position
=
music_pipe_size
(
player
->
pipe
))
<=
player
->
cross_fade_chunks
)
{
<=
player
->
cross_fade_chunks
)
{
/* perform cross fade */
/* perform cross fade */
...
@@ -706,14 +733,14 @@ static void do_play(void)
...
@@ -706,14 +733,14 @@ static void do_play(void)
/* the decoder has finished the current song;
/* the decoder has finished the current song;
make it decode the next song */
make it decode the next song */
assert
(
pc
.
next_song
!=
NULL
);
assert
(
pc
.
next_song
!=
NULL
);
assert
(
dc
.
pipe
==
NULL
||
dc
.
pipe
==
player
.
pipe
);
assert
(
!
player_dc_at_next_song
(
&
player
)
);
player
.
queued
=
false
;
player
.
queued
=
false
;
dc
.
pipe
=
music_pipe_new
();
dc
.
pipe
=
music_pipe_new
();
dc_start_async
(
pc
.
next_song
);
dc_start_async
(
pc
.
next_song
);
}
}
if
(
dc
.
pipe
!=
NULL
&&
dc
.
pipe
!=
player
.
pipe
&&
if
(
player_dc_at_next_song
(
&
player
)
&&
player
.
xfade
==
XFADE_UNKNOWN
&&
player
.
xfade
==
XFADE_UNKNOWN
&&
!
decoder_is_starting
())
{
!
decoder_is_starting
())
{
/* enable cross fading in this song? if yes,
/* enable cross fading in this song? if yes,
...
@@ -748,7 +775,7 @@ static void do_play(void)
...
@@ -748,7 +775,7 @@ static void do_play(void)
/* XXX synchronize in a better way */
/* XXX synchronize in a better way */
g_usleep
(
10000
);
g_usleep
(
10000
);
}
else
if
(
dc
.
pipe
!=
NULL
&&
dc
.
pipe
!=
player
.
pipe
)
{
}
else
if
(
player_dc_at_next_song
(
&
player
)
)
{
/* at the beginning of a new song */
/* at the beginning of a new song */
if
(
!
player_song_border
(
&
player
))
if
(
!
player_song_border
(
&
player
))
...
...
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