Ring Daemon 16.0.0
|
#include <audiolayer.h>
Public Member Functions | |
AudioLayer (const AudioPreference &) | |
void | flushMain () |
Flush main buffer. | |
void | flushUrgent () |
Flush urgent buffer. | |
virtual int | getAudioDeviceIndex (const std::string &name, AudioDeviceType type) const =0 |
virtual std::string | getAudioDeviceName (int index, AudioDeviceType type) const =0 |
virtual std::vector< std::string > | getCaptureDeviceList () const =0 |
double | getCaptureGain () const |
Get capture stream gain (microphone) | |
AudioFormat | getFormat () const |
Get the audio format of the layer (sample rate & channel number). | |
virtual int | getIndexCapture () const =0 |
virtual int | getIndexPlayback () const =0 |
virtual int | getIndexRingtone () const =0 |
virtual std::vector< std::string > | getPlaybackDeviceList () const =0 |
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]. | |
virtual void | startStream (AudioDeviceType stream=AudioDeviceType::ALL)=0 |
Start the capture stream and prepare the playback stream. | |
virtual void | stopStream (AudioDeviceType stream=AudioDeviceType::ALL)=0 |
Stop the playback and capture streams. | |
virtual void | updatePreference (AudioPreference &pref, int index, AudioDeviceType type)=0 |
template<class Rep , class Period > | |
bool | waitForStart (const std::chrono::duration< Rep, Period > &rel_time) const |
virtual | ~AudioLayer () |
Protected Types | |
enum class | Status { Idle , Starting , Started } |
Protected Member Functions | |
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) |
Protected Attributes | |
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 60 of file audiolayer.h.
|
strongprotected |
Enumerator | |
---|---|
Idle | |
Starting | |
Started |
Definition at line 66 of file audiolayer.h.
jami::AudioLayer::AudioLayer | ( | const AudioPreference & | pref | ) |
Definition at line 40 of file audiolayer.cpp.
References jami::RingBuffer::createReadOffset(), jami::RingBufferPool::DEFAULT_ID, jami::emitSignal(), jami::AudioPreference::isAGCEnabled(), JAMI_LOG, pref_, and urgentRingBuffer_.
|
virtual |
Definition at line 64 of file audiolayer.cpp.
|
protected |
Definition at line 83 of file audiolayer.cpp.
References jami::emitSignal().
Referenced by jami::PortAudioLayer::PortAudioLayer().
|
protected |
Definition at line 101 of file audiolayer.cpp.
References jami::RingBuffer::flushAll(), jami::RingBufferPool::flushAllBuffers(), jami::Manager::getRingBufferPool(), jami::Manager::instance(), and urgentRingBuffer_.
Referenced by jami::OpenSLLayer::stopStream().
void jami::AudioLayer::flushMain | ( | ) |
Flush main buffer.
Definition at line 89 of file audiolayer.cpp.
References jami::RingBufferPool::flushAllBuffers(), jami::Manager::getRingBufferPool(), and jami::Manager::instance().
Referenced by jami::PortAudioLayer::startStream(), jami::AlsaLayer::stopStream(), and jami::PortAudioLayer::stopStream().
void jami::AudioLayer::flushUrgent | ( | ) |
Flush urgent buffer.
Definition at line 95 of file audiolayer.cpp.
References jami::RingBuffer::flushAll(), and urgentRingBuffer_.
Referenced by jami::PortAudioLayer::startStream(), jami::AlsaLayer::stopStream(), and jami::PortAudioLayer::stopStream().
|
pure virtual |
Implemented in jami::OpenSLLayer, jami::PulseLayer, jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, and jami::PortAudioLayer.
|
pure virtual |
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, jami::PulseLayer, jami::PortAudioLayer, and jami::OpenSLLayer.
|
pure virtual |
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, jami::PulseLayer, jami::OpenSLLayer, and jami::PortAudioLayer.
|
inline |
Get capture stream gain (microphone)
Definition at line 155 of file audiolayer.h.
References captureGain_.
|
inline |
Get the audio format of the layer (sample rate & channel number).
Definition at line 178 of file audiolayer.h.
References audioFormat_.
Referenced by jami::AlsaLayer::startStream().
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, and jami::PortAudioLayer.
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, and jami::PortAudioLayer.
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, and jami::PortAudioLayer.
|
inlineprotected |
Definition at line 207 of file audiolayer.h.
References jami::emitSignal(), getToPlay(), and getToRing().
|
pure virtual |
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, jami::PulseLayer, jami::OpenSLLayer, and jami::PortAudioLayer.
|
inline |
Get playback stream gain (speaker)
Definition at line 166 of file audiolayer.h.
References playbackGain_.
Get the sample rate of the audio layer.
Definition at line 173 of file audiolayer.h.
References audioFormat_, and jami::AudioFormat::sample_rate.
Referenced by notifyIncomingCall().
|
protected |
Definition at line 295 of file audiolayer.cpp.
References jami::RingBufferPool::DEFAULT_ID, jami::RingBufferPool::discard(), jami::emitSignal(), jami::libav_utils::fillWithSilence(), jami::RingBuffer::get(), jami::Manager::getRingBufferPool(), jami::Manager::instance(), jami_tracepoint, notifyIncomingCall(), playbackQueue_, resampler_, and urgentRingBuffer_.
Referenced by jami::OpenSLLayer::engineServicePlay(), getPlayback(), jami::AlsaLayer::playback(), and jami::PulseLayer::writeToSpeaker().
|
protected |
Definition at line 279 of file audiolayer.cpp.
References jami::emitSignal(), jami::Manager::instance(), isRingtoneMuted_, resampler_, and jami::AudioFormat::sample_rate.
Referenced by jami::OpenSLLayer::engineServiceRing(), getPlayback(), jami::AlsaLayer::ringtone(), and jami::PulseLayer::ringtoneToSpeaker().
|
protected |
Callback to be called by derived classes when the audio output is opened.
Definition at line 67 of file audiolayer.cpp.
References audioFormat_, audioInputFormat_, jami::emitSignal(), jami::Manager::hardwareAudioFormatChanged(), jami::Manager::instance(), JAMI_LOG, nativeFrameSize_, jami::AudioFormat::sampleFormat, jami::RingBuffer::setFormat(), jami::AudioFormat::toString(), and urgentRingBuffer_.
Referenced by jami::OpenSLLayer::initAudioEngine(), jami::JackLayer::JackLayer(), and jami::AlsaLayer::startStream().
|
protected |
Set the input format on necessary objects.
Definition at line 77 of file audiolayer.cpp.
References JAMI_LOG, and jami::AudioFormat::toString().
Referenced by jami::JackLayer::JackLayer().
|
inline |
Definition at line 129 of file audiolayer.h.
References isCaptureMuted_.
|
inline |
Definition at line 136 of file audiolayer.h.
References isPlaybackMuted_.
|
inline |
Definition at line 143 of file audiolayer.h.
References isRingtoneMuted_.
|
inline |
Determine whether or not the audio layer is active (i.e.
playback opened)
Definition at line 96 of file audiolayer.h.
References Started, and status_.
Referenced by waitForStart().
Mute capture (microphone)
Definition at line 134 of file audiolayer.h.
References jami::emitSignal(), and isCaptureMuted_.
Mute playback.
Definition at line 141 of file audiolayer.h.
References jami::emitSignal(), and isPlaybackMuted_.
Definition at line 144 of file audiolayer.h.
References jami::emitSignal(), and isRingtoneMuted_.
void jami::AudioLayer::notifyIncomingCall | ( | ) |
Emit an audio notification (beep) on incoming calls.
Definition at line 257 of file audiolayer.cpp.
References audioFormat_, jami::emitSignal(), jami::RingBuffer::flushAll(), getSampleRate(), jami::RingBuffer::put(), jami::AudioFormat::sampleFormat, and urgentRingBuffer_.
Referenced by getToPlay().
Definition at line 108 of file audiolayer.cpp.
References playbackStarted_.
Referenced by jami::AlsaLayer::run(), jami::OpenSLLayer::startStream(), jami::PulseLayer::stopStream(), jami::OpenSLLayer::stopStream(), jami::PortAudioLayer::stopStream(), and jami::PulseLayer::~PulseLayer().
Start/Stop playing the incoming call notification sound (beep) while playing back audio (typically during an ongoing call).
Definition at line 117 of file audiolayer.h.
|
protected |
Definition at line 342 of file audiolayer.cpp.
References jami::emitSignal(), jami_tracepoint, mainRingBuffer_, playbackStarted_, and recordStarted_.
Referenced by jami::AlsaLayer::capture(), jami::PulseLayer::readFromMic(), and jami::OpenSLLayer::startAudioCapture().
void jami::AudioLayer::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.
buffer | The buffer containing the data to be played ( ringtones ) |
Definition at line 250 of file audiolayer.cpp.
References jami::emitSignal(), jami::RingBuffer::put(), and urgentRingBuffer_.
Definition at line 114 of file audiolayer.cpp.
References recordStarted_.
Referenced by jami::AlsaLayer::run(), jami::OpenSLLayer::startAudioCapture(), jami::PortAudioLayer::stopStream(), and jami::PulseLayer::~PulseLayer().
Set capture stream gain (microphone) Range should be [-1.0, 1.0].
Definition at line 150 of file audiolayer.h.
References captureGain_, and jami::emitSignal().
Definition at line 150 of file audiolayer.cpp.
References jami::AudioPreference::getEchoCanceller(), hasNativeAEC_, JAMI_INFO, pref_, and jami::shouldUseAudioProcessorEchoCancel().
Referenced by jami::AlsaLayer::AlsaLayer(), jami::PortAudioLayer::PortAudioLayer(), jami::PulseLayer::startStream(), and jami::OpenSLLayer::startStream().
Definition at line 163 of file audiolayer.cpp.
References jami::AudioPreference::getNoiseReduce(), hasNativeNS_, JAMI_INFO, pref_, and jami::shouldUseAudioProcessorNoiseSuppression().
Referenced by jami::AlsaLayer::AlsaLayer(), jami::PortAudioLayer::PortAudioLayer(), jami::PulseLayer::PulseLayer(), and jami::OpenSLLayer::startStream().
Set playback stream gain (speaker) Range should be [-1.0, 1.0].
Definition at line 161 of file audiolayer.h.
References jami::emitSignal(), and playbackGain_.
|
pure virtual |
Start the capture stream and prepare the playback stream.
The playback starts accordingly to its threshold
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, jami::PulseLayer, jami::OpenSLLayer, and jami::PortAudioLayer.
|
pure virtual |
Stop the playback and capture streams.
Drops the pending frames and put the capture and playback handles to PREPARED state
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, jami::PulseLayer, jami::OpenSLLayer, and jami::PortAudioLayer.
|
pure virtual |
Implemented in jami::PortAudioLayer.
|
inline |
Definition at line 99 of file audiolayer.h.
References jami::emitSignal(), isStarted(), mutex_, and startedCv_.
|
protected |
Sample Rate that should be sent to the sound card.
Definition at line 266 of file audiolayer.h.
Referenced by getFormat(), getSampleRate(), hardwareFormatAvailable(), notifyIncomingCall(), jami::AlsaLayer::playback(), jami::AlsaLayer::ringtone(), and jami::AlsaLayer::startStream().
|
protected |
Sample Rate for input.
Definition at line 271 of file audiolayer.h.
Referenced by hardwareFormatAvailable(), jami::JackLayer::JackLayer(), and jami::AlsaLayer::startStream().
|
protected |
Gain applied to mic signal.
Definition at line 241 of file audiolayer.h.
Referenced by getCaptureGain(), and setCaptureGain().
Definition at line 235 of file audiolayer.h.
Referenced by setHasNativeAEC().
Definition at line 236 of file audiolayer.h.
Referenced by setHasNativeNS().
|
protected |
True if capture is not to be used.
Definition at line 221 of file audiolayer.h.
Referenced by isCaptureMuted(), muteCapture(), jami::PulseLayer::readFromMic(), and jami::OpenSLLayer::startAudioCapture().
|
protected |
True if playback is not to be used.
Definition at line 226 of file audiolayer.h.
Referenced by isPlaybackMuted(), mutePlayback(), and jami::PulseLayer::writeToSpeaker().
True if ringtone should be muted.
Definition at line 231 of file audiolayer.h.
Referenced by getToRing(), isRingtoneMuted(), muteRingtone(), and jami::PulseLayer::ringtoneToSpeaker().
|
protected |
Buffers for audio processing.
Definition at line 254 of file audiolayer.h.
Referenced by putRecorded().
|
mutableprotected |
Lock for the entire audio layer.
Definition at line 283 of file audiolayer.h.
Referenced by jami::AlsaLayer::startStream(), jami::PulseLayer::startStream(), jami::OpenSLLayer::startStream(), jami::PortAudioLayer::startStream(), jami::AlsaLayer::stopStream(), jami::PulseLayer::stopStream(), jami::OpenSLLayer::stopStream(), jami::PortAudioLayer::stopStream(), and waitForStart().
|
protected |
Definition at line 273 of file audiolayer.h.
Referenced by hardwareFormatAvailable().
|
protected |
Gain applied to playback signal.
Definition at line 246 of file audiolayer.h.
Referenced by getPlaybackGain(), and setPlaybackGain().
|
protected |
Definition at line 255 of file audiolayer.h.
Referenced by getToPlay().
Definition at line 233 of file audiolayer.h.
Referenced by playbackChanged(), and putRecorded().
|
protected |
Definition at line 249 of file audiolayer.h.
Referenced by AudioLayer(), setHasNativeAEC(), and setHasNativeNS().
Definition at line 234 of file audiolayer.h.
Referenced by putRecorded(), and recordChanged().
|
protected |
Manage sampling rate conversion.
Definition at line 288 of file audiolayer.h.
Referenced by getToPlay(), and getToRing().
|
mutableprotected |
Definition at line 261 of file audiolayer.h.
Referenced by jami::OpenSLLayer::shutdownAudioEngine(), jami::PulseLayer::startStream(), jami::PulseLayer::stopStream(), and waitForStart().
|
protected |
Whether or not the audio layer's playback stream is started.
Definition at line 260 of file audiolayer.h.
Referenced by isStarted(), jami::AlsaLayer::run(), jami::AlsaLayer::startStream(), jami::PulseLayer::startStream(), jami::OpenSLLayer::startStream(), jami::PortAudioLayer::startStream(), jami::AlsaLayer::stopStream(), jami::PulseLayer::stopStream(), jami::OpenSLLayer::stopStream(), jami::PortAudioLayer::stopStream(), and jami::AlsaLayer::~AlsaLayer().
|
protected |
Urgent ring buffer used for ringtones.
Definition at line 278 of file audiolayer.h.
Referenced by AudioLayer(), flush(), flushUrgent(), getToPlay(), hardwareFormatAvailable(), notifyIncomingCall(), and putUrgent().