Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(441)

Unified Diff: media/tools/wav_ola_test.cc

Issue 157001: Modify OLA to use window size in seconds instead of bytes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/audio_renderer_algorithm_ola.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/tools/wav_ola_test.cc
===================================================================
--- media/tools/wav_ola_test.cc (revision 20385)
+++ media/tools/wav_ola_test.cc (working copy)
@@ -23,7 +23,7 @@
using media::AudioRendererAlgorithmOLA;
using media::DataBuffer;
-const size_t kDefaultWindowSize = 4096;
+const double kDefaultWindowLength = 0.08;
struct WavHeader {
int32 riff;
@@ -42,15 +42,16 @@
// 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 @@
private:
FILE* input_;
AudioRendererAlgorithmOLA* ola_;
+ size_t window_size_;
DISALLOW_COPY_AND_ASSIGN(Dummy);
};
@@ -104,11 +106,17 @@
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 @@
// 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;
« no previous file with comments | « media/filters/audio_renderer_algorithm_ola.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698