|
Ring Daemon
|
#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 | startCaptureStream (const std::string &id) |
| Start a capture stream on the given device (eg. | |
| virtual void | startStream (AudioDeviceType stream)=0 |
| Start the capture stream and prepare the playback stream. | |
| virtual void | stopCaptureStream (const std::string &id) |
| Stop an ongoing capture stream on the given device. | |
| 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 : uint8_t { 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 59 of file audiolayer.h.
|
strongprotected |
| Enumerator | |
|---|---|
| Idle | |
| Starting | |
| Started | |
Definition at line 65 of file audiolayer.h.
| jami::AudioLayer::AudioLayer | ( | const AudioPreference & | pref | ) |
Definition at line 39 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 62 of file audiolayer.cpp.
|
protected |
Definition at line 81 of file audiolayer.cpp.
References jami::emitSignal().
Referenced by jami::PortAudioLayer::PortAudioLayer().

|
protected |
Definition at line 99 of file audiolayer.cpp.
References jami::RingBuffer::flushAll(), jami::RingBufferPool::flushAllBuffers(), jami::Manager::getRingBufferPool(), jami::Manager::instance(), and urgentRingBuffer_.

| void jami::AudioLayer::flushMain | ( | ) |
Flush main buffer.
Definition at line 87 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 93 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::PulseLayer, jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, jami::AAudioLayer, and jami::PortAudioLayer.
|
pure virtual |
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, jami::PulseLayer, jami::AAudioLayer, and jami::PortAudioLayer.
|
pure virtual |
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, jami::PulseLayer, jami::AAudioLayer, and jami::PortAudioLayer.
|
inline |
Get capture stream gain (microphone)
Definition at line 168 of file audiolayer.h.
References captureGain_.
|
inline |
Get the audio format of the layer (sample rate & channel number).
Definition at line 191 of file audiolayer.h.
References audioFormat_.
Referenced by jami::AlsaLayer::startStream().
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, jami::AAudioLayer, and jami::PortAudioLayer.
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, jami::AAudioLayer, and jami::PortAudioLayer.
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, jami::AAudioLayer, and jami::PortAudioLayer.
|
inlineprotected |
Definition at line 220 of file audiolayer.h.
References jami::emitSignal(), getToPlay(), and getToRing().

|
pure virtual |
Implemented in jami::AlsaLayer, jami::CoreLayer, jami::CoreLayer, jami::PulseLayer, jami::AAudioLayer, and jami::PortAudioLayer.
|
inline |
Get playback stream gain (speaker)
Definition at line 179 of file audiolayer.h.
References playbackGain_.
Get the sample rate of the audio layer.
Definition at line 186 of file audiolayer.h.
References audioFormat_, and jami::AudioFormat::sample_rate.
Referenced by notifyIncomingCall().
|
protected |
Definition at line 292 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 getPlayback(), jami::AlsaLayer::playback(), and jami::PulseLayer::writeToSpeaker().

|
protected |
Definition at line 275 of file audiolayer.cpp.
References jami::emitSignal(), jami::Manager::instance(), isRingtoneMuted_, resampler_, and jami::AudioFormat::sample_rate.
Referenced by 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 65 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::JackLayer::JackLayer(), and jami::AlsaLayer::startStream().

|
protected |
Set the input format on necessary objects.
Definition at line 75 of file audiolayer.cpp.
References JAMI_LOG, and jami::AudioFormat::toString().
Referenced by jami::JackLayer::JackLayer().

|
inline |
Definition at line 142 of file audiolayer.h.
References isCaptureMuted_.
|
inline |
Definition at line 149 of file audiolayer.h.
References isPlaybackMuted_.
|
inline |
Definition at line 156 of file audiolayer.h.
References isRingtoneMuted_.
|
inline |
Determine whether or not the audio layer is active (i.e.
playback opened)
Definition at line 109 of file audiolayer.h.
References Started, and status_.
Referenced by waitForStart().
Mute capture (microphone)
Definition at line 147 of file audiolayer.h.
References jami::emitSignal(), and isCaptureMuted_.

Mute playback.
Definition at line 154 of file audiolayer.h.
References jami::emitSignal(), and isPlaybackMuted_.

Definition at line 157 of file audiolayer.h.
References jami::emitSignal(), and isRingtoneMuted_.

| void jami::AudioLayer::notifyIncomingCall | ( | ) |
Emit an audio notification (beep) on incoming calls.
Definition at line 253 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 106 of file audiolayer.cpp.
References playbackStarted_.
Referenced by jami::AlsaLayer::run(), jami::PulseLayer::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 130 of file audiolayer.h.
|
protected |
Definition at line 339 of file audiolayer.cpp.
References jami::emitSignal(), jami_tracepoint, mainRingBuffer_, playbackStarted_, and recordStarted_.
Referenced by jami::AlsaLayer::capture(), and jami::PulseLayer::readFromMic().

| 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 246 of file audiolayer.cpp.
References jami::emitSignal(), jami::RingBuffer::put(), and urgentRingBuffer_.

Definition at line 112 of file audiolayer.cpp.
References recordStarted_.
Referenced by jami::AlsaLayer::run(), jami::PortAudioLayer::stopStream(), and jami::PulseLayer::~PulseLayer().
Set capture stream gain (microphone) Range should be [-1.0, 1.0].
Definition at line 163 of file audiolayer.h.
References captureGain_, and jami::emitSignal().

Definition at line 148 of file audiolayer.cpp.
References jami::emitSignal(), jami::AudioPreference::getEchoCanceller(), hasNativeAEC_, JAMI_INFO, pref_, and jami::shouldUseAudioProcessorEchoCancel().
Referenced by jami::AAudioLayer::AAudioLayer(), jami::AlsaLayer::AlsaLayer(), jami::PortAudioLayer::PortAudioLayer(), and jami::PulseLayer::startStream().

Definition at line 160 of file audiolayer.cpp.
References jami::emitSignal(), jami::AudioPreference::getNoiseReduce(), hasNativeNS_, JAMI_INFO, pref_, and jami::shouldUseAudioProcessorNoiseSuppression().
Referenced by jami::AAudioLayer::AAudioLayer(), jami::AlsaLayer::AlsaLayer(), jami::PortAudioLayer::PortAudioLayer(), and jami::PulseLayer::PulseLayer().

Set playback stream gain (speaker) Range should be [-1.0, 1.0].
Definition at line 174 of file audiolayer.h.
References jami::emitSignal(), and playbackGain_.

Start a capture stream on the given device (eg.
a window handle, or a hard-coded string like "desktop-audio"). Not all audio layers will implement this method, so default implementation does nothing.
| id | The identifier of the device from which audio should be captured |
Reimplemented in jami::PulseLayer.
Definition at line 82 of file audiolayer.h.
References jami::emitSignal().

|
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::PulseLayer, jami::AAudioLayer, jami::PortAudioLayer, and jami::CoreLayer.
Stop an ongoing capture stream on the given device.
Not all audio layers will implement this method, so default implementation does nothing.
| id | The identifier of the capture device from which audio should stop being captured |
Reimplemented in jami::PulseLayer.
Definition at line 89 of file audiolayer.h.
References jami::emitSignal().

|
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::AAudioLayer, and jami::PortAudioLayer.
|
pure virtual |
Implemented in jami::AAudioLayer, and jami::PortAudioLayer.
|
inline |
Definition at line 112 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 279 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 284 of file audiolayer.h.
Referenced by hardwareFormatAvailable(), jami::JackLayer::JackLayer(), and jami::AlsaLayer::startStream().
|
protected |
Gain applied to mic signal.
Definition at line 254 of file audiolayer.h.
Referenced by getCaptureGain(), and setCaptureGain().
Definition at line 248 of file audiolayer.h.
Referenced by setHasNativeAEC().
Definition at line 249 of file audiolayer.h.
Referenced by setHasNativeNS().
|
protected |
True if capture is not to be used.
Definition at line 234 of file audiolayer.h.
Referenced by isCaptureMuted(), muteCapture(), and jami::PulseLayer::readFromMic().
|
protected |
True if playback is not to be used.
Definition at line 239 of file audiolayer.h.
Referenced by isPlaybackMuted(), mutePlayback(), and jami::PulseLayer::writeToSpeaker().
True if ringtone should be muted.
Definition at line 244 of file audiolayer.h.
Referenced by getToRing(), isRingtoneMuted(), muteRingtone(), and jami::PulseLayer::ringtoneToSpeaker().
|
protected |
Buffers for audio processing.
Definition at line 267 of file audiolayer.h.
Referenced by putRecorded().
|
mutableprotected |
Lock for the entire audio layer.
Definition at line 296 of file audiolayer.h.
Referenced by jami::AlsaLayer::startStream(), jami::PulseLayer::startStream(), jami::AAudioLayer::startStream(), jami::PortAudioLayer::startStream(), jami::AlsaLayer::stopStream(), jami::PulseLayer::stopStream(), jami::AAudioLayer::stopStream(), jami::PortAudioLayer::stopStream(), waitForStart(), and jami::AAudioLayer::~AAudioLayer().
|
protected |
Definition at line 286 of file audiolayer.h.
Referenced by hardwareFormatAvailable().
|
protected |
Gain applied to playback signal.
Definition at line 259 of file audiolayer.h.
Referenced by getPlaybackGain(), and setPlaybackGain().
|
protected |
Definition at line 268 of file audiolayer.h.
Referenced by getToPlay().
Definition at line 246 of file audiolayer.h.
Referenced by playbackChanged(), and putRecorded().
|
protected |
Definition at line 262 of file audiolayer.h.
Referenced by AudioLayer(), setHasNativeAEC(), and setHasNativeNS().
Definition at line 247 of file audiolayer.h.
Referenced by putRecorded(), and recordChanged().
|
protected |
Manage sampling rate conversion.
Definition at line 301 of file audiolayer.h.
Referenced by getToPlay(), and getToRing().
|
mutableprotected |
Definition at line 274 of file audiolayer.h.
Referenced by jami::PulseLayer::startStream(), jami::PortAudioLayer::startStream(), jami::PulseLayer::stopStream(), jami::PortAudioLayer::stopStream(), and waitForStart().
|
protected |
Whether or not the audio layer's playback stream is started.
Definition at line 273 of file audiolayer.h.
Referenced by isStarted(), jami::AlsaLayer::run(), jami::AlsaLayer::startStream(), jami::PulseLayer::startStream(), jami::PortAudioLayer::startStream(), jami::AlsaLayer::stopStream(), jami::PulseLayer::stopStream(), jami::PortAudioLayer::stopStream(), and jami::AlsaLayer::~AlsaLayer().
|
protected |
Urgent ring buffer used for ringtones.
Definition at line 291 of file audiolayer.h.
Referenced by AudioLayer(), flush(), flushUrgent(), getToPlay(), hardwareFormatAvailable(), notifyIncomingCall(), and putUrgent().