diff options
author | grunell@chromium.org <grunell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-27 08:25:59 +0000 |
---|---|---|
committer | grunell@chromium.org <grunell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-27 08:25:59 +0000 |
commit | 7b4783cf6819cecf0af3a0d0dbd4aaefa7fef5e7 (patch) | |
tree | db34cb2e63d3028f580b6091f5a08fe4ecbf4f9d /media/audio/fake_audio_input_stream.cc | |
parent | 3ff66ccb117a4067e4a8fadf083a7a73d41b6630 (diff) | |
download | chromium_src-7b4783cf6819cecf0af3a0d0dbd4aaefa7fef5e7.zip chromium_src-7b4783cf6819cecf0af3a0d0dbd4aaefa7fef5e7.tar.gz chromium_src-7b4783cf6819cecf0af3a0d0dbd4aaefa7fef5e7.tar.bz2 |
Revert 272884 "reland 260073013: Added automatic mode to FakeInp..."
Breaks device enumeration.
BUG=377650
> reland 260073013: Added automatic mode to FakeInputAudioStream to generate automatic beeps
>
> Added automatic mode to FakeInputAudioStream to generate automatic beeps.
>
> This patch is to allow writing audio only tests using the fake input stream, also it changes the name of the fake device from "Default" to "Fake Audio, which I hope it will make things less confusing.
>
> Previously it broke the mac bots due to it somehow triggered crbug/288562, crbug/371271, which should have been fixed by https://codereview.chromium.org/274073002/
>
> TBR=ananta@chromium.org, dalecurtis@chromium.org
>
> NOTRY=true
>
> BUG=358541
> TEST=bots existing webrtc tests.
>
> Review URL: https://codereview.chromium.org/279223002
TBR=xians@chromium.org
Review URL: https://codereview.chromium.org/300143005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272932 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/fake_audio_input_stream.cc')
-rw-r--r-- | media/audio/fake_audio_input_stream.cc | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/media/audio/fake_audio_input_stream.cc b/media/audio/fake_audio_input_stream.cc index e05b257..5ec09a4 100644 --- a/media/audio/fake_audio_input_stream.cc +++ b/media/audio/fake_audio_input_stream.cc @@ -20,16 +20,10 @@ namespace { const int kBeepDurationMilliseconds = 20; const int kBeepFrequency = 400; -// Intervals between two automatic beeps. -const int kAutomaticBeepIntervalInMs = 500; - -// Automatic beep will be triggered every |kAutomaticBeepIntervalInMs| unless -// users explicitly call BeepOnce(), which will disable the automatic beep. struct BeepContext { - BeepContext() : beep_once(false), automatic(true) {} + BeepContext() : beep_once(false) {} base::Lock beep_lock; bool beep_once; - bool automatic; }; static base::LazyInstance<BeepContext> g_beep_context = @@ -84,37 +78,14 @@ void FakeAudioInputStream::Start(AudioInputCallback* callback) { void FakeAudioInputStream::DoCallback() { DCHECK(callback_); - const TimeTicks now = TimeTicks::Now(); - base::TimeDelta next_callback_time = - last_callback_time_ + callback_interval_ * 2 - now; - - // If we are falling behind, try to catch up as much as we can in the next - // callback. - if (next_callback_time < base::TimeDelta()) - next_callback_time = base::TimeDelta(); - - // Accumulate the time from the last beep. - interval_from_last_beep_ += now - last_callback_time_; - - last_callback_time_ = now; - memset(buffer_.get(), 0, buffer_size_); bool should_beep = false; { BeepContext* beep_context = g_beep_context.Pointer(); base::AutoLock auto_lock(beep_context->beep_lock); - if (beep_context->automatic) { - base::TimeDelta delta = interval_from_last_beep_ - - TimeDelta::FromMilliseconds(kAutomaticBeepIntervalInMs); - if (delta > base::TimeDelta()) { - should_beep = true; - interval_from_last_beep_ = delta; - } - } else { - should_beep = beep_context->beep_once; - beep_context->beep_once = false; - } + should_beep = beep_context->beep_once; + beep_context->beep_once = false; } // If this object was instructed to generate a beep or has started to @@ -132,6 +103,7 @@ void FakeAudioInputStream::DoCallback() { while (position + high_bytes <= buffer_size_) { // Write high values first. memset(buffer_.get() + position, 128, high_bytes); + // Then leave low values in the buffer with |high_bytes|. position += high_bytes * 2; } @@ -144,6 +116,16 @@ void FakeAudioInputStream::DoCallback() { callback_->OnData(this, buffer_.get(), buffer_size_, buffer_size_, 1.0); frames_elapsed_ += params_.frames_per_buffer(); + const TimeTicks now = TimeTicks::Now(); + base::TimeDelta next_callback_time = + last_callback_time_ + callback_interval_ * 2 - now; + + // If we are falling behind, try to catch up as much as we can in the next + // callback. + if (next_callback_time < base::TimeDelta()) + next_callback_time = base::TimeDelta(); + + last_callback_time_ = now; thread_.message_loop()->PostDelayedTask( FROM_HERE, base::Bind(&FakeAudioInputStream::DoCallback, base::Unretained(this)), @@ -181,7 +163,6 @@ void FakeAudioInputStream::BeepOnce() { BeepContext* beep_context = g_beep_context.Pointer(); base::AutoLock auto_lock(beep_context->beep_lock); beep_context->beep_once = true; - beep_context->automatic = false; } } // namespace media |