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

Side by Side Diff: media/audio/android/opensles_input.cc

Issue 12806009: Add OpenSL configurations (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: rebase Created 7 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
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/android/opensles_input.h" 5 #include "media/audio/android/opensles_input.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/audio/android/audio_manager_android.h" 8 #include "media/audio/android/audio_manager_android.h"
9 9
10 namespace media { 10 namespace media {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 SLDataSource audio_source = { &mic_locator, NULL }; 186 SLDataSource audio_source = { &mic_locator, NULL };
187 187
188 // Audio sink configuration. 188 // Audio sink configuration.
189 SLDataLocator_AndroidSimpleBufferQueue buffer_queue = { 189 SLDataLocator_AndroidSimpleBufferQueue buffer_queue = {
190 SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, // Locator type. 190 SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE, // Locator type.
191 static_cast<SLuint32>(kNumOfQueuesInBuffer) // Number of buffers. 191 static_cast<SLuint32>(kNumOfQueuesInBuffer) // Number of buffers.
192 }; 192 };
193 SLDataSink audio_sink = { &buffer_queue, &format_ }; 193 SLDataSink audio_sink = { &buffer_queue, &format_ };
194 194
195 // Create an audio recorder. 195 // Create an audio recorder.
196 const SLuint32 number_of_interfaces = 1; 196 const SLuint32 number_of_interfaces = 2;
tommi (sloooow) - chröme 2013/03/21 14:56:44 what about: const SLInterfaceID interface_id[] = {
leozwang1 2013/03/21 15:33:35 Done.
197 const SLInterfaceID interface_id[number_of_interfaces] = { 197 const SLInterfaceID interface_id[number_of_interfaces] = {
198 SL_IID_ANDROIDSIMPLEBUFFERQUEUE 198 SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
199 SL_IID_ANDROIDCONFIGURATION
199 }; 200 };
200 const SLboolean interface_required[number_of_interfaces] = { 201 const SLboolean interface_required[number_of_interfaces] = {
202 SL_BOOLEAN_TRUE,
201 SL_BOOLEAN_TRUE 203 SL_BOOLEAN_TRUE
202 }; 204 };
203 err = (*engine)->CreateAudioRecorder(engine, 205 err = (*engine)->CreateAudioRecorder(engine,
204 recorder_object_.Receive(), 206 recorder_object_.Receive(),
205 &audio_source, 207 &audio_source,
206 &audio_sink, 208 &audio_sink,
207 number_of_interfaces, 209 number_of_interfaces,
208 interface_id, 210 interface_id,
209 interface_required); 211 interface_required);
210 DCHECK_EQ(SL_RESULT_SUCCESS, err); 212 DCHECK_EQ(SL_RESULT_SUCCESS, err);
211 if (SL_RESULT_SUCCESS != err) { 213 if (SL_RESULT_SUCCESS != err) {
212 DLOG(ERROR) << "CreateAudioRecorder failed with error code " << err; 214 DLOG(ERROR) << "CreateAudioRecorder failed with error code " << err;
213 return false; 215 return false;
214 } 216 }
215 217
218 // CreateAudioRecorder and specify SL_IID_ANDROIDCONFIGURATION.
qinmin 2013/03/21 14:56:19 create AudioRecorder
leozwang1 2013/03/21 15:33:35 Done.
219 SLAndroidConfigurationItf recorder_config;
220 err = recorder_object_->GetInterface(recorder_object_.Get(),
221 SL_IID_ANDROIDCONFIGURATION,
222 &recorder_config);
223 DCHECK_EQ(SL_RESULT_SUCCESS, err);
qinmin 2013/03/21 14:56:19 the DCHECK seems redundant with the if statement b
tommi (sloooow) - chröme 2013/03/21 14:56:44 This DCHECK and the if() that follows are contradi
leozwang1 2013/03/21 15:33:35 Done.
leozwang1 2013/03/21 15:33:35 Done.
224 if (SL_RESULT_SUCCESS != err)
225 return false;
226
227 SLint32 stream_type = SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION;
228 err = (*recorder_config)->SetConfiguration(
229 recorder_config,
230 SL_ANDROID_KEY_RECORDING_PRESET,
231 &stream_type, sizeof(SLint32));
232 DCHECK_EQ(SL_RESULT_SUCCESS, err);
qinmin 2013/03/21 14:56:19 ditto
tommi (sloooow) - chröme 2013/03/21 14:56:44 same here.
leozwang1 2013/03/21 15:33:35 Done.
leozwang1 2013/03/21 15:33:35 Done.
233 if (SL_RESULT_SUCCESS != err)
234 return false;
235
216 // Realize the recorder object in synchronous mode. 236 // Realize the recorder object in synchronous mode.
217 err = recorder_object_->Realize(recorder_object_.Get(), SL_BOOLEAN_FALSE); 237 err = recorder_object_->Realize(recorder_object_.Get(), SL_BOOLEAN_FALSE);
218 DCHECK_EQ(SL_RESULT_SUCCESS, err); 238 DCHECK_EQ(SL_RESULT_SUCCESS, err);
tommi (sloooow) - chröme 2013/03/21 14:56:44 can you fix these (and below) as well?
leozwang1 2013/03/21 15:33:35 Done.
219 if (SL_RESULT_SUCCESS != err) { 239 if (SL_RESULT_SUCCESS != err) {
220 DLOG(ERROR) << "Recprder Realize() failed with error code " << err; 240 DLOG(ERROR) << "Recprder Realize() failed with error code " << err;
221 return false; 241 return false;
222 } 242 }
223 243
224 // Get an implicit recorder interface. 244 // Get an implicit recorder interface.
225 err = recorder_object_->GetInterface(recorder_object_.Get(), 245 err = recorder_object_->GetInterface(recorder_object_.Get(),
226 SL_IID_RECORD, 246 SL_IID_RECORD,
227 &recorder_); 247 &recorder_);
228 DCHECK_EQ(SL_RESULT_SUCCESS, err); 248 DCHECK_EQ(SL_RESULT_SUCCESS, err);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 } 312 }
293 } 313 }
294 314
295 void OpenSLESInputStream::HandleError(SLresult error) { 315 void OpenSLESInputStream::HandleError(SLresult error) {
296 DLOG(FATAL) << "OpenSLES error " << error; 316 DLOG(FATAL) << "OpenSLES error " << error;
297 if (callback_) 317 if (callback_)
298 callback_->OnError(this, error); 318 callback_->OnError(this, error);
299 } 319 }
300 320
301 } // namespace media 321 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698