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

Unified Diff: content/renderer/media/audio_device_factory.h

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/audio_device_factory.h
diff --git a/content/renderer/media/audio_device_factory.h b/content/renderer/media/audio_device_factory.h
new file mode 100644
index 0000000000000000000000000000000000000000..289a85dc3decdb895c813c63b380df6892feb596
--- /dev/null
+++ b/content/renderer/media/audio_device_factory.h
@@ -0,0 +1,71 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
+#define CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "base/logging.h"
+#include "content/common/content_export.h"
+#include "media/base/audio_renderer_sink.h"
+
+// Factory interface for AudioRendererSink implementations.
+class AudioDeviceFactoryInterface {
+ public:
+ virtual media::AudioRendererSink* Create() = 0;
+ virtual ~AudioDeviceFactoryInterface() {}
+};
+
+// AudioDeviceFactoryInterface implementation.
+// A reference to an instance of this class can be provided to users/clients
+// of audio devices. The user can then create the specified audio device.
+//
+// Pseudo code:
+//
+// scoped_ptr<AudioDeviceFactoryInterface> factory_;
+// scoped_ptr<MockedAudioMessageFilter> filter_;
+// scoped_ptr<AudioDeviceClient> client_;
+//
+// filter_.reset(new MockedAudioMessageFilter());
+// factory_.reset(
+// new media::AudioDeviceFactory<AudioDevice, MockedAudioMessageFilter>(
+// filter_));
+// client_.reset(new AudioDeviceClient(audio_params, factory_.get()));
+//
+// class AudioDeviceClient : public media::AudioRendererSink::RenderCallback {
+// public:
+// AudioDeviceClient::AudioDeviceClient(const AudioParameters& params,
+// AudioDeviceFactoryInterface* factory)
+// : audio_device_(factory->Create()) {
+// audio_device_->Initialize(params, this);
+// }
+//
+// private:
+// scoped_refptr<media::AudioRendererSink> audio_device_;
+// }
+//
+template<typename AudioDeviceImplementation,
+ typename AudioMessageFilterImplementation>
+class AudioDeviceFactory
+ : public AudioDeviceFactoryInterface {
+ public:
+ explicit AudioDeviceFactory(AudioMessageFilterImplementation* filter)
+ : filter_(filter) {
+ CHECK(filter_);
+ }
+ virtual ~AudioDeviceFactory() {}
+
+ // Creates the AudioRendererSink implementation and injects the cached
+ // audio message filter.
+ virtual media::AudioRendererSink* Create() OVERRIDE {
+ return new AudioDeviceImplementation(filter_);
+ }
+
+ private:
+ AudioMessageFilterImplementation* filter_;
+ DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory);
+};
+
+#endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_

Powered by Google App Engine
This is Rietveld 408576698