Refactor OpenSL audio driver

Message:
I want to start this review, the basica framework is almost done.

Description:
This implementation is similar to current one, but
1. followed the design doc at
https://docs.google.com/a/google.com/document/d/1g5q2SVtkFPl2OSjvSF3eeLb_S7sCnbINxiBUES6XLCM/edit
which uses two threads, playout thread and recording thread, uses large
audio buffer, etc.
2. google code style.

What are missing in this cl,
1. a better way to control schedule/thread priority.
2. java/jni interface to better support what cannot be done in OpenSL.

Please take a review, thanks.
Review URL: https://webrtc-codereview.appspot.com/902004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3040 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
leozwang@webrtc.org 2012-11-02 16:48:03 +00:00
parent 737ed3bfa5
commit 5f9970fb0b
2 changed files with 1316 additions and 1549 deletions

View File

@ -8,14 +8,10 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_OPENSLES_ANDROID_H #ifndef SRC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_OPENSLES_ANDROID_H_
#define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_OPENSLES_ANDROID_H #define SRC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_OPENSLES_ANDROID_H_
#include "audio_device_generic.h" #include <jni.h>
#include "critical_section_wrapper.h"
#include <jni.h> // For accessing AudioDeviceAndroid.java
#include <queue>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -23,294 +19,299 @@
#include <SLES/OpenSLES_Android.h> #include <SLES/OpenSLES_Android.h>
#include <SLES/OpenSLES_AndroidConfiguration.h> #include <SLES/OpenSLES_AndroidConfiguration.h>
namespace webrtc #include <queue>
{
#include "modules/audio_device/audio_device_generic.h"
#include "system_wrappers/interface/critical_section_wrapper.h"
namespace webrtc {
class EventWrapper; class EventWrapper;
const WebRtc_UWord32 N_MAX_INTERFACES = 3; const WebRtc_UWord32 N_MAX_INTERFACES = 3;
const WebRtc_UWord32 N_MAX_OUTPUT_DEVICES = 6; const WebRtc_UWord32 N_MAX_OUTPUT_DEVICES = 6;
const WebRtc_UWord32 N_MAX_INPUT_DEVICES = 3; const WebRtc_UWord32 N_MAX_INPUT_DEVICES = 3;
const WebRtc_UWord32 N_REC_SAMPLES_PER_SEC = 16000;//44000; // Default fs const WebRtc_UWord32 N_REC_SAMPLES_PER_SEC = 16000; // Default fs
const WebRtc_UWord32 N_PLAY_SAMPLES_PER_SEC = 16000;//44000; // Default fs const WebRtc_UWord32 N_PLAY_SAMPLES_PER_SEC = 16000; // Default fs
const WebRtc_UWord32 N_REC_CHANNELS = 1; // default is mono recording const WebRtc_UWord32 N_REC_CHANNELS = 1;
const WebRtc_UWord32 N_PLAY_CHANNELS = 1; // default is mono playout const WebRtc_UWord32 N_PLAY_CHANNELS = 1;
const WebRtc_UWord32 REC_BUF_SIZE_IN_SAMPLES = 480; // Handle max 10 ms @ 48 kHz const WebRtc_UWord32 REC_BUF_SIZE_IN_SAMPLES = 480;
const WebRtc_UWord32 PLAY_BUF_SIZE_IN_SAMPLES = 480; const WebRtc_UWord32 PLAY_BUF_SIZE_IN_SAMPLES = 480;
const WebRtc_UWord32 REC_MAX_TEMP_BUF_SIZE_PER_10ms =
N_REC_CHANNELS * REC_BUF_SIZE_IN_SAMPLES * sizeof(int16_t);
const WebRtc_UWord32 PLAY_MAX_TEMP_BUF_SIZE_PER_10ms =
N_PLAY_CHANNELS * PLAY_BUF_SIZE_IN_SAMPLES * sizeof(int16_t);
// Number of the buffers in playout queue // Number of the buffers in playout queue
const WebRtc_UWord16 N_PLAY_QUEUE_BUFFERS = 2; const WebRtc_UWord16 N_PLAY_QUEUE_BUFFERS = 8;
// Number of buffers in recording queue // Number of buffers in recording queue
const WebRtc_UWord16 N_REC_QUEUE_BUFFERS = 2; // TODO(xian): Reduce the numbers of buffers to improve the latency.
// Number of 10 ms recording blocks in rec buffer const WebRtc_UWord16 N_REC_QUEUE_BUFFERS = 8;
const WebRtc_UWord16 N_REC_BUFFERS = 20; // Some values returned from getMinBufferSize
// (Nexus S playout 72ms, recording 64ms)
// (Galaxy, 167ms, 44ms)
// (Nexus 7, 72ms, 48ms)
// (Xoom 92ms, 40ms)
class ThreadWrapper; class ThreadWrapper;
class AudioDeviceAndroidOpenSLES: public AudioDeviceGeneric class AudioDeviceAndroidOpenSLES: public AudioDeviceGeneric {
{ public:
public: explicit AudioDeviceAndroidOpenSLES(const WebRtc_Word32 id);
AudioDeviceAndroidOpenSLES(const WebRtc_Word32 id); ~AudioDeviceAndroidOpenSLES();
~AudioDeviceAndroidOpenSLES();
// Retrieve the currently utilized audio layer // Retrieve the currently utilized audio layer
virtual WebRtc_Word32 virtual WebRtc_Word32
ActiveAudioLayer(AudioDeviceModule::AudioLayer& audioLayer) const; ActiveAudioLayer(AudioDeviceModule::AudioLayer& audioLayer) const; // NOLINT
// Main initializaton and termination // Main initializaton and termination
virtual WebRtc_Word32 Init(); virtual WebRtc_Word32 Init();
virtual WebRtc_Word32 Terminate(); virtual WebRtc_Word32 Terminate();
virtual bool Initialized() const; virtual bool Initialized() const;
// Device enumeration // Device enumeration
virtual WebRtc_Word16 PlayoutDevices(); virtual WebRtc_Word16 PlayoutDevices();
virtual WebRtc_Word16 RecordingDevices(); virtual WebRtc_Word16 RecordingDevices();
virtual WebRtc_Word32 virtual WebRtc_Word32
PlayoutDeviceName(WebRtc_UWord16 index, PlayoutDeviceName(WebRtc_UWord16 index,
char name[kAdmMaxDeviceNameSize], char name[kAdmMaxDeviceNameSize],
char guid[kAdmMaxGuidSize]); char guid[kAdmMaxGuidSize]);
virtual WebRtc_Word32 virtual WebRtc_Word32
RecordingDeviceName(WebRtc_UWord16 index, RecordingDeviceName(WebRtc_UWord16 index,
char name[kAdmMaxDeviceNameSize], char name[kAdmMaxDeviceNameSize],
char guid[kAdmMaxGuidSize]); char guid[kAdmMaxGuidSize]);
// Device selection // Device selection
virtual WebRtc_Word32 SetPlayoutDevice(WebRtc_UWord16 index); virtual WebRtc_Word32 SetPlayoutDevice(WebRtc_UWord16 index);
virtual WebRtc_Word32 virtual WebRtc_Word32
SetPlayoutDevice(AudioDeviceModule::WindowsDeviceType device); SetPlayoutDevice(AudioDeviceModule::WindowsDeviceType device);
virtual WebRtc_Word32 SetRecordingDevice(WebRtc_UWord16 index); virtual WebRtc_Word32 SetRecordingDevice(WebRtc_UWord16 index);
virtual WebRtc_Word32 virtual WebRtc_Word32
SetRecordingDevice(AudioDeviceModule::WindowsDeviceType device); SetRecordingDevice(AudioDeviceModule::WindowsDeviceType device);
// Audio transport initialization // Audio transport initialization
virtual WebRtc_Word32 PlayoutIsAvailable(bool& available); virtual WebRtc_Word32 PlayoutIsAvailable(bool& available); // NOLINT
virtual WebRtc_Word32 InitPlayout(); virtual WebRtc_Word32 InitPlayout();
virtual bool PlayoutIsInitialized() const; virtual bool PlayoutIsInitialized() const;
virtual WebRtc_Word32 RecordingIsAvailable(bool& available); virtual WebRtc_Word32 RecordingIsAvailable(bool& available); // NOLINT
virtual WebRtc_Word32 InitRecording(); virtual WebRtc_Word32 InitRecording();
virtual bool RecordingIsInitialized() const; virtual bool RecordingIsInitialized() const;
// Audio transport control // Audio transport control
virtual WebRtc_Word32 StartPlayout(); virtual WebRtc_Word32 StartPlayout();
virtual WebRtc_Word32 StopPlayout(); virtual WebRtc_Word32 StopPlayout();
virtual bool Playing() const; virtual bool Playing() const;
virtual WebRtc_Word32 StartRecording(); virtual WebRtc_Word32 StartRecording();
virtual WebRtc_Word32 StopRecording(); virtual WebRtc_Word32 StopRecording();
virtual bool Recording() const; virtual bool Recording() const;
// Microphone Automatic Gain Control (AGC) // Microphone Automatic Gain Control (AGC)
virtual WebRtc_Word32 SetAGC(bool enable); virtual WebRtc_Word32 SetAGC(bool enable);
virtual bool AGC() const; virtual bool AGC() const;
// Volume control based on the Windows Wave API (Windows only) // Volume control based on the Windows Wave API (Windows only)
virtual WebRtc_Word32 SetWaveOutVolume(WebRtc_UWord16 volumeLeft, virtual WebRtc_Word32 SetWaveOutVolume(WebRtc_UWord16 volumeLeft,
WebRtc_UWord16 volumeRight); WebRtc_UWord16 volumeRight);
virtual WebRtc_Word32 WaveOutVolume(WebRtc_UWord16& volumeLeft, virtual WebRtc_Word32 WaveOutVolume(
WebRtc_UWord16& volumeRight) const; WebRtc_UWord16& volumeLeft, // NOLINT
WebRtc_UWord16& volumeRight) const; // NOLINT
// Audio mixer initialization // Audio mixer initialization
virtual WebRtc_Word32 SpeakerIsAvailable(bool& available); virtual WebRtc_Word32 SpeakerIsAvailable(bool& available); // NOLINT
virtual WebRtc_Word32 InitSpeaker(); virtual WebRtc_Word32 InitSpeaker();
virtual bool SpeakerIsInitialized() const; virtual bool SpeakerIsInitialized() const;
SLPlayItf playItf; virtual WebRtc_Word32 MicrophoneIsAvailable(
virtual WebRtc_Word32 MicrophoneIsAvailable(bool& available); bool& available);
virtual WebRtc_Word32 InitMicrophone(); virtual WebRtc_Word32 InitMicrophone();
virtual bool MicrophoneIsInitialized() const; virtual bool MicrophoneIsInitialized() const;
// Speaker volume controls // Speaker volume controls
virtual WebRtc_Word32 SpeakerVolumeIsAvailable(bool& available); virtual WebRtc_Word32 SpeakerVolumeIsAvailable(
virtual WebRtc_Word32 SetSpeakerVolume(WebRtc_UWord32 volume); bool& available); // NOLINT
virtual WebRtc_Word32 SpeakerVolume(WebRtc_UWord32& volume) const; virtual WebRtc_Word32 SetSpeakerVolume(WebRtc_UWord32 volume);
virtual WebRtc_Word32 MaxSpeakerVolume(WebRtc_UWord32& maxVolume) const; virtual WebRtc_Word32 SpeakerVolume(
virtual WebRtc_Word32 MinSpeakerVolume(WebRtc_UWord32& minVolume) const; WebRtc_UWord32& volume) const; // NOLINT
virtual WebRtc_Word32 SpeakerVolumeStepSize(WebRtc_UWord16& stepSize) const; virtual WebRtc_Word32 MaxSpeakerVolume(
WebRtc_UWord32& maxVolume) const; // NOLINT
virtual WebRtc_Word32 MinSpeakerVolume(
WebRtc_UWord32& minVolume) const; // NOLINT
virtual WebRtc_Word32 SpeakerVolumeStepSize(
WebRtc_UWord16& stepSize) const; // NOLINT
// Microphone volume controls // Microphone volume controls
virtual WebRtc_Word32 MicrophoneVolumeIsAvailable(bool& available); virtual WebRtc_Word32 MicrophoneVolumeIsAvailable(
virtual WebRtc_Word32 SetMicrophoneVolume(WebRtc_UWord32 volume); bool& available); // NOLINT
virtual WebRtc_Word32 MicrophoneVolume(WebRtc_UWord32& volume) const; virtual WebRtc_Word32 SetMicrophoneVolume(WebRtc_UWord32 volume);
virtual WebRtc_Word32 MaxMicrophoneVolume(WebRtc_UWord32& maxVolume) const; virtual WebRtc_Word32 MicrophoneVolume(
virtual WebRtc_Word32 MinMicrophoneVolume(WebRtc_UWord32& minVolume) const; WebRtc_UWord32& volume) const; // NOLINT
virtual WebRtc_Word32 virtual WebRtc_Word32 MaxMicrophoneVolume(
MicrophoneVolumeStepSize(WebRtc_UWord16& stepSize) const; WebRtc_UWord32& maxVolume) const; // NOLINT
virtual WebRtc_Word32 MinMicrophoneVolume(
WebRtc_UWord32& minVolume) const; // NOLINT
virtual WebRtc_Word32
MicrophoneVolumeStepSize(WebRtc_UWord16& stepSize) const; // NOLINT
// Speaker mute control // Speaker mute control
virtual WebRtc_Word32 SpeakerMuteIsAvailable(bool& available); virtual WebRtc_Word32 SpeakerMuteIsAvailable(bool& available); // NOLINT
virtual WebRtc_Word32 SetSpeakerMute(bool enable); virtual WebRtc_Word32 SetSpeakerMute(bool enable);
virtual WebRtc_Word32 SpeakerMute(bool& enabled) const; virtual WebRtc_Word32 SpeakerMute(bool& enabled) const; // NOLINT
// Microphone mute control // Microphone mute control
virtual WebRtc_Word32 MicrophoneMuteIsAvailable(bool& available); virtual WebRtc_Word32 MicrophoneMuteIsAvailable(bool& available); // NOLINT
virtual WebRtc_Word32 SetMicrophoneMute(bool enable); virtual WebRtc_Word32 SetMicrophoneMute(bool enable);
virtual WebRtc_Word32 MicrophoneMute(bool& enabled) const; virtual WebRtc_Word32 MicrophoneMute(bool& enabled) const; // NOLINT
// Microphone boost control // Microphone boost control
virtual WebRtc_Word32 MicrophoneBoostIsAvailable(bool& available); virtual WebRtc_Word32 MicrophoneBoostIsAvailable(bool& available); // NOLINT
virtual WebRtc_Word32 SetMicrophoneBoost(bool enable); virtual WebRtc_Word32 SetMicrophoneBoost(bool enable);
virtual WebRtc_Word32 MicrophoneBoost(bool& enabled) const; virtual WebRtc_Word32 MicrophoneBoost(bool& enabled) const; // NOLINT
// Stereo support // Stereo support
virtual WebRtc_Word32 StereoPlayoutIsAvailable(bool& available); virtual WebRtc_Word32 StereoPlayoutIsAvailable(bool& available); // NOLINT
virtual WebRtc_Word32 SetStereoPlayout(bool enable); virtual WebRtc_Word32 SetStereoPlayout(bool enable);
virtual WebRtc_Word32 StereoPlayout(bool& enabled) const; virtual WebRtc_Word32 StereoPlayout(bool& enabled) const; // NOLINT
virtual WebRtc_Word32 StereoRecordingIsAvailable(bool& available); virtual WebRtc_Word32 StereoRecordingIsAvailable(bool& available); // NOLINT
virtual WebRtc_Word32 SetStereoRecording(bool enable); virtual WebRtc_Word32 SetStereoRecording(bool enable);
virtual WebRtc_Word32 StereoRecording(bool& enabled) const; virtual WebRtc_Word32 StereoRecording(bool& enabled) const; // NOLINT
// Delay information and control // Delay information and control
virtual WebRtc_Word32 virtual WebRtc_Word32
SetPlayoutBuffer(const AudioDeviceModule::BufferType type, SetPlayoutBuffer(const AudioDeviceModule::BufferType type,
WebRtc_UWord16 sizeMS); WebRtc_UWord16 sizeMS);
virtual WebRtc_Word32 PlayoutBuffer(AudioDeviceModule::BufferType& type, virtual WebRtc_Word32 PlayoutBuffer(
WebRtc_UWord16& sizeMS) const; AudioDeviceModule::BufferType& type, // NOLINT
virtual WebRtc_Word32 PlayoutDelay(WebRtc_UWord16& delayMS) const; WebRtc_UWord16& sizeMS) const;
virtual WebRtc_Word32 RecordingDelay(WebRtc_UWord16& delayMS) const; virtual WebRtc_Word32 PlayoutDelay(
WebRtc_UWord16& delayMS) const; // NOLINT
virtual WebRtc_Word32 RecordingDelay(
WebRtc_UWord16& delayMS) const; // NOLINT
// CPU load // CPU load
virtual WebRtc_Word32 CPULoad(WebRtc_UWord16& load) const; virtual WebRtc_Word32 CPULoad(WebRtc_UWord16& load) const; // NOLINT
// Error and warning information // Error and warning information
virtual bool PlayoutWarning() const; virtual bool PlayoutWarning() const;
virtual bool PlayoutError() const; virtual bool PlayoutError() const;
virtual bool RecordingWarning() const; virtual bool RecordingWarning() const;
virtual bool RecordingError() const; virtual bool RecordingError() const;
virtual void ClearPlayoutWarning(); virtual void ClearPlayoutWarning();
virtual void ClearPlayoutError(); virtual void ClearPlayoutError();
virtual void ClearRecordingWarning(); virtual void ClearRecordingWarning();
virtual void ClearRecordingError(); virtual void ClearRecordingError();
// Attach audio buffer // Attach audio buffer
virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer); virtual void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer);
// Speaker audio routing // Speaker audio routing
virtual WebRtc_Word32 SetLoudspeakerStatus(bool enable); virtual WebRtc_Word32 SetLoudspeakerStatus(bool enable);
virtual WebRtc_Word32 GetLoudspeakerStatus(bool& enable) const; virtual WebRtc_Word32 GetLoudspeakerStatus(bool& enable) const; // NOLINT
private: private:
// Lock // Lock
void Lock() void Lock() {
{ crit_sect_.Enter();
_critSect.Enter(); };
}; void UnLock() {
void UnLock() crit_sect_.Leave();
{ };
_critSect.Leave();
};
static void PlayerSimpleBufferQueueCallback( static void PlayerSimpleBufferQueueCallback(
SLAndroidSimpleBufferQueueItf queueItf, SLAndroidSimpleBufferQueueItf queueItf,
void *pContext); void *pContext);
void PlayerSimpleBufferQueueCallbackHandler( static void RecorderSimpleBufferQueueCallback(
SLAndroidSimpleBufferQueueItf queueItf); SLAndroidSimpleBufferQueueItf queueItf,
static void RecorderSimpleBufferQueueCallback( void *pContext);
SLAndroidSimpleBufferQueueItf queueItf, void PlayerSimpleBufferQueueCallbackHandler(
void *pContext); SLAndroidSimpleBufferQueueItf queueItf);
void RecorderSimpleBufferQueueCallbackHandler( void RecorderSimpleBufferQueueCallbackHandler(
SLAndroidSimpleBufferQueueItf queueItf); SLAndroidSimpleBufferQueueItf queueItf);
void CheckErr(SLresult res); void CheckErr(SLresult res);
// Delay updates // Delay updates
void UpdateRecordingDelay(); void UpdateRecordingDelay();
void UpdatePlayoutDelay(WebRtc_UWord32 nSamplePlayed); void UpdatePlayoutDelay(WebRtc_UWord32 nSamplePlayed);
// Init // Init
WebRtc_Word32 InitSampleRate(); WebRtc_Word32 InitSampleRate();
// Threads // Misc
static bool RecThreadFunc(void*); AudioDeviceBuffer* voe_audio_buffer_;
static bool PlayThreadFunc(void*); CriticalSectionWrapper& crit_sect_;
bool RecThreadProcess(); WebRtc_Word32 id_;
bool PlayThreadProcess();
// Misc // audio unit
AudioDeviceBuffer* _ptrAudioBuffer; SLObjectItf sles_engine_;
CriticalSectionWrapper& _critSect;
WebRtc_Word32 _id;
// audio unit // playout device
SLObjectItf _slEngineObject; SLObjectItf sles_player_;
SLEngineItf sles_engine_itf_;
SLPlayItf sles_player_itf_;
SLAndroidSimpleBufferQueueItf sles_player_sbq_itf_;
SLObjectItf sles_output_mixer_;
SLVolumeItf sles_speaker_volume_;
// playout device // recording device
SLObjectItf _slPlayer; SLObjectItf sles_recorder_;
SLEngineItf _slEngine; SLRecordItf sles_recorder_itf_;
SLPlayItf _slPlayerPlay; SLAndroidSimpleBufferQueueItf sles_recorder_sbq_itf_;
SLAndroidSimpleBufferQueueItf _slPlayerSimpleBufferQueue; SLDeviceVolumeItf sles_mic_volume_;
SLObjectItf _slOutputMixObject; WebRtc_UWord32 mic_dev_id_;
SLVolumeItf _slSpeakerVolume;
// recording device WebRtc_UWord32 play_warning_, play_error_;
SLObjectItf _slRecorder; WebRtc_UWord32 rec_warning_, rec_error_;
SLRecordItf _slRecorderRecord;
SLAudioIODeviceCapabilitiesItf _slAudioIODeviceCapabilities;
SLAndroidSimpleBufferQueueItf _slRecorderSimpleBufferQueue;
SLDeviceVolumeItf _slMicVolume;
WebRtc_UWord32 _micDeviceId; // States
WebRtc_UWord32 _recQueueSeq; bool is_recording_dev_specified_;
bool is_playout_dev_specified_;
bool is_initialized_;
bool is_recording_;
bool is_playing_;
bool is_rec_initialized_;
bool is_play_initialized_;
bool is_mic_initialized_;
bool is_speaker_initialized_;
// Events // Delay
EventWrapper& _timeEventRec; WebRtc_UWord16 playout_delay_;
// Threads WebRtc_UWord16 recording_delay_;
ThreadWrapper* _ptrThreadRec;
WebRtc_UWord32 _recThreadID;
// TODO(xians), remove the following flag
bool _recThreadIsInitialized;
// Playout buffer // AGC state
WebRtc_Word8 _playQueueBuffer[N_PLAY_QUEUE_BUFFERS][2 bool agc_enabled_;
* PLAY_BUF_SIZE_IN_SAMPLES];
WebRtc_UWord32 _playQueueSeq;
// States // Threads
bool _recordingDeviceIsSpecified; ThreadWrapper* rec_thread_;
bool _playoutDeviceIsSpecified; WebRtc_UWord32 rec_thread_id_;
bool _initialized; static bool RecThreadFunc(void* context);
bool _recording; bool RecThreadFuncImpl();
bool _playing; EventWrapper& rec_timer_;
bool _recIsInitialized;
bool _playIsInitialized;
bool _micIsInitialized;
bool _speakerIsInitialized;
// Warnings and errors WebRtc_UWord32 mic_sampling_rate_;
WebRtc_UWord16 _playWarning; WebRtc_UWord32 speaker_sampling_rate_;
WebRtc_UWord16 _playError; WebRtc_UWord32 max_speaker_vol_;
WebRtc_UWord16 _recWarning; WebRtc_UWord32 min_speaker_vol_;
WebRtc_UWord16 _recError; bool loundspeaker_on_;
// Delay SLDataFormat_PCM player_pcm_;
WebRtc_UWord16 _playoutDelay; SLDataFormat_PCM record_pcm_;
WebRtc_UWord16 _recordingDelay;
// AGC state std::queue<WebRtc_Word8*> rec_queue_;
bool _AGC; std::queue<WebRtc_Word8*> rec_voe_audio_queue_;
std::queue<WebRtc_Word8*> rec_voe_ready_queue_;
WebRtc_Word8 rec_buf_[N_REC_QUEUE_BUFFERS][
N_REC_CHANNELS * sizeof(int16_t) * REC_BUF_SIZE_IN_SAMPLES];
WebRtc_Word8 rec_voe_buf_[N_REC_QUEUE_BUFFERS][
N_REC_CHANNELS * sizeof(int16_t) * REC_BUF_SIZE_IN_SAMPLES];
// The sampling rate to use with Audio Device Buffer std::queue<WebRtc_Word8*> play_queue_;
WebRtc_UWord32 _adbSampleRate; WebRtc_Word8 play_buf_[N_PLAY_QUEUE_BUFFERS][
// Stored device properties N_PLAY_CHANNELS * sizeof(int16_t) * PLAY_BUF_SIZE_IN_SAMPLES];
WebRtc_UWord32 _samplingRateIn; // Sampling frequency for Mic
WebRtc_UWord32 _samplingRateOut; // Sampling frequency for Speaker
WebRtc_UWord32 _maxSpeakerVolume; // The maximum speaker volume value
WebRtc_UWord32 _minSpeakerVolume; // The minimum speaker volume value
bool _loudSpeakerOn;
// Recording buffer used by the queues.
int8_t rec_buffer_[N_REC_BUFFERS][2 * REC_BUF_SIZE_IN_SAMPLES];
// Queues accessed by both callback thread and recording thread after
// recording has been started.
std::queue<int8_t*> rec_worker_queue_;
std::queue<int8_t*> rec_available_queue_;
// Queue accssed by only callback thread after recording has been started.
std::queue<int8_t*> rec_callback_queue_;
// Flag to protect setting the recording thread priority multiple times.
bool is_thread_priority_set_;
}; };
} // namespace webrtc } // namespace webrtc
#endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_OPENSLES_ANDROID_H #endif // SRC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_OPENSLES_ANDROID_H_