MythTV  master
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
AudioOutputBase Class Referenceabstract

#include <audiooutputbase.h>

Inheritance diagram for AudioOutputBase:
Inheritance graph
[legend]
Collaboration diagram for AudioOutputBase:
Collaboration graph
[legend]

Public Member Functions

 AudioOutputBase (const AudioSettings &settings)
 
 ~AudioOutputBase () override
 Destructor. More...
 
AudioOutputSettingsGetOutputSettingsCleaned (bool digital=true) override
 Returns capabilities supported by the audio device amended to take into account the digital audio options (AC3, DTS, E-AC3 and TrueHD) More...
 
AudioOutputSettingsGetOutputSettingsUsers (bool digital=false) override
 Returns capabilities supported by the audio device amended to take into account the digital audio options (AC3, DTS, E-AC3 and TrueHD) as well as the user settings. More...
 
void Reconfigure (const AudioSettings &settings) override
 (Re)Configure AudioOutputBase More...
 
void SetEffDsp (int dsprate) override
 Set the effective DSP rate. More...
 
void SetStretchFactor (float factor) override
 Set the timestretch factor. More...
 
float GetStretchFactor (void) const override
 Get the timetretch factor. More...
 
int GetChannels (void) const override
 
AudioFormat GetFormat (void) const override
 
int GetBytesPerFrame (void) const override
 
bool CanPassthrough (int samplerate, int channels, AVCodecID codec, int profile) const override
 Test if we can output digital audio and if sample rate is supported. More...
 
bool CanDownmix (void) const override
 
bool IsUpmixing (void) override
 Source is currently being upmixed. More...
 
bool ToggleUpmix (void) override
 Toggle between stereo and upmixed 5.1 if the source material is stereo. More...
 
bool CanUpmix (void) override
 Upmixing of the current source is available if requested. More...
 
bool CanProcess (AudioFormat) override
 
uint32_t CanProcess (void) override
 
void Reset (void) override
 Reset the audiobuffer, timecode and mythmusic visualisation. More...
 
void SetSWVolume (int new_volume, bool save) override
 Set the volume for software volume control. More...
 
int GetSWVolume (void) override
 Get the volume for software volume control. More...
 
bool AddFrames (void *buffer, int frames, std::chrono::milliseconds timecode) override
 Add frames to the audiobuffer and perform any required processing. More...
 
bool AddData (void *buffer, int len, std::chrono::milliseconds timecode, int frames) override
 Add data to the audiobuffer and perform any required processing. More...
 
bool NeedDecodingBeforePassthrough () const override
 
std::chrono::milliseconds LengthLastData (void) const override
 
void SetTimecode (std::chrono::milliseconds timecode) override
 Set the timecode of the samples most recently added to the audiobuffer. More...
 
bool IsPaused (void) const override
 
void Pause (bool paused) override
 
void PauseUntilBuffered (void) override
 
void Drain (void) override
 Block until all available frames have been written to the device. More...
 
std::chrono::milliseconds GetAudiotime (void) override
 Calculate the timecode of the samples that are about to become audible. More...
 
std::chrono::milliseconds GetAudioBufferedTime (void) override
 Get the difference in timecode between the samples that are about to become audible and the samples most recently added to the audiobuffer, i.e. More...
 
virtual void Status (void)
 Report status via an OutputEvent. More...
 
void SetSourceBitrate (int rate) override
 Set the bitrate of the source material, reported in periodic OutputEvents. More...
 
void GetBufferStatus (uint &fill, uint &total) override
 Fill in the number of bytes in the audiobuffer and the total size of the audiobuffer. More...
 
void bufferOutputData (bool y) override
 
int readOutputData (unsigned char *read_buffer, size_t max_length) override
 
- Public Member Functions inherited from AudioOutput
 AudioOutput ()=default
 
 ~AudioOutput () override
 
QString GetError (void) const
 
QString GetWarning (void) const
 
bool PulseStatus (void) const
 
virtual int DecodeAudio (AVCodecContext *ctx, uint8_t *buffer, int &data_size, const AVPacket *pkt)
 Utility routine. More...
 
- Public Member Functions inherited from VolumeBase
 VolumeBase ()
 
virtual ~VolumeBase ()=default
 
void SWVolume (bool set)
 
bool SWVolume (void) const
 
virtual uint GetCurrentVolume (void) const
 
virtual void SetCurrentVolume (int value)
 
virtual void AdjustCurrentVolume (int change)
 
virtual void ToggleMute (void)
 
virtual MuteState GetMuteState (void) const
 
virtual MuteState SetMuteState (MuteState)
 
- Public Member Functions inherited from OutputListeners
 OutputListeners ()=default
 
 ~OutputListeners () override=default
 
bool hasVisual (void)
 
void addVisual (MythTV::Visual *v)
 
void removeVisual (MythTV::Visual *v)
 
QMutex * mutex ()
 
void setBufferSize (unsigned int sz)
 
unsigned int bufferSize () const
 
- Public Member Functions inherited from MythObservable
 MythObservable ()
 
virtual ~MythObservable ()
 
void addListener (QObject *listener)
 Add a listener to the observable. More...
 
void removeListener (QObject *listener)
 Remove a listener to the observable. More...
 
void dispatch (const MythEvent &event)
 Dispatch an event to all listeners. More...
 
bool hasListeners (void)
 
- Public Member Functions inherited from MThread
 MThread (const QString &objectName)
 Standard constructor. More...
 
 MThread (const QString &objectName, QRunnable *runnable)
 Use this constructor if you want the default run() method to run the QRunnable's run() method instead of entering the Qt event loop. More...
 
virtual ~MThread ()
 
 MThread (const MThread &)=delete
 
MThreadoperator= (const MThread &)=delete
 
void RunProlog (void)
 Sets up a thread, call this if you reimplement run(). More...
 
void RunEpilog (void)
 Cleans up a thread's resources, call this if you reimplement run(). More...
 
QThread * qthread (void)
 Returns the thread, this will always return the same pointer no matter how often you restart the thread. More...
 
void setObjectName (const QString &name)
 
QString objectName (void) const
 
void setPriority (QThread::Priority priority)
 
