diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-05-27 16:38:28 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-05-27 16:38:28 +0100 |
| commit | 661de111c0dbc968ecb004eca5b26f8400b136f1 (patch) | |
| tree | 3097de840bd9b6acf48bc5cc857371998cb00bff /test/audio_decoder_test.cc | |
| parent | a28f926237c3de58c202843bea7913c276d0cbbc (diff) | |
FFmpegContent does not need audio_length().
Diffstat (limited to 'test/audio_decoder_test.cc')
| -rw-r--r-- | test/audio_decoder_test.cc | 78 |
1 files changed, 40 insertions, 38 deletions
diff --git a/test/audio_decoder_test.cc b/test/audio_decoder_test.cc index 8e570f674..3753ca379 100644 --- a/test/audio_decoder_test.cc +++ b/test/audio_decoder_test.cc @@ -32,44 +32,6 @@ using std::cout; using std::min; using boost::shared_ptr; -class TestAudioDecoder : public AudioDecoder -{ -public: - TestAudioDecoder (shared_ptr<AudioContent> content) - : AudioDecoder (content) - , _position (0) - {} - - bool pass (PassReason) - { - Frame const N = min ( - Frame (2000), - _audio_content->audio_length() - _position - ); - - shared_ptr<AudioBuffers> buffers (new AudioBuffers (_audio_content->audio_channels(), N)); - for (int i = 0; i < _audio_content->audio_channels(); ++i) { - for (int j = 0; j < N; ++j) { - buffers->data(i)[j] = j + _position; - } - } - - audio (buffers, ContentTime::from_frames (_position, _audio_content->resampled_audio_frame_rate ())); - _position += N; - - return N < 2000; - } - - void seek (ContentTime t, bool accurate) - { - AudioDecoder::seek (t, accurate); - _position = t.frames (_audio_content->resampled_audio_frame_rate ()); - } - -private: - Frame _position; -}; - class TestAudioContent : public AudioContent { public: @@ -109,6 +71,46 @@ public: void set_audio_mapping (AudioMapping) {} }; +class TestAudioDecoder : public AudioDecoder +{ +public: + TestAudioDecoder (shared_ptr<TestAudioContent> content) + : AudioDecoder (content) + , _test_audio_content (content) + , _position (0) + {} + + bool pass (PassReason) + { + Frame const N = min ( + Frame (2000), + _test_audio_content->audio_length() - _position + ); + + shared_ptr<AudioBuffers> buffers (new AudioBuffers (_audio_content->audio_channels(), N)); + for (int i = 0; i < _audio_content->audio_channels(); ++i) { + for (int j = 0; j < N; ++j) { + buffers->data(i)[j] = j + _position; + } + } + + audio (buffers, ContentTime::from_frames (_position, _audio_content->resampled_audio_frame_rate ())); + _position += N; + + return N < 2000; + } + + void seek (ContentTime t, bool accurate) + { + AudioDecoder::seek (t, accurate); + _position = t.frames (_audio_content->resampled_audio_frame_rate ()); + } + +private: + boost::shared_ptr<TestAudioContent> _test_audio_content; + Frame _position; +}; + shared_ptr<TestAudioContent> content; shared_ptr<TestAudioDecoder> decoder; |
