[gegl/video-rejuvenation: 30/30] ui: tweak low latency audio playback



commit c77d63335755286bc1b766223d4d34815dd3d94c
Author: Øyvind Kolås <pippin gimp org>
Date:   Sat Oct 24 00:16:13 2015 +0200

    ui: tweak low latency audio playback

 bin/mrg-ui.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/bin/mrg-ui.c b/bin/mrg-ui.c
index 37b756c..9081287 100644
--- a/bin/mrg-ui.c
+++ b/bin/mrg-ui.c
@@ -81,8 +81,8 @@ static void sdl_audio_cb(void *udata, Uint8 *stream, int len)
 
 static void sdl_add_audio_sample (int sample_pos, float left, float right)
 {
-   audio_data[audio_len/2 + 0] = left * 32767.0;
-   audio_data[audio_len/2 + 1] = right * 32767.0;
+   audio_data[audio_len/2 + 0] = left * 32767.0 * 0.66;
+   audio_data[audio_len/2 + 1] = right * 32767.0 * 0.66;
    audio_len += 4;
 
    if (audio_len >= AUDIO_BUF_LEN)
@@ -348,7 +348,7 @@ static void open_audio (int frequency)
   spec.freq = frequency;
   spec.format = AUDIO_S16SYS;
   spec.channels = 2;
-  spec.samples = 1024;
+  spec.samples = 127;
   spec.callback = sdl_audio_cb;
   SDL_OpenAudio(&spec, 0);
 
@@ -1018,14 +1018,15 @@ static void gegl_ui (Mrg *mrg, void *data)
                 o->scale,
                  o->render_quality);
 
+  if (o->is_video)
   {
     GeglAudio *audio = NULL;
     gdouble fps;
-    if (o->is_video)
-    {
-      gegl_node_get (o->load, "audio", &audio, "frame-rate", &fps, NULL);
-    if (audio && audio->samples > 0)
+    gegl_node_get (o->load, "audio", &audio, "frame-rate", &fps, NULL);
+    if (audio)
     {
+       if (audio->samples > 0)
+       {
        int i;
        if (!audio_started)
         {
@@ -1041,10 +1042,9 @@ static void gegl_ui (Mrg *mrg, void *data)
        while ( (audio_post / 4.0) / audio->samplerate < (o->frame_no / fps) - 0.05 )
        {
          g_usleep (100); /* sync audio */
+       } 
        }
-
-    g_object_unref (audio);
-    }
+       g_object_unref (audio);
     }
   }
   


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]