QThread::Priority priority (void) const
 
bool isFinished (void) const
 
bool isRunning (void) const
 
void setStackSize (uint stackSize)
 
uint stackSize (void) const
 
void exit (int retcode=0)
 Use this to exit from the thread if you are using a Qt event loop. More...
 
void start (QThread::Priority p=QThread::InheritPriority)
 Tell MThread to start running the thread in the near future. More...
 
void terminate (void)
 Kill a thread unsafely. More...
 
void quit (void)
 calls exit(0) More...
 
bool wait (std::chrono::milliseconds time=std::chrono::milliseconds::max())
 Wait for the MThread to exit, with a maximum timeout. More...
 

Static Public Member Functions

static const char * quality_string (int q)
 
- Static Public Member Functions inherited from AudioOutput
static void Cleanup (void)
 
static ADCVectGetOutputList (void)
 
static AudioDeviceConfigGetAudioDeviceConfig (QString &name, const QString &desc, bool willsuspendpa=false)
 
static AudioOutputOpenAudio (const QString &main_device, const QString &passthru_device, AudioFormat format, int channels, AVCodecID codec, int samplerate, AudioOutputSource source, bool set_initial_vol, bool passthru, int upmixer_startup=0, AudioOutputSettings *custom=nullptr)
 
static AudioOutputOpenAudio (AudioSettings &settings, bool willsuspendpa=true)
 
static AudioOutputOpenAudio (const QString &main_device, const QString &passthru_device=QString(), bool willsuspendpa=true)
 
- Static Public Member Functions inherited from VolumeBase
static MuteState NextMuteState (MuteState)
 
- Static Public Member Functions inherited from MThread
static void ThreadSetup (const QString &name)
 This is to be called on startup in those few threads that haven't been ported to MThread. More...
 
static void ThreadCleanup (void)
 This is to be called on exit in those few threads that haven't been ported to MThread. More...
 
static void Cleanup (void)
 This will print out all the running threads, call exit(1) on each and then wait up to 5 seconds total for all the threads to exit. More...
 
static void GetAllThreadNames (QStringList &list)
 
static void GetAllRunningThreadNames (QStringList &list)
 

Static Public Attributes

static const uint kAudioSRCInputSize = 16384
 
static const uint kAudioRingBufferSize = 10239936U
 Audio Buffer Size – should be divisible by 32,24,16,12,10,8,6,4,2.. More...
 
- Static Public Attributes inherited from AudioOutput
static const int kMaxSizeBuffer = 384000
 kMaxSizeBuffer is the maximum size of a buffer to be used with DecodeAudio More...
 

Protected Types

enum  { QUALITY_DISABLED = -1, QUALITY_LOW = 0, QUALITY_MEDIUM = 1, QUALITY_HIGH = 2 }
 

Protected Member Functions

void InitSettings (const AudioSettings &settings)
 
virtual bool OpenDevice (void)=0
 
virtual void CloseDevice (void)=0
 
virtual void WriteAudio (unsigned char *aubuf, int size)=0
 
virtual int GetBufferedOnSoundcard (void) const =0
 Return the size in bytes of frames currently in the audio buffer adjusted with the audio playback latency. More...
 
virtual AudioOutputSettingsGetOutputSettings (bool)
 
void KillAudio (void)
 Kill the output thread and cleanup. More...
 
virtual bool StartOutputThread (void)
 
virtual void StopOutputThread (void)
 
int GetAudioData (uchar *buffer, int buf_size, bool full_buffer, volatile uint *local_raud=nullptr)
 Copy frames from the audiobuffer into the buffer provided. More...
 
void OutputAudioLoop (void)
 Run in the output thread, write frames to the output device as they become available and there's space in the device buffer to write them. More...
 
void run () override
 Main routine for the output thread. More...
 
int CheckFreeSpace (int &frames)
 Check that there's enough space in the audiobuffer to write the provided number of frames. More...
 
int audiolen () const
 Get the number of bytes in the audiobuffer. More...
 
int audiofree () const
 Get the free space in the audiobuffer in bytes. More...
 
int audioready () const
 Get the scaled number of bytes in the audiobuffer, i.e. More...
 
void SetStretchFactorLocked (float factor)
 Set the timestretch factor. More...
 
std::chrono::milliseconds GetBaseAudBufTimeCode () const
 
bool usesSpdif () const
 
- Protected Member Functions inherited from AudioOutput
void Error (const QString &msg)
 
void SilentError (const QString &msg)
 
void Warn (const QString &msg)
 
void ClearError (void)
 
void ClearWarning (void)
 
- Protected Member Functions inherited from VolumeBase
virtual int GetVolumeChannel (int channel) const =0
 
virtual void SetVolumeChannel (int channel, int volume)=0
 
void UpdateVolume (void)
 
void SyncVolume (void)
 
void SetChannels (int new_channels)
 
- Protected Member Functions inherited from OutputListeners
void error (const QString &e)
 
void dispatchVisual (uchar *b, unsigned long b_len, std::chrono::milliseconds timecode, int chan, int prec)
 
void prepareVisuals ()
 
- Protected Member Functions inherited from MThread
int exec (void)
 Enters the qt event loop. call exit or quit to exit thread. More...
 

Protected Attributes

int m_channels {-1}
 
AVCodecID m_codec {AV_CODEC_ID_NONE}
 
int m_bytesPerFrame {0}
 
int m_outputBytesPerFrame {0}
 
AudioFormat m_format {FORMAT_NONE}
 
AudioFormat m_outputFormat {FORMAT_NONE}
 
int m_sampleRate {-1}
 
int m_effDsp {0}
 
int m_fragmentSize {0}
 
long m_soundcardBufferSize {0}
 
QString m_mainDevice
 
QString m_passthruDevice
 
bool m_discreteDigital {false}
 
bool m_passthru {false}
 
bool m_enc {false}
 
bool m_reEnc {false}
 
float m_stretchFactor {1.0F}
 
int m_effStretchFactor {100000}
 
AudioOutputSource m_source
 
bool m_killAudio {false}
 
bool m_pauseAudio {false}
 
bool m_actuallyPaused {false}
 
bool m_wasPaused {false}
 
