diff mbox

[1/6] pa: allow processing buffer pieces

Message ID 1288195475-3807-2-git-send-email-kraxel@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann Oct. 27, 2010, 4:04 p.m. UTC
Remove some state update dependencies between the pulseaudio worker
threads and main thread.  The worker threads can process the buffer
piecewise now.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 audio/paaudio.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/audio/paaudio.c b/audio/paaudio.c
index ff71dac..f768ca9 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -83,7 +83,7 @@  static void *qpa_thread_out (void *arg)
         }
 
         decr = to_mix = pa->live;
-        rpos = hw->rpos;
+        rpos = pa->rpos;
 
         if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {
             return NULL;
@@ -110,8 +110,8 @@  static void *qpa_thread_out (void *arg)
             return NULL;
         }
 
-        pa->live = 0;
         pa->rpos = rpos;
+        pa->live -= decr;
         pa->decr += decr;
     }
 
@@ -178,7 +178,7 @@  static void *qpa_thread_in (void *arg)
         }
 
         incr = to_grab = pa->dead;
-        wpos = hw->wpos;
+        wpos = pa->wpos;
 
         if (audio_pt_unlock (&pa->pt, AUDIO_FUNC)) {
             return NULL;
@@ -323,6 +323,7 @@  static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as)
     audio_pcm_init_info (&hw->info, &obt_as);
     hw->samples = conf.samples;
     pa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
+    pa->rpos = hw->rpos;
     if (!pa->pcm_buf) {
         dolog ("Could not allocate buffer (%d bytes)\n",
                hw->samples << hw->info.shift);
@@ -377,6 +378,7 @@  static int qpa_init_in (HWVoiceIn *hw, struct audsettings *as)
     audio_pcm_init_info (&hw->info, &obt_as);
     hw->samples = conf.samples;
     pa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
+    pa->wpos = hw->wpos;
     if (!pa->pcm_buf) {
         dolog ("Could not allocate buffer (%d bytes)\n",
                hw->samples << hw->info.shift);