From 1fbb4b0d5933c41031e19f70335153ad3de118ea Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Fri, 6 May 2016 00:23:07 +0200 Subject: [PATCH] [transcode] Fix problem for file types where ffmpeg decode returns 0 It seems ffmpeg/libav reads a file type like Monkey's audio in large chunks, so that each packet must be passed to the decoder multiple times. The decoder will return 0 until the packet is completed. This change makes forked-daapd able to deal with a return value of 0. --- src/transcode.c | 6 ++---- src/transcode.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/transcode.c b/src/transcode.c index fd378037..776393d8 100644 --- a/src/transcode.c +++ b/src/transcode.c @@ -1559,7 +1559,7 @@ transcode_decode(struct decoded_frame **decoded, struct decode_ctx *ctx) // data pointer is adjusted with an offset if (used < packet.size) { - DPRINTF(E_DBG, L_XCODE, "Decoder did not finish packet, packet will be resumed\n"); + DPRINTF(E_SPAM, L_XCODE, "Decoder did not finish packet, packet will be resumed\n"); ctx->resume_offset += used; ctx->resume = 1; @@ -1568,8 +1568,6 @@ transcode_decode(struct decoded_frame **decoded, struct decode_ctx *ctx) while (!got_frame); // Return the decoded frame and stream index - frame->pts = av_frame_get_best_effort_timestamp(frame); - *decoded = malloc(sizeof(struct decoded_frame)); if (!*decoded) { @@ -1582,7 +1580,7 @@ transcode_decode(struct decoded_frame **decoded, struct decode_ctx *ctx) (*decoded)->frame = frame; (*decoded)->stream_index = stream_index; - return used; + return got_frame; } // Filters and encodes diff --git a/src/transcode.h b/src/transcode.h index 8f9a2fa1..0e1687a6 100644 --- a/src/transcode.h +++ b/src/transcode.h @@ -62,7 +62,7 @@ transcode_decoded_free(struct decoded_frame *decoded); * @out decoded A newly allocated struct with a pointer to the frame and the * stream. Must be freed with transcode_decoded_free(). * @in ctx Decode context - * @return Bytes read if OK, negative if error, 0 if EOF + * @return Positive if OK, negative if error, 0 if EOF */ int transcode_decode(struct decoded_frame **decoded, struct decode_ctx *ctx);