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
63b33b6e
Commit
63b33b6e
authored
Oct 06, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player_thread: move code to player_open_output()
Common function that manages "player" attributes after audio_output_all_open() has returned.
parent
23670795
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
22 deletions
+37
-22
player_thread.c
src/player_thread.c
+37
-22
No files found.
src/player_thread.c
View file @
63b33b6e
...
@@ -277,6 +277,41 @@ real_song_duration(const struct song *song, double decoder_duration)
...
@@ -277,6 +277,41 @@ real_song_duration(const struct song *song, double decoder_duration)
}
}
/**
/**
* Wrapper for audio_output_all_open(). Upon failure, it pauses the
* player.
*
* @return true on success
*/
static
bool
player_open_output
(
struct
player
*
player
)
{
assert
(
audio_format_defined
(
&
player
->
play_audio_format
));
assert
(
pc
.
state
==
PLAYER_STATE_PLAY
||
pc
.
state
==
PLAYER_STATE_PAUSE
);
if
(
audio_output_all_open
(
&
player
->
play_audio_format
,
player_buffer
))
{
player
->
paused
=
false
;
player_lock
();
pc
.
state
=
PLAYER_STATE_PLAY
;
player_unlock
();
return
true
;
}
else
{
/* pause: the user may resume playback as soon as an
audio output becomes available */
player
->
paused
=
true
;
player_lock
();
pc
.
error
=
PLAYER_ERROR_AUDIO
;
pc
.
state
=
PLAYER_STATE_PAUSE
;
player_unlock
();
return
false
;
}
}
/**
* The decoder has acknowledged the "START" command (see
* The decoder has acknowledged the "START" command (see
* player_wait_for_decoder()). This function checks if the decoder
* player_wait_for_decoder()). This function checks if the decoder
* initialization has completed yet.
* initialization has completed yet.
...
@@ -321,23 +356,12 @@ player_check_decoder_startup(struct player *player)
...
@@ -321,23 +356,12 @@ player_check_decoder_startup(struct player *player)
player
->
play_audio_format
=
dc
->
out_audio_format
;
player
->
play_audio_format
=
dc
->
out_audio_format
;
player
->
decoder_starting
=
false
;
player
->
decoder_starting
=
false
;
if
(
!
player
->
paused
&&
if
(
!
player
->
paused
&&
!
player_open_output
(
player
))
{
!
audio_output_all_open
(
&
dc
->
out_audio_format
,
player_buffer
))
{
char
*
uri
=
song_get_uri
(
dc
->
song
);
char
*
uri
=
song_get_uri
(
dc
->
song
);
g_warning
(
"problems opening audio device "
g_warning
(
"problems opening audio device "
"while playing
\"
%s
\"
"
,
uri
);
"while playing
\"
%s
\"
"
,
uri
);
g_free
(
uri
);
g_free
(
uri
);
player_lock
();
pc
.
error
=
PLAYER_ERROR_AUDIO
;
/* pause: the user may resume playback as soon
as an audio output becomes available */
pc
.
state
=
PLAYER_STATE_PAUSE
;
player_unlock
();
player
->
paused
=
true
;
return
true
;
return
true
;
}
}
...
@@ -517,17 +541,8 @@ static void player_process_command(struct player *player)
...
@@ -517,17 +541,8 @@ static void player_process_command(struct player *player)
player_lock
();
player_lock
();
pc
.
state
=
PLAYER_STATE_PLAY
;
pc
.
state
=
PLAYER_STATE_PLAY
;
}
else
if
(
audio_output_all_open
(
&
player
->
play_audio_format
,
player_buffer
))
{
/* unpaused, continue playing */
player_lock
();
pc
.
state
=
PLAYER_STATE_PLAY
;
}
else
{
}
else
{
/* the audio device has failed - rollback to
player_open_output
(
player
);
pause mode */
pc
.
error
=
PLAYER_ERROR_AUDIO
;
player
->
paused
=
true
;
player_lock
();
player_lock
();
}
}
...
...
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