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

Unified Diff: trunk/src/media/audio/android/audio_android_unittest.cc

Issue 335343004: Revert 277794 "Modifies AudioInputCallback::OnData and use media..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 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 | « trunk/src/media/audio/alsa/alsa_input.cc ('k') | trunk/src/media/audio/android/audio_record_input.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/media/audio/android/audio_android_unittest.cc
===================================================================
--- trunk/src/media/audio/android/audio_android_unittest.cc (revision 277811)
+++ trunk/src/media/audio/android/audio_android_unittest.cc (working copy)
@@ -148,9 +148,10 @@
// Gmock implementation of AudioInputStream::AudioInputCallback.
class MockAudioInputCallback : public AudioInputStream::AudioInputCallback {
public:
- MOCK_METHOD4(OnData,
+ MOCK_METHOD5(OnData,
void(AudioInputStream* stream,
- const AudioBus* src,
+ const uint8* src,
+ uint32 size,
uint32 hardware_delay_bytes,
double volume));
MOCK_METHOD1(OnError, void(AudioInputStream* stream));
@@ -263,19 +264,14 @@
// AudioInputStream::AudioInputCallback implementation.
virtual void OnData(AudioInputStream* stream,
- const AudioBus* src,
+ const uint8* src,
+ uint32 size,
uint32 hardware_delay_bytes,
double volume) OVERRIDE {
- const int num_samples = src->frames() * src->channels();
- scoped_ptr<int16> interleaved(new int16[num_samples]);
- const int bytes_per_sample = sizeof(*interleaved);
- src->ToInterleaved(src->frames(), bytes_per_sample, interleaved.get());
-
// Store data data in a temporary buffer to avoid making blocking
// fwrite() calls in the audio callback. The complete buffer will be
// written to file in the destructor.
- const int size = bytes_per_sample * num_samples;
- if (!buffer_->Append((const uint8*)interleaved.get(), size))
+ if (!buffer_->Append(src, size))
event_->Signal();
}
@@ -311,19 +307,13 @@
// AudioInputStream::AudioInputCallback implementation
virtual void OnData(AudioInputStream* stream,
- const AudioBus* src,
+ const uint8* src,
+ uint32 size,
uint32 hardware_delay_bytes,
double volume) OVERRIDE {
const base::TimeTicks now_time = base::TimeTicks::Now();
const int diff = (now_time - previous_time_).InMilliseconds();
- EXPECT_EQ(params_.bits_per_sample(), 16);
- const int num_samples = src->frames() * src->channels();
- scoped_ptr<int16> interleaved(new int16[num_samples]);
- const int bytes_per_sample = sizeof(*interleaved);
- src->ToInterleaved(src->frames(), bytes_per_sample, interleaved.get());
- const int size = bytes_per_sample * num_samples;
-
base::AutoLock lock(lock_);
if (diff > 1000) {
started_ = true;
@@ -344,7 +334,7 @@
// Append new data to the FIFO and extend the size if the max capacity
// was exceeded. Flush the FIFO when extended just in case.
- if (!fifo_->Append((const uint8*)interleaved.get(), size)) {
+ if (!fifo_->Append(src, size)) {
fifo_->set_forward_capacity(2 * fifo_->forward_capacity());
fifo_->Clear();
}
@@ -650,10 +640,14 @@
int count = 0;
MockAudioInputCallback sink;
- EXPECT_CALL(sink, OnData(audio_input_stream_, NotNull(), _, _))
+ EXPECT_CALL(sink,
+ OnData(audio_input_stream_,
+ NotNull(),
+ params.
+ GetBytesPerBuffer(), _, _))
.Times(AtLeast(num_callbacks))
.WillRepeatedly(
- CheckCountAndPostQuitTask(&count, num_callbacks, loop()));
+ CheckCountAndPostQuitTask(&count, num_callbacks, loop()));
EXPECT_CALL(sink, OnError(audio_input_stream_)).Times(0);
OpenAndStartAudioInputStreamOnAudioThread(&sink);
« no previous file with comments | « trunk/src/media/audio/alsa/alsa_input.cc ('k') | trunk/src/media/audio/android/audio_record_input.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698