[gegl] bin: rework audio timing for video playback
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] bin: rework audio timing for video playback
- Date: Fri, 22 Mar 2019 01:49:05 +0000 (UTC)
commit 6e1fd149ccd7e982aace8fc984ef2654d93fc0cf
Author: Øyvind Kolås <pippin gimp org>
Date: Fri Mar 22 02:35:44 2019 +0100
bin: rework audio timing for video playback
Relying on newly added mrg API mrg_pcm_audio_get_queued_length, after
all UI and cairo drawing is complete for a frame, queue the related PCM
data if this was a video-frame, then wait until 0.25 of the previous
frames PCM data or less is queued before proceeding with flipping/displaying
the current frame.
Video playback works better with mipmap rendering even when no mipmap rendering
is happening due to fewer buffer copies.
bin/ui-core.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/bin/ui-core.c b/bin/ui-core.c
index f9ce4d91a..991111ad0 100644
--- a/bin/ui-core.c
+++ b/bin/ui-core.c
@@ -3996,9 +3996,14 @@ static void iterate_frame (GeState *o)
temp_buf[i*2+1] = audio->data[1][i] * 32767.0 * 0.46;
}
- mrg_pcm_queue (mrg, (void*)&temp_buf[0], sample_count);
- while (mrg_pcm_get_queued (mrg) > sample_count / 2)
- g_usleep (50);
+ mrg_pcm_queue (mrg, (void*)&temp_buf[0], sample_count);
+
+ /* after queing our currently decoded audio frame, we
+ wait until the pcm buffer is nearly ready to play
+ back our content
+ */
+ while (mrg_pcm_get_queued_length (mrg) > (1.0/fps) * 1.25 )
+ g_usleep (100);
}
@@ -4798,10 +4803,6 @@ static void gegl_ui (Mrg *mrg, void *data)
break;
}
- if (o->playing)
- {
- iterate_frame (o);
- }
if (o->show_controls && 0)
{
@@ -5009,6 +5010,15 @@ static void gegl_ui (Mrg *mrg, void *data)
ui_show_bindings (mrg, o);
}
+ /* iterate frame, and queue pcm last - since this might cause
+ waiting with presenting the video frame until the pcm data
+ of the frame is about to be played
+ */
+ if (o->playing)
+ {
+ iterate_frame (o);
+ }
+
}
/***********************************************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]