bool m_unpauseWhenReady {false}
 
bool m_setInitialVol
 
bool m_bufferOutputDataForUse {false}
 
int m_configuredChannels {0}
 
int m_maxChannels {0}
 
int m_srcQuality {QUALITY_MEDIUM}
 
long m_sourceBitRate {-1}
 
int m_sourceSampleRate {0}
 
- Protected Attributes inherited from AudioOutput
QString m_lastError
 
QString m_lastWarn
 
bool m_pulseWasSuspended {false}
 
AVFramem_frame {nullptr}
 
- Protected Attributes inherited from VolumeBase
bool m_internalVol {false}
 
- Protected Attributes inherited from MythObservable
QMutex * m_lock {nullptr}
 
QSet< QObject * > m_listeners
 
- Protected Attributes inherited from MThread
MThreadInternalm_thread {nullptr}
 
QRunnable * m_runnable {nullptr}
 
bool m_prologExecuted {true}
 
bool m_epilogExecuted {true}
 

Private Member Functions

bool SetupPassthrough (AVCodecID codec, int codec_profile, int &samplerate_tmp, int &channels_tmp)
 
AudioOutputSettingsOutputSettings (bool digital=true)
 
int CopyWithUpmix (char *buffer, int frames, uint &org_waud)
 Copy frames into the audiobuffer, upmixing en route if necessary. More...
 
void SetAudiotime (int frames, std::chrono::milliseconds timecode)
 Set the timecode of the top of the ringbuffer Exclude all other processing elements as they dont vary between AddData calls. More...
 

Private Attributes

AudioOutputSettingsm_outputSettingsRaw {nullptr}
 
AudioOutputSettingsm_outputSettings {nullptr}
 
AudioOutputSettingsm_outputSettingsDigitalRaw {nullptr}
 
AudioOutputSettingsm_outputSettingsDigital {nullptr}
 
bool m_needResampler {false}
 
SRC_STATE * m_srcCtx {nullptr}
 
soundtouch::SoundTouch * m_pSoundStretch {nullptr}
 
AudioOutputDigitalEncoderm_encoder {nullptr}
 
FreeSurroundm_upmixer {nullptr}
 
int m_sourceChannels {-1}
 
int m_sourceBytesPerFrame {0}
 
bool m_upmixDefault {false}
 
bool m_needsUpmix {false}
 
bool m_needsDownmix {false}
 
int m_surroundMode {QUALITY_LOW}
 
float m_oldStretchFactor {1.0F}
 
int m_volume {80}
 
QString m_volumeControl
 
bool m_processing {false}
 
int64_t m_framesBuffered {0}
 
bool m_audioThreadExists {false}
 
QMutex m_audioBufLock
 Writes to the audiobuffer, reconfigures and audiobuffer resets can only take place while holding this lock. More...
 
QMutex m_avsyncLock
 must hold avsync_lock to read or write 'audiotime' and 'audiotime_updated' More...
 
std::chrono::milliseconds m_audioTime {0ms}
 timecode of audio leaving the soundcard (same units as timecodes) More...
 
volatile uint m_raud {0}
 Audio circular buffer. More...
 
volatile uint m_waud {0}
 
std::chrono::milliseconds m_audbufTimecode {0ms}
 timecode of audio most recently placed into buffer More...
 
AsyncLooseLock m_resetActive
 
QMutex m_killAudioLock
 
std::chrono::seconds m_currentSeconds {-1s}
 
float * m_srcIn
 
SRC_DATA m_srcData {}
 
uint m_memoryCorruptionTest0 {0xdeadbeef}
 
std::array< float, kAudioSRCInputSizem_srcInBuf {}
 
uint m_memoryCorruptionTest1 {0xdeadbeef}
 
float * m_srcOut {nullptr}
 
int m_kAudioSRCOutputSize {0}
 
uint m_memoryCorruptionTest2 {0xdeadbeef}
 
std::array< uchar, kAudioRingBufferSizem_audioBuffer {0}
 main audio buffer More...
 
uint m_memoryCorruptionTest3 {0xdeadbeef}
 
bool m_configureSucceeded {false}
 
std::chrono::milliseconds m_lengthLastData {0ms}
 
bool m_usesSpdif {true}
 
SPDIFEncoderm_spdifEnc {nullptr}
 
bool m_forcedProcessing {false}
 
int m_previousBpf {0}
 

Additional Inherited Members

- Public Types inherited from AudioOutput
using ADCVect = QVector< AudioDeviceConfig >
 
- Static Protected Member Functions inherited from MThread
static void setTerminationEnabled (bool enabled=true)
 
static void usleep (std::chrono::microseconds time)
 
template<typename R , typename P >
static std::enable_if_t< std::chrono::treat_as_floating_point< R >::value, void > usleep (std::chrono::duration< R, P > time)
 

Detailed Description

Definition at line 51 of file audiooutputbase.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
QUALITY_DISABLED 
QUALITY_LOW 
QUALITY_MEDIUM 
QUALITY_HIGH 

Definition at line 208 of file audiooutputbase.h.

Constructor & Destructor Documentation

◆ AudioOutputBase()

AudioOutputBase::AudioOutputBase ( const AudioSettings settings)
explicit

Definition at line 65 of file audiooutputbase.cpp.

◆ ~AudioOutputBase()

AudioOutputBase::~AudioOutputBase ( )
override

Destructor.

You must kill the output thread via KillAudio() prior to destruction

Definition at line 94 of file audiooutputbase.cpp.

Member Function Documentation

◆ quality_string()

const char * AudioOutputBase::quality_string ( int  q)
static

Definition at line 53 of file audiooutputbase.cpp.

Referenced by AudioOutputBase(), and Reconfigure().

◆ GetOutputSettingsCleaned()

AudioOutputSettings * AudioOutputBase::GetOutputSettingsCleaned ( bool  digital = true)
overridevirtual

Returns capabilities supported by the audio device amended to take into account the digital audio options (AC3, DTS, E-AC3 and TrueHD)

Reimplemented from AudioOutput.

Definition at line 156 of file audiooutputbase.cpp.

Referenced by GetOutputSettingsUsers().

