diff options
author | kylep@chromium.org <kylep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 21:04:44 +0000 |
---|---|---|
committer | kylep@chromium.org <kylep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-10 21:04:44 +0000 |
commit | 4cdbad1fd0f03fc0db25955acacab5e0d9e8f5c4 (patch) | |
tree | 9e4fae5c2e250c1c31ce78c17eedd73b08588f75 /media/tools | |
parent | 78f69a4f9f08d5e983639d5648386cfe0657110e (diff) | |
download | chromium_src-4cdbad1fd0f03fc0db25955acacab5e0d9e8f5c4.zip chromium_src-4cdbad1fd0f03fc0db25955acacab5e0d9e8f5c4.tar.gz chromium_src-4cdbad1fd0f03fc0db25955acacab5e0d9e8f5c4.tar.bz2 |
Modify OLA to use window size in seconds instead of bytes.
BUG=16011
TEST=none
Review URL: http://codereview.chromium.org/157001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20416 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/tools')
-rw-r--r-- | media/tools/wav_ola_test.cc | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/media/tools/wav_ola_test.cc b/media/tools/wav_ola_test.cc index 9676861..5835bf2 100644 --- a/media/tools/wav_ola_test.cc +++ b/media/tools/wav_ola_test.cc @@ -23,7 +23,7 @@ using file_util::ScopedFILE; using media::AudioRendererAlgorithmOLA; using media::DataBuffer; -const size_t kDefaultWindowSize = 4096; +const double kDefaultWindowLength = 0.08; struct WavHeader { int32 riff; @@ -42,15 +42,16 @@ struct WavHeader { // Dummy class to feed data to OLA algorithm. Necessary to create callback. class Dummy { public: - Dummy(FILE* in, AudioRendererAlgorithmOLA* ola) + Dummy(FILE* in, AudioRendererAlgorithmOLA* ola, size_t window_size) : input_(in), - ola_(ola) { + ola_(ola), + window_size_(window_size) { } void ReadDataForAlg() { scoped_refptr<DataBuffer> b(new DataBuffer()); - uint8* buf = b->GetWritableData(kDefaultWindowSize); - if (fread(buf, 1, kDefaultWindowSize, input_) > 0) { + uint8* buf = b->GetWritableData(window_size_); + if (fread(buf, 1, window_size_, input_) > 0) { ola_->EnqueueBuffer(b.get()); } } @@ -58,6 +59,7 @@ class Dummy { private: FILE* input_; AudioRendererAlgorithmOLA* ola_; + size_t window_size_; DISALLOW_COPY_AND_ASSIGN(Dummy); }; @@ -104,11 +106,17 @@ int main(int argc, const char** argv) { return 1; } + size_t window_size = static_cast<size_t>(wav.sample_rate + * (wav.bit_rate / 8) + * wav.channels + * kDefaultWindowLength); + // Instantiate dummy class and callback to feed data to |ola|. - Dummy guy(input.get(), &ola); + Dummy guy(input.get(), &ola, window_size); AudioRendererAlgorithmOLA::RequestReadCallback* cb = NewCallback(&guy, &Dummy::ReadDataForAlg); ola.Initialize(wav.channels, + wav.sample_rate, wav.bit_rate, static_cast<float>(playback_rate), cb); @@ -129,7 +137,7 @@ int main(int argc, const char** argv) { // Create buffer to be filled by |ola|. scoped_refptr<DataBuffer> buffer(new DataBuffer()); - uint8* buf = buffer->GetWritableData(kDefaultWindowSize); + uint8* buf = buffer->GetWritableData(window_size); // Keep track of bytes written to disk and bytes copied to |b|. size_t bytes_written = 0; |