Index: trunk/src/media/audio/win/audio_output_win_unittest.cc |
=================================================================== |
--- trunk/src/media/audio/win/audio_output_win_unittest.cc (revision 290374) |
+++ trunk/src/media/audio/win/audio_output_win_unittest.cc (working copy) |
@@ -37,7 +37,7 @@ |
static const wchar_t kAudioFile1_16b_m_16K[] |
= L"media\\test\\data\\sweep02_16b_mono_16KHz.raw"; |
-static int ClearData(AudioBus* audio_bus, int total_bytes_delay) { |
+static int ClearData(AudioBus* audio_bus, AudioBuffersState buffers_state) { |
audio_bus->Zero(); |
return audio_bus->frames(); |
} |
@@ -52,7 +52,7 @@ |
} |
// AudioSourceCallback::OnMoreData implementation: |
virtual int OnMoreData(AudioBus* audio_bus, |
- int total_bytes_delay) { |
+ AudioBuffersState buffers_state) { |
++callback_count_; |
// Touch the channel memory value to make sure memory is good. |
audio_bus->Zero(); |
@@ -89,9 +89,9 @@ |
: laggy_after_buffer_(laggy_after_buffer), lag_in_ms_(lag_in_ms) { |
} |
virtual int OnMoreData(AudioBus* audio_bus, |
- int total_bytes_delay) { |
+ AudioBuffersState buffers_state) { |
// Call the base, which increments the callback_count_. |
- TestSourceBasic::OnMoreData(audio_bus, total_bytes_delay); |
+ TestSourceBasic::OnMoreData(audio_bus, buffers_state); |
if (callback_count() > kMaxNumBuffers) { |
::Sleep(lag_in_ms_); |
} |
@@ -520,22 +520,32 @@ |
// pending bytes will go down and eventually read zero. |
InSequence s; |
- EXPECT_CALL(source, OnMoreData(NotNull(), 0)) |
+ EXPECT_CALL(source, OnMoreData(NotNull(), |
+ Field(&AudioBuffersState::pending_bytes, 0))) |
.WillOnce(Invoke(ClearData)); |
// Note: If AudioManagerWin::NumberOfWaveOutBuffers() ever changes, or if this |
// test is run on Vista, these expectations will fail. |
- EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms)) |
+ EXPECT_CALL(source, OnMoreData(NotNull(), |
+ Field(&AudioBuffersState::pending_bytes, |
+ bytes_100_ms))) |
.WillOnce(Invoke(ClearData)); |
- EXPECT_CALL(source, OnMoreData(NotNull(), 2 * bytes_100_ms)) |
+ EXPECT_CALL(source, OnMoreData(NotNull(), |
+ Field(&AudioBuffersState::pending_bytes, |
+ 2 * bytes_100_ms))) |
.WillOnce(Invoke(ClearData)); |
- EXPECT_CALL(source, OnMoreData(NotNull(), 2 * bytes_100_ms)) |
+ EXPECT_CALL(source, OnMoreData(NotNull(), |
+ Field(&AudioBuffersState::pending_bytes, |
+ 2 * bytes_100_ms))) |
.Times(AnyNumber()) |
.WillRepeatedly(Return(0)); |
- EXPECT_CALL(source, OnMoreData(NotNull(), bytes_100_ms)) |
+ EXPECT_CALL(source, OnMoreData(NotNull(), |
+ Field(&AudioBuffersState::pending_bytes, |
+ bytes_100_ms))) |
.Times(AnyNumber()) |
.WillRepeatedly(Return(0)); |
- EXPECT_CALL(source, OnMoreData(NotNull(), 0)) |
+ EXPECT_CALL(source, OnMoreData(NotNull(), |
+ Field(&AudioBuffersState::pending_bytes, 0))) |
.Times(AnyNumber()) |
.WillRepeatedly(Return(0)); |
@@ -561,8 +571,8 @@ |
// AudioSourceCallback::OnMoreData implementation: |
virtual int OnMoreData(AudioBus* audio_bus, |
- int total_bytes_delay) { |
- socket_->Send(&total_bytes_delay, sizeof(total_bytes_delay)); |
+ AudioBuffersState buffers_state) { |
+ socket_->Send(&buffers_state, sizeof(buffers_state)); |
uint32 size = socket_->Receive(data_.get(), data_size_); |
DCHECK_EQ(static_cast<size_t>(size) % sizeof(*audio_bus_->channel(0)), 0U); |
audio_bus_->CopyTo(audio_bus); |
@@ -570,7 +580,7 @@ |
} |
virtual int OnMoreIOData(AudioBus* source, |
AudioBus* dest, |
- int total_bytes_delay) { |
+ AudioBuffersState buffers_state) { |
NOTREACHED(); |
return 0; |
} |
@@ -612,13 +622,13 @@ |
SineWaveAudioSource sine(1, ctx.sine_freq, ctx.sample_rate); |
const int kTwoSecFrames = ctx.sample_rate * 2; |
- int total_bytes_delay = 0; |
+ AudioBuffersState buffers_state; |
int times = 0; |
for (int ix = 0; ix < kTwoSecFrames; ix += ctx.frames) { |
- if (ctx.socket->Receive(&total_bytes_delay, sizeof(total_bytes_delay)) == 0) |
+ if (ctx.socket->Receive(&buffers_state, sizeof(buffers_state)) == 0) |
break; |
- if ((times > 0) && (total_bytes_delay < 1000)) __debugbreak(); |
- sine.OnMoreData(audio_bus.get(), total_bytes_delay); |
+ if ((times > 0) && (buffers_state.pending_bytes < 1000)) __debugbreak(); |
+ sine.OnMoreData(audio_bus.get(), buffers_state); |
ctx.socket->Send(data.get(), ctx.packet_size_bytes); |
++times; |
} |