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

Side by Side 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: Moved factory to content/renderer/media 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
6 #define CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
7 #pragma once
8
9 #include "base/compiler_specific.h"
10 #include "base/logging.h"
11 #include "media/base/audio_renderer_sink.h"
12
13 // Factory interface for AudioRendererSink implementations.
14 class AudioDeviceFactoryInterface {
15 public:
16 virtual media::AudioRendererSink* Create() = 0;
17 virtual ~AudioDeviceFactoryInterface() {}
18 };
19
20 // AudioDeviceFactoryInterface implementation.
21 // A reference to an instance of this class can be provided to users/clients
22 // of audio devices. The user can then create the specified audio device.
23 //
24 // Pseudo code:
25 //
26 // scoped_ptr<AudioDeviceFactoryInterface> factory_;
27 // scoped_ptr<MockedAudioMessageFilter> filter_;
28 // scoped_ptr<AudioDeviceClient> client_;
29 //
30 // filter_.reset(new MockedAudioMessageFilter());
31 // factory_.reset(
32 // new media::AudioDeviceFactory<AudioDevice, MockedAudioMessageFilter>(
33 // filter_));
34 // client_.reset(new AudioDeviceClient(audio_params, factory_.get()));
35 //
36 // class AudioDeviceClient : public media::AudioRendererSink::RenderCallback {
37 // public:
38 // AudioDeviceClient::AudioDeviceClient(const AudioParameters& params,
39 // AudioDeviceFactoryInterface* factory)
40 // : audio_device_(factory->Create()) {
41 // audio_device_->Initialize(params, this);
42 // }
43 //
44 // private:
45 // scoped_refptr<media::AudioRendererSink> audio_device_;
46 // }
47 //
48 template<typename AudioDeviceImplementation,
49 typename AudioMessageFilterImplementation>
50 class AudioDeviceFactory : public AudioDeviceFactoryInterface {
51 public:
52 explicit AudioDeviceFactory(AudioMessageFilterImplementation* filter)
53 : filter_(filter) {
54 CHECK(filter_);
55 }
56 virtual ~AudioDeviceFactory() {}
57
58 // Creates the AudioRendererSink implementation and injects the cached
59 // audio message filter.
60 virtual media::AudioRendererSink* Create() OVERRIDE {
61 return new AudioDeviceImplementation(filter_);
62 }
63
64 private:
65 AudioMessageFilterImplementation* filter_;
66 DISALLOW_COPY_AND_ASSIGN(AudioDeviceFactory);
67 };
68
69 #endif // CONTENT_RENDERER_MEDIA_AUDIO_DEVICE_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698