summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
Diffstat (limited to 'media')
-rw-r--r--media/audio/audio_input_unittest.cc17
-rw-r--r--media/audio/mac/audio_input_mac.cc14
-rw-r--r--media/audio/mac/audio_input_mac.h2
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);
};