X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fraop_buffer.c;h=866134604264c9c95b290c2f97014783a0fe94fb;hb=590c2b20db01a0568d8f6dab2e25037a069faab5;hp=45a1aeb587b4a3aba99a98cf16459034224510ad;hpb=1b4a582b04fc39d9d4d930acb4d0803bdedfb32e;p=deb_shairplay.git diff --git a/src/lib/raop_buffer.c b/src/lib/raop_buffer.c index 45a1aeb..8661346 100644 --- a/src/lib/raop_buffer.c +++ b/src/lib/raop_buffer.c @@ -1,3 +1,17 @@ +/** + * Copyright (C) 2011-2012 Juho Vähä-Herttua + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + #include #include #include @@ -11,7 +25,7 @@ #include "crypto/crypto.h" #include "alac/alac.h" -#define RAOP_BUFFER_LENGTH 16 +#define RAOP_BUFFER_LENGTH 32 typedef struct { /* Packet available */ @@ -58,20 +72,21 @@ static int get_fmtp_info(ALACSpecificConfig *config, const char *fmtp) { int intarr[12]; + char *original; char *strptr; int i; /* Parse fmtp string to integers */ - strptr = strdup(fmtp); + original = strptr = strdup(fmtp); for (i=0; i<12; i++) { if (strptr == NULL) { - free(strptr); + free(original); return -1; } intarr[i] = atoi(utils_strsep(&strptr, " ")); } - free(strptr); - strptr = NULL; + free(original); + original = strptr = NULL; /* Fill the config struct */ config->frameLength = intarr[1]; @@ -131,7 +146,8 @@ set_decoder_info(alac_file *alac, ALACSpecificConfig *config) } raop_buffer_t * -raop_buffer_init(const char *fmtp, +raop_buffer_init(const char *rtpmap, + const char *fmtp, const unsigned char *aeskey, const unsigned char *aesiv) { @@ -140,6 +156,7 @@ raop_buffer_init(const char *fmtp, ALACSpecificConfig *alacConfig; int i; + assert(rtpmap); assert(fmtp); assert(aeskey); assert(aesiv); @@ -171,7 +188,7 @@ raop_buffer_init(const char *fmtp, raop_buffer_entry_t *entry = &raop_buffer->entries[i]; entry->audio_buffer_size = audio_buffer_size; entry->audio_buffer_len = 0; - entry->audio_buffer = raop_buffer->buffer+i*audio_buffer_size; + entry->audio_buffer = (char *)raop_buffer->buffer+i*audio_buffer_size; } /* Initialize ALAC decoder */ @@ -197,8 +214,8 @@ void raop_buffer_destroy(raop_buffer_t *raop_buffer) { if (raop_buffer) { + destroy_alac(raop_buffer->alac); free(raop_buffer->buffer); - free(raop_buffer->alac); free(raop_buffer); } }