Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jami::PortAudioLayer Class Referencefinal

#include <portaudiolayer.h>

Inheritance diagram for jami::PortAudioLayer:
Inheritance graph
Collaboration diagram for jami::PortAudioLayer:
Collaboration graph

Classes

struct  PortAudioLayerImpl
 

Public Member Functions

int getAudioDeviceIndex (const std::string &name, AudioDeviceType type) const override
 
std::string getAudioDeviceName (int index, AudioDeviceType type) const override
 
std::vector< std::string > getCaptureDeviceList () const override
 
int getIndexCapture () const override
 
int getIndexPlayback () const override
 
int getIndexRingtone () const override
 
std::vector< std::string > getPlaybackDeviceList () const override
 
 PortAudioLayer (const AudioPreference &pref)
 
void startStream (AudioDeviceType stream=AudioDeviceType::ALL) override
 Start the capture stream and prepare the playback stream.
 
void stopStream (AudioDeviceType stream=AudioDeviceType::ALL) override
 Stop the playback and capture streams.
 
void updatePreference (AudioPreference &pref, int index, AudioDeviceType type) override
 
 ~PortAudioLayer ()
 
- Public Member Functions inherited from jami::AudioLayer
 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

- Protected Types inherited from jami::AudioLayer
enum class  Status { Idle , Starting , Started }
 
- Protected Member Functions inherited from jami::AudioLayer
void devicesChanged ()
 
void flush ()
 
std::shared_ptr< AudioFramegetPlayback (AudioFormat format, size_t samples)
 
std::shared_ptr< AudioFramegetToPlay (AudioFormat format, size_t writableSamples)
 
std::shared_ptr< AudioFramegetToRing (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 inherited from jami::AudioLayer
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< RingBuffermainRingBuffer_
 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< AudioFrameResizerplaybackQueue_
 
bool playbackStarted_ {false}
 
const AudioPreferencepref_
 
bool recordStarted_ {false}
 
std::unique_ptr< Resamplerresampler_
 Manage sampling rate conversion.
 
std::condition_variable startedCv_
 
std::atomic< Statusstatus_ {Status::Idle}
 Whether or not the audio layer's playback stream is started.
 
RingBuffer urgentRingBuffer_
 Urgent ring buffer used for ringtones.
 

Detailed Description

Definition at line 27 of file portaudiolayer.h.

Constructor & Destructor Documentation

◆ PortAudioLayer()

jami::PortAudioLayer::PortAudioLayer ( const AudioPreference pref)

◆ ~PortAudioLayer()

jami::PortAudioLayer::~PortAudioLayer ( )

Definition at line 120 of file portaudiolayer.cpp.

References stopStream().

Here is the call graph for this function:

Member Function Documentation

◆ getAudioDeviceIndex()

int jami::PortAudioLayer::getAudioDeviceIndex ( const std::string &  name,
AudioDeviceType  type 
) const
overridevirtual

Implements jami::AudioLayer.

Definition at line 138 of file portaudiolayer.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getAudioDeviceName()

std::string jami::PortAudioLayer::getAudioDeviceName ( int  index,
AudioDeviceType  type 
) const
overridevirtual

Implements jami::AudioLayer.

Definition at line 148 of file portaudiolayer.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getCaptureDeviceList()

std::vector< std::string > jami::PortAudioLayer::getCaptureDeviceList ( ) const
overridevirtual

Implements jami::AudioLayer.

Definition at line 126 of file portaudiolayer.cpp.

References jami::CAPTURE.

◆ getIndexCapture()

int jami::PortAudioLayer::getIndexCapture ( ) const
overridevirtual

Implements jami::AudioLayer.

Definition at line 156 of file portaudiolayer.cpp.

References jami::CAPTURE.

◆ getIndexPlayback()

int jami::PortAudioLayer::getIndexPlayback ( ) const
overridevirtual

Implements jami::AudioLayer.

Definition at line 162 of file portaudiolayer.cpp.

References jami::PLAYBACK.

◆ getIndexRingtone()

int jami::PortAudioLayer::getIndexRingtone ( ) const
overridevirtual

Implements jami::AudioLayer.

Definition at line 169 of file portaudiolayer.cpp.

References jami::RINGTONE.

◆ getPlaybackDeviceList()

std::vector< std::string > jami::PortAudioLayer::getPlaybackDeviceList ( ) const
overridevirtual

Implements jami::AudioLayer.

Definition at line 132 of file portaudiolayer.cpp.

References jami::PLAYBACK.

◆ startStream()

void jami::PortAudioLayer::startStream ( AudioDeviceType  stream = AudioDeviceType::ALL)
overridevirtual

Start the capture stream and prepare the playback stream.

The playback starts accordingly to its threshold

Implements jami::AudioLayer.

Definition at line 175 of file portaudiolayer.cpp.

References jami::ALL, jami::CAPTURE, jami::emitSignal(), jami::AudioLayer::flushMain(), jami::AudioLayer::flushUrgent(), jami::AudioLayer::Idle, JAMI_WARN, jami::AudioLayer::mutex_, jami::PLAYBACK, jami::RINGTONE, jami::AudioLayer::Started, and jami::AudioLayer::status_.

Here is the call graph for this function:

◆ stopStream()

void jami::PortAudioLayer::stopStream ( AudioDeviceType  stream = AudioDeviceType::ALL)
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 218 of file portaudiolayer.cpp.

References jami::ALL, jami::CAPTURE, jami::emitSignal(), jami::AudioLayer::flushMain(), jami::AudioLayer::flushUrgent(), jami::Input, jami::IO, JAMI_DBG, jami::AudioLayer::mutex_, jami::Output, jami::PLAYBACK, jami::AudioLayer::playbackChanged(), jami::AudioLayer::recordChanged(), jami::RINGTONE, jami::AudioLayer::Started, and jami::AudioLayer::status_.

Referenced by ~PortAudioLayer().

Here is the call graph for this function:

◆ updatePreference()

void jami::PortAudioLayer::updatePreference ( AudioPreference pref,
int  index,
AudioDeviceType  type 
)
overridevirtual

Implements jami::AudioLayer.

Definition at line 269 of file portaudiolayer.cpp.

References jami::CAPTURE, jami::emitSignal(), jami::PLAYBACK, and jami::RINGTONE.

Here is the call graph for this function:

The documentation for this class was generated from the following files: