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

Side by Side Diff: media/audio/linux/audio_manager_linux.cc

Issue 5350003: Move audio output number limit to AudioManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "media/audio/linux/audio_manager_linux.h" 5 #include "media/audio/linux/audio_manager_linux.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/audio/audio_output_dispatcher.h" 9 #include "media/audio/audio_output_dispatcher.h"
10 #include "media/audio/fake_audio_input_stream.h" 10 #include "media/audio/fake_audio_input_stream.h"
11 #include "media/audio/fake_audio_output_stream.h" 11 #include "media/audio/fake_audio_output_stream.h"
12 #include "media/audio/linux/alsa_input.h" 12 #include "media/audio/linux/alsa_input.h"
13 #include "media/audio/linux/alsa_output.h" 13 #include "media/audio/linux/alsa_output.h"
14 #include "media/audio/linux/alsa_wrapper.h" 14 #include "media/audio/linux/alsa_wrapper.h"
15 #include "media/base/limits.h" 15 #include "media/base/limits.h"
16 #include "media/base/media_switches.h" 16 #include "media/base/media_switches.h"
17 17
18 namespace { 18 namespace {
19 19
20 // Maximum number of output streams that can be open simultaneously.
21 const size_t kMaxOutputStreams = 50;
22
20 const int kMaxInputChannels = 2; 23 const int kMaxInputChannels = 2;
21 24
22 } // namespace 25 } // namespace
23 26
24 // Implementation of AudioManager. 27 // Implementation of AudioManager.
25 bool AudioManagerLinux::HasAudioOutputDevices() { 28 bool AudioManagerLinux::HasAudioOutputDevices() {
26 // TODO(ajwong): Make this actually query audio devices. 29 // TODO(ajwong): Make this actually query audio devices.
27 return true; 30 return true;
28 } 31 }
29 32
30 bool AudioManagerLinux::HasAudioInputDevices() { 33 bool AudioManagerLinux::HasAudioInputDevices() {
31 // TODO(satish): Make this actually query audio devices. 34 // TODO(satish): Make this actually query audio devices.
32 return true; 35 return true;
33 } 36 }
34 37
35 AudioOutputStream* AudioManagerLinux::MakeAudioOutputStream( 38 AudioOutputStream* AudioManagerLinux::MakeAudioOutputStream(
36 AudioParameters params) { 39 AudioParameters params) {
37 // Early return for testing hook. Do this before checking for 40 // Early return for testing hook. Do this before checking for
38 // |initialized_|. 41 // |initialized_|.
39 if (params.format == AudioParameters::AUDIO_MOCK) { 42 if (params.format == AudioParameters::AUDIO_MOCK) {
40 return FakeAudioOutputStream::MakeFakeStream(params); 43 return FakeAudioOutputStream::MakeFakeStream(params);
41 } 44 }
42 45
43 if (!initialized()) { 46 if (!initialized()) {
44 return NULL; 47 return NULL;
45 } 48 }
46 49
50 // Don't allow opening more than |kMaxOutputStreams| streams.
51 if (active_streams_.size() >= kMaxOutputStreams) {
52 return NULL;
53 }
54
47 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice; 55 std::string device_name = AlsaPcmOutputStream::kAutoSelectDevice;
48 if (CommandLine::ForCurrentProcess()->HasSwitch( 56 if (CommandLine::ForCurrentProcess()->HasSwitch(
49 switches::kAlsaOutputDevice)) { 57 switches::kAlsaOutputDevice)) {
50 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 58 device_name = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
51 switches::kAlsaOutputDevice); 59 switches::kAlsaOutputDevice);
52 } 60 }
53 AlsaPcmOutputStream* stream = 61 AlsaPcmOutputStream* stream =
54 new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this, 62 new AlsaPcmOutputStream(device_name, params, wrapper_.get(), this,
55 GetMessageLoop()); 63 GetMessageLoop());
56 64
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if (stream) { 127 if (stream) {
120 AutoLock l(lock_); 128 AutoLock l(lock_);
121 active_streams_.erase(stream); 129 active_streams_.erase(stream);
122 } 130 }
123 } 131 }
124 132
125 // static 133 // static
126 AudioManager* AudioManager::CreateAudioManager() { 134 AudioManager* AudioManager::CreateAudioManager() {
127 return new AudioManagerLinux(); 135 return new AudioManagerLinux();
128 } 136 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/audio_renderer_host.cc ('k') | media/audio/mac/audio_manager_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698