[pulseaudio-commits] r2405 - in /branches/coling/airtunes/src/modules: module-raop-sink.c rtp/raop_client.c rtp/raop_client.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sun May 11 08:06:16 PDT 2008


Author: coling
Date: Sun May 11 17:06:14 2008
New Revision: 2405

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2405&root=pulseaudio&view=rev
Log:
Change suggested by Lennart. Do not return a memchunk, instead pass in the pointer.

Modified:
    branches/coling/airtunes/src/modules/module-raop-sink.c
    branches/coling/airtunes/src/modules/rtp/raop_client.c
    branches/coling/airtunes/src/modules/rtp/raop_client.h

Modified: branches/coling/airtunes/src/modules/module-raop-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/coling/airtunes/src/modules/module-raop-sink.c?rev=2405&root=pulseaudio&r1=2404&r2=2405&view=diff
==============================================================================
--- branches/coling/airtunes/src/modules/module-raop-sink.c (original)
+++ branches/coling/airtunes/src/modules/module-raop-sink.c Sun May 11 17:06:14 2008
@@ -226,7 +226,7 @@
                         /* Encode it */
                         size_t rl = u->raw_memchunk.length;
                         u->encoding_overhead += u->next_encoding_overhead;
-                        u->encoded_memchunk = pa_raop_client_encode_sample(u->raop, &u->raw_memchunk);
+                        pa_raop_client_encode_sample(u->raop, &u->raw_memchunk, &u->encoded_memchunk);
                         u->next_encoding_overhead = (u->encoded_memchunk.length - (rl - u->raw_memchunk.length));
                         u->encoding_ratio = u->encoded_memchunk.length / (rl - u->raw_memchunk.length);
                     }
@@ -482,6 +482,9 @@
     if (u->raw_memchunk.memblock)
         pa_memblock_unref(u->raw_memchunk.memblock);
 
+    if (u->encoded_memchunk.memblock)
+        pa_memblock_unref(u->encoded_memchunk.memblock);
+
     if (u->raop)
         pa_raop_client_free(u->raop);
 

Modified: branches/coling/airtunes/src/modules/rtp/raop_client.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/coling/airtunes/src/modules/rtp/raop_client.c?rev=2405&root=pulseaudio&r1=2404&r2=2405&view=diff
==============================================================================
--- branches/coling/airtunes/src/modules/rtp/raop_client.c (original)
+++ branches/coling/airtunes/src/modules/rtp/raop_client.c Sun May 11 17:06:14 2008
@@ -96,10 +96,9 @@
     void* closed_userdata;
 
     uint8_t *buffer;
-    uint32_t buffer_length;
+    size_t buffer_length;
     uint8_t *buffer_index;
     uint16_t buffer_count;
-    pa_memchunk memchunk;
 };
 
 /**
@@ -374,7 +373,6 @@
     c->core = core;
     c->fd = -1;
     c->host = pa_xstrdup(host);
-    pa_memchunk_reset(&c->memchunk);
     c->rtsp = pa_rtsp_client_new("iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
 
     /* Initialise the AES encryption system */
@@ -404,8 +402,6 @@
 {
     pa_assert(c);
 
-    if (c->memchunk.memblock)
-        pa_memblock_unref(c->memchunk.memblock);
     pa_xfree(c->buffer);
     pa_rtsp_client_free(c->rtsp);
     pa_xfree(c->aes_iv);
@@ -418,9 +414,10 @@
 
 static void noop(PA_GCC_UNUSED void* p) {}
 
-pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw)
-{
-    uint16_t len, bufmax;
+int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchunk* encoded)
+{
+    uint16_t len;
+    size_t bufmax;
     uint8_t *bp, bpos;
     uint8_t *ibp, *maxibp;
     int size;
@@ -440,6 +437,7 @@
     pa_assert(raw);
     pa_assert(raw->memblock);
     pa_assert(raw->length > 0);
+    pa_assert(encoded);
 
     /* We have to send 4 byte chunks */
     bsize = (int)(raw->length / 4);
@@ -448,16 +446,16 @@
     /* Leave 16 bytes extra to allow for the ALAC header which is about 55 bits */
     bufmax = length + header_size + 16;
     if (bufmax > c->buffer_length) {
-        if (c->memchunk.memblock)
-            pa_memblock_unref(c->memchunk.memblock);
+        if (encoded->memblock)
+            pa_memblock_unref(encoded->memblock);
 
         c->buffer = pa_xrealloc(c->buffer, bufmax);
         c->buffer_length = bufmax;
-        c->memchunk.memblock = pa_memblock_new_user(c->core->mempool, c->buffer, bufmax, noop, 0);
-    }
-    c->memchunk.index = 0;
-    c->memchunk.length = 0;
-    b = pa_memblock_acquire(c->memchunk.memblock);
+        encoded->memblock = pa_memblock_new_user(c->core->mempool, c->buffer, bufmax, noop, 0);
+    }
+    encoded->index = 0;
+    encoded->length = 0;
+    b = pa_memblock_acquire(encoded->memblock);
     memcpy(b, header, header_size);
 
     /* Now write the actual samples */
@@ -490,7 +488,7 @@
         raw->length -= 4;
     }
     pa_memblock_release(raw->memblock);
-    c->memchunk.length = header_size + size;
+    encoded->length = header_size + size;
 
     /* store the lenght (endian swapped: make this better) */
     len = size + header_size - 4;
@@ -501,9 +499,9 @@
     aes_encrypt(c, (b + header_size), size);
 
     /* We're done with the chunk */
-    pa_memblock_release(c->memchunk.memblock);
-
-    return c->memchunk;
+    pa_memblock_release(encoded->memblock);
+
+    return 0;
 }
 
 

Modified: branches/coling/airtunes/src/modules/rtp/raop_client.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/coling/airtunes/src/modules/rtp/raop_client.h?rev=2405&root=pulseaudio&r1=2404&r2=2405&view=diff
==============================================================================
--- branches/coling/airtunes/src/modules/rtp/raop_client.h (original)
+++ branches/coling/airtunes/src/modules/rtp/raop_client.h Sun May 11 17:06:14 2008
@@ -33,7 +33,7 @@
 pa_raop_client* pa_raop_client_new(pa_core *core, const char* host);
 void pa_raop_client_free(pa_raop_client* c);
 
-pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw);
+int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchunk* encoded);
 
 typedef void (*pa_raop_client_cb_t)(int fd, void *userdata);
 void pa_raop_client_set_callback(pa_raop_client* c, pa_raop_client_cb_t callback, void *userdata);




More information about the pulseaudio-commits mailing list