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

Side by Side Diff: content/renderer/media/audio_renderer_mixer_manager.h

Issue 11359196: Associate audio streams with their source/destination RenderView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased; and numerous clean-ups. Created 8 years 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_
6 #define CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ 6 #define CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 #include "media/audio/audio_parameters.h" 12 #include "media/audio/audio_parameters.h"
13 #include "media/base/audio_renderer_sink.h"
13 14
14 namespace media { 15 namespace media {
15 class AudioRendererMixer; 16 class AudioRendererMixer;
16 class AudioRendererMixerInput; 17 class AudioRendererMixerInput;
17 } 18 }
18 19
19 namespace content { 20 namespace content {
20 21
21 // Manages sharing of an AudioRendererMixer among AudioRendererMixerInputs based 22 // Manages sharing of an AudioRendererMixer among AudioRendererMixerInputs based
22 // on their AudioParameters configuration. Inputs with the same AudioParameters 23 // on their AudioParameters configuration. Inputs with the same AudioParameters
23 // configuration will share a mixer while a new AudioRendererMixer will be 24 // configuration will share a mixer while a new AudioRendererMixer will be
24 // lazily created if one with the exact AudioParameters does not exist. 25 // lazily created if one with the exact AudioParameters does not exist.
25 // 26 //
26 // There should only be one instance of AudioRendererMixerManager per render 27 // There should only be one instance of AudioRendererMixerManager per render
27 // thread. 28 // thread.
28 // 29 //
29 // TODO(dalecurtis): Right now we require AudioParameters to be an exact match 30 // TODO(dalecurtis): Right now we require AudioParameters to be an exact match
30 // when we should be able to ignore bits per channel since we're only dealing 31 // when we should be able to ignore bits per channel since we're only dealing
31 // with floats. However, bits per channel is currently used to interleave the 32 // with floats. However, bits per channel is currently used to interleave the
32 // audio data by AudioOutputDevice::AudioThreadCallback::Process for consumption 33 // audio data by AudioOutputDevice::AudioThreadCallback::Process for consumption
33 // via the shared memory. See http://crbug.com/114700. 34 // via the shared memory. See http://crbug.com/114700.
34 class CONTENT_EXPORT AudioRendererMixerManager { 35 class CONTENT_EXPORT AudioRendererMixerManager {
35 public: 36 public:
36 // Construct an instance using the given audio hardware configuration. 37 // Construct an instance using the given audio hardware configuration.
37 AudioRendererMixerManager(int hardware_sample_rate, int hardware_buffer_size); 38 AudioRendererMixerManager(int hardware_sample_rate, int hardware_buffer_size);
38 ~AudioRendererMixerManager(); 39 virtual ~AudioRendererMixerManager();
scherkus (not reviewing) 2012/11/27 22:55:26 sadness. why not add a SetAudioRendererSinkForTes
miu 2012/11/28 07:26:20 Done.
39 40
40 // Creates an AudioRendererMixerInput with the proper callbacks necessary to 41 // Creates an AudioRendererMixerInput with the proper callbacks necessary to
41 // retrieve an AudioRendererMixer instance from AudioRendererMixerManager. 42 // retrieve an AudioRendererMixer instance from AudioRendererMixerManager.
42 // Caller must ensure AudioRendererMixerManager outlives the returned input. 43 // Caller must ensure AudioRendererMixerManager outlives the returned input.
43 media::AudioRendererMixerInput* CreateInput(); 44 media::AudioRendererMixerInput* CreateInput();
44 45
45 private: 46 private:
46 friend class AudioRendererMixerManagerTest; 47 friend class AudioRendererMixerManagerTest;
47 48
49 // Returns a new instance connected to the underlying audio implementation.
50 // This method is overridden for unit testing.
51 virtual media::AudioRendererSink* CreateAudioRendererSink();
52
48 // Returns a mixer instance based on AudioParameters; an existing one if one 53 // Returns a mixer instance based on AudioParameters; an existing one if one
49 // with the provided AudioParameters exists or a new one if not. 54 // with the provided AudioParameters exists or a new one if not.
50 media::AudioRendererMixer* GetMixer(const media::AudioParameters& params); 55 media::AudioRendererMixer* GetMixer(const media::AudioParameters& params);
51 56
52 // Remove a mixer instance given a mixer if the only other reference is held 57 // Remove a mixer instance given a mixer if the only other reference is held
53 // by AudioRendererMixerManager. Every AudioRendererMixer owner must call 58 // by AudioRendererMixerManager. Every AudioRendererMixer owner must call
54 // this method when it's done with a mixer. 59 // this method when it's done with a mixer.
55 void RemoveMixer(const media::AudioParameters& params); 60 void RemoveMixer(const media::AudioParameters& params);
56 61
57 // Map of AudioParameters to <AudioRendererMixer, Count>. Count allows 62 // Map of AudioParameters to <AudioRendererMixer, Count>. Count allows
(...skipping 12 matching lines...) Expand all
70 // each AudioRendererMixer instance. 75 // each AudioRendererMixer instance.
71 int hardware_sample_rate_; 76 int hardware_sample_rate_;
72 int hardware_buffer_size_; 77 int hardware_buffer_size_;
73 78
74 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManager); 79 DISALLOW_COPY_AND_ASSIGN(AudioRendererMixerManager);
75 }; 80 };
76 81
77 } // namespace content 82 } // namespace content
78 83
79 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_ 84 #endif // CONTENT_RENDERER_MEDIA_AUDIO_RENDERER_MIXER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698