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

Side by Side Diff: media/audio/audio_manager_base.h

Issue 9570014: Move some generic functions to AudioManagerBase to be inherited by platform-specific AudioManager*** (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix the memory leak in the alsa unittests Created 8 years, 9 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
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 MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_
6 #define MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ 6 #define MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/atomic_ref_count.h" 10 #include "base/atomic_ref_count.h"
(...skipping 20 matching lines...) Expand all
31 31
32 virtual void Init() OVERRIDE; 32 virtual void Init() OVERRIDE;
33 33
34 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE; 34 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE;
35 35
36 virtual string16 GetAudioInputDeviceModel() OVERRIDE; 36 virtual string16 GetAudioInputDeviceModel() OVERRIDE;
37 37
38 virtual bool CanShowAudioInputSettings() OVERRIDE; 38 virtual bool CanShowAudioInputSettings() OVERRIDE;
39 virtual void ShowAudioInputSettings() OVERRIDE; 39 virtual void ShowAudioInputSettings() OVERRIDE;
40 40
41 virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) 41 virtual void GetAudioInputDeviceNames(
42 OVERRIDE; 42 media::AudioDeviceNames* device_names) OVERRIDE;
43
44 virtual AudioOutputStream* MakeAudioOutputStream(
45 const AudioParameters& params) OVERRIDE;
46
47 virtual AudioInputStream* MakeAudioInputStream(
48 const AudioParameters& params, const std::string& device_id) OVERRIDE;
43 49
44 virtual AudioOutputStream* MakeAudioOutputStreamProxy( 50 virtual AudioOutputStream* MakeAudioOutputStreamProxy(
45 const AudioParameters& params) OVERRIDE; 51 const AudioParameters& params) OVERRIDE;
46 52
47 virtual bool IsRecordingInProcess() OVERRIDE; 53 virtual bool IsRecordingInProcess() OVERRIDE;
48 54
55 // Called internally by the audio stream when it has been closed.
56 virtual void ReleaseOutputStream(AudioOutputStream* stream);
57 virtual void ReleaseInputStream(AudioInputStream* stream);
58
49 void IncreaseActiveInputStreamCount(); 59 void IncreaseActiveInputStreamCount();
50 void DecreaseActiveInputStreamCount(); 60 void DecreaseActiveInputStreamCount();
51 61
52 // Shuts down the audio thread and releases all the audio output dispatchers 62 // Shuts down the audio thread and releases all the audio output dispatchers
53 // on the audio thread. All AudioOutputProxy instances should be freed before 63 // on the audio thread. All AudioOutputProxy instances should be freed before
54 // Shutdown is called. 64 // Shutdown is called.
55 void Shutdown(); 65 void Shutdown();
56 66
67 // Returns the platform specific number of audio streams allowed. This is a
68 // practical limit to prevent failure caused by too many audio streams opened.
69 virtual int GetMaxAudioOutputStreamsAllowed() = 0;
70
71 virtual AudioOutputStream* MakeAudioLinearOutputStream(
72 const AudioParameters& params) = 0;
73
74 virtual AudioOutputStream* MakeAudioLowLatencyOutputStream(
75 const AudioParameters& params) = 0;
76
77 virtual AudioInputStream* MakeAudioLinearInputStream(
78 const AudioParameters& params, const std::string& device_id) = 0;
79
80 virtual AudioInputStream* MakeAudioLowLatencyInputStream(
81 const AudioParameters& params, const std::string& device_id) = 0;
82
57 protected: 83 protected:
58 AudioManagerBase(); 84 AudioManagerBase();
59 85
60 typedef std::map<AudioParameters, scoped_refptr<AudioOutputDispatcher>, 86 typedef std::map<AudioParameters, scoped_refptr<AudioOutputDispatcher>,
61 AudioParameters::Compare> 87 AudioParameters::Compare>
62 AudioOutputDispatchersMap; 88 AudioOutputDispatchersMap;
63 89
64 void ShutdownOnAudioThread(); 90 void ShutdownOnAudioThread();
65 91
66 // Thread used to interact with AudioOutputStreams created by this 92 // Thread used to interact with AudioOutputStreams created by this
67 // audio manger. 93 // audio manger.
68 scoped_ptr<base::Thread> audio_thread_; 94 scoped_ptr<base::Thread> audio_thread_;
69 mutable base::Lock audio_thread_lock_; 95 mutable base::Lock audio_thread_lock_;
70 96
71 // Map of cached AudioOutputDispatcher instances. Must only be touched 97 // Map of cached AudioOutputDispatcher instances. Must only be touched
72 // from the audio thread (no locking). 98 // from the audio thread (no locking).
73 AudioOutputDispatchersMap output_dispatchers_; 99 AudioOutputDispatchersMap output_dispatchers_;
74 100
75 // Counts the number of active input streams to find out if something else 101 // Counts the number of active input streams to find out if something else
76 // is currently recording in Chrome. 102 // is currently recording in Chrome.
77 base::AtomicRefCount num_active_input_streams_; 103 base::AtomicRefCount num_active_input_streams_;
78 104
105 // Number of currently open output streams.
106 int num_output_streams_;
107
79 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase); 108 DISALLOW_COPY_AND_ASSIGN(AudioManagerBase);
80 }; 109 };
81 110
82 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_ 111 #endif // MEDIA_AUDIO_AUDIO_MANAGER_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698