◆ GetOutputSettingsUsers()

AudioOutputSettings * AudioOutputBase::GetOutputSettingsUsers ( bool  digital = false)
overridevirtual

Returns capabilities supported by the audio device amended to take into account the digital audio options (AC3, DTS, E-AC3 and TrueHD) as well as the user settings.

Reimplemented from AudioOutput.

Definition at line 185 of file audiooutputbase.cpp.

Referenced by InitSettings().

◆ Reconfigure()

void AudioOutputBase::Reconfigure ( const AudioSettings orig_settings)
overridevirtual

◆ SetEffDsp()

void AudioOutputBase::SetEffDsp ( int  dsprate)
overridevirtual

Set the effective DSP rate.

Equal to 100 * samples per second NuppelVideo sets this every sync frame to achieve av sync

Implements AudioOutput.

Definition at line 981 of file audiooutputbase.cpp.

◆ SetStretchFactor()

void AudioOutputBase::SetStretchFactor ( float  factor)
overridevirtual

Set the timestretch factor.

Reimplemented from AudioOutput.

Definition at line 357 of file audiooutputbase.cpp.

◆ GetStretchFactor()

float AudioOutputBase::GetStretchFactor ( void  ) const
overridevirtual

Get the timetretch factor.

Reimplemented from AudioOutput.

Definition at line 366 of file audiooutputbase.cpp.

◆ GetChannels()

int AudioOutputBase::GetChannels ( void  ) const
inlineoverridevirtual

Reimplemented from AudioOutput.

Definition at line 70 of file audiooutputbase.h.

◆ GetFormat()

AudioFormat AudioOutputBase::GetFormat ( void  ) const
inlineoverridevirtual

Reimplemented from AudioOutput.

Definition at line 71 of file audiooutputbase.h.

◆ GetBytesPerFrame()

int AudioOutputBase::GetBytesPerFrame ( void  ) const
inlineoverridevirtual

Reimplemented from AudioOutput.

Definition at line 72 of file audiooutputbase.h.

◆ CanPassthrough()

bool AudioOutputBase::CanPassthrough ( int  samplerate,
int  channels,
AVCodecID  codec,
int  profile 
) const
overridevirtual

Test if we can output digital audio and if sample rate is supported.

Reimplemented from AudioOutput.

Definition at line 209 of file audiooutputbase.cpp.

◆ CanDownmix()

bool AudioOutputBase::CanDownmix ( void  ) const
inlineoverridevirtual

Reimplemented from AudioOutput.

Definition at line 77 of file audiooutputbase.h.

◆ IsUpmixing()

bool AudioOutputBase::IsUpmixing ( void  )
overridevirtual

Source is currently being upmixed.

Reimplemented from AudioOutput.

Definition at line 374 of file audiooutputbase.cpp.

Referenced by ToggleUpmix().

◆ ToggleUpmix()

bool AudioOutputBase::ToggleUpmix ( void  )
overridevirtual

Toggle between stereo and upmixed 5.1 if the source material is stereo.

Reimplemented from AudioOutput.

Definition at line 382 of file audiooutputbase.cpp.

◆ CanUpmix()

bool AudioOutputBase::CanUpmix ( void  )
overridevirtual

Upmixing of the current source is available if requested.

Reimplemented from AudioOutput.

Definition at line 400 of file audiooutputbase.cpp.

◆ CanProcess() [1/2]

bool AudioOutputBase::CanProcess ( AudioFormat  fmt)
inlineoverridevirtual
Parameters
fmtThe audio format in question. return true if class can handle AudioFormat All AudioOutput derivative must be able to handle S16

Reimplemented from AudioOutput.

Definition at line 81 of file audiooutputbase.h.

◆ CanProcess() [2/2]

uint32_t AudioOutputBase::CanProcess ( void  )
inlineoverridevirtual
Returns
bitmask of all AudioFormat handled All AudioOutput derivative must be able to handle S16

Reimplemented from AudioOutput.

Definition at line 82 of file audiooutputbase.h.

◆ Reset()

void AudioOutputBase::Reset ( void  )
overridevirtual

Reset the audiobuffer, timecode and mythmusic visualisation.

Implements AudioOutput.

Reimplemented in AudioOutputNULL.

Definition at line 931 of file audiooutputbase.cpp.

Referenced by PauseUntilBuffered(), and AudioOutputNULL::Reset().

◆ SetSWVolume()

void AudioOutputBase::SetSWVolume ( int  new_volume,
bool  save 
)
overridevirtual

Set the volume for software volume control.

Implements VolumeBase.

Definition at line 1167 of file audiooutputbase.cpp.

◆ GetSWVolume()

int AudioOutputBase::GetSWVolume ( void  )
overridevirtual

Get the volume for software volume control.

Implements VolumeBase.

Definition at line 1177 of file audiooutputbase.cpp.

◆ AddFrames()

bool AudioOutputBase::AddFrames ( void *  in_buffer,
int  in_frames,
std::chrono::milliseconds  timecode 
)
overridevirtual

Add frames to the audiobuffer and perform any required processing.

Returns false if there's not enough space right now

Implements AudioOutput.

Definition at line 1311 of file audiooutputbase.cpp.

◆ AddData()

bool AudioOutputBase::AddData ( void *  in_buffer,
int  in_len,
std::chrono::milliseconds  timecode,
int  frames 
)
overridevirtual

Add data to the audiobuffer and perform any required processing.

Returns false if there's not enough space right now

Implements AudioOutput.

Definition at line 1323 of file audiooutputbase.cpp.

Referenced by AudioOutputAudioTrack::AddData(), and AddFrames().

◆ NeedDecodingBeforePassthrough()

bool AudioOutputBase::NeedDecodingBeforePassthrough ( ) const
inlineoverridevirtual
Returns
true if AudioOutput class can determine the length in millisecond of native audio frames bitstreamed passed to AddData. If false, LengthLastData method must be implemented

Reimplemented from AudioOutput.

Definition at line 96 of file audiooutputbase.h.

◆ LengthLastData()

std::chrono::milliseconds AudioOutputBase::LengthLastData ( void  ) const
inlineoverridevirtual
Returns
the length of the last data added in millisecond. This function must be implemented if NeedDecodingBeforePassthrough returned false

