This commit is contained in:
James Laird
2013-04-01 21:44:58 +11:00
parent efe7d2c63c
commit b509a644d0
3 changed files with 11 additions and 8 deletions
+3 -5
View File
@@ -11,7 +11,7 @@
shairport_cfg config;
int debuglev = 1;
int debuglev = 0;
void die(char *format, ...) {
fprintf(stderr, "FATAL: ");
@@ -42,7 +42,6 @@ void debug(char *format, ...) {
char *base64_enc(uint8_t *input, int length) {
int ret;
BIO *bmem, *b64;
BUF_MEM *bptr;
b64 = BIO_new(BIO_f_base64());
@@ -50,7 +49,7 @@ char *base64_enc(uint8_t *input, int length) {
b64 = BIO_push(b64, bmem);
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
BIO_write(b64, input, length);
ret = BIO_flush(b64);
BIO_flush(b64);
BIO_get_mem_ptr(b64, &bptr);
char *buf = (char *)malloc(bptr->length);
@@ -65,7 +64,6 @@ char *base64_enc(uint8_t *input, int length) {
}
uint8_t *base64_dec(char *input, int *outlen) {
int ret;
BIO *bmem, *b64;
int inlen = strlen(input);
@@ -78,7 +76,7 @@ uint8_t *base64_dec(char *input, int *outlen) {
BIO_write(bmem, input, inlen);
while (inlen++ & 3)
BIO_write(bmem, "=", 1);
ret = BIO_flush(bmem);
BIO_flush(bmem);
int bufsize = strlen(input)*3/4 + 1;
uint8_t *buf = malloc(bufsize);
+1
View File
@@ -15,6 +15,7 @@ typedef struct {
int buffer_start_fill;
} shairport_cfg;
extern int debuglev;
void die(char *format, ...);
void warn(char *format, ...);
void debug(char *format, ...);
+7 -3
View File
@@ -51,7 +51,6 @@ static pthread_mutex_t vol_mutex = PTHREAD_MUTEX_INITIALIZER;
// default buffer size
// needs to be a power of 2 because of the way BUFIDX(seqno) works
#define BUFFER_FRAMES 512
#define START_FILL 250
#define MAX_PACKET 2048
typedef struct audio_buffer_entry { // decoded audio packets
@@ -321,10 +320,10 @@ static short *buffer_get_frame(void) {
buf_fill = ab_write - ab_read;
bf_est_update(buf_fill);
// check if t+16, t+32, t+64, t+128, ... (START_FILL / 2)
// check if t+16, t+32, t+64, t+128, ... (buffer_start_fill / 2)
// packets have arrived... last-chance resend
if (!ab_buffering) {
for (i = 16; i < (START_FILL / 2); i = (i * 2)) {
for (i = 16; i < (config.buffer_start_fill / 2); i = (i * 2)) {
next = ab_read + i;
abuf = audio_buffer + BUFIDX(next);
if (!abuf->ready) {
@@ -456,8 +455,13 @@ void player_flush(void) {
}
int player_play(stream_cfg *stream) {
if (config.buffer_start_fill > BUFFER_FRAMES)
die("specified buffer starting fill %d > buffer size %d\n",
config.buffer_start_fill, BUFFER_FRAMES);
AES_set_decrypt_key(stream->aeskey, 128, &aes);
aesiv = stream->aesiv;
// XXX these leak memory
init_decoder(stream->fmtp);
init_buffer();
#ifdef FANCY_RESAMPLING