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

#include <audiooutput.h>

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

Classes

class  AudioDeviceConfig
 

Public Types

using ADCVect = QVector< AudioDeviceConfig >
 

Public Member Functions

 AudioOutput ()=default
 
 ~AudioOutput () override
 
virtual void Reconfigure (const AudioSettings &settings)=0
 
virtual void SetStretchFactor (float factor)
 
virtual float GetStretchFactor (void) const
 
virtual int GetChannels (void) const
 
virtual AudioFormat GetFormat (void) const
 
virtual int GetBytesPerFrame (void) const
 
virtual AudioOutputSettingsGetOutputSettingsCleaned (bool digital=true)
 
virtual AudioOutputSettingsGetOutputSettingsUsers (bool digital=true)
 
virtual bool CanPassthrough (int samplerate, int channels, AVCodecID codec, int profile) const
 
virtual bool CanDownmix (void) const
 
virtual void SetEffDsp (int dsprate)=0
 
virtual void Reset (void)=0
 
virtual bool AddFrames (void *buffer, int frames, int64_t timecode)=0
 Add frames to the audiobuffer for playback. More...
 
virtual bool AddData (void *buffer, int len, int64_t timecode, int frames)=0
 Add data to the audiobuffer for playback. More...
 
virtual bool NeedDecodingBeforePassthrough (void) const
 
virtual int64_t LengthLastData (void) const
 
virtual void SetTimecode (int64_t timecode)=0
 
virtual bool IsPaused (void) const =0
 
virtual void Pause (bool paused)=0
 
virtual void PauseUntilBuffered (void)=0
 
virtual void Drain (void)=0
 
virtual int64_t GetAudiotime (void)=0
 
virtual int64_t GetAudioBufferedTime (void)
 report amount of audio buffered in milliseconds. More...
 
virtual void SetSourceBitrate (int)
 
QString GetError (void) const
 
QString GetWarning (void) const
 
virtual void GetBufferStatus (uint &fill, uint &total)
 
virtual void bufferOutputData (bool y)=0
 
virtual int readOutputData (unsigned char *read_buffer, int max_length)=0
 
virtual bool IsUpmixing (void)
 
virtual bool ToggleUpmix (void)
 
virtual bool CanUpmix (void)
 
bool PulseStatus (void)
 
virtual bool CanProcess (AudioFormat fmt)
 
virtual uint32_t CanProcess (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)
 

Static Public Member Functions

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 Attributes

static const int MAX_SIZE_BUFFER = 384000
 MAX_SIZE_BUFFER is the maximum size of a buffer to be used with DecodeAudio. More...
 

Protected Member Functions

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
 
virtual void SetSWVolume (int new_volume, bool save)=0
 
virtual int GetSWVolume (void)=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 Attributes

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
 

Private Member Functions

 Q_DECLARE_TR_FUNCTIONS (AudioOutput)
 

Detailed Description

Definition at line 22 of file audiooutput.h.

Member Typedef Documentation

◆ ADCVect

Definition at line 45 of file audiooutput.h.

Constructor & Destructor Documentation

◆ AudioOutput()

AudioOutput::AudioOutput ( )
default

◆ ~AudioOutput()

AudioOutput::~AudioOutput ( )
override

Definition at line 244 of file audiooutput.cpp.

Member Function Documentation

◆ Q_DECLARE_TR_FUNCTIONS()

AudioOutput::Q_DECLARE_TR_FUNCTIONS ( AudioOutput  )
private

◆ Cleanup()

void AudioOutput::Cleanup ( void  )
static

Definition at line 51 of file audiooutput.cpp.

◆ GetOutputList()

AudioOutput::ADCVect * AudioOutput::GetOutputList ( void  )
static

Definition at line 420 of file audiooutput.cpp.

Referenced by AudioConfigSettings::AudioRescan(), and AudioSetupWizard::Load().

◆ GetAudioDeviceConfig()

