Index: media/audio/audio_manager_base.cc |
=================================================================== |
--- media/audio/audio_manager_base.cc (revision 189519) |
+++ media/audio/audio_manager_base.cc (working copy) |
@@ -63,6 +63,14 @@ |
CHECK(audio_thread_->Start()); |
#endif |
message_loop_ = audio_thread_->message_loop_proxy(); |
+ |
+#if defined(OS_ANDROID) |
+ JNIEnv* env = base::android::AttachCurrentThread(); |
+ jobject context = base::android::GetApplicationContext(); |
+ DCHECK(context); |
Ami GONE FROM CHROMIUM
2013/03/21 21:26:21
unnecessary- GAC() does this
leozwang1
2013/03/21 23:10:07
Done.
|
+ j_audio_manager_.Reset( |
+ Java_AudioManagerAndroid_createAudioManagerAndroid(env, context)); |
+#endif |
} |
AudioManagerBase::~AudioManagerBase() { |
@@ -128,6 +136,11 @@ |
if (stream) |
++num_output_streams_; |
+#if defined(OS_ANDROID) |
+ if (1 == num_output_streams_) |
tommi (sloooow) - chröme
2013/03/21 20:58:16
To be on the safe side:
if (stream && 1 == num_ou
Ami GONE FROM CHROMIUM
2013/03/21 21:26:21
better yet, move this into the if at l.136 above?
leozwang1
2013/03/21 23:10:07
Done.
leozwang1
2013/03/21 23:10:07
Done.
leozwang1
2013/03/21 23:10:07
Done.
|
+ RegisterHeadsetReceiver(); |
+#endif |
+ |
return stream; |
} |
@@ -170,7 +183,7 @@ |
++num_input_streams_; |
#if defined(OS_ANDROID) |
- if (num_input_streams_ == 1) |
+ if (1 == num_input_streams_) |
tommi (sloooow) - chröme
2013/03/21 20:58:16
same here
leozwang1
2013/03/21 23:10:07
Done.
|
SetAudioMode(kAudioModeInCommunication); |
#endif |
@@ -256,6 +269,10 @@ |
// streams. |
--num_output_streams_; |
delete stream; |
+#if defined(OS_ANDROID) |
+ if (!num_output_streams_) |
+ UnregisterHeadsetReceiver(); |
+#endif |
} |
void AudioManagerBase::ReleaseInputStream(AudioInputStream* stream) { |
@@ -371,12 +388,22 @@ |
#if defined(OS_ANDROID) |
void AudioManagerBase::SetAudioMode(int mode) { |
- JNIEnv* env = base::android::AttachCurrentThread(); |
- jobject context = base::android::GetApplicationContext(); |
- DCHECK(context); |
+ Java_AudioManagerAndroid_setMode( |
+ base::android::AttachCurrentThread(), |
+ j_audio_manager_.obj(), mode); |
+} |
- Java_AudioManagerAndroid_setMode(env, context, mode); |
+void AudioManagerBase::RegisterHeadsetReceiver() { |
+ Java_AudioManagerAndroid_registerHeadsetReceiver( |
+ base::android::AttachCurrentThread(), |
+ j_audio_manager_.obj()); |
} |
-#endif |
+void AudioManagerBase::UnregisterHeadsetReceiver() { |
+ Java_AudioManagerAndroid_unregisterHeadsetReceiver( |
+ base::android::AttachCurrentThread(), |
+ j_audio_manager_.obj()); |
+} |
+#endif // defined(OS_ANDROID) |
+ |
} // namespace media |