summaryrefslogtreecommitdiffstats
path: root/mplayer.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2011-04-07 23:05:16 +0300
committerUoti Urpala <uau@mplayer2.org>2011-04-08 04:05:57 +0300
commitcbeed30ae8346520ca5561dbd3689bae2b5d9add (patch)
tree058c6134afa3fbe8cc56181ec959da9b1a343d7a /mplayer.c
parent52f11f73b1b645290679a460329585ded512d8ca (diff)
downloadmpv-cbeed30ae8346520ca5561dbd3689bae2b5d9add.tar.bz2
mpv-cbeed30ae8346520ca5561dbd3689bae2b5d9add.tar.xz
core: wake up a bit less often for audio-only files
Sleep 100 ms between filling audio output buffers. Also do the sleeping in input read functions to enable immediate wakeups on new input.
Diffstat (limited to 'mplayer.c')
-rw-r--r--mplayer.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/mplayer.c b/mplayer.c
index ec42de4548..072d4152bb 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -2387,23 +2387,11 @@ static int fill_audio_out_buffers(struct MPContext *mpctx)
current_module="play_audio";
- while (1) {
- int sleep_time;
- // all the current uses of ao_data.pts seem to be in aos that handle
- // sync completely wrong; there should be no need to use ao_data.pts
- // in get_space()
- ao_data.pts = ((mpctx->sh_video?mpctx->sh_video->timer:0)+mpctx->delay)*90000.0;
- playsize = mpctx->audio_out->get_space();
- if (mpctx->sh_video || playsize >= ao_data.outburst)
- break;
-
- // handle audio-only case:
- // this is where mplayer sleeps during audio-only playback
- // to avoid 100% CPU use
- sleep_time = (ao_data.outburst - playsize) * 1000 / ao_data.bps;
- if (sleep_time < 10) sleep_time = 10; // limit to 100 wakeups per second
- usec_sleep(sleep_time * 1000);
- }
+ // all the current uses of ao_data.pts seem to be in aos that handle
+ // sync completely wrong; there should be no need to use ao_data.pts
+ // in get_space()
+ ao_data.pts = ((mpctx->sh_video?mpctx->sh_video->timer:0)+mpctx->delay)*90000.0;
+ playsize = mpctx->audio_out->get_space();
// Fill buffer if needed:
current_module="decode_audio";
@@ -3366,10 +3354,14 @@ static void run_playloop(struct MPContext *mpctx)
print_status(mpctx, a_pos, false);
- if (end_at.type == END_AT_TIME && end_at.pos < a_pos)
- mpctx->stop_play = PT_NEXT_ENTRY;
update_subtitles(mpctx, a_pos, mpctx->video_offset, false);
update_osd_msg(mpctx);
+ if (end_at.type == END_AT_TIME && end_at.pos < a_pos) {
+ mpctx->stop_play = AT_END_OF_FILE;
+ } else if (!mpctx->stop_play) {
+ int sleep_time = full_audio_buffers || !mpctx->sh_audio ? 100 : 20;
+ mp_input_get_cmd(mpctx->input, sleep_time, true);
+ }
} else {
/*========================== PLAY VIDEO ============================*/