| Index: media/audio/android/audio_manager_android.cc
|
| diff --git a/media/audio/android/audio_manager_android.cc b/media/audio/android/audio_manager_android.cc
|
| index a7ec08d69c4d30e60b56716a450f43ae8c1e6b86..02881688bc672e5a5807208d1f23ea6811203e0e 100644
|
| --- a/media/audio/android/audio_manager_android.cc
|
| +++ b/media/audio/android/audio_manager_android.cc
|
| @@ -63,30 +63,39 @@ AudioManagerAndroid::AudioManagerAndroid(
|
| audio_log_factory),
|
| communication_mode_is_on_(false),
|
| output_volume_override_set_(false),
|
| - output_volume_override_(0) {
|
| + output_volume_override_(0),
|
| + initialized_(false) {
|
| SetMaxOutputStreamsAllowed(kMaxOutputStreams);
|
| -
|
| - // WARNING: This is executed on the UI loop, do not add any code here which
|
| - // loads libraries or attempts to call out into the OS. Instead add such code
|
| - // to the InitializeOnAudioThread() method below.
|
| -
|
| - // Task must be posted last to avoid races from handing out "this" to the
|
| - // audio thread.
|
| - GetTaskRunner()->PostTask(FROM_HERE, base::Bind(
|
| - &AudioManagerAndroid::InitializeOnAudioThread,
|
| - base::Unretained(this)));
|
| }
|
|
|
| AudioManagerAndroid::~AudioManagerAndroid() {
|
| DCHECK(GetTaskRunner()->BelongsToCurrentThread());
|
| Shutdown();
|
|
|
| + if (j_audio_manager_.is_null())
|
| + return;
|
| DVLOG(2) << "Destroying Java part of the audio manager";
|
| Java_AudioManagerAndroid_close(base::android::AttachCurrentThread(),
|
| j_audio_manager_.obj());
|
| j_audio_manager_.Reset();
|
| }
|
|
|
| +void AudioManagerAndroid::InitializeIfNeeded() {
|
| + if (initialized_)
|
| + return;
|
| +
|
| + // WARNING: This is executed on the UI loop, do not add any code here which
|
| + // loads libraries or attempts to call out into the OS. Instead add such code
|
| + // to the InitializeOnAudioThread() method below.
|
| +
|
| + // Task must be posted last to avoid races from handing out "this" to the
|
| + // audio thread.
|
| + GetTaskRunner()->PostTask(FROM_HERE, base::Bind(
|
| + &AudioManagerAndroid::InitializeOnAudioThread,
|
| + base::Unretained(this)));
|
| + initialized_ = true;
|
| +}
|
| +
|
| bool AudioManagerAndroid::HasAudioOutputDevices() {
|
| return true;
|
| }
|
|
|