MythTV  master
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

const char * quality_string (int q)
 
 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, int64_t timecode) override
 Add frames to the audiobuffer and perform any required processing. More...
 
bool AddData (void *buffer, int len, int64_t timecode, int frames) override
 Add data to the audiobuffer and perform any required processing. More...
 
bool NeedDecodingBeforePassthrough () const override
 
int64_t LengthLastData (void) const override
 
void SetTimecode (int64_t 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...
 
int64_t GetAudiotime (void) override
 Calculate the timecode of the samples that are about to become audible. More...
 
int64_t 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, int max_length) override
 
- Public Member Functions inherited from AudioOutput
 AudioOutput ()=default
 
 ~AudioOutput () override
 
QString GetError (void) const
 
QString GetWarning (void) const
 
bool PulseStatus (void)
 
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
 
virtual ~OutputListeners ()=default
 
bool hasVisual (void)
 
void addVisual (MythTV::Visual *)
 
void removeVisual (MythTV::Visual *)
 
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 ()
 
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=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 (unsigned long time=ULONG_MAX)
 Wait for the MThread to exit, with a maximum timeout. More...
 

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 MAX_SIZE_BUFFER = 384000
 MAX_SIZE_BUFFER is the maximum size of a buffer to be used with DecodeAudio. More...
 
- Static Public Attributes inherited from MThread
static const int kDefaultStartTimeout
 

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...
 
int 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, unsigned long written, 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_bytes_per_frame {0}
 
int m_output_bytes_per_frame {0}
 
AudioFormat m_format {FORMAT_NONE}
 
AudioFormat m_output_format {FORMAT_NONE}
 
int m_samplerate {-1}
 
int m_effdsp {0}
 
int m_fragment_size {0}
 
long m_soundcard_buffer_size {0}
 
QString m_main_device
 
QString m_passthru_device
 
bool m_discretedigital {false}
 
bool m_passthru {false}
 
bool m_enc {false}
 
bool m_reenc {false}
 
float m_stretchfactor {1.0F}
 
int m_eff_stretchfactor {100000}
 
AudioOutputSource source
 
bool m_killaudio {false}
 
bool m_pauseaudio {false}
 
bool m_actually_paused {false}
 
bool m_was_paused {false}
 
bool m_unpause_when_ready {false}
 
bool m_set_initial_vol
 
bool m_buffer_output_data_for_use {false}
 
int m_configured_channels {0}
 
int m_max_channels {0}
 
int m_src_quality {QUALITY_MEDIUM}
 
long m_source_bitrate {-1}
 
