- /* Audio packets can contain multiple frames, so we may have to call avcodec_decode_audio4
- several times. Make a simple copy so we can alter data and size.
- */
- AVPacket copy_packet = *packet;
-
- while (copy_packet.size > 0) {
- int frame_finished;
- DCPOMATIC_DISABLE_WARNINGS
- int decode_result = avcodec_decode_audio4 (stream->stream(_format_context)->codec, _frame, &frame_finished, ©_packet);
- DCPOMATIC_ENABLE_WARNINGS
- if (decode_result < 0) {
- /* avcodec_decode_audio4 can sometimes return an error even though it has decoded
- some valid data; for example dca_subframe_footer can return AVERROR_INVALIDDATA
- if it overreads the auxiliary data. ffplay carries on if frame_finished is true,
- even in the face of such an error, so I think we should too.
-
- Returning from the method here caused mantis #352.
- */
- LOG_WARNING ("avcodec_decode_audio4 failed (%1)", decode_result);
+ auto context = _codec_context[stream->index(_format_context)];
+ auto frame = audio_frame (stream);