[pulseaudio-commits] r2400 - in /branches/coling/airtunes/src/modules: module-raop-sink.c rtp/raop_client.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sun May 11 06:35:02 PDT 2008
Author: coling
Date: Sun May 11 15:35:01 2008
New Revision: 2400
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2400&root=pulseaudio&view=rev
Log:
Move the ownership of the encoded data memchunk into the raop_client.
This does not seem to fix the pool full messages so I'll have to try and suss that out.
Modified:
branches/coling/airtunes/src/modules/module-raop-sink.c
branches/coling/airtunes/src/modules/rtp/raop_client.c
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=2400&root=pulseaudio&r1=2399&r2=2400&view=diff
==============================================================================
--- branches/coling/airtunes/src/modules/module-raop-sink.c (original)
+++ branches/coling/airtunes/src/modules/module-raop-sink.c Sun May 11 15:35:01 2008
@@ -1,4 +1,4 @@
-/* $Id$ */
+/* $Id: module-esound-sink.c 2043 2007-11-09 18:25:40Z lennart $ */
/***
This file is part of PulseAudio.
@@ -109,6 +109,7 @@
int64_t offset;
int64_t encoding_overhead;
+ int32_t next_encoding_overhead;
double encoding_ratio;
pa_raop_client *raop;
@@ -224,10 +225,9 @@
if (u->encoded_memchunk.length <= 0) {
/* Encode it */
size_t rl = u->raw_memchunk.length;
- if (u->encoded_memchunk.memblock)
- pa_memblock_unref(u->encoded_memchunk.memblock);
+ u->encoding_overhead += u->next_encoding_overhead;
u->encoded_memchunk = pa_raop_client_encode_sample(u->raop, u->core->mempool, &u->raw_memchunk);
- u->encoding_overhead += (u->encoded_memchunk.length - (rl - u->raw_memchunk.length));
+ 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);
}
pa_assert(u->encoded_memchunk.length > 0);
@@ -258,11 +258,6 @@
u->encoded_memchunk.index += l;
u->encoded_memchunk.length -= l;
-
- if (u->encoded_memchunk.length <= 0) {
- pa_memblock_unref(u->encoded_memchunk.memblock);
- pa_memchunk_reset(&u->encoded_memchunk);
- }
pollfd->revents = 0;
@@ -381,6 +376,7 @@
pa_memchunk_reset(&u->encoded_memchunk);
u->offset = 0;
u->encoding_overhead = 0;
+ u->next_encoding_overhead = 0;
u->encoding_ratio = 1.0;
pa_thread_mq_init(&u->thread_mq, m->core->mainloop);
@@ -477,9 +473,6 @@
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=2400&root=pulseaudio&r1=2399&r2=2400&view=diff
==============================================================================
--- branches/coling/airtunes/src/modules/rtp/raop_client.c (original)
+++ branches/coling/airtunes/src/modules/rtp/raop_client.c Sun May 11 15:35:01 2008
@@ -74,7 +74,7 @@
struct pa_raop_client {
pa_mainloop_api *mainloop;
- const char *host;
+ char *host;
char *sid;
pa_rtsp_client *rtsp;
@@ -93,9 +93,10 @@
void* userdata;
uint8_t *buffer;
+ uint32_t buffer_length;
uint8_t *buffer_index;
uint16_t buffer_count;
- /*pa_memchunk memchunk;*/
+ pa_memchunk memchunk;
};
/**
@@ -356,6 +357,7 @@
c->mainloop = mainloop;
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 */
@@ -386,6 +388,9 @@
{
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);
pa_xfree(c->aes_nv);
@@ -403,9 +408,8 @@
uint8_t *bp, bpos;
uint8_t *ibp, *maxibp;
int size;
- uint8_t *p;
+ uint8_t *b, *p;
uint16_t bsize;
- pa_memchunk rv;
size_t length;
static uint8_t header[] = {
0x24, 0x00, 0x00, 0x00,
@@ -427,13 +431,22 @@
/* Leave 16 bytes extra to allow for the ALAC header which is about 55 bits */
bufmax = length + header_size + 16;
- c->buffer = pa_xrealloc(c->buffer, bufmax);
- memcpy(c->buffer, header, header_size);
- pa_memchunk_reset(&rv);
- rv.memblock = pa_memblock_new_user(mempool, c->buffer, (header_size + length), noop, 1);
+ if (bufmax > c->buffer_length) {
+ if (c->memchunk.memblock)
+ pa_memblock_unref(c->memchunk.memblock);
+
+ c->buffer = pa_xrealloc(c->buffer, bufmax);
+ c->buffer_length = bufmax;
+ pa_log_debug("Creating new memblock");
+ c->memchunk.memblock = pa_memblock_new_user(mempool, c->buffer, bufmax, noop, 0);
+ }
+ c->memchunk.index = 0;
+ c->memchunk.length = 0;
+ b = pa_memblock_acquire(c->memchunk.memblock);
+ memcpy(b, header, header_size);
/* Now write the actual samples */
- bp = c->buffer + header_size;
+ bp = b + header_size;
size = bpos = 0;
bit_writer(&bp,&bpos,&size,1,3); // channel=1, stereo
bit_writer(&bp,&bpos,&size,0,4); // unknown
@@ -462,16 +475,20 @@
raw->length -= 4;
}
pa_memblock_release(raw->memblock);
- rv.length = header_size + size;
+ c->memchunk.length = header_size + size;
/* store the lenght (endian swapped: make this better) */
len = size + header_size - 4;
- *(c->buffer + 2) = len >> 8;
- *(c->buffer + 3) = len & 0xff;
+ *(b + 2) = len >> 8;
+ *(b + 3) = len & 0xff;
/* encrypt our data */
- aes_encrypt(c, (c->buffer + header_size), size);
- return rv;
+ aes_encrypt(c, (b + header_size), size);
+
+ /* We're done with the chunk */
+ pa_memblock_release(c->memchunk.memblock);
+
+ return c->memchunk;
}
More information about the pulseaudio-commits
mailing list