summaryrefslogtreecommitdiffstats
path: root/audio/decode/dec_audio.c
diff options
context:
space:
mode:
Diffstat (limited to 'audio/decode/dec_audio.c')
-rw-r--r--audio/decode/dec_audio.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index 5eca89b1e2..cd83cfd55e 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -202,7 +202,7 @@ static bool is_new_segment(struct dec_audio *da, struct demux_packet *p)
(p->start != da->start || p->end != da->end || p->codec != da->codec);
}
-void audio_work(struct dec_audio *da)
+static void feed_packet(struct dec_audio *da)
{
if (da->current_frame || !da->ad_driver)
return;
@@ -228,6 +228,14 @@ void audio_work(struct dec_audio *da)
da->packet = NULL;
}
+ da->current_state = DATA_AGAIN;
+}
+
+static void read_frame(struct dec_audio *da)
+{
+ if (da->current_frame || !da->ad_driver)
+ return;
+
bool progress = da->ad_driver->receive_frame(da, &da->current_frame);
da->current_state = da->current_frame ? DATA_OK : DATA_AGAIN;
@@ -271,6 +279,15 @@ void audio_work(struct dec_audio *da)
}
}
+void audio_work(struct dec_audio *da)
+{
+ read_frame(da);
+ if (!da->current_frame) {
+ feed_packet(da);
+ read_frame(da); // retry, to avoid redundant iterations
+ }
+}
+
// Fetch an audio frame decoded with audio_work(). Returns one of:
// DATA_OK: *out_frame is set to a new image
// DATA_WAIT: waiting for demuxer; will receive a wakeup signal