Ring Daemon 16.0.0
|
#include <alsalayer.h>
Public Member Functions | |
AlsaLayer (const AudioPreference &pref) | |
Constructor. | |
std::string | buildDeviceTopo (const std::string &plugin, int card) |
Concatenate two strings. | |
void | capture () |
int | getAudioDeviceIndex (const std::string &description, AudioDeviceType type) const |
An index is associated with its string description. | |
std::string | getAudioDeviceName (int index, AudioDeviceType type) const |
virtual std::vector< std::string > | getCaptureDeviceList () const |
Scan the sound card available on the system. | |
virtual int | getIndexCapture () const |
Get the index of the audio card for capture. | |
virtual int | getIndexPlayback () const |
Get the index of the audio card for playback. | |
virtual int | getIndexRingtone () const |
Get the index of the audio card for ringtone (could be differnet from playback) | |
virtual std::vector< std::string > | getPlaybackDeviceList () const |
void | playback () |
void | ringtone () |
void | run () |
Reimplementation of run() | |
virtual void | startStream (AudioDeviceType stream=AudioDeviceType::ALL) |
Start the capture stream and prepare the playback stream. | |
virtual void | stopStream (AudioDeviceType stream=AudioDeviceType::ALL) |
Stop the playback and capture streams. | |
~AlsaLayer () | |
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 () |
Static Public Member Functions | |
static bool | soundCardIndexExists (int card, AudioDeviceType stream) |
Check if the given index corresponds to an existing sound card and supports the specified streaming mode. | |
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 47 of file alsalayer.h.
jami::AlsaLayer::AlsaLayer | ( | const AudioPreference & | pref | ) |
Constructor.
Definition at line 36 of file alsalayer.cpp.
References jami::AudioLayer::setHasNativeAEC(), and jami::AudioLayer::setHasNativeNS().
jami::AlsaLayer::~AlsaLayer | ( | ) |
Destructor.
Definition at line 47 of file alsalayer.cpp.
References jami::AudioLayer::Idle, and jami::AudioLayer::status_.
Concatenate two strings.
Used to build a valid pcm device name.
plugin | the alsa PCM name |
card | the sound card number |
Definition at line 501 of file alsalayer.cpp.
References jami::emitSignal(), and PCM_DEFAULT.
Referenced by startStream().
void jami::AlsaLayer::capture | ( | ) |
Definition at line 656 of file alsalayer.cpp.
References jami::emitSignal(), JAMI_ERR, and jami::AudioLayer::putRecorded().
Referenced by run().
|
virtual |
An index is associated with its string description.
description | The string description |
Implements jami::AudioLayer.
Definition at line 623 of file alsalayer.cpp.
References jami::CAPTURE.
|
virtual |
Implements jami::AudioLayer.
Definition at line 636 of file alsalayer.cpp.
References jami::CAPTURE, getCaptureDeviceList(), getPlaybackDeviceList(), JAMI_ERR, jami::PLAYBACK, and jami::RINGTONE.
|
virtual |
Scan the sound card available on the system.
Implements jami::AudioLayer.
Definition at line 539 of file alsalayer.cpp.
References jami::getValues().
Referenced by getAudioDeviceName().
Get the index of the audio card for capture.
Implements jami::AudioLayer.
Definition at line 119 of file alsalayer.h.
Get the index of the audio card for playback.
Implements jami::AudioLayer.
Definition at line 126 of file alsalayer.h.
Referenced by startStream().
Get the index of the audio card for ringtone (could be differnet from playback)
Implements jami::AudioLayer.
Definition at line 133 of file alsalayer.h.
Referenced by startStream().
|
virtual |
Implements jami::AudioLayer.
Definition at line 545 of file alsalayer.cpp.
References jami::getValues().
Referenced by getAudioDeviceName().
void jami::AlsaLayer::playback | ( | ) |
Definition at line 678 of file alsalayer.cpp.
References jami::AudioLayer::audioFormat_, jami::emitSignal(), jami::AudioLayer::getToPlay(), and jami::safeUpdate().
Referenced by run().
void jami::AlsaLayer::ringtone | ( | ) |
Definition at line 695 of file alsalayer.cpp.
References jami::AudioLayer::audioFormat_, jami::emitSignal(), jami::AudioLayer::getToRing(), and jami::safeUpdate().
Referenced by run().
void jami::AlsaLayer::run | ( | ) |
Reimplementation of run()
Definition at line 62 of file alsalayer.cpp.
References capture(), jami::emitSignal(), playback(), jami::AudioLayer::playbackChanged(), jami::AudioLayer::recordChanged(), ringtone(), jami::AudioLayer::Started, and jami::AudioLayer::status_.
|
static |
Check if the given index corresponds to an existing sound card and supports the specified streaming mode.
card | An index |
stream | The stream mode AudioDeviceType::CAPTURE AudioDeviceType::PLAYBACK AudioDeviceType::RINGTONE |
Definition at line 604 of file alsalayer.cpp.
References jami::emitSignal(), and jami::PLAYBACK.
|
virtual |
Start the capture stream and prepare the playback stream.
The playback starts accordingly to its threshold ALSA Library API
Implements jami::AudioLayer.
Definition at line 121 of file alsalayer.cpp.
References ALSA_CAPTURE_DEVICE, ALSA_PLAYBACK_DEVICE, jami::AudioLayer::audioFormat_, jami::AudioLayer::audioInputFormat_, buildDeviceTopo(), jami::CAPTURE, jami::emitSignal(), jami::AudioLayer::getFormat(), getIndexPlayback(), getIndexRingtone(), jami::AudioLayer::hardwareFormatAvailable(), jami::AudioLayer::mutex_, PCM_DMIX, PCM_DMIX_DSNOOP, PCM_DSNOOP, jami::PLAYBACK, jami::RINGTONE, jami::AudioLayer::Started, jami::AudioLayer::Starting, and jami::AudioLayer::status_.
|
virtual |
Stop the playback and capture streams.
Drops the pending frames and put the capture and playback handles to PREPARED state ALSA Library API
Implements jami::AudioLayer.
Definition at line 167 of file alsalayer.cpp.
References jami::CAPTURE, jami::emitSignal(), jami::AudioLayer::flushMain(), jami::AudioLayer::flushUrgent(), jami::AudioLayer::Idle, jami::AudioLayer::mutex_, jami::PLAYBACK, jami::RINGTONE, and jami::AudioLayer::status_.