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

Side by Side Diff: media/audio/android/opensles_output.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_output.h" 5 #include "media/audio/android/opensles_output.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/audio/audio_util.h" 8 #include "media/audio/audio_util.h"
9 #include "media/audio/android/audio_manager_android.h" 9 #include "media/audio/android/audio_manager_android.h"
10 10
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 }; 184 };
185 SLDataSource audio_source = { &simple_buffer_queue, &format_ }; 185 SLDataSource audio_source = { &simple_buffer_queue, &format_ };
186 186
187 // Audio sink configuration. 187 // Audio sink configuration.
188 SLDataLocator_OutputMix locator_output_mix = { 188 SLDataLocator_OutputMix locator_output_mix = {
189 SL_DATALOCATOR_OUTPUTMIX, output_mixer_.Get() 189 SL_DATALOCATOR_OUTPUTMIX, output_mixer_.Get()
190 }; 190 };
191 SLDataSink audio_sink = { &locator_output_mix, NULL }; 191 SLDataSink audio_sink = { &locator_output_mix, NULL };
192 192
193 // Create an audio player. 193 // Create an audio player.
194 const SLuint32 number_of_interfaces = 1; 194 const SLuint32 number_of_interfaces = 3;
tommi (sloooow) - chröme 2013/03/21 14:56:44 could use arraysize() here.
leozwang1 2013/03/21 15:33:35 Done.
195 const SLInterfaceID interface_id[number_of_interfaces] = { 195 const SLInterfaceID interface_id[number_of_interfaces] = {
196 SL_IID_BUFFERQUEUE 196 SL_IID_BUFFERQUEUE,
197 SL_IID_VOLUME,
198 SL_IID_ANDROIDCONFIGURATION
197 }; 199 };
198 const SLboolean interface_required[number_of_interfaces] = { 200 const SLboolean interface_required[number_of_interfaces] = {
201 SL_BOOLEAN_TRUE,
202 SL_BOOLEAN_TRUE,
199 SL_BOOLEAN_TRUE 203 SL_BOOLEAN_TRUE
200 }; 204 };
201 err = (*engine)->CreateAudioPlayer(engine, 205 err = (*engine)->CreateAudioPlayer(engine,
202 player_object_.Receive(), 206 player_object_.Receive(),
203 &audio_source, 207 &audio_source,
204 &audio_sink, 208 &audio_sink,
205 number_of_interfaces, 209 number_of_interfaces,
206 interface_id, 210 interface_id,
207 interface_required); 211 interface_required);
208 DCHECK_EQ(SL_RESULT_SUCCESS, err); 212 DCHECK_EQ(SL_RESULT_SUCCESS, err);
209 if (SL_RESULT_SUCCESS != err) { 213 if (SL_RESULT_SUCCESS != err) {
210 DLOG(ERROR) << "CreateAudioPlayer() failed with error code " << err; 214 DLOG(ERROR) << "CreateAudioPlayer() failed with error code " << err;
211 return false; 215 return false;
212 } 216 }
213 217
218 // CreateAudioPlayer and specify SL_IID_ANDROIDCONFIGURATION.
qinmin 2013/03/21 14:56:19 white space in CreateAudioPlayer
leozwang1 2013/03/21 15:33:35 Done.
219 SLAndroidConfigurationItf player_config;
220 err = player_object_->GetInterface(player_object_.Get(),
221 SL_IID_ANDROIDCONFIGURATION,
222 &player_config);
223 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 thing for DCHECK vs if()
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_STREAM_VOICE;
228 err = (*player_config)->SetConfiguration(player_config,
229 SL_ANDROID_KEY_STREAM_TYPE,
230 &stream_type, sizeof(SLint32));
231 DCHECK_EQ(SL_RESULT_SUCCESS, err);
qinmin 2013/03/21 14:56:19 ditto
leozwang1 2013/03/21 15:33:35 Done.
232 if (SL_RESULT_SUCCESS != err)
233 return false;
234
214 // Realize the player object in synchronous mode. 235 // Realize the player object in synchronous mode.
215 err = player_object_->Realize(player_object_.Get(), SL_BOOLEAN_FALSE); 236 err = player_object_->Realize(player_object_.Get(), SL_BOOLEAN_FALSE);
216 DCHECK_EQ(SL_RESULT_SUCCESS, err); 237 DCHECK_EQ(SL_RESULT_SUCCESS, err);
217 if (SL_RESULT_SUCCESS != err) { 238 if (SL_RESULT_SUCCESS != err) {
218 DLOG(ERROR) << "Player Realize() failed with error code " << err; 239 DLOG(ERROR) << "Player Realize() failed with error code " << err;
219 return false; 240 return false;
220 } 241 }
221 242
222 // Get an implicit player interface. 243 // Get an implicit player interface.
223 err = player_object_->GetInterface( 244 err = player_object_->GetInterface(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 325 }
305 } 326 }
306 327
307 void OpenSLESOutputStream::HandleError(SLresult error) { 328 void OpenSLESOutputStream::HandleError(SLresult error) {
308 DLOG(ERROR) << "OpenSLES error " << error; 329 DLOG(ERROR) << "OpenSLES error " << error;
309 if (callback_) 330 if (callback_)
310 callback_->OnError(this, error); 331 callback_->OnError(this, error);
311 } 332 }
312 333
313 } // namespace media 334 } // namespace media
OLDNEW
« media/audio/android/opensles_input.cc ('K') | « media/audio/android/opensles_input.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698