From 9fb7ec8e5cd8ea22b9dcd52f415610c69565d783 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Sun, 4 Apr 2010 12:31:33 +0200 Subject: [PATCH] Make the WAV header optional --- src/httpd.c | 2 +- src/transcode.c | 9 ++++++--- src/transcode.h | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/httpd.c b/src/httpd.c index 3652879c..6d40b016 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -396,7 +396,7 @@ httpd_stream_file(struct evhttp_request *req, int id) stream_cb = stream_chunk_xcode_cb; - st->xcode = transcode_setup(mfi, &st->size); + st->xcode = transcode_setup(mfi, &st->size, 1); if (!st->xcode) { DPRINTF(E_WARN, L_HTTPD, "Transcoding setup failed, aborting streaming\n"); diff --git a/src/transcode.c b/src/transcode.c index 66f2b7fe..221fa56e 100644 --- a/src/transcode.c +++ b/src/transcode.c @@ -76,6 +76,7 @@ struct transcode_ctx { uint64_t samples; /* WAV header */ + int wavhdr; uint8_t header[44]; }; @@ -149,7 +150,7 @@ transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted) processed = 0; - if (ctx->offset == 0) + if (ctx->wavhdr && (ctx->offset == 0)) { evbuffer_add(evbuf, ctx->header, sizeof(ctx->header)); processed += sizeof(ctx->header); @@ -245,7 +246,7 @@ transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted) } struct transcode_ctx * -transcode_setup(struct media_file_info *mfi, off_t *est_size) +transcode_setup(struct media_file_info *mfi, off_t *est_size, int wavhdr) { struct transcode_ctx *ctx; int i; @@ -357,8 +358,10 @@ transcode_setup(struct media_file_info *mfi, off_t *est_size) ctx->duration = mfi->song_length; ctx->samples = mfi->sample_count; + ctx->wavhdr = wavhdr; - make_wav_header(ctx, est_size); + if (wavhdr) + make_wav_header(ctx, est_size); return ctx; diff --git a/src/transcode.h b/src/transcode.h index 23d3891b..f85c1a6a 100644 --- a/src/transcode.h +++ b/src/transcode.h @@ -10,7 +10,7 @@ int transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted); struct transcode_ctx * -transcode_setup(struct media_file_info *mfi, off_t *est_size); +transcode_setup(struct media_file_info *mfi, off_t *est_size, int wavhdr); void transcode_cleanup(struct transcode_ctx *ctx);