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

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

Issue 9655018: Make AudioParameters a class instead of a struct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright years 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
« no previous file with comments | « media/audio/audio_input_volume_unittest.cc ('k') | media/audio/audio_output_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "media/audio/audio_manager_base.h" 5 #include "media/audio/audio_manager_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "media/audio/audio_output_dispatcher.h" 10 #include "media/audio/audio_output_dispatcher.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // See bug: http://crbug.com/30242. 77 // See bug: http://crbug.com/30242.
78 if (num_output_streams_ >= max_num_output_streams_) { 78 if (num_output_streams_ >= max_num_output_streams_) {
79 DLOG(ERROR) << "Number of opened output audio streams " 79 DLOG(ERROR) << "Number of opened output audio streams "
80 << num_output_streams_ 80 << num_output_streams_
81 << " exceed the max allowed number " 81 << " exceed the max allowed number "
82 << max_num_output_streams_; 82 << max_num_output_streams_;
83 return NULL; 83 return NULL;
84 } 84 }
85 85
86 AudioOutputStream* stream = NULL; 86 AudioOutputStream* stream = NULL;
87 if (params.format == AudioParameters::AUDIO_MOCK) { 87 if (params.format() == AudioParameters::AUDIO_MOCK) {
88 stream = FakeAudioOutputStream::MakeFakeStream(this, params); 88 stream = FakeAudioOutputStream::MakeFakeStream(this, params);
89 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { 89 } else if (params.format() == AudioParameters::AUDIO_PCM_LINEAR) {
90 stream = MakeLinearOutputStream(params); 90 stream = MakeLinearOutputStream(params);
91 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { 91 } else if (params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) {
92 stream = MakeLowLatencyOutputStream(params); 92 stream = MakeLowLatencyOutputStream(params);
93 } 93 }
94 94
95 if (stream) 95 if (stream)
96 ++num_output_streams_; 96 ++num_output_streams_;
97 97
98 return stream; 98 return stream;
99 } 99 }
100 100
101 AudioInputStream* AudioManagerBase::MakeAudioInputStream( 101 AudioInputStream* AudioManagerBase::MakeAudioInputStream(
102 const AudioParameters& params, const std::string& device_id) { 102 const AudioParameters& params, const std::string& device_id) {
103 if (!params.IsValid() || (params.channels > kMaxInputChannels) || 103 if (!params.IsValid() || (params.channels() > kMaxInputChannels) ||
104 device_id.empty()) { 104 device_id.empty()) {
105 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id; 105 DLOG(ERROR) << "Audio parameters are invalid for device " << device_id;
106 return NULL; 106 return NULL;
107 } 107 }
108 108
109 if (num_input_streams_ >= max_num_input_streams_) { 109 if (num_input_streams_ >= max_num_input_streams_) {
110 DLOG(ERROR) << "Number of opened input audio streams " 110 DLOG(ERROR) << "Number of opened input audio streams "
111 << num_input_streams_ 111 << num_input_streams_
112 << " exceed the max allowed number " << max_num_input_streams_; 112 << " exceed the max allowed number " << max_num_input_streams_;
113 return NULL; 113 return NULL;
114 } 114 }
115 115
116 AudioInputStream* stream = NULL; 116 AudioInputStream* stream = NULL;
117 if (params.format == AudioParameters::AUDIO_MOCK) { 117 if (params.format() == AudioParameters::AUDIO_MOCK) {
118 stream = FakeAudioInputStream::MakeFakeStream(this, params); 118 stream = FakeAudioInputStream::MakeFakeStream(this, params);
119 } else if (params.format == AudioParameters::AUDIO_PCM_LINEAR) { 119 } else if (params.format() == AudioParameters::AUDIO_PCM_LINEAR) {
120 stream = MakeLinearInputStream(params, device_id); 120 stream = MakeLinearInputStream(params, device_id);
121 } else if (params.format == AudioParameters::AUDIO_PCM_LOW_LATENCY) { 121 } else if (params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) {
122 stream = MakeLowLatencyInputStream(params, device_id); 122 stream = MakeLowLatencyInputStream(params, device_id);
123 } 123 }
124 124
125 if (stream) 125 if (stream)
126 ++num_input_streams_; 126 ++num_input_streams_;
127 127
128 return stream; 128 return stream;
129 } 129 }
130 130
131 AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy( 131 AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy(
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 // both physical audio stream objects that belong to the dispatcher as 219 // both physical audio stream objects that belong to the dispatcher as
220 // well as the message loop of the audio thread that will soon go away. 220 // well as the message loop of the audio thread that will soon go away.
221 // So, better crash now than later. 221 // So, better crash now than later.
222 CHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive"; 222 CHECK(dispatcher->HasOneRef()) << "AudioOutputProxies are still alive";
223 dispatcher = NULL; 223 dispatcher = NULL;
224 } 224 }
225 } 225 }
226 226
227 output_dispatchers_.clear(); 227 output_dispatchers_.clear();
228 } 228 }
OLDNEW
« no previous file with comments | « media/audio/audio_input_volume_unittest.cc ('k') | media/audio/audio_output_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698