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
a790b645
Commit
a790b645
authored
Mar 10, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player_thread: moved code to player_send_silence()
parent
5dfad1d5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
22 deletions
+39
-22
player_thread.c
src/player_thread.c
+39
-22
No files found.
src/player_thread.c
View file @
a790b645
...
...
@@ -221,6 +221,44 @@ player_check_decoder_startup(struct player *player)
}
}
/**
* Sends a chunk of silence to the audio outputs. This is called when
* there is not enough decoded data in the pipe yet, to prevent
* underruns in the hardware buffers.
*/
static
bool
player_send_silence
(
struct
player
*
player
)
{
struct
music_chunk
*
chunk
;
size_t
frame_size
=
audio_format_frame_size
(
&
player
->
play_audio_format
);
/* this formula ensures that we don't send
partial frames */
unsigned
num_frames
=
sizeof
(
chunk
->
data
)
/
frame_size
;
assert
(
audio_format_defined
(
&
player
->
play_audio_format
));
chunk
=
music_buffer_allocate
(
player_buffer
);
if
(
chunk
==
NULL
)
{
g_warning
(
"Failed to allocate silence buffer"
);
return
false
;
}
#ifndef NDEBUG
chunk
->
audio_format
=
player
->
play_audio_format
;
#endif
chunk
->
length
=
num_frames
*
frame_size
;
memset
(
chunk
->
data
,
0
,
chunk
->
length
);
if
(
!
audio_output_all_play
(
chunk
))
{
music_buffer_return
(
player_buffer
,
chunk
);
return
false
;
}
return
true
;
}
static
bool
player_seek_decoder
(
struct
player
*
player
)
{
double
where
;
...
...
@@ -629,31 +667,10 @@ static void do_play(void)
/* the decoder is too busy and hasn't provided
new PCM data in time: send silence (if the
output pipe is empty) */
struct
music_chunk
*
chunk
;
size_t
frame_size
=
audio_format_frame_size
(
&
player
.
play_audio_format
);
/* this formula ensures that we don't send
partial frames */
unsigned
num_frames
=
CHUNK_SIZE
/
frame_size
;
chunk
=
music_buffer_allocate
(
player_buffer
);
if
(
chunk
==
NULL
)
continue
;
#ifndef NDEBUG
chunk
->
audio_format
=
player
.
play_audio_format
;
#endif
chunk
->
length
=
num_frames
*
frame_size
;
memset
(
chunk
->
data
,
0
,
chunk
->
length
);
/*DEBUG("waiting for decoded audio, play silence\n");*/
if
(
!
audio_output_all_play
(
chunk
))
{
music_buffer_return
(
player_buffer
,
chunk
);
if
(
!
player_send_silence
(
&
player
))
break
;
}
}
}
if
(
player
.
queued
)
{
assert
(
pc
.
next_song
!=
NULL
);
...
...
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