Reimplemented from AudioOutput.

Definition at line 97 of file audiooutputbase.h.

◆ SetTimecode()

void AudioOutputBase::SetTimecode ( std::chrono::milliseconds  timecode)
overridevirtual

Set the timecode of the samples most recently added to the audiobuffer.

Used by mythmusic for seeking since it doesn't provide timecodes to AddData()

Implements AudioOutput.

Definition at line 969 of file audiooutputbase.cpp.

◆ IsPaused()

bool AudioOutputBase::IsPaused ( void  ) const
inlineoverridevirtual

Implements AudioOutput.

Definition at line 100 of file audiooutputbase.h.

◆ Pause()

void AudioOutputBase::Pause ( bool  paused)
overridevirtual

Implements AudioOutput.

Definition at line 909 of file audiooutputbase.cpp.

Referenced by AddData(), AudioOutputAudioTrack::Pause(), and PauseUntilBuffered().

◆ PauseUntilBuffered()

void AudioOutputBase::PauseUntilBuffered ( void  )
overridevirtual

Implements AudioOutput.

Definition at line 921 of file audiooutputbase.cpp.

◆ Drain()

void AudioOutputBase::Drain ( void  )
overridevirtual

Block until all available frames have been written to the device.

Implements AudioOutput.

Reimplemented in AudioOutputPulseAudio.

Definition at line 1829 of file audiooutputbase.cpp.

Referenced by AudioOutputPulseAudio::Drain().

◆ GetAudiotime()

std::chrono::milliseconds AudioOutputBase::GetAudiotime ( void  )
overridevirtual

Calculate the timecode of the samples that are about to become audible.

Implements AudioOutput.

Reimplemented in AudioOutputCA.

Definition at line 1025 of file audiooutputbase.cpp.

Referenced by GetAudioBufferedTime(), OutputAudioLoop(), SetAudiotime(), and Status().

◆ GetAudioBufferedTime()

std::chrono::milliseconds AudioOutputBase::GetAudioBufferedTime ( void  )
overridevirtual

Get the difference in timecode between the samples that are about to become audible and the samples most recently added to the audiobuffer, i.e.

the time in ms representing the sum total of buffered samples

Reimplemented from AudioOutput.

Definition at line 1155 of file audiooutputbase.cpp.

◆ Status()

void AudioOutputBase::Status ( void  )
virtual

Report status via an OutputEvent.

Definition at line 1613 of file audiooutputbase.cpp.

Referenced by AudioOutputJACK::JackCallback(), and OutputAudioLoop().

◆ SetSourceBitrate()

void AudioOutputBase::SetSourceBitrate ( int  rate)
overridevirtual

Set the bitrate of the source material, reported in periodic OutputEvents.

Reimplemented from AudioOutput.

Definition at line 271 of file audiooutputbase.cpp.

Referenced by AudioOutputAudioTrack::SetSourceBitrate().

◆ GetBufferStatus()

void AudioOutputBase::GetBufferStatus ( uint fill,
uint total 
)
overridevirtual

Fill in the number of bytes in the audiobuffer and the total size of the audiobuffer.

Reimplemented from AudioOutput.

Definition at line 1637 of file audiooutputbase.cpp.

◆ bufferOutputData()

void AudioOutputBase::bufferOutputData ( bool  y)
inlineoverridevirtual

Implements AudioOutput.

Definition at line 118 of file audiooutputbase.h.

◆ readOutputData()

int AudioOutputBase::readOutputData ( unsigned char *  read_buffer,
size_t  max_length 
)
overridevirtual

Implements AudioOutput.

Reimplemented in AudioOutputNULL.

Definition at line 1854 of file audiooutputbase.cpp.

◆ InitSettings()

void AudioOutputBase::InitSettings ( const AudioSettings settings)
protected

◆ OpenDevice()

virtual bool AudioOutputBase::OpenDevice ( void  )
protectedpure virtual

◆ CloseDevice()

virtual void AudioOutputBase::CloseDevice ( void  )
protectedpure virtual

◆ WriteAudio()

virtual void AudioOutputBase::WriteAudio ( unsigned char *  aubuf,
int  size 
)
protectedpure virtual

◆ GetBufferedOnSoundcard()

virtual int AudioOutputBase::GetBufferedOnSoundcard ( void  ) const
protectedpure virtual

Return the size in bytes of frames currently in the audio buffer adjusted with the audio playback latency.

Implemented in AudioOutputCA, AudioOutputNULL, AudioOutputPulseAudio, AudioOutputJACK, AudioOutputAudioTrack, AudioOutputOpenSLES, AudioOutputOSS, AudioOutputALSA, AudioOutputDX, and AudioOutputWin.

Referenced by GetAudiotime().

◆ GetOutputSettings()

virtual AudioOutputSettings* AudioOutputBase::GetOutputSettings ( bool  )
inlineprotectedvirtual

◆ KillAudio()

void AudioOutputBase::KillAudio ( void  )
protected

◆ StartOutputThread()

bool AudioOutputBase::StartOutputThread ( void  )
protectedvirtual

◆ StopOutputThread()

void AudioOutputBase::StopOutputThread ( void  )
protectedvirtual

◆ GetAudioData()

int AudioOutputBase::GetAudioData ( uchar *  buffer,
int  size,
bool  full_buffer,
volatile uint local_raud = nullptr 
)
protected

Copy frames from the audiobuffer into the buffer provided.

If 'full_buffer' is true we copy either 'size' bytes (if available) or nothing. Otherwise, we'll copy less than 'size' bytes if that's all that's available. Returns the number of bytes copied.

Definition at line 1742 of file audiooutputbase.cpp.

Referenced by AudioOutputJACK::JackCallback(), OutputAudioLoop(), and AudioOutputCA::RenderAudio().

◆ OutputAudioLoop()

void AudioOutputBase::OutputAudioLoop ( void  )
protected

Run in the output thread, write frames to the output device as they become available and there's space in the device buffer to write them.

Definition at line 1648 of file audiooutputbase.cpp.

Referenced by run().

◆ run()