AudioOutput::AudioDeviceConfig * AudioOutput::GetAudioDeviceConfig ( QString &  name,
QString &  desc,
bool  willsuspendpa = false 
)
static

◆ OpenAudio() [1/3]

AudioOutput * AudioOutput::OpenAudio ( 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

◆ OpenAudio() [2/3]

AudioOutput * AudioOutput::OpenAudio ( AudioSettings settings,
bool  willsuspendpa = true 
)
static

Definition at line 80 of file audiooutput.cpp.

◆ OpenAudio() [3/3]

AudioOutput * AudioOutput::OpenAudio ( const QString &  main_device,
const QString &  passthru_device = QString(),
bool  willsuspendpa = true 
)
static

Definition at line 71 of file audiooutput.cpp.

◆ Reconfigure()

virtual void AudioOutput::Reconfigure ( const AudioSettings settings)
pure virtual

◆ SetStretchFactor()

void AudioOutput::SetStretchFactor ( float  factor)
virtual

Reimplemented in AudioOutputBase.

Definition at line 253 of file audiooutput.cpp.

Referenced by MusicPlayer::setSpeed(), and AudioPlayer::SetStretchFactor().

◆ GetStretchFactor()

virtual float AudioOutput::GetStretchFactor ( void  ) const
inlinevirtual

Reimplemented in AudioOutputBase.

Definition at line 72 of file audiooutput.h.

◆ GetChannels()

virtual int AudioOutput::GetChannels ( void  ) const
inlinevirtual

Reimplemented in AudioOutputBase.

Definition at line 73 of file audiooutput.h.

◆ GetFormat()

virtual AudioFormat AudioOutput::GetFormat ( void  ) const
inlinevirtual

Reimplemented in AudioOutputBase.

Definition at line 74 of file audiooutput.h.

◆ GetBytesPerFrame()

virtual int AudioOutput::GetBytesPerFrame ( void  ) const
inlinevirtual

Reimplemented in AudioOutputBase.

Definition at line 75 of file audiooutput.h.

Referenced by AudioPlayer::AddAudioData(), and MythRAOPConnection::ProcessAudio().

◆ GetOutputSettingsCleaned()

AudioOutputSettings * AudioOutput::GetOutputSettingsCleaned ( bool  digital = true)
virtual

Reimplemented in AudioOutputBase.

Definition at line 257 of file audiooutput.cpp.

Referenced by GetAudioDeviceConfig().

◆ GetOutputSettingsUsers()

AudioOutputSettings * AudioOutput::GetOutputSettingsUsers ( bool  digital = true)
virtual

Reimplemented in AudioOutputBase.

Definition at line 262 of file audiooutput.cpp.

Referenced by AudioPlayer::GetMaxChannels(), AudioPlayer::GetMaxHDRate(), and TestDigitalFeature().

◆ CanPassthrough()

bool AudioOutput::CanPassthrough ( int  samplerate,
int  channels,
AVCodecID  codec,
int  profile 
) const
virtual

Reimplemented in AudioOutputBase, and AudioReencodeBuffer.

Definition at line 267 of file audiooutput.cpp.

Referenced by AudioPlayer::CanPassthrough().

◆ CanDownmix()

virtual bool AudioOutput::CanDownmix ( void  ) const
inlinevirtual

Reimplemented in AudioOutputBase.

Definition at line 81 of file audiooutput.h.

Referenced by AudioPlayer::CanDownmix().

◆ SetEffDsp()

virtual void AudioOutput::SetEffDsp ( int  dsprate)
pure virtual

Implemented in AudioOutputBase, and AudioReencodeBuffer.

Referenced by AudioPlayer::SetEffDsp().

◆ Reset()

virtual void AudioOutput::Reset ( void  )
pure virtual

◆ AddFrames()

virtual bool AudioOutput::AddFrames ( void *  buffer,
int  frames,
int64_t  timecode 
)
pure virtual

Add frames to the audiobuffer for playback.

Parameters
[in]bufferpointer to audio data
[in]framesnumber of frames added.
[in]timecodetimecode of the first sample added (in msec)
Returns
false if there wasn't enough space in audio buffer to process all the data

Implemented in AudioOutputBase, and AudioReencodeBuffer.

Referenced by AudioTestThread::run().

◆ AddData()

virtual bool AudioOutput::AddData ( void *  buffer,
int  len,
int64_t  timecode,
int  frames 
)
pure virtual

Add data to the audiobuffer for playback.

Parameters
[in]bufferpointer to audio data
[in]lenlength of audio data added
[in]timecodetimecode of the first sample added (in msec)
[in]framesnumber of frames added.
Returns
false if there wasn't enough space in audio buffer to process all the data

Implemented in AudioOutputBase, AudioReencodeBuffer, and AudioOutputAudioTrack.

Referenced by AudioPlayer::AddAudioData(), MythRAOPConnection::AudioCardLatency(), MythRAOPConnection::ProcessAudio(), and avfDecoder::run().

◆ NeedDecodingBeforePassthrough()

virtual bool AudioOutput::NeedDecodingBeforePassthrough ( void  ) const
inlinevirtual
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 in AudioOutputBase.

Definition at line 119 of file audiooutput.h.

Referenced by AudioPlayer::NeedDecodingBeforePassthrough().

◆ LengthLastData()

virtual int64_t AudioOutput::LengthLastData ( void  ) const
inlinevirtual
Returns
the length of the last data added in millisecond. This function must be implemented if NeedDecodingBeforePassthrough returned false

Reimplemented in AudioOutputBase.

Definition at line 126 of file audiooutput.h.

Referenced by AudioPlayer::LengthLastData(), MythRAOPConnection::ProcessAudio(), and AudioTestThread::run().

◆ SetTimecode()

virtual void AudioOutput::SetTimecode ( int64_t  timecode)
pure virtual

◆ IsPaused()

virtual bool AudioOutput::IsPaused ( void  ) const
pure virtual

◆ Pause()

virtual void AudioOutput::Pause ( bool  paused)
pure virtual

◆ PauseUntilBuffered()

virtual void AudioOutput::PauseUntilBuffered ( void  )
pure virtual

◆ Drain()

virtual void AudioOutput::Drain ( void  )
pure virtual

◆ GetAudiotime()

virtual int64_t AudioOutput::GetAudiotime ( void  )
pure virtual

◆ GetAudioBufferedTime()

virtual int64_t AudioOutput::GetAudioBufferedTime ( void  )
inlinevirtual

report amount of audio buffered in milliseconds.

Reimplemented in AudioOutputBase.

Definition at line 139 of file audiooutput.h.

Referenced by MythPlayer::EventLoop(), AudioPlayer::GetAudioBufferedTime(), MythRAOPConnection::ProcessAudio(), MythRAOPConnection::ProcessSync(), and avfDecoder::run().

◆ SetSourceBitrate()

virtual void AudioOutput::SetSourceBitrate ( int  )
inlinevirtual

◆ GetError()

QString AudioOutput::GetError ( void  ) const
inline

◆ GetWarning()

QString AudioOutput::GetWarning ( void  ) const
inline

Definition at line 144 of file audiooutput.h.

◆ GetBufferStatus()

virtual void AudioOutput::GetBufferStatus ( uint fill,
uint total 
)
inlinevirtual

Reimplemented in AudioOutputBase.

Definition at line 146 of file audiooutput.h.

Referenced by AudioPlayer::GetBufferStatus(), and CdDecoder::run().

◆ bufferOutputData()

virtual void AudioOutput::bufferOutputData ( bool  y)
pure virtual

Implemented in AudioOutputBase, and AudioReencodeBuffer.

◆ readOutputData()

virtual int AudioOutput::readOutputData ( unsigned char *  read_buffer,
int  max_length 
)
pure virtual

◆ IsUpmixing()

virtual bool AudioOutput::IsUpmixing ( void  )
inlinevirtual

Reimplemented in AudioOutputBase.

Definition at line 154 of file audiooutput.h.

Referenced by AudioPlayer::IsUpmixing().

◆ ToggleUpmix()

virtual bool AudioOutput::ToggleUpmix ( void  )
inlinevirtual

Reimplemented in AudioOutputBase.

Definition at line 155 of file audiooutput.h.

Referenced by AudioPlayer::EnableUpmix(), and MusicCommon::toggleUpmix().

◆ CanUpmix()

virtual bool AudioOutput::CanUpmix ( void  )
inlinevirtual

Reimplemented in AudioOutputBase.

Definition at line 156 of file audiooutput.h.

Referenced by AudioPlayer::CanUpmix().

◆ PulseStatus()

bool AudioOutput::PulseStatus ( void  )
inline

Definition at line 157 of file audiooutput.h.

◆ CanProcess() [1/2]

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

Reimplemented in AudioOutputBase.

Definition at line 164 of file audiooutput.h.

Referenced by AudioPlayer::CanProcess().

◆ CanProcess() [2/2]

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

Reimplemented in AudioOutputBase.

Definition at line 170 of file audiooutput.h.

◆ DecodeAudio()

int AudioOutput::DecodeAudio ( AVCodecContext *  ctx,
uint8_t *  buffer,
int &  data_size,
const AVPacket *  pkt 
)
virtual

Utility routine.

DecodeAudio Decode an audio packet, and compact it if data is planar Return negative error code if an error occurred during decoding or the number of bytes consumed from the input AVPacket data_size contains the size of decoded data copied into buffer.

Decode an audio packet, and compact it if data is planar Return negative error code if an error occurred during decoding or the number of bytes consumed from the input AVPacket data_size contains the size of decoded data copied into buffer data decoded will be S16 samples if class instance can't handle HD audio or S16 and above otherwise. No U8 PCM format can be returned

Parameters
[in]ctxThe current audio context information.
[in]bufferDestination for the copy
[out]data_sizeThe number of bytes copied.
[in]pktThe source data packet

Definition at line 600 of file audiooutput.cpp.

Referenced by AudioPlayer::DecodeAudio(), and avfDecoder::run().

◆ Error()

void AudioOutput::Error ( const QString &  msg)
protected

◆ SilentError()

void AudioOutput::SilentError ( const QString &  msg)
protected

Definition at line 283 of file audiooutput.cpp.

Referenced by AudioOutputBase::Reconfigure().

◆ Warn()

void AudioOutput::Warn ( const QString &  msg)
protected

Definition at line 288 of file audiooutput.cpp.

Referenced by AudioOutputALSA::GetOutputSettings().

◆ ClearError()

void AudioOutput::ClearError ( void  )
protected

◆ ClearWarning()

void AudioOutput::ClearWarning ( void  )
protected

Definition at line 299 of file audiooutput.cpp.

Member Data Documentation

◆ MAX_SIZE_BUFFER

const int AudioOutput::MAX_SIZE_BUFFER = 384000
static

MAX_SIZE_BUFFER is the maximum size of a buffer to be used with DecodeAudio.

Definition at line 192 of file audiooutput.h.

Referenced by MythRAOPConnection::AudioCardLatency(), avfDecoder::avfDecoder(), AvFormatDecoder::AvFormatDecoder(), and MythRAOPConnection::decodeAudioPacket().

◆ m_lastError

QString AudioOutput::m_lastError
protected

Definition at line 201 of file audiooutput.h.

◆ m_lastWarn

QString AudioOutput::m_lastWarn
protected

Definition at line 202 of file audiooutput.h.

◆ m_pulsewassuspended

bool AudioOutput::m_pulsewassuspended {false}
protected

Definition at line 203 of file audiooutput.h.

Referenced by OpenAudio().

◆ m_frame

AVFrame* AudioOutput::m_frame {nullptr}
protected

Definition at line 204 of file audiooutput.h.


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