Skip to content

Commit

Permalink
audio: make sure we don't read a frame from a finished stream
Browse files Browse the repository at this point in the history
  • Loading branch information
fmang committed Aug 7, 2017
1 parent bc4df8e commit 5f2d493
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ static void fill_audio(struct oshu_audio *audio, Uint8 *buffer, int len)
int sample_size = av_get_bytes_per_sample(frame->format);
int planar = av_sample_fmt_is_planar(frame->format);
while (len > 0 && !audio->finished) {
if (audio->sample_index >= frame->nb_samples)
next_frame(audio);
if (planar) {
while (len > 0 && audio->sample_index < frame->nb_samples) {
/* Copy 1 sample per iteration. */
Expand All @@ -256,6 +254,8 @@ static void fill_audio(struct oshu_audio *audio, Uint8 *buffer, int len)
len -= block;
audio->sample_index += block / (sample_size * frame->channels);
}
if (audio->sample_index >= frame->nb_samples)
next_frame(audio);
}
assert (len >= 0);
memset(buffer, len, audio->device_spec.silence);
Expand Down

0 comments on commit 5f2d493

Please sign in to comment.