fix retarded breakage in previous commit.

Originally committed to SVN as r2304.
This commit is contained in:
Karl Blomster 2008-08-14 23:49:11 +00:00
parent d1c62c1324
commit bf931df635
2 changed files with 11 additions and 8 deletions

View file

@ -152,11 +152,8 @@ LAVCAudioProvider::LAVCAudioProvider(Aegisub::String _filename)
if (!buffer)
throw _T("ffmpeg audio provider: Failed to allocate audio decoding buffer, out of memory?");
overshoot_buffer = (int16_t *)malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
if (!overshoot_buffer)
throw _T("ffmpeg audio provider: Failed to allocate audio decoding buffer, out of memory?");
leftover_samples = 0;
leftover_samples = 0;
last_output_sample = -1;
} catch (...) {
Destroy();
@ -174,8 +171,6 @@ void LAVCAudioProvider::Destroy()
{
if (buffer)
free(buffer);
if (overshoot_buffer)
free(overshoot_buffer);
if (rsct)
audio_resample_close(rsct);
if (codecContext)
@ -188,6 +183,12 @@ void LAVCAudioProvider::GetAudio(void *buf, int64_t start, int64_t count)
{
int16_t *_buf = (int16_t *)buf;
/* this exception disabled for now */
/* if (last_output_sample != start-1)
throw _T("ffmpeg audio provider: nonlinear access attempted, try loading audio to RAM or HD cache"); */
last_output_sample += count;
int64_t samples_to_decode = (num_samples - start) * channels; /* samples left to the end of the stream */
if (count < samples_to_decode) /* haven't reached the end yet, so just decode the requested number of samples */
samples_to_decode = count * channels; /* times the number of channels */
@ -284,7 +285,7 @@ void LAVCAudioProvider::GetAudio(void *buf, int64_t start, int64_t count)
}
}
samples_to_decode -= decoded_samples;
samples_to_decode -= decoded_samples;
}
}

View file

@ -76,6 +76,8 @@ private:
int16_t *buffer;
int16_t *overshoot_buffer;
int64_t last_output_sample;
int leftover_samples;
void Destroy();