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

Unified Diff: webrtc/modules/audio_device/android/audio_device_template.h

Issue 1165923002: Removes automatic setting of COMM mode in WebRTC (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Removed CHECK Created 5 years, 6 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: webrtc/modules/audio_device/android/audio_device_template.h
diff --git a/webrtc/modules/audio_device/android/audio_device_template.h b/webrtc/modules/audio_device/android/audio_device_template.h
index 69ede541c41cdce55cfdebb161e6e9d51d8bb57d..adc66fa6d44d4caaa3d4ce907d26ca183f49e17d 100644
--- a/webrtc/modules/audio_device/android/audio_device_template.h
+++ b/webrtc/modules/audio_device/android/audio_device_template.h
@@ -11,12 +11,17 @@
#ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_
#define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_
+#include <android/log.h>
+
#include "webrtc/base/checks.h"
#include "webrtc/base/thread_checker.h"
#include "webrtc/modules/audio_device/android/audio_manager.h"
#include "webrtc/modules/audio_device/audio_device_generic.h"
#include "webrtc/system_wrappers/interface/trace.h"
+#define TAG "AudioDeviceTemplate"
+#define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
+
namespace webrtc {
// InputType/OutputType can be any class that implements the capturing/rendering
@@ -125,12 +130,6 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
}
int32_t InitPlayout() override {
- // Switches the Android audio mode to MODE_IN_COMMUNICATION to ensure that
- // audio routing, volume control and echo performance are the best possible
- // for VoIP. InitRecording() does the same type of call but only the first
- // call has any effect.
- // This call does nothing if MODE_IN_COMMUNICATION was already set.
- audio_manager_->SetCommunicationMode(true);
return output_.InitPlayout();
}
@@ -144,12 +143,6 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
}
int32_t InitRecording() override {
- // Switches the Android audio mode to MODE_IN_COMMUNICATION to ensure that
- // audio routing, volume control and echo performance are the best possible
- // for VoIP. InitRecording() does the same type of call but only the first
- // call has any effect.
- // This call does nothing if MODE_IN_COMMUNICATION was already set.
- audio_manager_->SetCommunicationMode(true);
return input_.InitRecording();
}
@@ -158,6 +151,9 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
}
int32_t StartPlayout() override {
+ if (!audio_manager_->IsCommunicationModeEnabled()) {
+ ALOGW("The application should use MODE_IN_COMMUNICATION audio mode!");
+ }
return output_.StartPlayout();
}
@@ -166,11 +162,6 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
if (!Playing())
return 0;
int32_t err = output_.StopPlayout();
- if (!Recording()) {
- // Restore initial audio mode since all audio streaming is disabled.
- // The default mode was stored in Init().
- audio_manager_->SetCommunicationMode(false);
- }
return err;
}
@@ -179,6 +170,9 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
}
int32_t StartRecording() override {
+ if (!audio_manager_->IsCommunicationModeEnabled()) {
+ ALOGW("The application should use MODE_IN_COMMUNICATION audio mode!");
+ }
return input_.StartRecording();
}
@@ -187,11 +181,6 @@ class AudioDeviceTemplate : public AudioDeviceGeneric {
if (!Recording())
return 0;
int32_t err = input_.StopRecording();
- if (!Playing()) {
- // Restore initial audio mode since all audio streaming is disabled.
- // The default mode was is stored in Init().
- audio_manager_->SetCommunicationMode(false);
- }
return err;
}

Powered by Google App Engine
This is Rietveld 408576698