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
fc6d836a
Commit
fc6d836a
authored
Mar 07, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player_thread: moved code to player_check_decoder_startup()
parent
2ba52784
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
40 deletions
+69
-40
player_thread.c
src/player_thread.c
+69
-40
No files found.
src/player_thread.c
View file @
fc6d836a
...
@@ -78,6 +78,17 @@ struct player {
...
@@ -78,6 +78,17 @@ struct player {
* is cross fading enabled?
* is cross fading enabled?
*/
*/
enum
xfade_state
xfade
;
enum
xfade_state
xfade
;
/**
* The current audio format for the audio outputs.
*/
struct
audio_format
play_audio_format
;
/**
* Coefficient for converting a PCM buffer size into a time
* span.
*/
double
size_to_time
;
};
};
static
void
player_command_finished
(
void
)
static
void
player_command_finished
(
void
)
...
@@ -140,6 +151,54 @@ player_wait_for_decoder(struct player *player)
...
@@ -140,6 +151,54 @@ player_wait_for_decoder(struct player *player)
return
true
;
return
true
;
}
}
static
bool
player_check_decoder_startup
(
struct
player
*
player
)
{
assert
(
player
->
decoder_starting
);
if
(
decoder_has_failed
())
{
/* the decoder failed */
assert
(
dc
.
next_song
==
NULL
||
dc
.
next_song
->
url
!=
NULL
);
pc
.
errored_song
=
dc
.
next_song
;
pc
.
error
=
PLAYER_ERROR_FILE
;
return
false
;
}
else
if
(
!
decoder_is_starting
())
{
/* the decoder is ready and ok */
player
->
decoder_starting
=
false
;
if
(
!
audio_output_all_open
(
&
dc
.
out_audio_format
))
{
char
*
uri
=
song_get_uri
(
dc
.
next_song
);
g_warning
(
"problems opening audio device "
"while playing
\"
%s
\"
"
,
uri
);
g_free
(
uri
);
assert
(
dc
.
next_song
==
NULL
||
dc
.
next_song
->
url
!=
NULL
);
pc
.
errored_song
=
dc
.
next_song
;
pc
.
error
=
PLAYER_ERROR_AUDIO
;
return
false
;
}
if
(
player
->
paused
)
audio_output_all_close
();
pc
.
total_time
=
dc
.
total_time
;
pc
.
audio_format
=
dc
.
in_audio_format
;
player
->
play_audio_format
=
dc
.
out_audio_format
;
player
->
size_to_time
=
audioFormatSizeToTime
(
&
dc
.
out_audio_format
);
return
true
;
}
else
{
/* the decoder is not yet ready; wait
some more */
notify_wait
(
&
pc
.
notify
);
return
true
;
}
}
static
bool
player_seek_decoder
(
struct
player
*
player
)
static
bool
player_seek_decoder
(
struct
player
*
player
)
{
{
double
where
;
double
where
;
...
@@ -311,13 +370,12 @@ static void do_play(void)
...
@@ -311,13 +370,12 @@ static void do_play(void)
.
queued
=
false
,
.
queued
=
false
,
.
song
=
NULL
,
.
song
=
NULL
,
.
xfade
=
XFADE_UNKNOWN
,
.
xfade
=
XFADE_UNKNOWN
,
.
size_to_time
=
0
.
0
,
};
};
unsigned
int
crossFadeChunks
=
0
;
unsigned
int
crossFadeChunks
=
0
;
/** has cross-fading begun? */
/** has cross-fading begun? */
bool
cross_fading
=
false
;
bool
cross_fading
=
false
;
static
const
char
silence
[
CHUNK_SIZE
];
static
const
char
silence
[
CHUNK_SIZE
];
struct
audio_format
play_audio_format
;
double
sizeToTime
=
0
.
0
;
player
.
buffer
=
music_buffer_new
(
pc
.
buffer_chunks
);
player
.
buffer
=
music_buffer_new
(
pc
.
buffer_chunks
);
player
.
pipe
=
music_pipe_new
();
player
.
pipe
=
music_pipe_new
();
...
@@ -359,42 +417,12 @@ static void do_play(void)
...
@@ -359,42 +417,12 @@ static void do_play(void)
}
}
if
(
player
.
decoder_starting
)
{
if
(
player
.
decoder_starting
)
{
if
(
decoder_has_failed
())
{
bool
success
;
/* the decoder failed */
assert
(
dc
.
next_song
==
NULL
||
dc
.
next_song
->
url
!=
NULL
);
pc
.
errored_song
=
dc
.
next_song
;
pc
.
error
=
PLAYER_ERROR_FILE
;
break
;
}
else
if
(
!
decoder_is_starting
())
{
/* the decoder is ready and ok */
player
.
decoder_starting
=
false
;
if
(
!
audio_output_all_open
(
&
dc
.
out_audio_format
))
{
char
*
uri
=
song_get_uri
(
dc
.
next_song
);
g_warning
(
"problems opening audio device "
"while playing
\"
%s
\"
"
,
uri
);
g_free
(
uri
);
assert
(
dc
.
next_song
==
NULL
||
dc
.
next_song
->
url
!=
NULL
);
pc
.
errored_song
=
dc
.
next_song
;
pc
.
error
=
PLAYER_ERROR_AUDIO
;
break
;
}
if
(
player
.
paused
)
audio_output_all_close
();
pc
.
total_time
=
dc
.
total_time
;
success
=
player_check_decoder_startup
(
&
player
);
pc
.
audio_format
=
dc
.
in_audio_format
;
if
(
!
success
)
play_audio_format
=
dc
.
out_audio_format
;
break
;
sizeToTime
=
audioFormatSizeToTime
(
&
dc
.
out_audio_format
);
continue
;
}
else
{
/* the decoder is not yet ready; wait
some more */
notify_wait
(
&
pc
.
notify
);
continue
;
}
}
}
#ifndef NDEBUG
#ifndef NDEBUG
...
@@ -425,7 +453,7 @@ static void do_play(void)
...
@@ -425,7 +453,7 @@ static void do_play(void)
crossFadeChunks
=
crossFadeChunks
=
cross_fade_calc
(
pc
.
cross_fade_seconds
,
dc
.
total_time
,
cross_fade_calc
(
pc
.
cross_fade_seconds
,
dc
.
total_time
,
&
dc
.
out_audio_format
,
&
dc
.
out_audio_format
,
&
play_audio_format
,
&
play
er
.
play
_audio_format
,
music_buffer_size
(
player
.
buffer
)
-
music_buffer_size
(
player
.
buffer
)
-
pc
.
buffered_before_play
);
pc
.
buffered_before_play
);
if
(
crossFadeChunks
>
0
)
{
if
(
crossFadeChunks
>
0
)
{
...
@@ -494,7 +522,8 @@ static void do_play(void)
...
@@ -494,7 +522,8 @@ static void do_play(void)
/* play the current chunk */
/* play the current chunk */
success
=
play_chunk
(
player
.
song
,
chunk
,
success
=
play_chunk
(
player
.
song
,
chunk
,
&
play_audio_format
,
sizeToTime
);
&
player
.
play_audio_format
,
player
.
size_to_time
);
music_buffer_return
(
player
.
buffer
,
chunk
);
music_buffer_return
(
player
.
buffer
,
chunk
);
if
(
!
success
)
if
(
!
success
)
...
@@ -522,7 +551,7 @@ static void do_play(void)
...
@@ -522,7 +551,7 @@ static void do_play(void)
break
;
break
;
}
else
{
}
else
{
size_t
frame_size
=
size_t
frame_size
=
audio_format_frame_size
(
&
play_audio_format
);
audio_format_frame_size
(
&
play
er
.
play
_audio_format
);
/* this formula ensures that we don't send
/* this formula ensures that we don't send
partial frames */
partial frames */
unsigned
num_frames
=
CHUNK_SIZE
/
frame_size
;
unsigned
num_frames
=
CHUNK_SIZE
/
frame_size
;
...
...
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