void AudioOutputBase::run ( )
overrideprotectedvirtual

Main routine for the output thread.

Reimplemented from MThread.

Definition at line 1845 of file audiooutputbase.cpp.

◆ CheckFreeSpace()

int AudioOutputBase::CheckFreeSpace ( int &  frames)
protected

Check that there's enough space in the audiobuffer to write the provided number of frames.

If there is not enough space, set 'frames' to the number that will fit

Returns the number of bytes that the frames will take up

Definition at line 1190 of file audiooutputbase.cpp.

Referenced by AddData(), and CopyWithUpmix().

◆ audiolen()

int AudioOutputBase::audiolen ( ) const
inlineprotected

Get the number of bytes in the audiobuffer.

Definition at line 990 of file audiooutputbase.cpp.

Referenced by audiofree(), and audioready().

◆ audiofree()

int AudioOutputBase::audiofree ( ) const
protected

Get the free space in the audiobuffer in bytes.

Definition at line 1000 of file audiooutputbase.cpp.

Referenced by AddData(), CheckFreeSpace(), and GetBufferStatus().

◆ audioready()

int AudioOutputBase::audioready ( ) const
protected

Get the scaled number of bytes in the audiobuffer, i.e.

the number of samples * the output bytes per sample

This value can differ from that returned by audiolen if samples are being converted to floats and the output sample format is not 32 bits

Definition at line 1015 of file audiooutputbase.cpp.

Referenced by AddData(), Drain(), GetAudioData(), AudioOutputCA::GetAudiotime(), GetAudiotime(), and OutputAudioLoop().

◆ SetStretchFactorLocked()

void AudioOutputBase::SetStretchFactorLocked ( float  lstretchfactor)
protected

Set the timestretch factor.

You must hold the audio_buflock to call this safely

Definition at line 282 of file audiooutputbase.cpp.

Referenced by Reconfigure(), and SetStretchFactor().

◆ GetBaseAudBufTimeCode()

std::chrono::milliseconds AudioOutputBase::GetBaseAudBufTimeCode ( ) const
inlineprotected

Definition at line 167 of file audiooutputbase.h.

Referenced by AudioOutputCA::GetAudiotime().

◆ usesSpdif()

bool AudioOutputBase::usesSpdif ( ) const
inlineprotected

Definition at line 170 of file audiooutputbase.h.

Referenced by GetAudiotime().

◆ SetupPassthrough()

bool AudioOutputBase::SetupPassthrough ( AVCodecID  codec,
int  codec_profile,
int &  samplerate_tmp,
int &  channels_tmp 
)
private

Definition at line 409 of file audiooutputbase.cpp.

Referenced by Reconfigure().

◆ OutputSettings()

AudioOutputSettings * AudioOutputBase::OutputSettings ( bool  digital = true)
private

Definition at line 457 of file audiooutputbase.cpp.

Referenced by Reconfigure().

◆ CopyWithUpmix()

int AudioOutputBase::CopyWithUpmix ( char *  buffer,
int  frames,
uint org_waud 
)
private

Copy frames into the audiobuffer, upmixing en route if necessary.

Returns the number of frames written, which may be less than requested if the upmixer buffered some (or all) of them

Definition at line 1225 of file audiooutputbase.cpp.

Referenced by AddData().

◆ SetAudiotime()

void AudioOutputBase::SetAudiotime ( int  frames,
std::chrono::milliseconds  timecode 
)
private

Set the timecode of the top of the ringbuffer Exclude all other processing elements as they dont vary between AddData calls.

Definition at line 1105 of file audiooutputbase.cpp.

Referenced by AddData().

Member Data Documentation

◆ kAudioSRCInputSize

const uint AudioOutputBase::kAudioSRCInputSize = 16384
static

Definition at line 122 of file audiooutputbase.h.

Referenced by AddData(), and Reconfigure().

◆ kAudioRingBufferSize

const uint AudioOutputBase::kAudioRingBufferSize = 10239936U
static

Audio Buffer Size – should be divisible by 32,24,16,12,10,8,6,4,2..

Definition at line 126 of file audiooutputbase.h.

Referenced by AddData(), audiofree(), audiolen(), CopyWithUpmix(), GetAudioData(), and GetBufferStatus().

◆ m_channels

int AudioOutputBase::m_channels {-1}
protected

◆ m_codec

AVCodecID AudioOutputBase::m_codec {AV_CODEC_ID_NONE}
protected

Definition at line 175 of file audiooutputbase.h.

Referenced by AudioOutputAudioTrack::OpenDevice(), Reconfigure(), and ToggleUpmix().

◆ m_bytesPerFrame

int AudioOutputBase::m_bytesPerFrame {0}
protected

◆ m_outputBytesPerFrame

int AudioOutputBase::m_outputBytesPerFrame {0}
protected

◆ m_format

AudioFormat AudioOutputBase::m_format {FORMAT_NONE}
protected

Definition at line 178 of file audiooutputbase.h.

Referenced by AddData(), CopyWithUpmix(), GetFormat(), Reconfigure(), Status(), and ToggleUpmix().

◆ m_outputFormat

AudioFormat AudioOutputBase::m_outputFormat {FORMAT_NONE}
protected

◆ m_sampleRate

int AudioOutputBase::m_sampleRate {-1}
protected

◆ m_effDsp

int AudioOutputBase::m_effDsp {0}
protected

◆ m_fragmentSize

int AudioOutputBase::m_fragmentSize {0}
protected

◆ m_soundcardBufferSize

long AudioOutputBase::m_soundcardBufferSize {0}
protected

◆ m_mainDevice

QString AudioOutputBase::m_mainDevice
protected

◆ m_passthruDevice

QString AudioOutputBase::m_passthruDevice
protected

◆ m_discreteDigital

bool AudioOutputBase::m_discreteDigital {false}
protected

◆ m_passthru

bool AudioOutputBase::m_passthru {false}
protected

◆ m_enc

bool AudioOutputBase::m_enc {false}
protected

◆ m_reEnc

bool AudioOutputBase::m_reEnc {false}
protected

Definition at line 191 of file audiooutputbase.h.

Referenced by Reconfigure().

◆ m_stretchFactor

