diff options
Diffstat (limited to 'media/audio')
-rw-r--r-- | media/audio/alsa/alsa_input.cc | 8 | ||||
-rw-r--r-- | media/audio/alsa/alsa_input.h | 4 | ||||
-rw-r--r-- | media/audio/alsa/alsa_output.cc | 4 | ||||
-rw-r--r-- | media/audio/alsa/alsa_output.h | 9 | ||||
-rw-r--r-- | media/audio/audio_parameters.h | 1 | ||||
-rw-r--r-- | media/audio/audio_parameters_unittest.cc | 38 |
6 files changed, 53 insertions, 11 deletions
diff --git a/media/audio/alsa/alsa_input.cc b/media/audio/alsa/alsa_input.cc index bf31f5196d..9cde236b59 100644 --- a/media/audio/alsa/alsa_input.cc +++ b/media/audio/alsa/alsa_input.cc @@ -32,7 +32,8 @@ AlsaPcmInputStream::AlsaPcmInputStream(AudioManagerBase* audio_manager, device_name_(device_name), params_(params), bytes_per_buffer_(params.frames_per_buffer() * - (params.channels() * params.bits_per_sample()) / 8), + (params.channels() * params.bits_per_sample()) / + 8), wrapper_(wrapper), buffer_duration_(base::TimeDelta::FromMicroseconds( params.frames_per_buffer() * base::Time::kMicrosecondsPerSecond / @@ -41,9 +42,8 @@ AlsaPcmInputStream::AlsaPcmInputStream(AudioManagerBase* audio_manager, device_handle_(NULL), mixer_handle_(NULL), mixer_element_handle_(NULL), - weak_factory_(this), - read_callback_behind_schedule_(false) { -} + read_callback_behind_schedule_(false), + weak_factory_(this) {} AlsaPcmInputStream::~AlsaPcmInputStream() {} diff --git a/media/audio/alsa/alsa_input.h b/media/audio/alsa/alsa_input.h index 6e9aad9056..90c388382a 100644 --- a/media/audio/alsa/alsa_input.h +++ b/media/audio/alsa/alsa_input.h @@ -80,10 +80,12 @@ class AlsaPcmInputStream : public AgcAudioStream<AudioInputStream> { snd_pcm_t* device_handle_; // Handle to the ALSA PCM recording device. snd_mixer_t* mixer_handle_; // Handle to the ALSA microphone mixer. snd_mixer_elem_t* mixer_element_handle_; // Handle to the capture element. - base::WeakPtrFactory<AlsaPcmInputStream> weak_factory_; scoped_ptr<uint8[]> audio_buffer_; // Buffer used for reading audio data. bool read_callback_behind_schedule_; + // NOTE: Weak pointers must be invalidated before all other member variables. + base::WeakPtrFactory<AlsaPcmInputStream> weak_factory_; + DISALLOW_COPY_AND_ASSIGN(AlsaPcmInputStream); }; diff --git a/media/audio/alsa/alsa_output.cc b/media/audio/alsa/alsa_output.cc index 308bedc509..690d738f19 100644 --- a/media/audio/alsa/alsa_output.cc +++ b/media/audio/alsa/alsa_output.cc @@ -153,11 +153,11 @@ AlsaPcmOutputStream::AlsaPcmOutputStream(const std::string& device_name, message_loop_(base::MessageLoop::current()), playback_handle_(NULL), frames_per_packet_(packet_size_ / bytes_per_frame_), - weak_factory_(this), state_(kCreated), volume_(1.0f), source_callback_(NULL), - audio_bus_(AudioBus::Create(params)) { + audio_bus_(AudioBus::Create(params)), + weak_factory_(this) { DCHECK(manager_->GetTaskRunner()->BelongsToCurrentThread()); DCHECK_EQ(audio_bus_->frames() * bytes_per_frame_, packet_size_); diff --git a/media/audio/alsa/alsa_output.h b/media/audio/alsa/alsa_output.h index 65a23f7512..180564584c 100644 --- a/media/audio/alsa/alsa_output.h +++ b/media/audio/alsa/alsa_output.h @@ -201,10 +201,6 @@ class MEDIA_EXPORT AlsaPcmOutputStream : public AudioOutputStream { scoped_ptr<media::SeekableBuffer> buffer_; uint32 frames_per_packet_; - // Allows us to run tasks on the AlsaPcmOutputStream instance which are - // bound by its lifetime. - base::WeakPtrFactory<AlsaPcmOutputStream> weak_factory_; - InternalState state_; float volume_; // Volume level from 0.0 to 1.0. @@ -217,6 +213,11 @@ class MEDIA_EXPORT AlsaPcmOutputStream : public AudioOutputStream { scoped_ptr<ChannelMixer> channel_mixer_; scoped_ptr<AudioBus> mixed_audio_bus_; + // Allows us to run tasks on the AlsaPcmOutputStream instance which are + // bound by its lifetime. + // NOTE: Weak pointers must be invalidated before all other member variables. + base::WeakPtrFactory<AlsaPcmOutputStream> weak_factory_; + DISALLOW_COPY_AND_ASSIGN(AlsaPcmOutputStream); }; diff --git a/media/audio/audio_parameters.h b/media/audio/audio_parameters.h index b65f64fc67..b23d26fdca 100644 --- a/media/audio/audio_parameters.h +++ b/media/audio/audio_parameters.h @@ -50,6 +50,7 @@ class MEDIA_EXPORT AudioParameters { NO_EFFECTS = 0x0, ECHO_CANCELLER = 0x1, DUCKING = 0x2, // Enables ducking if the OS supports it. + KEYBOARD_MIC = 0x4, }; AudioParameters(); diff --git a/media/audio/audio_parameters_unittest.cc b/media/audio/audio_parameters_unittest.cc index f0d37129eb..390b205a09 100644 --- a/media/audio/audio_parameters_unittest.cc +++ b/media/audio/audio_parameters_unittest.cc @@ -63,6 +63,10 @@ TEST(AudioParameters, GetBytesPerBuffer) { EXPECT_EQ(800, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, 1000, 16, 200) .GetBytesPerBuffer()); + EXPECT_EQ(300, AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, + 1000, 8, 100) + .GetBytesPerBuffer()); } TEST(AudioParameters, GetBytesPerSecond) { @@ -119,6 +123,23 @@ TEST(AudioParameters, Compare) { AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, 2000, 16, 200), + AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 1000, 8, 100), + AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 1000, 8, 200), + AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 1000, 16, 100), + AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 1000, 16, 200), + AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 2000, 8, 100), + AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 2000, 8, 200), + AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 2000, 16, 100), + AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 2000, 16, 200), + AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_MONO, 1000, 8, 100), AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_MONO, @@ -152,6 +173,23 @@ TEST(AudioParameters, Compare) { CHANNEL_LAYOUT_STEREO, 2000, 16, 100), AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO, 2000, 16, 200), + + AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 1000, 8, 100), + AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 1000, 8, 200), + AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 1000, 16, 100), + AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 1000, 16, 200), + AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 2000, 8, 100), + AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 2000, 8, 200), + AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 2000, 16, 100), + AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, + CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC, 2000, 16, 200), }; for (size_t i = 0; i < arraysize(values); ++i) { |