Ring Daemon 16.0.0
Loading...
Searching...
No Matches
jami::OpenSLLayer Class Reference

#include <opensllayer.h>

Inheritance diagram for jami::OpenSLLayer:
Inheritance graph
Collaboration diagram for jami::OpenSLLayer:
Collaboration graph

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.
 
- 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 50 of file opensllayer.h.

Constructor & Destructor Documentation

◆ OpenSLLayer()

jami::OpenSLLayer::OpenSLLayer ( const AudioPreference pref)

Constructor.

Definition at line 39 of file opensllayer.cpp.

◆ ~OpenSLLayer()

jami::OpenSLLayer::~OpenSLLayer ( )

Destructor.

Definition at line 44 of file opensllayer.cpp.

References shutdownAudioEngine().

Here is the call graph for this function:

Member Function Documentation

◆ engineServicePlay()

void jami::OpenSLLayer::engineServicePlay ( )

◆ engineServiceRec()

void jami::OpenSLLayer::engineServiceRec ( )

Definition at line 321 of file opensllayer.cpp.

Referenced by startStream().

◆ engineServiceRing()

void jami::OpenSLLayer::engineServiceRing ( )

◆ getAudioDeviceIndex()

virtual int jami::OpenSLLayer::getAudioDeviceIndex ( const std::string &  ,
AudioDeviceType   
) const
inlineoverridevirtual

Implements jami::AudioLayer.

Definition at line 95 of file opensllayer.h.

◆ getAudioDeviceName()

virtual std::string jami::OpenSLLayer::getAudioDeviceName ( int  ,
AudioDeviceType   
) const
inlineoverridevirtual

Implements jami::AudioLayer.

Definition at line 97 of file opensllayer.h.

◆ getCaptureDeviceList()

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

Scan the sound card available for capture on the system.

Returns
std::vector<std::string> The vector containing the string description of the card

Implements jami::AudioLayer.

Definition at line 387 of file opensllayer.cpp.

References jami::emitSignal(), JAMI_DBG, JAMI_ERR, and MAX_NUMBER_INPUT_DEVICES.

Here is the call graph for this function:

◆ getPlaybackDeviceList()

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

Scan the sound card available for capture on the system.

Returns
std::vector<std::string> The vector containing the string description of the card

Implements jami::AudioLayer.

Definition at line 453 of file opensllayer.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ init()

void jami::OpenSLLayer::init ( )

◆ initAudioEngine()

◆ shutdownAudioEngine()

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().

Here is the call graph for this function:

◆ startAudioCapture()

◆ startStream()

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

◆ stopAudioCapture()

void jami::OpenSLLayer::stopAudioCapture ( )

Definition at line 367 of file opensllayer.cpp.

References jami::emitSignal(), and JAMI_DBG.

Referenced by shutdownAudioEngine(), and stopStream().

Here is the call graph for this function:

◆ stopStream()

void jami::OpenSLLayer::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 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().

Here is the call graph for this function:

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