SoDaRadio-12.2.0-cut_dependencies:6c82803
Loading...
Searching...
No Matches
SoDaCLI::AudioOutThread Class Reference

Receives demodulated audio from SoDaServer and plays it. More...

#include <CLIAudio.hxx>

Inheritance diagram for SoDaCLI::AudioOutThread:

Public Member Functions

 AudioOutThread (const std::string &sockPath, const QAudioDevice &dev, float initVolume=0.0f, QObject *parent=nullptr)
 ~AudioOutThread ()
void setVolume (float v)
 Set playback volume (thread-safe).
double getRMS () const
 Return the RMS of samples received in the last completed second.
void stopAudio ()
 Stop the thread cleanly.

Protected Member Functions

void run () override

Private Attributes

std::string sock_path
QAudioDevice device
std::atomic< float > pending_volume
std::atomic< bool > stop_flag
std::atomic< double > last_rms {-1.0}

Detailed Description

Receives demodulated audio from SoDaServer and plays it.

Connects as a QLocalSocket client to sockPath (the server's _rxa socket). Incoming float32 samples are forwarded directly to a QAudioSink in push mode. Volume is adjustable at any time.

Create, call start(), then use setVolume() to unmute.

Definition at line 92 of file CLIAudio.hxx.

Constructor & Destructor Documentation

◆ AudioOutThread()

SoDaCLI::AudioOutThread::AudioOutThread ( const std::string & sockPath,
const QAudioDevice & dev,
float initVolume = 0.0f,
QObject * parent = nullptr )
explicit
Parameters
sockPathFull path of the _rxa socket.
devAudio output device.
initVolumeInitial volume [0.0 = muted, 1.0 = full].
parentOptional Qt parent.

◆ ~AudioOutThread()

SoDaCLI::AudioOutThread::~AudioOutThread ( )

Member Function Documentation

◆ getRMS()

double SoDaCLI::AudioOutThread::getRMS ( ) const
inline

Return the RMS of samples received in the last completed second.

Returns -1.0 if no data has been received yet.

Definition at line 117 of file CLIAudio.hxx.

References last_rms.

◆ run()

void SoDaCLI::AudioOutThread::run ( )
overrideprotected

◆ setVolume()

void SoDaCLI::AudioOutThread::setVolume ( float v)
inline

Set playback volume (thread-safe).

Parameters
vLinear volume in [0.0, 1.0].

Definition at line 111 of file CLIAudio.hxx.

References pending_volume.

◆ stopAudio()

void SoDaCLI::AudioOutThread::stopAudio ( )

Stop the thread cleanly.

Member Data Documentation

◆ device

QAudioDevice SoDaCLI::AudioOutThread::device
private

Definition at line 129 of file CLIAudio.hxx.

◆ last_rms

std::atomic<double> SoDaCLI::AudioOutThread::last_rms {-1.0}
private

Definition at line 132 of file CLIAudio.hxx.

Referenced by getRMS().

◆ pending_volume

std::atomic<float> SoDaCLI::AudioOutThread::pending_volume
private

Definition at line 130 of file CLIAudio.hxx.

Referenced by setVolume().

◆ sock_path

std::string SoDaCLI::AudioOutThread::sock_path
private

Definition at line 128 of file CLIAudio.hxx.

◆ stop_flag

std::atomic<bool> SoDaCLI::AudioOutThread::stop_flag
private

Definition at line 131 of file CLIAudio.hxx.


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