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

Side by Side Diff: webrtc/modules/audio_device/android/opensles_player.cc

Issue 1419693004: Fix for "Android audio playout doesn't support non-call media stream" (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: nits Created 5 years, 1 month 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 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 20 matching lines...) Expand all
31 if (err != SL_RESULT_SUCCESS) { \ 31 if (err != SL_RESULT_SUCCESS) { \
32 ALOGE("%s failed: %d", #op, err); \ 32 ALOGE("%s failed: %d", #op, err); \
33 return __VA_ARGS__; \ 33 return __VA_ARGS__; \
34 } \ 34 } \
35 } while (0) 35 } while (0)
36 36
37 namespace webrtc { 37 namespace webrtc {
38 38
39 OpenSLESPlayer::OpenSLESPlayer(AudioManager* audio_manager) 39 OpenSLESPlayer::OpenSLESPlayer(AudioManager* audio_manager)
40 : audio_parameters_(audio_manager->GetPlayoutAudioParameters()), 40 : audio_parameters_(audio_manager->GetPlayoutAudioParameters()),
41 stream_type_(audio_manager->OutputStreamType()),
41 audio_device_buffer_(NULL), 42 audio_device_buffer_(NULL),
42 initialized_(false), 43 initialized_(false),
43 playing_(false), 44 playing_(false),
44 bytes_per_buffer_(0), 45 bytes_per_buffer_(0),
45 buffer_index_(0), 46 buffer_index_(0),
46 engine_(nullptr), 47 engine_(nullptr),
47 player_(nullptr), 48 player_(nullptr),
48 simple_buffer_queue_(nullptr), 49 simple_buffer_queue_(nullptr),
49 volume_(nullptr) { 50 volume_(nullptr) {
50 ALOGD("ctor%s", GetThreadInfo().c_str()); 51 ALOGD("ctor%s", GetThreadInfo().c_str());
52 RTC_DCHECK(stream_type_ == SL_ANDROID_STREAM_VOICE ||
magjed_webrtc 2015/10/28 09:08:33 Maybe add ' << stream_type_' at end of DCHECK so y
henrika_webrtc 2015/10/28 10:48:01 Done.
53 stream_type_ == SL_ANDROID_STREAM_RING ||
54 stream_type_ == SL_ANDROID_STREAM_MEDIA);
51 // Use native audio output parameters provided by the audio manager and 55 // Use native audio output parameters provided by the audio manager and
52 // define the PCM format structure. 56 // define the PCM format structure.
53 pcm_format_ = CreatePCMConfiguration(audio_parameters_.channels(), 57 pcm_format_ = CreatePCMConfiguration(audio_parameters_.channels(),
54 audio_parameters_.sample_rate(), 58 audio_parameters_.sample_rate(),
55 audio_parameters_.bits_per_sample()); 59 audio_parameters_.bits_per_sample());
56 // Detach from this thread since we want to use the checker to verify calls 60 // Detach from this thread since we want to use the checker to verify calls
57 // from the internal audio thread. 61 // from the internal audio thread.
58 thread_checker_opensles_.DetachFromThread(); 62 thread_checker_opensles_.DetachFromThread();
59 } 63 }
60 64
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 344
341 // Use the Android configuration interface to set platform-specific 345 // Use the Android configuration interface to set platform-specific
342 // parameters. Should be done before player is realized. 346 // parameters. Should be done before player is realized.
343 SLAndroidConfigurationItf player_config; 347 SLAndroidConfigurationItf player_config;
344 RETURN_ON_ERROR( 348 RETURN_ON_ERROR(
345 player_object_->GetInterface(player_object_.Get(), 349 player_object_->GetInterface(player_object_.Get(),
346 SL_IID_ANDROIDCONFIGURATION, &player_config), 350 SL_IID_ANDROIDCONFIGURATION, &player_config),
347 false); 351 false);
348 // Set audio player configuration to SL_ANDROID_STREAM_VOICE which 352 // Set audio player configuration to SL_ANDROID_STREAM_VOICE which
349 // corresponds to android.media.AudioManager.STREAM_VOICE_CALL. 353 // corresponds to android.media.AudioManager.STREAM_VOICE_CALL.
350 SLint32 stream_type = SL_ANDROID_STREAM_VOICE; 354 SLint32 stream_type = stream_type_;
351 RETURN_ON_ERROR( 355 RETURN_ON_ERROR(
352 (*player_config) 356 (*player_config)
353 ->SetConfiguration(player_config, SL_ANDROID_KEY_STREAM_TYPE, 357 ->SetConfiguration(player_config, SL_ANDROID_KEY_STREAM_TYPE,
354 &stream_type, sizeof(SLint32)), 358 &stream_type, sizeof(SLint32)),
355 false); 359 false);
356 360
357 // Realize the audio player object after configuration has been set. 361 // Realize the audio player object after configuration has been set.
358 RETURN_ON_ERROR( 362 RETURN_ON_ERROR(
359 player_object_->Realize(player_object_.Get(), SL_BOOLEAN_FALSE), false); 363 player_object_->Realize(player_object_.Get(), SL_BOOLEAN_FALSE), false);
360 364
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 RTC_DCHECK(player_); 441 RTC_DCHECK(player_);
438 SLuint32 state; 442 SLuint32 state;
439 SLresult err = (*player_)->GetPlayState(player_, &state); 443 SLresult err = (*player_)->GetPlayState(player_, &state);
440 if (SL_RESULT_SUCCESS != err) { 444 if (SL_RESULT_SUCCESS != err) {
441 ALOGE("GetPlayState failed: %d", err); 445 ALOGE("GetPlayState failed: %d", err);
442 } 446 }
443 return state; 447 return state;
444 } 448 }
445 449
446 } // namespace webrtc 450 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698