int m_source_samplerate {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 internal_vol {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_prolog_executed {true}
 
bool m_epilog_executed {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, int64_t 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_output_settingsraw {nullptr}
 
AudioOutputSettingsm_output_settings {nullptr}
 
AudioOutputSettingsm_output_settingsdigitalraw {nullptr}
 
AudioOutputSettingsm_output_settingsdigital {nullptr}
 
bool m_need_resampler {false}
 
SRC_STATE * m_src_ctx {nullptr}
 
soundtouch::SoundTouch * m_pSoundStretch {nullptr}
 
AudioOutputDigitalEncoderm_encoder {nullptr}
 
FreeSurroundm_upmixer {nullptr}
 
int m_source_channels {-1}
 
int m_source_bytes_per_frame {0}
 
bool m_upmix_default {false}
 
bool m_needs_upmix {false}
 
bool m_needs_downmix {false}
 
int m_surround_mode {QUALITY_LOW}
 
float m_old_stretchfactor {1.0F}
 
int m_volume {80}
 
QString m_volumeControl
 
bool m_processing {false}
 
int64_t m_frames_buffered {0}
 
bool m_audio_thread_exists {false}
 
QMutex m_audio_buflock
 Writes to the audiobuffer, reconfigures and audiobuffer resets can only take place while holding this lock. More...
 
QMutex m_avsync_lock
 must hold avsync_lock to read or write 'audiotime' and 'audiotime_updated' More...
 
int64_t m_audiotime {0}
 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}
 
int64_t m_audbuf_timecode {0}
 timecode of audio most recently placed into buffer More...
 
AsyncLooseLock m_reset_active
 
QMutex m_killAudioLock {QMutex::NonRecursive}
 
long m_current_seconds {-1}
 
float * m_src_in
 
SRC_DATA m_src_data
 
uint m_memory_corruption_test0 {0xdeadbeef}
 
float m_src_in_buf [kAudioSRCInputSize+16]
 
uint m_memory_corruption_test1 {0xdeadbeef}
 
float * m_src_out {nullptr}
 
int m_kAudioSRCOutputSize {0}
 
uint m_memory_corruption_test2 {0xdeadbeef}
 
uchar m_audiobuffer [kAudioRingBufferSize]
 main audio buffer More...
 
uint m_memory_corruption_test3 {0xdeadbeef}
 
bool m_configure_succeeded {false}
 
int64_t m_length_last_data {0}
 
bool m_usesSpdif {true}
 
SPDIFEncoderm_spdifenc {nullptr}
 
bool m_forcedprocessing {false}
 
int m_previousbpf {0}
 

Additional Inherited Members

- Public Types inherited from AudioOutput
typedef QVector< AudioDeviceConfigADCVect
 
- Static Public Member Functions inherited from AudioOutput
static void Cleanup (void)
 
static ADCVectGetOutputList (void)
 
static AudioDeviceConfigGetAudioDeviceConfig (QString &name, 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 &)
 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 Protected Member Functions inherited from MThread
static void setTerminationEnabled (bool enabled=true)
 
static void sleep (unsigned long time)
 
static void msleep (unsigned long time)
 
static void usleep (unsigned long time)
 

Detailed Description

Definition at line 49 of file audiooutputbase.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
QUALITY_DISABLED 
QUALITY_LOW 
QUALITY_MEDIUM 
QUALITY_HIGH 

Definition at line 206 of file audiooutputbase.h.

Constructor & Destructor Documentation

◆ AudioOutputBase()

AudioOutputBase::AudioOutputBase ( const AudioSettings settings)
explicit

Definition at line 56 of file audiooutputbase.cpp.

◆ ~AudioOutputBase()

AudioOutputBase::~AudioOutputBase ( )
override

Destructor.

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

Definition at line 89 of file audiooutputbase.cpp.

Member Function Documentation

◆ quality_string()

const char * AudioOutputBase::quality_string ( int  q)

Definition at line 44 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 971 of file audiooutputbase.cpp.

◆ SetStretchFactor()

void AudioOutputBase::SetStretchFactor ( float  factor)
overridevirtual

Set the timestretch factor.

Reimplemented from AudioOutput.

Definition at line 356 of file audiooutputbase.cpp.

◆ GetStretchFactor()

float AudioOutputBase::GetStretchFactor ( void  ) const
overridevirtual

Get the timetretch factor.

Reimplemented from AudioOutput.

Definition at line 365 of file audiooutputbase.cpp.

◆ GetChannels()

int AudioOutputBase::GetChannels ( void  ) const
inlineoverridevirtual

Reimplemented from AudioOutput.

Definition at line 68 of file audiooutputbase.h.

◆ GetFormat()

AudioFormat AudioOutputBase::GetFormat ( void  ) const
inlineoverridevirtual

Reimplemented from AudioOutput.

Definition at line 69 of file audiooutputbase.h.

◆ GetBytesPerFrame()

int AudioOutputBase::GetBytesPerFrame ( void  ) const
inlineoverridevirtual

Reimplemented from AudioOutput.

Definition at line 70 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 75 of file audiooutputbase.h.

◆ IsUpmixing()

bool AudioOutputBase::IsUpmixing ( void  )
overridevirtual

Source is currently being upmixed.

Reimplemented from AudioOutput.

Definition at line 373 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 381 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 399 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 79 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 80 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 923 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 1159 of file audiooutputbase.cpp.

◆ GetSWVolume()

int AudioOutputBase::GetSWVolume ( void  )
overridevirtual

Get the volume for software volume control.

Implements VolumeBase.

Definition at line 1169 of file audiooutputbase.cpp.

◆ AddFrames()

bool AudioOutputBase::AddFrames ( void *  in_buffer,
int  in_frames,
int64_t  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 1303 of file audiooutputbase.cpp.

◆ AddData()

bool AudioOutputBase::AddData ( void *  in_buffer,
int  in_len,
int64_t  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 1315 of file audiooutputbase.cpp.

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

◆ NeedDecodingBeforePassthrough()

bool AudioOutputBase::NeedDecodingBeforePassthrough ( void  ) 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 94 of file audiooutputbase.h.

◆ LengthLastData()

int64_t 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 95 of file audiooutputbase.h.

◆ SetTimecode()

void AudioOutputBase::SetTimecode ( int64_t  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 959 of file audiooutputbase.cpp.

◆ IsPaused()

bool AudioOutputBase::IsPaused ( void  ) const
inlineoverridevirtual

Implements AudioOutput.

Definition at line 98 of file audiooutputbase.h.

◆ Pause()

void AudioOutputBase::Pause ( bool  paused)
overridevirtual

Implements AudioOutput.

Definition at line 901 of file audiooutputbase.cpp.

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

◆ PauseUntilBuffered()

void AudioOutputBase::PauseUntilBuffered ( void  )
overridevirtual

Implements AudioOutput.

Definition at line 913 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 1811 of file audiooutputbase.cpp.

Referenced by AudioOutputPulseAudio::Drain().

◆ GetAudiotime()

int64_t AudioOutputBase::GetAudiotime ( void  )
overridevirtual

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

Implements AudioOutput.

Reimplemented in AudioOutputCA.

Definition at line 1015 of file audiooutputbase.cpp.

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

◆ GetAudioBufferedTime()

int64_t 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 1147 of file audiooutputbase.cpp.

◆ Status()

void AudioOutputBase::Status ( void  )
virtual

Report status via an OutputEvent.

Definition at line 1602 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 1626 of file audiooutputbase.cpp.

◆ bufferOutputData()

void AudioOutputBase::bufferOutputData ( bool  y)
inlineoverridevirtual

Implements AudioOutput.

Definition at line 116 of file audiooutputbase.h.

◆ readOutputData()

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

Implements AudioOutput.

Reimplemented in AudioOutputNULL.

Definition at line 1836 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, AudioOutputAudioTrack, AudioOutputOMX, AudioOutputJACK, AudioOutputOpenSLES, AudioOutputALSA, AudioOutputDX, AudioOutputOSS, 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 1730 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 1637 of file audiooutputbase.cpp.

Referenced by run().

◆ run()

void AudioOutputBase::run ( void  )
overrideprotectedvirtual

Main routine for the output thread.

Reimplemented from MThread.

Definition at line 1827 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 1182 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 980 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 990 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 1005 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()

int AudioOutputBase::GetBaseAudBufTimeCode ( ) const
inlineprotected

Definition at line 165 of file audiooutputbase.h.

Referenced by AudioOutputCA::GetAudiotime().

◆ usesSpdif()

bool AudioOutputBase::usesSpdif ( ) const
inlineprotected

Definition at line 167 of file audiooutputbase.h.

Referenced by GetAudiotime(), and AudioOutputOMX::GetBufferedOnSoundcard().

◆ SetupPassthrough()

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

Definition at line 408 of file audiooutputbase.cpp.

Referenced by Reconfigure().

◆ OutputSettings()

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

Definition at line 456 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 1217 of file audiooutputbase.cpp.

Referenced by AddData().

◆ SetAudiotime()

void AudioOutputBase::SetAudiotime ( int  frames,
int64_t  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 1097 of file audiooutputbase.cpp.

Referenced by AddData().

Member Data Documentation

◆ kAudioSRCInputSize

const uint AudioOutputBase::kAudioSRCInputSize = 16384
static

Definition at line 120 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 124 of file audiooutputbase.h.

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

◆ m_channels

int AudioOutputBase::m_channels {-1}
protected

◆ m_codec

AVCodecID AudioOutputBase::m_codec {AV_CODEC_ID_NONE}
protected

◆ m_bytes_per_frame

int AudioOutputBase::m_bytes_per_frame {0}
protected

◆ m_output_bytes_per_frame

int AudioOutputBase::m_output_bytes_per_frame {0}
protected

◆ m_format

AudioFormat AudioOutputBase::m_format {FORMAT_NONE}
protected

Definition at line 175 of file audiooutputbase.h.

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

◆ m_output_format

AudioFormat AudioOutputBase::m_output_format {FORMAT_NONE}
protected

◆ m_samplerate

int AudioOutputBase::m_samplerate {-1}
protected

◆ m_effdsp

int AudioOutputBase::m_effdsp {0}
protected

◆ m_fragment_size

int AudioOutputBase::m_fragment_size {0}
protected

◆ m_soundcard_buffer_size

long AudioOutputBase::m_soundcard_buffer_size {0}
protected

◆ m_main_device

QString AudioOutputBase::m_main_device
protected

◆ m_passthru_device

QString AudioOutputBase::m_passthru_device
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 189 of file audiooutputbase.h.

Referenced by Reconfigure(), and AudioOutputOMX::WriteAudio().

◆ m_stretchfactor

float AudioOutputBase::m_stretchfactor {1.0F}
protected

◆ m_eff_stretchfactor

int AudioOutputBase::m_eff_stretchfactor {100000}
protected

Definition at line 192 of file audiooutputbase.h.

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

◆ source

AudioOutputSource AudioOutputBase::source
protected

Definition at line 193 of file audiooutputbase.h.

Referenced by Reconfigure().

◆ m_killaudio

bool AudioOutputBase::m_killaudio {false}
protected

◆ m_pauseaudio

bool AudioOutputBase::m_pauseaudio {false}
protected

◆ m_actually_paused

bool AudioOutputBase::m_actually_paused {false}
protected

◆ m_was_paused

bool AudioOutputBase::m_was_paused {false}
protected

◆ m_unpause_when_ready

bool AudioOutputBase::m_unpause_when_ready {false}
protected

◆ m_set_initial_vol

bool AudioOutputBase::m_set_initial_vol
protected

◆ m_buffer_output_data_for_use

bool AudioOutputBase::m_buffer_output_data_for_use {false}
protected

◆ m_configured_channels

int AudioOutputBase::m_configured_channels {0}
protected

◆ m_max_channels

int AudioOutputBase::m_max_channels {0}
protected

Definition at line 205 of file audiooutputbase.h.

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

◆ m_src_quality

int AudioOutputBase::m_src_quality {QUALITY_MEDIUM}
protected

Definition at line 213 of file audiooutputbase.h.

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

◆ m_source_bitrate

long AudioOutputBase::m_source_bitrate {-1}
protected

◆ m_source_samplerate

int AudioOutputBase::m_source_samplerate {0}
protected

◆ m_output_settingsraw

AudioOutputSettings* AudioOutputBase::m_output_settingsraw {nullptr}
private

Definition at line 223 of file audiooutputbase.h.

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

◆ m_output_settings

AudioOutputSettings* AudioOutputBase::m_output_settings {nullptr}
private

◆ m_output_settingsdigitalraw

AudioOutputSettings* AudioOutputBase::m_output_settingsdigitalraw {nullptr}
private

Definition at line 225 of file audiooutputbase.h.

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

◆ m_output_settingsdigital

AudioOutputSettings* AudioOutputBase::m_output_settingsdigital {nullptr}
private

◆ m_need_resampler

bool AudioOutputBase::m_need_resampler {false}
private

Definition at line 227 of file audiooutputbase.h.

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

◆ m_src_ctx

SRC_STATE* AudioOutputBase::m_src_ctx {nullptr}
private

Definition at line 228 of file audiooutputbase.h.

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

◆ m_pSoundStretch

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

Definition at line 229 of file audiooutputbase.h.

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

◆ m_encoder

AudioOutputDigitalEncoder* AudioOutputBase::m_encoder {nullptr}
private

Definition at line 230 of file audiooutputbase.h.

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

◆ m_upmixer

FreeSurround* AudioOutputBase::m_upmixer {nullptr}
private

◆ m_source_channels

int AudioOutputBase::m_source_channels {-1}
private

◆ m_source_bytes_per_frame

int AudioOutputBase::m_source_bytes_per_frame {0}
private

Definition at line 234 of file audiooutputbase.h.

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

◆ m_upmix_default

bool AudioOutputBase::m_upmix_default {false}
private

Definition at line 235 of file audiooutputbase.h.

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

◆ m_needs_upmix

bool AudioOutputBase::m_needs_upmix {false}
private

◆ m_needs_downmix

bool AudioOutputBase::m_needs_downmix {false}
private

Definition at line 237 of file audiooutputbase.h.

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

◆ m_surround_mode

int AudioOutputBase::m_surround_mode {QUALITY_LOW}
private

Definition at line 238 of file audiooutputbase.h.

Referenced by Reconfigure().

◆ m_old_stretchfactor

float AudioOutputBase::m_old_stretchfactor {1.0F}
private

Definition at line 239 of file audiooutputbase.h.

Referenced by KillAudio(), and Reconfigure().

◆ m_volume

int AudioOutputBase::m_volume {80}
private

Definition at line 240 of file audiooutputbase.h.

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

◆ m_volumeControl

QString AudioOutputBase::m_volumeControl
private

Definition at line 241 of file audiooutputbase.h.

Referenced by Reconfigure(), and SetSWVolume().

◆ m_processing

bool AudioOutputBase::m_processing {false}
private

◆ m_frames_buffered

int64_t AudioOutputBase::m_frames_buffered {0}
private

Definition at line 245 of file audiooutputbase.h.

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

◆ m_audio_thread_exists

bool AudioOutputBase::m_audio_thread_exists {false}
private

Definition at line 247 of file audiooutputbase.h.

Referenced by StartOutputThread(), and StopOutputThread().

◆ m_audio_buflock

QMutex AudioOutputBase::m_audio_buflock
private

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

Definition at line 253 of file audiooutputbase.h.

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

◆ m_avsync_lock

QMutex AudioOutputBase::m_avsync_lock
private

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

Definition at line 259 of file audiooutputbase.h.

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

◆ m_audiotime

int64_t AudioOutputBase::m_audiotime {0}
private

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

Definition at line 264 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 269 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 270 of file audiooutputbase.h.

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

◆ m_audbuf_timecode

int64_t AudioOutputBase::m_audbuf_timecode {0}
private

timecode of audio most recently placed into buffer

Definition at line 274 of file audiooutputbase.h.

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

◆ m_reset_active

AsyncLooseLock AudioOutputBase::m_reset_active
private

Definition at line 275 of file audiooutputbase.h.

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

◆ m_killAudioLock

QMutex AudioOutputBase::m_killAudioLock {QMutex::NonRecursive}
private

Definition at line 277 of file audiooutputbase.h.

Referenced by KillAudio().

◆ m_current_seconds

long AudioOutputBase::m_current_seconds {-1}
private

Definition at line 279 of file audiooutputbase.h.

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

◆ m_src_in

float* AudioOutputBase::m_src_in
private

Definition at line 281 of file audiooutputbase.h.

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

◆ m_src_data

SRC_DATA AudioOutputBase::m_src_data
private

Definition at line 284 of file audiooutputbase.h.

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

◆ m_memory_corruption_test0

uint AudioOutputBase::m_memory_corruption_test0 {0xdeadbeef}
private

Definition at line 285 of file audiooutputbase.h.

Referenced by ~AudioOutputBase().

◆ m_src_in_buf

float AudioOutputBase::m_src_in_buf[kAudioSRCInputSize+16]
private

Definition at line 286 of file audiooutputbase.h.

Referenced by AudioOutputBase().

◆ m_memory_corruption_test1

uint AudioOutputBase::m_memory_corruption_test1 {0xdeadbeef}
private

Definition at line 287 of file audiooutputbase.h.

Referenced by ~AudioOutputBase().

◆ m_src_out

float* AudioOutputBase::m_src_out {nullptr}
private

Definition at line 288 of file audiooutputbase.h.

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

◆ m_kAudioSRCOutputSize

int AudioOutputBase::m_kAudioSRCOutputSize {0}
private

Definition at line 289 of file audiooutputbase.h.

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

◆ m_memory_corruption_test2

uint AudioOutputBase::m_memory_corruption_test2 {0xdeadbeef}
private

Definition at line 290 of file audiooutputbase.h.

Referenced by ~AudioOutputBase().

◆ m_audiobuffer

uchar AudioOutputBase::m_audiobuffer[kAudioRingBufferSize]
private

main audio buffer

Definition at line 290 of file audiooutputbase.h.

Referenced by AudioOutputBase(), and Reset().

◆ m_memory_corruption_test3

uint AudioOutputBase::m_memory_corruption_test3 {0xdeadbeef}
private

Definition at line 295 of file audiooutputbase.h.

Referenced by ~AudioOutputBase().

◆ m_configure_succeeded

bool AudioOutputBase::m_configure_succeeded {false}
private

◆ m_length_last_data

int64_t AudioOutputBase::m_length_last_data {0}
private

Definition at line 297 of file audiooutputbase.h.

Referenced by AddData(), and LengthLastData().

◆ m_usesSpdif

bool AudioOutputBase::m_usesSpdif {true}
private

Definition at line 300 of file audiooutputbase.h.

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

◆ m_spdifenc

SPDIFEncoder* AudioOutputBase::m_spdifenc {nullptr}
private

Definition at line 301 of file audiooutputbase.h.

Referenced by AddData(), and SetupPassthrough().

◆ m_forcedprocessing

bool AudioOutputBase::m_forcedprocessing {false}
private

Definition at line 304 of file audiooutputbase.h.

Referenced by Reconfigure(), and SetStretchFactorLocked().

◆ m_previousbpf

int AudioOutputBase::m_previousbpf {0}
private

Definition at line 305 of file audiooutputbase.h.

Referenced by SetStretchFactorLocked().


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