float AudioOutputBase::m_stretchFactor {1.0F}
protected

◆ m_effStretchFactor

int AudioOutputBase::m_effStretchFactor {100000}
protected

Definition at line 194 of file audiooutputbase.h.

Referenced by GetAudiotime(), SetAudiotime(), and SetStretchFactorLocked().

◆ m_source

AudioOutputSource AudioOutputBase::m_source
protected

Definition at line 195 of file audiooutputbase.h.

Referenced by Reconfigure().

◆ m_killAudio

bool AudioOutputBase::m_killAudio {false}
protected

◆ m_pauseAudio

bool AudioOutputBase::m_pauseAudio {false}
protected

◆ m_actuallyPaused

bool AudioOutputBase::m_actuallyPaused {false}
protected

◆ m_wasPaused

bool AudioOutputBase::m_wasPaused {false}
protected

◆ m_unpauseWhenReady

bool AudioOutputBase::m_unpauseWhenReady {false}
protected

◆ m_setInitialVol

bool AudioOutputBase::m_setInitialVol
protected

◆ m_bufferOutputDataForUse

bool AudioOutputBase::m_bufferOutputDataForUse {false}
protected

◆ m_configuredChannels

int AudioOutputBase::m_configuredChannels {0}
protected

◆ m_maxChannels

int AudioOutputBase::m_maxChannels {0}
protected

Definition at line 207 of file audiooutputbase.h.

Referenced by CanPassthrough(), InitSettings(), Reconfigure(), and ToggleUpmix().

◆ m_srcQuality

int AudioOutputBase::m_srcQuality {QUALITY_MEDIUM}
protected

Definition at line 215 of file audiooutputbase.h.

Referenced by AudioOutputBase(), Reconfigure(), and AudioOutputALSA::SetParameters().

◆ m_sourceBitRate

long AudioOutputBase::m_sourceBitRate {-1}
protected

◆ m_sourceSampleRate

int AudioOutputBase::m_sourceSampleRate {0}
protected

◆ m_outputSettingsRaw

AudioOutputSettings* AudioOutputBase::m_outputSettingsRaw {nullptr}
private

Definition at line 225 of file audiooutputbase.h.

Referenced by GetOutputSettingsCleaned(), and ~AudioOutputBase().

◆ m_outputSettings

AudioOutputSettings* AudioOutputBase::m_outputSettings {nullptr}
private

◆ m_outputSettingsDigitalRaw

AudioOutputSettings* AudioOutputBase::m_outputSettingsDigitalRaw {nullptr}
private

Definition at line 227 of file audiooutputbase.h.

Referenced by GetOutputSettingsCleaned(), and ~AudioOutputBase().

◆ m_outputSettingsDigital

AudioOutputSettings* AudioOutputBase::m_outputSettingsDigital {nullptr}
private

◆ m_needResampler

bool AudioOutputBase::m_needResampler {false}
private

Definition at line 229 of file audiooutputbase.h.

Referenced by AddData(), KillAudio(), and Reconfigure().

◆ m_srcCtx

SRC_STATE* AudioOutputBase::m_srcCtx {nullptr}
private

Definition at line 230 of file audiooutputbase.h.

Referenced by AddData(), CheckFreeSpace(), KillAudio(), and Reconfigure().

◆ m_pSoundStretch

soundtouch::SoundTouch* AudioOutputBase::m_pSoundStretch {nullptr}
private

Definition at line 231 of file audiooutputbase.h.

Referenced by AddData(), KillAudio(), Reset(), SetAudiotime(), and SetStretchFactorLocked().

◆ m_encoder

AudioOutputDigitalEncoder* AudioOutputBase::m_encoder {nullptr}
private

Definition at line 232 of file audiooutputbase.h.

Referenced by AddData(), KillAudio(), Reconfigure(), Reset(), and SetAudiotime().

◆ m_upmixer

FreeSurround* AudioOutputBase::m_upmixer {nullptr}
private

◆ m_sourceChannels

int AudioOutputBase::m_sourceChannels {-1}
private

◆ m_sourceBytesPerFrame

int AudioOutputBase::m_sourceBytesPerFrame {0}
private

Definition at line 236 of file audiooutputbase.h.

Referenced by AddData(), AddFrames(), GetBytesPerFrame(), and Reconfigure().

◆ m_upmixDefault

bool AudioOutputBase::m_upmixDefault {false}
private

Definition at line 237 of file audiooutputbase.h.

Referenced by CanPassthrough(), InitSettings(), Reconfigure(), and ToggleUpmix().

◆ m_needsUpmix

bool AudioOutputBase::m_needsUpmix {false}
private

◆ m_needsDownmix

bool AudioOutputBase::m_needsDownmix {false}
private

Definition at line 239 of file audiooutputbase.h.

Referenced by AddData(), Reconfigure(), and SetStretchFactorLocked().

◆ m_surroundMode

int AudioOutputBase::m_surroundMode {QUALITY_LOW}
private

Definition at line 240 of file audiooutputbase.h.

Referenced by Reconfigure().

◆ m_oldStretchFactor

float AudioOutputBase::m_oldStretchFactor {1.0F}
private

Definition at line 241 of file audiooutputbase.h.

Referenced by KillAudio(), and Reconfigure().

◆ m_volume

int AudioOutputBase::m_volume {80}
private

Definition at line 242 of file audiooutputbase.h.

Referenced by AddData(), GetSWVolume(), Reconfigure(), and SetSWVolume().

◆ m_volumeControl

QString AudioOutputBase::m_volumeControl
private

Definition at line 243 of file audiooutputbase.h.

Referenced by Reconfigure(), and SetSWVolume().

◆ m_processing

bool AudioOutputBase::m_processing {false}
private

◆ m_framesBuffered

int64_t AudioOutputBase::m_framesBuffered {0}
private

Definition at line 247 of file audiooutputbase.h.

Referenced by AddData(), Reconfigure(), Reset(), SetStretchFactorLocked(), and SetTimecode().

◆ m_audioThreadExists

bool AudioOutputBase::m_audioThreadExists {false}
private

Definition at line 249 of file audiooutputbase.h.

