This source file includes following definitions.
- ACTION_P
- decoder_
- ExpectUnsupportedAudioDecoder
- OnAudioTimeCallback
- InitializeRenderer
- Initialize
- InitializeWithStatus
- InitializeAndStop
- InitializeAndStopDuringDecoderInit
- EnterPendingDecoderInitState
- Flush
- Preroll
- Preroll
- Play
- Pause
- Seek
- WaitForEnded
- IsReadPending
- WaitForPendingRead
- SatisfyPendingRead
- AbortPendingRead
- DeliverEndOfStream
- DeliverRemainingAudio
- ConsumeBufferedData
- ConsumeAllBufferedData
- frames_buffered
- buffer_capacity
- frames_remaining_in_buffer
- CallResumeAfterUnderflow
- CalculatePlayTime
- EndOfStreamTest
- AdvanceTime
- GetTime
- DecodeDecoder
- ResetDecoder
- DeliverBuffer
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_vector.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "media/base/audio_buffer.h"
#include "media/base/audio_hardware_config.h"
#include "media/base/audio_timestamp_helper.h"
#include "media/base/fake_audio_renderer_sink.h"
#include "media/base/gmock_callback_support.h"
#include "media/base/mock_filters.h"
#include "media/base/test_helpers.h"
#include "media/filters/audio_renderer_impl.h"
#include "testing/gtest/include/gtest/gtest.h"
using ::base::Time;
using ::base::TimeTicks;
using ::base::TimeDelta;
using ::testing::_;
using ::testing::AnyNumber;
using ::testing::Invoke;
using ::testing::Return;
namespace media {
static AudioCodec kCodec = kCodecVorbis;
static SampleFormat kSampleFormat = kSampleFormatPlanarF32;
static ChannelLayout kChannelLayout = CHANNEL_LAYOUT_STEREO;
static int kChannelCount = 2;
static int kChannels = ChannelLayoutToChannelCount(kChannelLayout);
static int kSamplesPerSecond = 44100;
static float kMutedAudio = 0.0f;
static float kPlayingAudio = 0.5f;
static const int kDataSize = 1024;
ACTION_P(EnterPendingDecoderInitStateAction, test) {
test->EnterPendingDecoderInitState(arg1);
}
class AudioRendererImplTest : public ::testing::Test {
public:
AudioRendererImplTest()
: hardware_config_(AudioParameters(), AudioParameters()),
needs_stop_(true),
demuxer_stream_(DemuxerStream::AUDIO),
decoder_(new MockAudioDecoder()) {
AudioDecoderConfig audio_config(kCodec,
kSampleFormat,
kChannelLayout,
kSamplesPerSecond,
NULL,
0,
false);
demuxer_stream_.set_audio_decoder_config(audio_config);
EXPECT_CALL(*decoder_, Decode(_, _))
.WillRepeatedly(Invoke(this, &AudioRendererImplTest::DecodeDecoder));
EXPECT_CALL(*decoder_, Reset(_))
.WillRepeatedly(Invoke(this, &AudioRendererImplTest::ResetDecoder));
EXPECT_CALL(demuxer_stream_, Read(_)).WillRepeatedly(
RunCallback<0>(DemuxerStream::kOk, DecoderBuffer::CreateEOSBuffer()));
AudioParameters out_params =
AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY,
kChannelLayout,
kSamplesPerSecond,
SampleFormatToBytesPerChannel(kSampleFormat) * 8,
512);
hardware_config_.UpdateOutputConfig(out_params);
ScopedVector<AudioDecoder> decoders;
decoders.push_back(decoder_);
sink_ = new FakeAudioRendererSink();
renderer_.reset(new AudioRendererImpl(message_loop_.message_loop_proxy(),
sink_,
decoders.Pass(),
SetDecryptorReadyCB(),
&hardware_config_));
renderer_->set_now_cb_for_testing(base::Bind(
&AudioRendererImplTest::GetTime, base::Unretained(this)));
}
virtual ~AudioRendererImplTest() {
SCOPED_TRACE("~AudioRendererImplTest()");
if (needs_stop_) {
WaitableMessageLoopEvent event;
renderer_->Stop(event.GetClosure());
event.RunAndWait();
}
}
void ExpectUnsupportedAudioDecoder() {
EXPECT_CALL(*decoder_, Initialize(_, _))
.WillOnce(RunCallback<1>(DECODER_ERROR_NOT_SUPPORTED));
}
MOCK_METHOD1(OnStatistics, void(const PipelineStatistics&));
MOCK_METHOD0(OnUnderflow, void());
MOCK_METHOD0(OnDisabled, void());
MOCK_METHOD1(OnError, void(PipelineStatus));
void OnAudioTimeCallback(TimeDelta current_time, TimeDelta max_time) {
CHECK(current_time <= max_time);
}
void InitializeRenderer(const PipelineStatusCB& pipeline_status_cb) {
renderer_->Initialize(
&demuxer_stream_,
pipeline_status_cb,
base::Bind(&AudioRendererImplTest::OnStatistics,
base::Unretained(this)),
base::Bind(&AudioRendererImplTest::OnUnderflow,
base::Unretained(this)),
base::Bind(&AudioRendererImplTest::OnAudioTimeCallback,
base::Unretained(this)),
ended_event_.GetClosure(),
base::Bind(&AudioRendererImplTest::OnDisabled,
base::Unretained(this)),
base::Bind(&AudioRendererImplTest::OnError,
base::Unretained(this)));
}
void Initialize() {
EXPECT_CALL(*decoder_, Initialize(_, _))
.WillOnce(RunCallback<1>(PIPELINE_OK));
EXPECT_CALL(*decoder_, Stop());
InitializeWithStatus(PIPELINE_OK);
next_timestamp_.reset(new AudioTimestampHelper(
hardware_config_.GetOutputConfig().sample_rate()));
}
void InitializeWithStatus(PipelineStatus expected) {
SCOPED_TRACE(base::StringPrintf("InitializeWithStatus(%d)", expected));
WaitableMessageLoopEvent event;
InitializeRenderer(event.GetPipelineStatusCB());
event.RunAndWaitForStatus(expected);
EXPECT_TRUE(decode_cb_.is_null());
}
void InitializeAndStop() {
EXPECT_CALL(*decoder_, Initialize(_, _))
.WillOnce(RunCallback<1>(PIPELINE_OK));
EXPECT_CALL(*decoder_, Stop());
WaitableMessageLoopEvent event;
InitializeRenderer(event.GetPipelineStatusCB());
renderer_->Stop(NewExpectedClosure());
event.RunAndWaitForStatus(PIPELINE_ERROR_ABORT);
EXPECT_EQ(renderer_->state_, AudioRendererImpl::kStopped);
}
void InitializeAndStopDuringDecoderInit() {
EXPECT_CALL(*decoder_, Initialize(_, _))
.WillOnce(EnterPendingDecoderInitStateAction(this));
EXPECT_CALL(*decoder_, Stop());
WaitableMessageLoopEvent event;
InitializeRenderer(event.GetPipelineStatusCB());
base::RunLoop().RunUntilIdle();
DCHECK(!init_decoder_cb_.is_null());
renderer_->Stop(NewExpectedClosure());
base::ResetAndReturn(&init_decoder_cb_).Run(PIPELINE_OK);
event.RunAndWaitForStatus(PIPELINE_ERROR_ABORT);
EXPECT_EQ(renderer_->state_, AudioRendererImpl::kStopped);
}
void EnterPendingDecoderInitState(PipelineStatusCB cb) {
init_decoder_cb_ = cb;
}
void Flush() {
WaitableMessageLoopEvent flush_event;
renderer_->Flush(flush_event.GetClosure());
flush_event.RunAndWait();
EXPECT_FALSE(IsReadPending());
}
void Preroll() {
Preroll(0, PIPELINE_OK);
}
void Preroll(int timestamp_ms, PipelineStatus expected) {
SCOPED_TRACE(base::StringPrintf("Preroll(%d, %d)", timestamp_ms, expected));
TimeDelta timestamp = TimeDelta::FromMilliseconds(timestamp_ms);
next_timestamp_->SetBaseTimestamp(timestamp);
WaitableMessageLoopEvent event;
renderer_->Preroll(timestamp, event.GetPipelineStatusCB());
WaitForPendingRead();
DeliverRemainingAudio();
event.RunAndWaitForStatus(PIPELINE_OK);
EXPECT_TRUE(decode_cb_.is_null());
}
void Play() {
SCOPED_TRACE("Play()");
WaitableMessageLoopEvent event;
renderer_->Play(event.GetClosure());
renderer_->SetPlaybackRate(1.0f);
event.RunAndWait();
}
void Pause() {
WaitableMessageLoopEvent pause_event;
renderer_->Pause(pause_event.GetClosure());
pause_event.RunAndWait();
}
void Seek() {
Pause();
Flush();
Preroll();
}
void WaitForEnded() {
SCOPED_TRACE("WaitForEnded()");
ended_event_.RunAndWait();
}
bool IsReadPending() const {
return !decode_cb_.is_null();
}
void WaitForPendingRead() {
SCOPED_TRACE("WaitForPendingRead()");
if (!decode_cb_.is_null())
return;
DCHECK(wait_for_pending_decode_cb_.is_null());
WaitableMessageLoopEvent event;
wait_for_pending_decode_cb_ = event.GetClosure();
event.RunAndWait();
DCHECK(!decode_cb_.is_null());
DCHECK(wait_for_pending_decode_cb_.is_null());
}
void SatisfyPendingRead(int size) {
CHECK_GT(size, 0);
CHECK(!decode_cb_.is_null());
scoped_refptr<AudioBuffer> buffer =
MakeAudioBuffer<float>(kSampleFormat,
kChannelLayout,
kChannelCount,
kSamplesPerSecond,
kPlayingAudio,
0.0f,
size,
next_timestamp_->GetTimestamp(),
next_timestamp_->GetFrameDuration(size));
next_timestamp_->AddFrames(size);
DeliverBuffer(AudioDecoder::kOk, buffer);
}
void AbortPendingRead() {
DeliverBuffer(AudioDecoder::kAborted, NULL);
}
void DeliverEndOfStream() {
DeliverBuffer(AudioDecoder::kOk, AudioBuffer::CreateEOSBuffer());
}
void DeliverRemainingAudio() {
SatisfyPendingRead(frames_remaining_in_buffer());
}
bool ConsumeBufferedData(int requested_frames, bool* muted) {
scoped_ptr<AudioBus> bus =
AudioBus::Create(kChannels, std::max(requested_frames, 1));
int frames_read;
if (!sink_->Render(bus.get(), 0, &frames_read)) {
if (muted)
*muted = true;
return false;
}
if (muted)
*muted = frames_read < 1 || bus->channel(0)[0] == kMutedAudio;
return frames_read == requested_frames;
}
int ConsumeAllBufferedData() {
renderer_->DisableUnderflowForTesting();
int frames_read = 0;
int total_frames_read = 0;
scoped_ptr<AudioBus> bus = AudioBus::Create(kChannels, 1024);
do {
TimeDelta audio_delay = TimeDelta::FromMicroseconds(
total_frames_read * Time::kMicrosecondsPerSecond /
static_cast<float>(hardware_config_.GetOutputConfig().sample_rate()));
frames_read = renderer_->Render(
bus.get(), audio_delay.InMilliseconds());
total_frames_read += frames_read;
} while (frames_read > 0);
return total_frames_read;
}
int frames_buffered() {
return renderer_->algorithm_->frames_buffered();
}
int buffer_capacity() {
return renderer_->algorithm_->QueueCapacity();
}
int frames_remaining_in_buffer() {
if (frames_buffered() > buffer_capacity()) {
return 0;
}
return buffer_capacity() - frames_buffered();
}
void CallResumeAfterUnderflow() {
renderer_->ResumeAfterUnderflow();
}
TimeDelta CalculatePlayTime(int frames_filled) {
return TimeDelta::FromMicroseconds(
frames_filled * Time::kMicrosecondsPerSecond /
renderer_->audio_parameters_.sample_rate());
}
void EndOfStreamTest(float playback_rate) {
Initialize();
Preroll();
Play();
renderer_->SetPlaybackRate(playback_rate);
int total_frames = frames_buffered();
int frames_filled = ConsumeAllBufferedData();
WaitForPendingRead();
const float kEpsilon = 0.20 * (total_frames / playback_rate);
EXPECT_NEAR(frames_filled, total_frames / playback_rate, kEpsilon);
TimeDelta audio_play_time = CalculatePlayTime(frames_filled);
DVLOG(1) << "audio_play_time = " << audio_play_time.InSecondsF();
DeliverEndOfStream();
AdvanceTime(audio_play_time / 2);
ConsumeBufferedData(frames_buffered(), NULL);
AdvanceTime(audio_play_time / 2);
ConsumeBufferedData(frames_buffered(), NULL);
WaitForEnded();
}
void AdvanceTime(TimeDelta time) {
base::AutoLock auto_lock(lock_);
time_ += time;
}
base::MessageLoop message_loop_;
scoped_ptr<AudioRendererImpl> renderer_;
scoped_refptr<FakeAudioRendererSink> sink_;
AudioHardwareConfig hardware_config_;
bool needs_stop_;
private:
TimeTicks GetTime() {
base::AutoLock auto_lock(lock_);
return time_;
}
void DecodeDecoder(const scoped_refptr<DecoderBuffer>& buffer,
const AudioDecoder::DecodeCB& decode_cb) {
EXPECT_TRUE(stop_decoder_cb_.is_null());
if (base::MessageLoop::current() != &message_loop_) {
message_loop_.PostTask(FROM_HERE, base::Bind(
&AudioRendererImplTest::DecodeDecoder,
base::Unretained(this), buffer, decode_cb));
return;
}
CHECK(decode_cb_.is_null()) << "Overlapping decodes are not permitted";
decode_cb_ = decode_cb;
if (!wait_for_pending_decode_cb_.is_null())
base::ResetAndReturn(&wait_for_pending_decode_cb_).Run();
}
void ResetDecoder(const base::Closure& reset_cb) {
CHECK(decode_cb_.is_null())
<< "Reset overlapping with reads is not permitted";
message_loop_.PostTask(FROM_HERE, reset_cb);
}
void DeliverBuffer(AudioDecoder::Status status,
const scoped_refptr<AudioBuffer>& buffer) {
CHECK(!decode_cb_.is_null());
base::ResetAndReturn(&decode_cb_).Run(status, buffer);
}
MockDemuxerStream demuxer_stream_;
MockAudioDecoder* decoder_;
base::Lock lock_;
TimeTicks time_;
AudioDecoder::DecodeCB decode_cb_;
scoped_ptr<AudioTimestampHelper> next_timestamp_;
WaitableMessageLoopEvent ended_event_;
base::Closure wait_for_pending_decode_cb_;
base::Closure stop_decoder_cb_;
PipelineStatusCB init_decoder_cb_;
DISALLOW_COPY_AND_ASSIGN(AudioRendererImplTest);
};
TEST_F(AudioRendererImplTest, Initialize_Successful) {
Initialize();
}
TEST_F(AudioRendererImplTest, Initialize_DecoderInitFailure) {
ExpectUnsupportedAudioDecoder();
InitializeWithStatus(DECODER_ERROR_NOT_SUPPORTED);
}
TEST_F(AudioRendererImplTest, Preroll) {
Initialize();
Preroll();
}
TEST_F(AudioRendererImplTest, Play) {
Initialize();
Preroll();
Play();
EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL));
WaitForPendingRead();
}
TEST_F(AudioRendererImplTest, EndOfStream) {
EndOfStreamTest(1.0);
}
TEST_F(AudioRendererImplTest, EndOfStream_FasterPlaybackSpeed) {
EndOfStreamTest(2.0);
}
TEST_F(AudioRendererImplTest, EndOfStream_SlowerPlaybackSpeed) {
EndOfStreamTest(0.5);
}
TEST_F(AudioRendererImplTest, Underflow) {
Initialize();
Preroll();
int initial_capacity = buffer_capacity();
Play();
EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL));
WaitForPendingRead();
EXPECT_CALL(*this, OnUnderflow());
EXPECT_FALSE(ConsumeBufferedData(kDataSize, NULL));
renderer_->ResumeAfterUnderflow();
bool muted = false;
EXPECT_EQ(0, frames_buffered());
EXPECT_FALSE(ConsumeBufferedData(kDataSize, &muted));
EXPECT_TRUE(muted);
EXPECT_GT(buffer_capacity(), initial_capacity);
DeliverRemainingAudio();
EXPECT_TRUE(ConsumeBufferedData(kDataSize, &muted));
EXPECT_FALSE(muted);
}
TEST_F(AudioRendererImplTest, Underflow_FollowedByFlush) {
Initialize();
Preroll();
int initial_capacity = buffer_capacity();
Play();
EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL));
WaitForPendingRead();
EXPECT_CALL(*this, OnUnderflow());
EXPECT_FALSE(ConsumeBufferedData(kDataSize, NULL));
renderer_->ResumeAfterUnderflow();
EXPECT_GT(buffer_capacity(), initial_capacity);
DeliverRemainingAudio();
Seek();
EXPECT_EQ(buffer_capacity(), initial_capacity);
}
TEST_F(AudioRendererImplTest, Underflow_EndOfStream) {
Initialize();
Preroll();
Play();
TimeDelta time_until_ended = CalculatePlayTime(frames_buffered());
EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL));
WaitForPendingRead();
EXPECT_CALL(*this, OnUnderflow());
EXPECT_FALSE(ConsumeBufferedData(kDataSize, NULL));
SatisfyPendingRead(kDataSize);
WaitForPendingRead();
bool muted = false;
EXPECT_EQ(kDataSize, frames_buffered());
EXPECT_FALSE(ConsumeBufferedData(kDataSize, &muted));
EXPECT_TRUE(muted);
DeliverEndOfStream();
EXPECT_EQ(kDataSize, frames_buffered());
EXPECT_TRUE(ConsumeBufferedData(kDataSize, &muted));
EXPECT_FALSE(muted);
AdvanceTime(time_until_ended);
EXPECT_FALSE(ConsumeBufferedData(kDataSize, &muted));
EXPECT_TRUE(muted);
WaitForEnded();
}
TEST_F(AudioRendererImplTest, Underflow_ResumeFromCallback) {
Initialize();
Preroll();
Play();
EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL));
WaitForPendingRead();
EXPECT_CALL(*this, OnUnderflow())
.WillOnce(Invoke(this, &AudioRendererImplTest::CallResumeAfterUnderflow));
EXPECT_FALSE(ConsumeBufferedData(kDataSize, NULL));
bool muted = false;
EXPECT_EQ(0, frames_buffered());
EXPECT_FALSE(ConsumeBufferedData(kDataSize, &muted));
EXPECT_TRUE(muted);
DeliverRemainingAudio();
EXPECT_TRUE(ConsumeBufferedData(kDataSize, &muted));
EXPECT_FALSE(muted);
}
TEST_F(AudioRendererImplTest, Underflow_SetPlaybackRate) {
Initialize();
Preroll();
Play();
EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL));
WaitForPendingRead();
EXPECT_EQ(FakeAudioRendererSink::kPlaying, sink_->state());
EXPECT_CALL(*this, OnUnderflow())
.WillOnce(Invoke(this, &AudioRendererImplTest::CallResumeAfterUnderflow));
EXPECT_FALSE(ConsumeBufferedData(kDataSize, NULL));
EXPECT_EQ(0, frames_buffered());
EXPECT_EQ(FakeAudioRendererSink::kPlaying, sink_->state());
renderer_->SetPlaybackRate(0);
EXPECT_EQ(FakeAudioRendererSink::kPaused, sink_->state());
DeliverRemainingAudio();
EXPECT_EQ(FakeAudioRendererSink::kPaused, sink_->state());
renderer_->SetPlaybackRate(1);
EXPECT_EQ(FakeAudioRendererSink::kPlaying, sink_->state());
}
TEST_F(AudioRendererImplTest, Underflow_PausePlay) {
Initialize();
Preroll();
Play();
EXPECT_TRUE(ConsumeBufferedData(frames_buffered(), NULL));
WaitForPendingRead();
EXPECT_EQ(FakeAudioRendererSink::kPlaying, sink_->state());
EXPECT_CALL(*this, OnUnderflow())
.WillOnce(Invoke(this, &AudioRendererImplTest::CallResumeAfterUnderflow));
EXPECT_FALSE(ConsumeBufferedData(kDataSize, NULL));
EXPECT_EQ(0, frames_buffered());
EXPECT_EQ(FakeAudioRendererSink::kPlaying, sink_->state());
renderer_->SetPlaybackRate(0.0);
renderer_->SetPlaybackRate(1.0);
DeliverRemainingAudio();
EXPECT_EQ(FakeAudioRendererSink::kPlaying, sink_->state());
}
TEST_F(AudioRendererImplTest, AbortPendingRead_Preroll) {
Initialize();
WaitableMessageLoopEvent event;
renderer_->Preroll(TimeDelta(), event.GetPipelineStatusCB());
WaitForPendingRead();
AbortPendingRead();
event.RunAndWaitForStatus(PIPELINE_OK);
Flush();
Preroll(1000, PIPELINE_OK);
}
TEST_F(AudioRendererImplTest, AbortPendingRead_Pause) {
Initialize();
Preroll();
Play();
EXPECT_TRUE(ConsumeBufferedData(frames_buffered() / 2, NULL));
WaitForPendingRead();
WaitableMessageLoopEvent event;
renderer_->Pause(event.GetClosure());
AbortPendingRead();
event.RunAndWait();
Flush();
Preroll(1000, PIPELINE_OK);
}
TEST_F(AudioRendererImplTest, AbortPendingRead_Flush) {
Initialize();
Preroll();
Play();
EXPECT_TRUE(ConsumeBufferedData(frames_buffered() / 2, NULL));
WaitForPendingRead();
Pause();
EXPECT_TRUE(IsReadPending());
WaitableMessageLoopEvent flush_event;
renderer_->Flush(flush_event.GetClosure());
AbortPendingRead();
flush_event.RunAndWait();
EXPECT_FALSE(IsReadPending());
Preroll(1000, PIPELINE_OK);
}
TEST_F(AudioRendererImplTest, PendingRead_Pause) {
Initialize();
Preroll();
Play();
EXPECT_TRUE(ConsumeBufferedData(frames_buffered() / 2, NULL));
WaitForPendingRead();
WaitableMessageLoopEvent event;
renderer_->Pause(event.GetClosure());
SatisfyPendingRead(kDataSize);
event.RunAndWait();
Flush();
Preroll(1000, PIPELINE_OK);
}
TEST_F(AudioRendererImplTest, PendingRead_Flush) {
Initialize();
Preroll();
Play();
EXPECT_TRUE(ConsumeBufferedData(frames_buffered() / 2, NULL));
WaitForPendingRead();
Pause();
EXPECT_TRUE(IsReadPending());
WaitableMessageLoopEvent flush_event;
renderer_->Flush(flush_event.GetClosure());
SatisfyPendingRead(kDataSize);
flush_event.RunAndWait();
EXPECT_FALSE(IsReadPending());
Preroll(1000, PIPELINE_OK);
}
TEST_F(AudioRendererImplTest, PendingRead_Stop) {
Initialize();
Preroll();
Play();
EXPECT_TRUE(ConsumeBufferedData(frames_buffered() / 2, NULL));
WaitForPendingRead();
Pause();
EXPECT_TRUE(IsReadPending());
WaitableMessageLoopEvent stop_event;
renderer_->Stop(stop_event.GetClosure());
needs_stop_ = false;
SatisfyPendingRead(kDataSize);
stop_event.RunAndWait();
EXPECT_FALSE(IsReadPending());
}
TEST_F(AudioRendererImplTest, PendingFlush_Stop) {
Initialize();
Preroll();
Play();
EXPECT_TRUE(ConsumeBufferedData(frames_buffered() / 2, NULL));
WaitForPendingRead();
Pause();
EXPECT_TRUE(IsReadPending());
WaitableMessageLoopEvent flush_event;
renderer_->Flush(flush_event.GetClosure());
SatisfyPendingRead(kDataSize);
WaitableMessageLoopEvent event;
renderer_->Stop(event.GetClosure());
event.RunAndWait();
needs_stop_ = false;
}
TEST_F(AudioRendererImplTest, InitializeThenStop) {
InitializeAndStop();
}
TEST_F(AudioRendererImplTest, InitializeThenStopDuringDecoderInit) {
InitializeAndStopDuringDecoderInit();
}
}