Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1987)

Unified Diff: content/renderer/media/webrtc_audio_device_impl.cc

Issue 10537121: Adds AudioDevice factory for all audio clients in Chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed DVLOGs Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/webrtc_audio_device_impl.cc
diff --git a/content/renderer/media/webrtc_audio_device_impl.cc b/content/renderer/media/webrtc_audio_device_impl.cc
index 37d2f3d6aeaba6d77bb7d890f373bb8e0d98a75c..85f3629652afd1048e01760f42f83d277450c290 100644
--- a/content/renderer/media/webrtc_audio_device_impl.cc
+++ b/content/renderer/media/webrtc_audio_device_impl.cc
@@ -8,6 +8,7 @@
#include "base/metrics/histogram.h"
#include "base/string_util.h"
#include "base/win/windows_version.h"
+#include "content/renderer/media/audio_device_factory.h"
#include "content/renderer/media/audio_hardware.h"
#include "content/renderer/render_thread_impl.h"
#include "media/audio/audio_util.h"
@@ -126,7 +127,8 @@ static void AddHistogramFramesPerBuffer(HistogramDirection dir, int param) {
}
}
-WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()
+WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl(
+ AudioDeviceFactoryInterface* audio_device_factory)
: ref_count_(0),
render_loop_(base::MessageLoopProxy::current()),
audio_transport_callback_(NULL),
@@ -141,8 +143,13 @@ WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()
recording_(false),
agc_is_enabled_(false) {
DVLOG(1) << "WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()";
+ DCHECK(audio_device_factory);
+ // TODO(henrika): remove this restriction when factory is used for the
+ // input side as well.
DCHECK(RenderThreadImpl::current()) <<
"WebRtcAudioDeviceImpl must be constructed on the render thread";
+ audio_output_device_ = audio_device_factory->Create();
+ DCHECK(audio_output_device_);
}
WebRtcAudioDeviceImpl::~WebRtcAudioDeviceImpl() {
@@ -410,7 +417,6 @@ int32_t WebRtcAudioDeviceImpl::Init() {
return 0;
DCHECK(!audio_input_device_);
- DCHECK(!audio_output_device_);
DCHECK(!input_buffer_.get());
DCHECK(!output_buffer_.get());
@@ -583,11 +589,10 @@ int32_t WebRtcAudioDeviceImpl::Init() {
AddHistogramFramesPerBuffer(kAudioOutput, out_buffer_size);
AddHistogramFramesPerBuffer(kAudioInput, in_buffer_size);
- // Create and configure the audio rendering client.
- audio_output_device_ = new AudioDevice(output_audio_parameters_, this);
+ // Configure the audio rendering client.
+ audio_output_device_->Initialize(output_audio_parameters_, this);
DCHECK(audio_input_device_);
- DCHECK(audio_output_device_);
// Allocate local audio buffers based on the parameters above.
// It is assumed that each audio sample contains 16 bits and each
@@ -627,13 +632,11 @@ int32_t WebRtcAudioDeviceImpl::Terminate() {
return 0;
DCHECK(audio_input_device_);
- DCHECK(audio_output_device_);
DCHECK(input_buffer_.get());
DCHECK(output_buffer_.get());
// Release all resources allocated in Init().
audio_input_device_ = NULL;
- audio_output_device_ = NULL;
input_buffer_.reset();
output_buffer_.reset();
@@ -697,7 +700,7 @@ int32_t WebRtcAudioDeviceImpl::SetRecordingDevice(WindowsDeviceType device) {
int32_t WebRtcAudioDeviceImpl::PlayoutIsAvailable(bool* available) {
DVLOG(1) << "PlayoutIsAvailable()";
- *available = (audio_output_device_ != NULL);
+ *available = initialized();
return 0;
}
@@ -709,7 +712,7 @@ int32_t WebRtcAudioDeviceImpl::InitPlayout() {
bool WebRtcAudioDeviceImpl::PlayoutIsInitialized() const {
DVLOG(1) << "PlayoutIsInitialized()";
- return (audio_output_device_ != NULL);
+ return initialized();
}
int32_t WebRtcAudioDeviceImpl::RecordingIsAvailable(bool* available) {

Powered by Google App Engine
This is Rietveld 408576698