- /* Give this data provided there is some, and its time is sane */
- if (ct >= ContentTime() && data->frames() > 0) {
- audio->emit (film(), *stream, data, ct);
- }
+
+void
+FFmpegDecoder::decode_and_process_audio_packet (AVPacket* packet)
+{
+ auto stream = audio_stream_from_index (packet->stream_index);
+ if (!stream) {
+ return;
+ }
+
+ auto context = _codec_context[stream->index(_format_context)];
+ auto frame = audio_frame (stream);
+
+ int r = avcodec_send_packet (context, packet);
+ if (r < 0) {
+ LOG_WARNING("avcodec_send_packet returned %1 for an audio packet", r);
+ }
+ while (r >= 0) {
+ r = avcodec_receive_frame (context, frame);
+ if (r == AVERROR(EAGAIN)) {
+ /* More input is required */
+ return;