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

Unified Diff: media/audio/android/opensles_output.cc

Issue 12806009: Add OpenSL configurations (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: add opensles_outtput.h 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 side-by-side diff with in-line comments
Download patch
Index: media/audio/android/opensles_output.cc
===================================================================
--- media/audio/android/opensles_output.cc (revision 189519)
+++ media/audio/android/opensles_output.cc (working copy)
@@ -79,7 +79,6 @@
// Start streaming data by setting the play state to |SL_PLAYSTATE_PLAYING|.
SLresult err = (*player_)->SetPlayState(player_, SL_PLAYSTATE_PLAYING);
- DCHECK_EQ(SL_RESULT_SUCCESS, err);
if (SL_RESULT_SUCCESS != err) {
DLOG(WARNING) << "SetPlayState() failed to start playing";
Ami GONE FROM CHROMIUM 2013/03/22 16:24:41 Why is this a WARNING when the rest of the failure
}
@@ -141,24 +140,27 @@
};
SLresult err = slCreateEngine(engine_object_.Receive(), 1, option, 0,
NULL, NULL);
- DCHECK_EQ(SL_RESULT_SUCCESS, err);
- if (SL_RESULT_SUCCESS != err)
+ if (SL_RESULT_SUCCESS != err) {
+ DLOG(ERROR) << "CreatePlayer slCreateEngine: " << err;
Ami GONE FROM CHROMIUM 2013/03/22 16:24:41 When there is this much duplicated code, it's usua
leozwang1 2013/03/23 07:00:39 Done.
return false;
+ }
// Realize the SL engine object in synchronous mode.
err = engine_object_->Realize(engine_object_.Get(), SL_BOOLEAN_FALSE);
- DCHECK_EQ(SL_RESULT_SUCCESS, err);
- if (SL_RESULT_SUCCESS != err)
+ if (SL_RESULT_SUCCESS != err) {
+ DLOG(ERROR) << "CreatePlayer Realize: " << err;
return false;
+ }
// Get the SL engine interface which is implicit.
SLEngineItf engine;
err = engine_object_->GetInterface(engine_object_.Get(),
SL_IID_ENGINE,
&engine);
- DCHECK_EQ(SL_RESULT_SUCCESS, err);
- if (SL_RESULT_SUCCESS != err)
+ if (SL_RESULT_SUCCESS != err) {
+ DLOG(ERROR) << "GetInterface(SL_IID_ENGINE): " << err;
Ami GONE FROM CHROMIUM 2013/03/22 16:24:41 These log messages are pretty inconsistent; some h
leozwang1 2013/03/23 07:00:39 Done.
return false;
+ }
// Create ouput mixer object to be used by the player.
// TODO(xians): Do we need the environmental reverb auxiliary effect?
@@ -167,15 +169,17 @@
0,
NULL,
NULL);
- DCHECK_EQ(SL_RESULT_SUCCESS, err);
- if (SL_RESULT_SUCCESS != err)
+ if (SL_RESULT_SUCCESS != err) {
+ DLOG(ERROR) << "CreateOutputMix: " << err;
return false;
+ }
// Realizing the output mix object in synchronous mode.
err = output_mixer_->Realize(output_mixer_.Get(), SL_BOOLEAN_FALSE);
- DCHECK_EQ(SL_RESULT_SUCCESS, err);
- if (SL_RESULT_SUCCESS != err)
+ if (SL_RESULT_SUCCESS != err) {
+ DLOG(ERROR) << "mixer Realize: " << err;
return false;
+ }
// Audio source configuration.
SLDataLocator_AndroidSimpleBufferQueue simple_buffer_queue = {
@@ -191,11 +195,15 @@
SLDataSink audio_sink = { &locator_output_mix, NULL };
// Create an audio player.
- const SLuint32 number_of_interfaces = 1;
- const SLInterfaceID interface_id[number_of_interfaces] = {
- SL_IID_BUFFERQUEUE
+ const SLInterfaceID interface_id[] = {
+ SL_IID_BUFFERQUEUE,
+ SL_IID_VOLUME,
+ SL_IID_ANDROIDCONFIGURATION
};
+ const SLuint32 number_of_interfaces = arraysize(interface_id);
Ami GONE FROM CHROMIUM 2013/03/22 16:24:41 inline into call below.
const SLboolean interface_required[number_of_interfaces] = {
Ami GONE FROM CHROMIUM 2013/03/22 16:24:41 drop number_of_interfaces
leozwang1 2013/03/22 21:37:09 Done.
+ SL_BOOLEAN_TRUE,
+ SL_BOOLEAN_TRUE,
SL_BOOLEAN_TRUE
};
err = (*engine)->CreateAudioPlayer(engine,
@@ -205,15 +213,32 @@
number_of_interfaces,
interface_id,
interface_required);
- DCHECK_EQ(SL_RESULT_SUCCESS, err);
if (SL_RESULT_SUCCESS != err) {
DLOG(ERROR) << "CreateAudioPlayer() failed with error code " << err;
return false;
}
+ // Create AudioPlayer and specify SL_IID_ANDROIDCONFIGURATION.
+ SLAndroidConfigurationItf player_config;
+ err = player_object_->GetInterface(player_object_.Get(),
+ SL_IID_ANDROIDCONFIGURATION,
+ &player_config);
+ if (SL_RESULT_SUCCESS != err) {
+ DLOG(ERROR) << "GetInterface(SL_IID_ANDROIDCONFIGURATION): " << err;
+ return false;
+ }
+
+ SLint32 stream_type = SL_ANDROID_STREAM_VOICE;
Ami GONE FROM CHROMIUM 2013/03/22 16:24:41 this variable is obscuring what the call below act
Ami GONE FROM CHROMIUM 2013/03/22 16:24:41 This seems to be the heart of the potential proble
leozwang1 2013/03/22 21:37:09 It's my concern too, we're going to do some tests.
Ami GONE FROM CHROMIUM 2013/03/22 22:29:55 I don't think you'd want to make the stream contai
leozwang1 2013/03/22 22:44:48 can you teach me how this "global state button (mi
Ami GONE FROM CHROMIUM 2013/03/22 23:34:20 I just mean that the toggle of what global mode to
+ err = (*player_config)->SetConfiguration(player_config,
+ SL_ANDROID_KEY_STREAM_TYPE,
+ &stream_type, sizeof(SLint32));
+ if (SL_RESULT_SUCCESS != err) {
+ DLOG(ERROR) << "SetConfiguration(SL_ANDROID_STREAM_VOICE): " << err;
+ return false;
+ }
+
// Realize the player object in synchronous mode.
err = player_object_->Realize(player_object_.Get(), SL_BOOLEAN_FALSE);
- DCHECK_EQ(SL_RESULT_SUCCESS, err);
if (SL_RESULT_SUCCESS != err) {
DLOG(ERROR) << "Player Realize() failed with error code " << err;
return false;
@@ -222,26 +247,31 @@
// Get an implicit player interface.
err = player_object_->GetInterface(
player_object_.Get(), SL_IID_PLAY, &player_);
- DCHECK_EQ(SL_RESULT_SUCCESS, err);
- if (SL_RESULT_SUCCESS != err)
+ if (SL_RESULT_SUCCESS != err) {
+ DLOG(ERROR) << "GetInterface(SL_IID_PLAYN): " << err;
return false;
+ }
// Get the simple buffer queue interface.
err = player_object_->GetInterface(player_object_.Get(),
SL_IID_BUFFERQUEUE,
&simple_buffer_queue_);
- DCHECK_EQ(SL_RESULT_SUCCESS, err);
- if (SL_RESULT_SUCCESS != err)
+ if (SL_RESULT_SUCCESS != err) {
+ DLOG(ERROR) << "GetInterface(SL_IID_BUFFERQUEUE): " << err;
return false;
+ }
// Register the input callback for the simple buffer queue.
// This callback will be called when the soundcard needs data.
err = (*simple_buffer_queue_)->RegisterCallback(simple_buffer_queue_,
SimpleBufferQueueCallback,
this);
- DCHECK_EQ(SL_RESULT_SUCCESS, err);
+ if (SL_RESULT_SUCCESS != err) {
+ DLOG(ERROR) << "AudioPlayer RegisterCallback: " << err;
+ return false;
+ }
- return (SL_RESULT_SUCCESS == err);
+ return true;
}
void OpenSLESOutputStream::SimpleBufferQueueCallback(
« media/audio/android/opensles_output.h ('K') | « media/audio/android/opensles_output.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698