diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-07-26 23:58:14 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-07-26 23:58:14 +0100 |
| commit | 010610c56198b913eca0f25d44f0e1c58e158b72 (patch) | |
| tree | 9c9bcf3b082fa87bbd56a8a6db900c2325d08f69 /src/lib/decoder.cc | |
| parent | 4928ece9b10df775ab3003c024f52bdd30d8f591 (diff) | |
Fix up resampling, possibly.
Diffstat (limited to 'src/lib/decoder.cc')
| -rw-r--r-- | src/lib/decoder.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index efa37672b..5f9ce6d7b 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -247,18 +247,22 @@ Decoder::process_audio (uint8_t* data, int channels, int size) } } + uint8_t* out_buffer = 0; + if (_swr_context) { - uint8_t const * in[1] = { - data + uint8_t const * in[2] = { + data, + 0 }; int const out_buffer_size_frames = ceil (frames * float (dcp_audio_sample_rate (_fs->audio_sample_rate)) / _fs->audio_sample_rate) + 32; int const out_buffer_size_bytes = out_buffer_size_frames * channels * 2; - uint8_t out_buffer[out_buffer_size_bytes]; + out_buffer = new uint8_t[out_buffer_size_bytes]; - uint8_t* out[1] = { - out_buffer + uint8_t* out[2] = { + out_buffer, + 0 }; int out_frames = swr_convert (_swr_context, out, out_buffer_size_frames, in, frames); @@ -266,6 +270,7 @@ Decoder::process_audio (uint8_t* data, int channels, int size) throw DecodeError ("could not run sample-rate converter"); } + data = out_buffer; size = out_frames * channels * 2; } @@ -276,6 +281,8 @@ Decoder::process_audio (uint8_t* data, int channels, int size) int available = _delay_line->feed (data, size); Audio (data, available); + + delete[] out_buffer; } /** Called by subclasses to tell the world that some video data is ready. |