Referenced by StartOutputThread(), and StopOutputThread().

◆ m_audioBufLock

QMutex AudioOutputBase::m_audioBufLock
private

Writes to the audiobuffer, reconfigures and audiobuffer resets can only take place while holding this lock.

Definition at line 255 of file audiooutputbase.h.

Referenced by AddData(), Drain(), KillAudio(), Reconfigure(), Reset(), and SetStretchFactor().

◆ m_avsyncLock

QMutex AudioOutputBase::m_avsyncLock
private

must hold avsync_lock to read or write 'audiotime' and 'audiotime_updated'

Definition at line 261 of file audiooutputbase.h.

Referenced by GetAudiotime(), Reconfigure(), and Reset().

◆ m_audioTime

std::chrono::milliseconds AudioOutputBase::m_audioTime {0ms}
private

timecode of audio leaving the soundcard (same units as timecodes)

Definition at line 266 of file audiooutputbase.h.

Referenced by GetAudiotime(), OutputAudioLoop(), Reconfigure(), Reset(), SetAudiotime(), SetStretchFactorLocked(), and SetTimecode().

◆ m_raud

volatile uint AudioOutputBase::m_raud {0}
private

Audio circular buffer.

Definition at line 271 of file audiooutputbase.h.

Referenced by audiolen(), Drain(), GetAudioData(), OutputAudioLoop(), Reconfigure(), Reset(), and SetStretchFactorLocked().

◆ m_waud

volatile uint AudioOutputBase::m_waud {0}
private

Definition at line 272 of file audiooutputbase.h.

Referenced by AddData(), audiolen(), Drain(), Reconfigure(), Reset(), and SetStretchFactorLocked().

◆ m_audbufTimecode

std::chrono::milliseconds AudioOutputBase::m_audbufTimecode {0ms}
private

timecode of audio most recently placed into buffer

Definition at line 276 of file audiooutputbase.h.

Referenced by GetAudioBufferedTime(), GetAudiotime(), GetBaseAudBufTimeCode(), Reconfigure(), Reset(), SetAudiotime(), SetStretchFactorLocked(), and SetTimecode().

◆ m_resetActive

AsyncLooseLock AudioOutputBase::m_resetActive
private

Definition at line 277 of file audiooutputbase.h.

Referenced by OutputAudioLoop(), Reconfigure(), Reset(), and SetStretchFactorLocked().

◆ m_killAudioLock

QMutex AudioOutputBase::m_killAudioLock
private

Definition at line 279 of file audiooutputbase.h.

Referenced by KillAudio().

◆ m_currentSeconds

std::chrono::seconds AudioOutputBase::m_currentSeconds {-1s}
private

Definition at line 281 of file audiooutputbase.h.

Referenced by Reconfigure(), Reset(), and Status().

◆ m_srcIn

float* AudioOutputBase::m_srcIn
private

Definition at line 283 of file audiooutputbase.h.

Referenced by AddData(), AudioOutputBase(), and Reconfigure().

◆ m_srcData

SRC_DATA AudioOutputBase::m_srcData {}
private

Definition at line 286 of file audiooutputbase.h.

Referenced by AddData(), and Reconfigure().

◆ m_memoryCorruptionTest0

uint AudioOutputBase::m_memoryCorruptionTest0 {0xdeadbeef}
private

Definition at line 287 of file audiooutputbase.h.

Referenced by ~AudioOutputBase().

◆ m_srcInBuf

std::array<float,kAudioSRCInputSize> AudioOutputBase::m_srcInBuf {}
private

Definition at line 288 of file audiooutputbase.h.

Referenced by AddData(), and AudioOutputBase().

◆ m_memoryCorruptionTest1

uint AudioOutputBase::m_memoryCorruptionTest1 {0xdeadbeef}
private

Definition at line 289 of file audiooutputbase.h.

Referenced by ~AudioOutputBase().

◆ m_srcOut

float* AudioOutputBase::m_srcOut {nullptr}
private

Definition at line 290 of file audiooutputbase.h.

Referenced by AddData(), Reconfigure(), and ~AudioOutputBase().

◆ m_kAudioSRCOutputSize

int AudioOutputBase::m_kAudioSRCOutputSize {0}
private

Definition at line 291 of file audiooutputbase.h.

Referenced by Reconfigure(), and ~AudioOutputBase().

◆ m_memoryCorruptionTest2

uint AudioOutputBase::m_memoryCorruptionTest2 {0xdeadbeef}
private

Definition at line 292 of file audiooutputbase.h.

Referenced by ~AudioOutputBase().

◆ m_audioBuffer

std::array<uchar,kAudioRingBufferSize> AudioOutputBase::m_audioBuffer {0}
private

main audio buffer

Definition at line 296 of file audiooutputbase.h.

Referenced by Reset().

◆ m_memoryCorruptionTest3

uint AudioOutputBase::m_memoryCorruptionTest3 {0xdeadbeef}
private

Definition at line 297 of file audiooutputbase.h.

Referenced by ~AudioOutputBase().

◆ m_configureSucceeded

bool AudioOutputBase::m_configureSucceeded {false}
private

◆ m_lengthLastData

std::chrono::milliseconds AudioOutputBase::m_lengthLastData {0ms}
private

Definition at line 299 of file audiooutputbase.h.

Referenced by AddData(), and LengthLastData().

◆ m_usesSpdif

bool AudioOutputBase::m_usesSpdif {true}
private

Definition at line 302 of file audiooutputbase.h.

Referenced by AudioOutputBase(), SetupPassthrough(), and usesSpdif().

◆ m_spdifEnc

SPDIFEncoder* AudioOutputBase::m_spdifEnc {nullptr}
private

Definition at line 303 of file audiooutputbase.h.

Referenced by AddData(), and SetupPassthrough().

◆ m_forcedProcessing

bool AudioOutputBase::m_forcedProcessing {false}
private

Definition at line 306 of file audiooutputbase.h.

Referenced by Reconfigure(), and SetStretchFactorLocked().

◆ m_previousBpf

int AudioOutputBase::m_previousBpf {0}
private

Definition at line 307 of file audiooutputbase.h.

Referenced by SetStretchFactorLocked().


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