Ring Daemon 16.0.0
|
#include <opensllayer.h>
Public Member Functions | |
void | engineServicePlay () |
void | engineServiceRec () |
void | engineServiceRing () |
virtual int | getAudioDeviceIndex (const std::string &, AudioDeviceType) const override |
virtual std::string | getAudioDeviceName (int, AudioDeviceType) const override |
std::vector< std::string > | getCaptureDeviceList () const override |
Scan the sound card available for capture on the system. | |
std::vector< std::string > | getPlaybackDeviceList () const override |
Scan the sound card available for capture on the system. | |
void | init () |
void | initAudioEngine () |
OpenSLLayer (const AudioPreference &pref) | |
Constructor. | |
void | shutdownAudioEngine () |
void | startAudioCapture () |
void | startStream (AudioDeviceType stream=AudioDeviceType::ALL) override |
Start the capture stream and prepare the playback stream. | |
void | stopAudioCapture () |
void | stopStream (AudioDeviceType stream=AudioDeviceType::ALL) override |
Stop the playback and capture streams. | |
~OpenSLLayer () | |
Destructor. | |
![]() | |
AudioLayer (const AudioPreference &) | |
void | flushMain () |
Flush main buffer. | |
void | flushUrgent () |
Flush urgent buffer. | |
double | getCaptureGain () const |
Get capture stream gain (microphone) | |
AudioFormat | getFormat () const |
Get the audio format of the layer (sample rate & channel number). | |
double | getPlaybackGain () const |
Get playback stream gain (speaker) | |
unsigned int | getSampleRate () const |
Get the sample rate of the audio layer. | |
bool | isCaptureMuted () const |
bool | isPlaybackMuted () const |
bool | isRingtoneMuted () const |
bool | isStarted () const |
Determine whether or not the audio layer is active (i.e. | |
void | muteCapture (bool muted) |
Mute capture (microphone) | |
void | mutePlayback (bool muted) |
Mute playback. | |
void | muteRingtone (bool muted) |
void | notifyIncomingCall () |
Emit an audio notification (beep) on incoming calls. | |
void | playIncomingCallNotification (bool play) |
Start/Stop playing the incoming call notification sound (beep) while playing back audio (typically during an ongoing call). | |
void | putUrgent (std::shared_ptr< AudioFrame > buffer) |
Send a chunk of data to the hardware buffer to start the playback Copy data in the urgent buffer. | |
void | setCaptureGain (double gain) |
Set capture stream gain (microphone) Range should be [-1.0, 1.0]. | |
void | setPlaybackGain (double gain) |
Set playback stream gain (speaker) Range should be [-1.0, 1.0]. | |
template<class Rep , class Period > | |
bool | waitForStart (const std::chrono::duration< Rep, Period > &rel_time) const |
virtual | ~AudioLayer () |
Additional Inherited Members | |
![]() | |
enum class | Status { Idle , Starting , Started } |
![]() | |
void | devicesChanged () |
void | flush () |
std::shared_ptr< AudioFrame > | getPlayback (AudioFormat format, size_t samples) |
std::shared_ptr< AudioFrame > | getToPlay (AudioFormat format, size_t writableSamples) |
std::shared_ptr< AudioFrame > | getToRing (AudioFormat format, size_t writableSamples) |
void | hardwareFormatAvailable (AudioFormat playback, size_t bufSize=0) |
Callback to be called by derived classes when the audio output is opened. | |
void | hardwareInputFormatAvailable (AudioFormat capture) |
Set the input format on necessary objects. | |
void | playbackChanged (bool started) |
void | putRecorded (std::shared_ptr< AudioFrame > &&frame) |
void | recordChanged (bool started) |
void | setHasNativeAEC (bool hasEAC) |
void | setHasNativeNS (bool hasNS) |
![]() | |
AudioFormat | audioFormat_ |
Sample Rate that should be sent to the sound card. | |
AudioFormat | audioInputFormat_ |
Sample Rate for input. | |
double | captureGain_ |
Gain applied to mic signal. | |
bool | hasNativeAEC_ {true} |
bool | hasNativeNS_ {false} |
bool | isCaptureMuted_ |
True if capture is not to be used. | |
bool | isPlaybackMuted_ |
True if playback is not to be used. | |
bool | isRingtoneMuted_ {false} |
True if ringtone should be muted. | |
std::shared_ptr< RingBuffer > | mainRingBuffer_ |
Buffers for audio processing. | |
std::mutex | mutex_ {} |
Lock for the entire audio layer. | |
size_t | nativeFrameSize_ {0} |
double | playbackGain_ |
Gain applied to playback signal. | |
std::unique_ptr< AudioFrameResizer > | playbackQueue_ |
bool | playbackStarted_ {false} |
const AudioPreference & | pref_ |
bool | recordStarted_ {false} |
std::unique_ptr< Resampler > | resampler_ |
Manage sampling rate conversion. | |
std::condition_variable | startedCv_ |
std::atomic< Status > | status_ {Status::Idle} |
Whether or not the audio layer's playback stream is started. | |
RingBuffer | urgentRingBuffer_ |
Urgent ring buffer used for ringtones. | |
Definition at line 50 of file opensllayer.h.
jami::OpenSLLayer::OpenSLLayer | ( | const AudioPreference & | pref | ) |
Constructor.
Definition at line 39 of file opensllayer.cpp.
jami::OpenSLLayer::~OpenSLLayer | ( | ) |
Destructor.
Definition at line 44 of file opensllayer.cpp.
References shutdownAudioEngine().
void jami::OpenSLLayer::engineServicePlay | ( | ) |
Definition at line 261 of file opensllayer.cpp.
References jami::emitSignal(), ProducerConsumerQueue< T >::front(), jami::AudioLayer::getToPlay(), JAMI_ERR, JAMI_WARN, ProducerConsumerQueue< T >::pop(), ProducerConsumerQueue< T >::push(), and sample_buf::size_.
Referenced by startStream().
void jami::OpenSLLayer::engineServiceRec | ( | ) |
Definition at line 321 of file opensllayer.cpp.
Referenced by startStream().
void jami::OpenSLLayer::engineServiceRing | ( | ) |
Definition at line 291 of file opensllayer.cpp.
References jami::emitSignal(), ProducerConsumerQueue< T >::front(), jami::AudioLayer::getToRing(), JAMI_ERR, JAMI_WARN, ProducerConsumerQueue< T >::pop(), ProducerConsumerQueue< T >::push(), and sample_buf::size_.
Referenced by startStream().
|
inlineoverridevirtual |
Implements jami::AudioLayer.
Definition at line 95 of file opensllayer.h.
|
inlineoverridevirtual |
Implements jami::AudioLayer.
Definition at line 97 of file opensllayer.h.
|
overridevirtual |
Scan the sound card available for capture on the system.
Implements jami::AudioLayer.
Definition at line 387 of file opensllayer.cpp.
References jami::emitSignal(), JAMI_DBG, JAMI_ERR, and MAX_NUMBER_INPUT_DEVICES.
|
overridevirtual |
Scan the sound card available for capture on the system.
Implements jami::AudioLayer.
Definition at line 453 of file opensllayer.cpp.
References jami::emitSignal().
void jami::OpenSLLayer::init | ( | ) |
void jami::OpenSLLayer::initAudioEngine | ( | ) |
Definition at line 169 of file opensllayer.cpp.
References jami::allocateSampleBufs(), BUF_COUNT, jami::emitSignal(), jami::AudioFormat::getBytesPerFrame(), jami::AudioLayer::hardwareFormatAvailable(), JAMI_LOG, JAMI_WARN, ProducerConsumerQueue< T >::push(), SLASSERT, and jami::AudioFormat::toString().
Referenced by startStream().
void jami::OpenSLLayer::shutdownAudioEngine | ( | ) |
Definition at line 199 of file opensllayer.cpp.
References ProducerConsumerQueue< T >::clear(), JAMI_DBG, jami::AudioLayer::startedCv_, and stopAudioCapture().
Referenced by ~OpenSLLayer().
void jami::OpenSLLayer::startAudioCapture | ( | ) |
Definition at line 327 of file opensllayer.cpp.
References jami::emitSignal(), jami::libav_utils::fillWithSilence(), ProducerConsumerQueue< T >::front(), jami::AudioFormat::getBytesPerFrame(), jami::AudioLayer::isCaptureMuted_, JAMI_DBG, ProducerConsumerQueue< T >::pop(), ProducerConsumerQueue< T >::push(), jami::AudioLayer::putRecorded(), and jami::AudioLayer::recordChanged().
Referenced by startStream().
|
overridevirtual |
Start the capture stream and prepare the playback stream.
The playback starts accordingly to its threshold
Implements jami::AudioLayer.
Definition at line 50 of file opensllayer.cpp.
References jami::CAPTURE, jami::emitSignal(), engineServicePlay(), engineServiceRec(), engineServiceRing(), initAudioEngine(), JAMI_ERR, JAMI_WARN, jami::AudioLayer::mutex_, jami::PLAYBACK, jami::AudioLayer::playbackChanged(), jami::RINGTONE, jami::AudioLayer::setHasNativeAEC(), jami::AudioLayer::setHasNativeNS(), startAudioCapture(), jami::AudioLayer::Started, and jami::AudioLayer::status_.
void jami::OpenSLLayer::stopAudioCapture | ( | ) |
Definition at line 367 of file opensllayer.cpp.
References jami::emitSignal(), and JAMI_DBG.
Referenced by shutdownAudioEngine(), and stopStream().
|
overridevirtual |
Stop the playback and capture streams.
Drops the pending frames and put the capture and playback handles to PREPARED state
Implements jami::AudioLayer.
Definition at line 113 of file opensllayer.cpp.
References BUF_COUNT, jami::CAPTURE, ProducerConsumerQueue< T >::clear(), jami::emitSignal(), jami::AudioLayer::flush(), jami::AudioLayer::Idle, JAMI_WARN, jami::AudioLayer::mutex_, jami::PLAYBACK, jami::AudioLayer::playbackChanged(), ProducerConsumerQueue< T >::push(), jami::RINGTONE, jami::AudioLayer::status_, and stopAudioCapture().