From 40f6ab5064a628dc11b79b5e571dc9444efac093 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 5 May 2011 21:34:17 +0300 Subject: ao_pcm, core: use new API in ao_pcm, change timing with it Change ao_pcm to use the new audio output driver API and clean up some of the code. Rewrite the logic controlling how playback timing works when using -ao pcm. Deprecate the "fast" suboption; its only effect now is to print a warning, but it's still accepted so that specifying it is not an error. Before, timing with -ao pcm and video enabled had two possible modes. In the default mode playback speed was rather arbitrary - not realtime, but not particularly fast. -ao pcm:fast tried to play back at maximum video playback speed - mostly succeeding, but not quite guaranteed to work in all cases. Now the default is to play at realtime speed. The -benchmark option can now be used to get faster playback (same as the video-only case). In the audio-only case playback is always maximum speed. --- mplayer.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index f988d92d1b..af3ad127eb 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2048,7 +2048,7 @@ static int check_framedrop(struct MPContext *mpctx, double frame_time) { struct MPOpts *opts = &mpctx->opts; // check for frame-drop: current_module = "check_framedrop"; - if (mpctx->sh_audio && !mpctx->d_audio->eof) { + if (mpctx->sh_audio && !mpctx->ao->untimed && !mpctx->d_audio->eof) { static int dropped_frames; float delay = opts->playback_speed * ao_get_delay(mpctx->ao); float d = delay-mpctx->delay; @@ -2411,6 +2411,9 @@ static int fill_audio_out_buffers(struct MPContext *mpctx) current_module="play_audio"; + if (ao->untimed && mpctx->sh_video && mpctx->delay > 0) + return 0; + // all the current uses of ao->pts seem to be in aos that handle // sync completely wrong; there should be no need to use ao->pts // in get_space() @@ -3366,7 +3369,7 @@ static void run_playloop(struct MPContext *mpctx) if (mpctx->sh_audio && !mpctx->paused && (!mpctx->restart_playback || !mpctx->sh_video)) { int status = fill_audio_out_buffers(mpctx); - full_audio_buffers = status >= 0; + full_audio_buffers = status >= 0 && !mpctx->ao->untimed; if (status == -2) // at eof, all audio at least written to ao if (!mpctx->sh_video) @@ -3412,7 +3415,9 @@ static void run_playloop(struct MPContext *mpctx) } else if (!mpctx->stop_play) { int sleep_time = 100; if (mpctx->sh_audio) { - if (full_audio_buffers) + if (mpctx->ao->untimed) + sleep_time = 0; + else if (full_audio_buffers) sleep_time = FFMAX(20, a_buf * 1000 - 50); else sleep_time = 20; -- cgit v1.2.3