diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-14 23:07:14 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-14 23:07:14 +0000 |
commit | 5a6e2dd4c11d1c1faadf1488d92e58ad17763f6c (patch) | |
tree | 2f12b1d382b4aa1b771bd264eb69e5c28a3c3b6a /media | |
parent | 942ba283b3d147f211e4995ee0a5c9cec8071aab (diff) | |
download | chromium_src-5a6e2dd4c11d1c1faadf1488d92e58ad17763f6c.zip chromium_src-5a6e2dd4c11d1c1faadf1488d92e58ad17763f6c.tar.gz chromium_src-5a6e2dd4c11d1c1faadf1488d92e58ad17763f6c.tar.bz2 |
Enable the AudioInputTest tests on the build bots and fix a bug in PCMQueueInAudioInputStream.
The tests should all succeed but on bots where audio hardware is missing, we should get a printout that no devices were detected.
Notably the mac bots do have the necessary equipment which is how I ran into the bug.
TEST=This runs more tests in media_unittests on the bots.
Review URL: http://codereview.chromium.org/8941001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/audio/audio_input_unittest.cc | 17 | ||||
-rw-r--r-- | media/audio/mac/audio_input_mac.cc | 14 | ||||
-rw-r--r-- | media/audio/mac/audio_input_mac.h | 2 |
3 files changed, 23 insertions, 10 deletions
diff --git a/media/audio/audio_input_unittest.cc b/media/audio/audio_input_unittest.cc index 5faa2e9..2c92640 100644 --- a/media/audio/audio_input_unittest.cc +++ b/media/audio/audio_input_unittest.cc @@ -88,14 +88,12 @@ class TestInputCallbackBlocking : public TestInputCallback { }; static bool CanRunAudioTests(AudioManager* audio_man) { - if (NULL == audio_man) - return false; + bool has_input = audio_man->HasAudioInputDevices(); - scoped_ptr<base::Environment> env(base::Environment::Create()); - if (env->HasVar("CHROME_HEADLESS")) - return false; + if (!has_input) + LOG(WARNING) << "No input devices detected"; - return audio_man->HasAudioInputDevices(); + return has_input; } static AudioInputStream* CreateTestAudioInputStream(AudioManager* audio_man) { @@ -194,10 +192,17 @@ TEST(AudioInputTest, Record) { } // Test a recording sequence with delays in the audio callback. +// TODO(joth): See bug 107546. This fails on slow bots. Once fixed, remove the +// CHROME_HEADLESS check below. TEST(AudioInputTest, RecordWithSlowSink) { scoped_refptr<AudioManager> audio_man(AudioManager::Create()); if (!CanRunAudioTests(audio_man.get())) return; + + scoped_ptr<base::Environment> env(base::Environment::Create()); + if (env->HasVar("CHROME_HEADLESS")) + return; + MessageLoop message_loop(MessageLoop::TYPE_DEFAULT); AudioInputStream* ais = CreateTestAudioInputStream(audio_man.get()); EXPECT_TRUE(ais->Open()); diff --git a/media/audio/mac/audio_input_mac.cc b/media/audio/mac/audio_input_mac.cc index 3f73c2e..eb6f167 100644 --- a/media/audio/mac/audio_input_mac.cc +++ b/media/audio/mac/audio_input_mac.cc @@ -21,7 +21,8 @@ PCMQueueInAudioInputStream::PCMQueueInAudioInputStream( : manager_(manager), callback_(NULL), audio_queue_(NULL), - buffer_size_bytes_(0) { + buffer_size_bytes_(0), + started_(false) { // We must have a manager. DCHECK(manager_); // A frame is one sample across all channels. In interleaved audio the per @@ -68,15 +69,18 @@ void PCMQueueInAudioInputStream::Start(AudioInputCallback* callback) { return; callback_ = callback; OSStatus err = AudioQueueStart(audio_queue_, NULL); - if (err != noErr) + if (err != noErr) { HandleError(err); - else + } else { + started_ = true; manager_->IncreaseActiveInputStreamCount(); + } } void PCMQueueInAudioInputStream::Stop() { - if (!audio_queue_) + if (!audio_queue_ || !started_) return; + // Stop is always called before Close. In case of error, this will be // also called when closing the input controller. manager_->DecreaseActiveInputStreamCount(); @@ -86,6 +90,8 @@ void PCMQueueInAudioInputStream::Stop() { OSStatus err = AudioQueueStop(audio_queue_, true); if (err != noErr) HandleError(err); + + started_ = false; } void PCMQueueInAudioInputStream::Close() { diff --git a/media/audio/mac/audio_input_mac.h b/media/audio/mac/audio_input_mac.h index 7569c36..26be177 100644 --- a/media/audio/mac/audio_input_mac.h +++ b/media/audio/mac/audio_input_mac.h @@ -67,6 +67,8 @@ class PCMQueueInAudioInputStream : public AudioInputStream { AudioQueueRef audio_queue_; // Size of each of the buffers in |audio_buffers_| uint32 buffer_size_bytes_; + // True iff Start() has been called successfully. + bool started_; DISALLOW_COPY_AND_ASSIGN(PCMQueueInAudioInputStream); }; |