Move the encoding loop around a bit such that it does not grab the data and keep...
authorColin Guthrie <pulse@colin.guthr.ie>
Mon, 26 May 2008 21:04:45 +0000 (21:04 +0000)
committerColin Guthrie <pulse@colin.guthr.ie>
Wed, 8 Oct 2008 19:32:08 +0000 (20:32 +0100)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2481 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/modules/module-raop-sink.c

index 79c517a..e17198c 100644 (file)
@@ -216,17 +216,19 @@ static void thread_func(void *userdata) {
                     ssize_t l;
                     void *p;
 
-                    if (u->raw_memchunk.length <= 0) {
-                        if (u->raw_memchunk.memblock)
-                            pa_memblock_unref(u->raw_memchunk.memblock);
-                        pa_memchunk_reset(&u->raw_memchunk);
-
-                        /* Grab unencoded data */
-                        pa_sink_render(u->sink, u->block_size, &u->raw_memchunk);
-                    }
-                    pa_assert(u->raw_memchunk.length > 0);
-
                     if (u->encoded_memchunk.length <= 0) {
+                        if (u->raw_memchunk.length <= 0) {
+                            if (u->raw_memchunk.memblock)
+                                pa_memblock_unref(u->raw_memchunk.memblock);
+                            pa_memchunk_reset(&u->raw_memchunk);
+
+                            /* Grab unencoded data */
+                            pa_sink_render(u->sink, u->block_size, &u->raw_memchunk);
+                            p = pa_memblock_acquire(u->raw_memchunk.memblock);
+                            pa_memblock_release(u->raw_memchunk.memblock);
+                        }
+                        pa_assert(u->raw_memchunk.length > 0);
+
                         /* Encode it */
                         size_t rl = u->raw_memchunk.length;
                         u->encoding_overhead += u->next_encoding_overhead;