X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Flibzmpeg3%2Faudio%2Faudio.C;h=5d88c169ad88cb443d0587f16db1a1e0d860045a;hp=4a98bbf431c54f2e10b5fe12f55df4b0a99bc60a;hb=83c58d6d78f6bf0d1d1fd4cfba8654906fe6ec29;hpb=120f82197b4bdfdad9a5a666d773b45a8064d049 diff --git a/cinelerra-5.1/libzmpeg3/audio/audio.C b/cinelerra-5.1/libzmpeg3/audio/audio.C index 4a98bbf4..5d88c169 100644 --- a/cinelerra-5.1/libzmpeg3/audio/audio.C +++ b/cinelerra-5.1/libzmpeg3/audio/audio.C @@ -720,9 +720,10 @@ decode_audio(void *output_v, int atyp, int channel, int len) // tell/eof %jd/%d\n", output_position, output_size, aud_pos, end_pos, // demand, demux->tell_byte(), demux->eof()); if( demux->eof() ) break; + int needed_history = len > AUDIO_HISTORY ? len : AUDIO_HISTORY; /* if overflowing, shift audio back */ - if( src->seekable && output_size > AUDIO_HISTORY ) { - int diff = demand + output_size - AUDIO_HISTORY; + if( src->seekable && output_size > needed_history ) { + int diff = demand + output_size - needed_history; shift_audio(diff); } int samples = read_frame(1); @@ -742,7 +743,7 @@ decode_audio(void *output_v, int atyp, int channel, int len) j = track->track_position() - output_position; k = output_size - j; if( k > len ) k = len; - float *out = channel < output_channels ? + float *out = j >= 0 && channel < output_channels ? output[channel] + j : 0; /* transmit data in specified format */