[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.
This commit is contained in:
ejurgensen 2016-05-06 00:23:07 +02:00
parent 9a56044c77
commit 1fbb4b0d59
2 changed files with 3 additions and 5 deletions

View File

@ -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

View File

@ -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);