Make the WAV header optional

This commit is contained in:
Julien BLACHE 2010-04-04 12:31:33 +02:00
parent e3fb8f00cf
commit 9fb7ec8e5c
3 changed files with 8 additions and 5 deletions

View File

@ -396,7 +396,7 @@ httpd_stream_file(struct evhttp_request *req, int id)
stream_cb = stream_chunk_xcode_cb; stream_cb = stream_chunk_xcode_cb;
st->xcode = transcode_setup(mfi, &st->size); st->xcode = transcode_setup(mfi, &st->size, 1);
if (!st->xcode) if (!st->xcode)
{ {
DPRINTF(E_WARN, L_HTTPD, "Transcoding setup failed, aborting streaming\n"); DPRINTF(E_WARN, L_HTTPD, "Transcoding setup failed, aborting streaming\n");

View File

@ -76,6 +76,7 @@ struct transcode_ctx {
uint64_t samples; uint64_t samples;
/* WAV header */ /* WAV header */
int wavhdr;
uint8_t header[44]; uint8_t header[44];
}; };
@ -149,7 +150,7 @@ transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted)
processed = 0; processed = 0;
if (ctx->offset == 0) if (ctx->wavhdr && (ctx->offset == 0))
{ {
evbuffer_add(evbuf, ctx->header, sizeof(ctx->header)); evbuffer_add(evbuf, ctx->header, sizeof(ctx->header));
processed += sizeof(ctx->header); processed += sizeof(ctx->header);
@ -245,7 +246,7 @@ transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted)
} }
struct transcode_ctx * 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; struct transcode_ctx *ctx;
int i; int i;
@ -357,8 +358,10 @@ transcode_setup(struct media_file_info *mfi, off_t *est_size)
ctx->duration = mfi->song_length; ctx->duration = mfi->song_length;
ctx->samples = mfi->sample_count; ctx->samples = mfi->sample_count;
ctx->wavhdr = wavhdr;
make_wav_header(ctx, est_size); if (wavhdr)
make_wav_header(ctx, est_size);
return ctx; return ctx;

View File

@ -10,7 +10,7 @@ int
transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted); transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted);
struct transcode_ctx * 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 void
transcode_cleanup(struct transcode_ctx *ctx); transcode_cleanup(struct transcode_ctx *ctx);