Android: Split out audio device targets
This CL splits out the audio device module Java code into a separate target, and also splits up the audio device module implementations into three different build targets, one for OpenSLES, AAudio, and the Java based implementation. Bug: webrtc:7452, webrtc:9048 Change-Id: I8ec09c73580b468837223ddd420fb29ca61fdea5 Reviewed-on: https://webrtc-review.googlesource.com/66461 Reviewed-by: Paulina Hensman <phensman@webrtc.org> Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22727}
This commit is contained in:
committed by
Commit Bot
parent
571e6c9105
commit
e2be7ee2e8
@ -56,7 +56,7 @@ class AAudioPlayer final : public AudioOutput,
|
||||
public rtc::MessageHandler {
|
||||
public:
|
||||
explicit AAudioPlayer(AudioManager* audio_manager);
|
||||
~AAudioPlayer();
|
||||
~AAudioPlayer() override;
|
||||
|
||||
int Init() override;
|
||||
int Terminate() override;
|
||||
|
||||
@ -66,6 +66,10 @@ int AAudioRecorder::InitRecording() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AAudioRecorder::RecordingIsInitialized() const {
|
||||
return initialized_;
|
||||
}
|
||||
|
||||
int AAudioRecorder::StartRecording() {
|
||||
RTC_LOG(INFO) << "StartRecording";
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
@ -98,6 +102,10 @@ int AAudioRecorder::StopRecording() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AAudioRecorder::Recording() const {
|
||||
return recording_;
|
||||
}
|
||||
|
||||
void AAudioRecorder::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
|
||||
RTC_LOG(INFO) << "AttachAudioBuffer";
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
|
||||
@ -48,17 +48,17 @@ class AAudioRecorder : public AudioInput,
|
||||
public rtc::MessageHandler {
|
||||
public:
|
||||
explicit AAudioRecorder(AudioManager* audio_manager);
|
||||
~AAudioRecorder();
|
||||
~AAudioRecorder() override;
|
||||
|
||||
int Init() override;
|
||||
int Terminate() override;
|
||||
|
||||
int InitRecording() override;
|
||||
bool RecordingIsInitialized() const override { return initialized_; }
|
||||
bool RecordingIsInitialized() const override;
|
||||
|
||||
int StartRecording() override;
|
||||
int StopRecording() override;
|
||||
bool Recording() const override { return recording_; }
|
||||
bool Recording() const override;
|
||||
|
||||
void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override;
|
||||
|
||||
|
||||
@ -76,7 +76,7 @@ class AndroidAudioDeviceModule : public AudioDeviceModule {
|
||||
thread_checker_.DetachFromThread();
|
||||
}
|
||||
|
||||
virtual ~AndroidAudioDeviceModule() { RTC_LOG(INFO) << __FUNCTION__; }
|
||||
~AndroidAudioDeviceModule() override { RTC_LOG(INFO) << __FUNCTION__; }
|
||||
|
||||
int32_t ActiveAudioLayer(
|
||||
AudioDeviceModule::AudioLayer* audioLayer) const override {
|
||||
|
||||
@ -20,20 +20,11 @@
|
||||
#include "rtc_base/refcount.h"
|
||||
#include "rtc_base/refcountedobject.h"
|
||||
|
||||
#include "sdk/android/generated_audio_jni/jni/WebRtcAudioManager_jni.h"
|
||||
#include "sdk/android/generated_audio_device_base_jni/jni/WebRtcAudioManager_jni.h"
|
||||
#include "sdk/android/src/jni/audio_device/audio_common.h"
|
||||
#include "sdk/android/src/jni/jni_helpers.h"
|
||||
|
||||
#if defined(AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO)
|
||||
#include "sdk/android/src/jni/audio_device/aaudio_player.h"
|
||||
#include "sdk/android/src/jni/audio_device/aaudio_recorder.h"
|
||||
#endif
|
||||
#include "sdk/android/src/jni/audio_device/audio_device_module.h"
|
||||
#include "sdk/android/src/jni/audio_device/audio_manager.h"
|
||||
#include "sdk/android/src/jni/audio_device/audio_record_jni.h"
|
||||
#include "sdk/android/src/jni/audio_device/audio_track_jni.h"
|
||||
#include "sdk/android/src/jni/audio_device/opensles_player.h"
|
||||
#include "sdk/android/src/jni/audio_device/opensles_recorder.h"
|
||||
#include "sdk/android/src/jni/jni_helpers.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#ifndef SDK_ANDROID_SRC_JNI_AUDIO_DEVICE_AUDIO_MANAGER_H_
|
||||
#define SDK_ANDROID_SRC_JNI_AUDIO_DEVICE_AUDIO_MANAGER_H_
|
||||
|
||||
#include <SLES/OpenSLES.h>
|
||||
#include <jni.h>
|
||||
#include <memory>
|
||||
|
||||
@ -20,7 +19,6 @@
|
||||
#include "rtc_base/thread_checker.h"
|
||||
#include "sdk/android/native_api/jni/scoped_java_ref.h"
|
||||
#include "sdk/android/src/jni/audio_device/audio_common.h"
|
||||
#include "sdk/android/src/jni/audio_device/opensles_common.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/platform_thread.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
#include "sdk/android/generated_audio_jni/jni/WebRtcAudioRecord_jni.h"
|
||||
#include "sdk/android/generated_java_audio_device_jni/jni/WebRtcAudioRecord_jni.h"
|
||||
#include "sdk/android/src/jni/audio_device/audio_common.h"
|
||||
#include "sdk/android/src/jni/jni_helpers.h"
|
||||
#include "system_wrappers/include/metrics.h"
|
||||
@ -115,6 +115,10 @@ int32_t AudioRecordJni::InitRecording() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AudioRecordJni::RecordingIsInitialized() const {
|
||||
return initialized_;
|
||||
}
|
||||
|
||||
int32_t AudioRecordJni::StartRecording() {
|
||||
RTC_LOG(INFO) << "StartRecording";
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
@ -153,6 +157,10 @@ int32_t AudioRecordJni::StopRecording() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AudioRecordJni::Recording() const {
|
||||
return recording_;
|
||||
}
|
||||
|
||||
void AudioRecordJni::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) {
|
||||
RTC_LOG(INFO) << "AttachAudioBuffer";
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
|
||||
@ -51,11 +51,11 @@ class AudioRecordJni : public AudioInput {
|
||||
int32_t Terminate() override;
|
||||
|
||||
int32_t InitRecording() override;
|
||||
bool RecordingIsInitialized() const override { return initialized_; }
|
||||
bool RecordingIsInitialized() const override;
|
||||
|
||||
int32_t StartRecording() override;
|
||||
int32_t StopRecording() override;
|
||||
bool Recording() const override { return recording_; }
|
||||
bool Recording() const override;
|
||||
|
||||
void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override;
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
*/
|
||||
|
||||
#include "sdk/android/src/jni/audio_device/audio_track_jni.h"
|
||||
#include "sdk/android/src/jni/audio_device/audio_manager.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
@ -18,7 +17,8 @@
|
||||
#include "rtc_base/format_macros.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/platform_thread.h"
|
||||
#include "sdk/android/generated_audio_jni/jni/WebRtcAudioTrack_jni.h"
|
||||
#include "sdk/android/generated_java_audio_device_jni/jni/WebRtcAudioTrack_jni.h"
|
||||
#include "sdk/android/src/jni/audio_device/audio_manager.h"
|
||||
#include "sdk/android/src/jni/jni_helpers.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -80,6 +80,10 @@ int32_t AudioTrackJni::InitPlayout() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AudioTrackJni::PlayoutIsInitialized() const {
|
||||
return initialized_;
|
||||
}
|
||||
|
||||
int32_t AudioTrackJni::StartPlayout() {
|
||||
RTC_LOG(INFO) << "StartPlayout";
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
@ -117,6 +121,10 @@ int32_t AudioTrackJni::StopPlayout() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AudioTrackJni::Playing() const {
|
||||
return playing_;
|
||||
}
|
||||
|
||||
bool AudioTrackJni::SpeakerVolumeIsAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -48,11 +48,11 @@ class AudioTrackJni : public AudioOutput {
|
||||
int32_t Terminate() override;
|
||||
|
||||
int32_t InitPlayout() override;
|
||||
bool PlayoutIsInitialized() const override { return initialized_; }
|
||||
bool PlayoutIsInitialized() const override;
|
||||
|
||||
int32_t StartPlayout() override;
|
||||
int32_t StopPlayout() override;
|
||||
bool Playing() const override { return playing_; }
|
||||
bool Playing() const override;
|
||||
|
||||
bool SpeakerVolumeIsAvailable() override;
|
||||
int SetSpeakerVolume(uint32_t volume) override;
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
|
||||
#include "sdk/android/src/jni/audio_device/build_info.h"
|
||||
|
||||
#include "sdk/android/generated_audio_jni/jni/BuildInfo_jni.h"
|
||||
#include "sdk/android/generated_audio_device_base_jni/jni/BuildInfo_jni.h"
|
||||
#include "sdk/android/src/jni/jni_helpers.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -106,6 +106,8 @@ OpenSLEngineManager::OpenSLEngineManager() {
|
||||
thread_checker_.DetachFromThread();
|
||||
}
|
||||
|
||||
OpenSLEngineManager::~OpenSLEngineManager() = default;
|
||||
|
||||
SLObjectItf OpenSLEngineManager::GetOpenSLEngine() {
|
||||
RTC_LOG(INFO) << "GetOpenSLEngine";
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
|
||||
@ -70,6 +70,7 @@ typedef ScopedSLObject<SLObjectItf, const SLObjectItf_*> ScopedSLObjectItf;
|
||||
class OpenSLEngineManager {
|
||||
public:
|
||||
OpenSLEngineManager();
|
||||
~OpenSLEngineManager();
|
||||
SLObjectItf GetOpenSLEngine();
|
||||
|
||||
private:
|
||||
|
||||
@ -114,6 +114,10 @@ int OpenSLESPlayer::InitPlayout() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool OpenSLESPlayer::PlayoutIsInitialized() const {
|
||||
return initialized_;
|
||||
}
|
||||
|
||||
int OpenSLESPlayer::StartPlayout() {
|
||||
ALOGD("StartPlayout[tid=%d]", rtc::CurrentThreadId());
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
@ -168,6 +172,10 @@ int OpenSLESPlayer::StopPlayout() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool OpenSLESPlayer::Playing() const {
|
||||
return playing_;
|
||||
}
|
||||
|
||||
bool OpenSLESPlayer::SpeakerVolumeIsAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -68,11 +68,11 @@ class OpenSLESPlayer : public AudioOutput {
|
||||
int Terminate() override;
|
||||
|
||||
int InitPlayout() override;
|
||||
bool PlayoutIsInitialized() const override { return initialized_; }
|
||||
bool PlayoutIsInitialized() const override;
|
||||
|
||||
int StartPlayout() override;
|
||||
int StopPlayout() override;
|
||||
bool Playing() const override { return playing_; }
|
||||
bool Playing() const override;
|
||||
|
||||
bool SpeakerVolumeIsAvailable() override;
|
||||
int SetSpeakerVolume(uint32_t volume) override;
|
||||
|
||||
@ -110,6 +110,10 @@ int OpenSLESRecorder::InitRecording() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool OpenSLESRecorder::RecordingIsInitialized() const {
|
||||
return initialized_;
|
||||
}
|
||||
|
||||
int OpenSLESRecorder::StartRecording() {
|
||||
ALOGD("StartRecording[tid=%d]", rtc::CurrentThreadId());
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
@ -168,6 +172,10 @@ int OpenSLESRecorder::StopRecording() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool OpenSLESRecorder::Recording() const {
|
||||
return recording_;
|
||||
}
|
||||
|
||||
void OpenSLESRecorder::AttachAudioBuffer(AudioDeviceBuffer* audio_buffer) {
|
||||
ALOGD("AttachAudioBuffer");
|
||||
RTC_DCHECK(thread_checker_.CalledOnValidThread());
|
||||
|
||||
@ -71,11 +71,11 @@ class OpenSLESRecorder : public AudioInput {
|
||||
int Terminate() override;
|
||||
|
||||
int InitRecording() override;
|
||||
bool RecordingIsInitialized() const override { return initialized_; }
|
||||
bool RecordingIsInitialized() const override;
|
||||
|
||||
int StartRecording() override;
|
||||
int StopRecording() override;
|
||||
bool Recording() const override { return recording_; }
|
||||
bool Recording() const override;
|
||||
|
||||
void AttachAudioBuffer(AudioDeviceBuffer* audio_buffer) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user