vdr-plugin-softhddevice-drm-gles 1.5.9-20e15de
cAudioDecoder Class Reference

cAudioDecoder - Audio decoder class More...

#include <codec_audio.h>

Public Member Functions

 cAudioDecoder (cSoftHdAudio *)
 Audio decoder class constructor.
 
 ~cAudioDecoder (void)
 Audio decoder class destructor.
 
void Open (AVCodecID, AVCodecParameters *=nullptr, AVRational={ .num=1,.den=90000 })
 Open and initiate the audio decoder.
 
void Close (void)
 Close the audio decoder.
 
void Decode (const AVPacket *)
 Decode an audio packet.
 
void FlushBuffers (void)
 Flush the audio decoder.
 
void SetPassthrough (int)
 Set audio pass-through mask.
 
AVCodecID GetCodecId () const
 

Private Member Functions

int DecodePassthrough (const AVPacket *, AVFrame *)
 Passthrough audio data.
 
int UpdateFormat (void)
 Handle audio format changes.
 

Private Attributes

cSoftHdAudiom_pAudio
 audio module
 
AVCodecContext * m_pAudioCtx = nullptr
 ffmpeg audio codec context
 
AVCodecID m_codecId = AV_CODEC_ID_NONE
 current codec id
 
AVFrame * m_pFrame
 decoded ffmpeg audio frame
 
int64_t m_lastPts = AV_NOPTS_VALUE
 last seen PTS
 
int m_passthroughMask
 passthrough mask to be set
 
int m_currentPassthrough
 current passthrough mask
 
int m_currentSampleRate
 current sample rate
 
int m_currentNumChannels
 current number of channels
 
int m_currentHwSampleRate
 current hw sample rate
 
int m_currentHwNumChannels
 current number of hw channels
 
uint16_t m_spdifOutput [MAX_FRAME_SIZE *2]
 SPDIF output buffer.
 
int m_spdifIndex
 index into SPDIF output buffer
 
int m_spdifRepeatCount
 SPDIF repeat counter.
 

Detailed Description

cAudioDecoder - Audio decoder class

Definition at line 76 of file codec_audio.h.

Constructor & Destructor Documentation

◆ cAudioDecoder()

cAudioDecoder::cAudioDecoder ( cSoftHdAudio audio)

Audio decoder class constructor.

Parameters
audioaudio module

Definition at line 46 of file codec_audio.cpp.

References L_CODEC, LOGDEBUG2, LOGFATAL, m_passthroughMask, and m_pFrame.

◆ ~cAudioDecoder()

cAudioDecoder::~cAudioDecoder ( void  )

Audio decoder class destructor.

Definition at line 59 of file codec_audio.cpp.

References Close(), and m_pFrame.

Member Function Documentation

◆ Close()

void cAudioDecoder::Close ( void  )

Close the audio decoder.

Definition at line 118 of file codec_audio.cpp.

References AV_NOPTS_VALUE, L_CODEC, LOGDEBUG2, m_codecId, m_lastPts, and m_pAudioCtx.

Referenced by cSoftHdDevice::PlayAudio(), and ~cAudioDecoder().

◆ Decode()

void cAudioDecoder::Decode ( const AVPacket *  avpkt)

◆ DecodePassthrough()

int cAudioDecoder::DecodePassthrough ( const AVPacket *  avpkt,
AVFrame *  frame 
)
private

Passthrough audio data.

Build spdif headers depending on the codec and send the data to the audio device. Currently supported: AC3, EAC3, DTS

Parameters
avpktundecoded audio packet
framedecoded audio frame
Returns
0 codec is not supported for passthrough, use Filter to handle the data
-1 sth went wrong, data will be discarded
1 data accepted if finished, spdif header was created and data was sent to passthrough device

Definition at line 143 of file codec_audio.cpp.

References AC3_FRAME_SIZE, CODEC_AC3, CODEC_DTS, CODEC_EAC3, DTS1_FRAME_SIZE, DTS2_FRAME_SIZE, DTS3_FRAME_SIZE, DTS_PREAMBLE_16BE_1, DTS_PREAMBLE_16BE_2, EAC3_FRAME_SIZE, cSoftHdAudio::Enqueue(), IEC61937_AC3, IEC61937_DTS1, IEC61937_DTS2, IEC61937_DTS3, IEC61937_EAC3, IEC61937_NULL, IEC61937_PREAMBLE1, IEC61937_PREAMBLE2, LOGERROR, m_currentHwSampleRate, m_passthroughMask, m_pAudio, m_pAudioCtx, m_spdifIndex, m_spdifOutput, m_spdifRepeatCount, and cSoftHdAudio::SetTimebase().

Referenced by Decode().

◆ FlushBuffers()

void cAudioDecoder::FlushBuffers ( void  )

Flush the audio decoder.

Definition at line 399 of file codec_audio.cpp.

References AV_NOPTS_VALUE, L_CODEC, LOGDEBUG2, m_codecId, m_lastPts, and m_pAudioCtx.

Referenced by cSoftHdDevice::ClearAudio().

◆ GetCodecId()

AVCodecID cAudioDecoder::GetCodecId ( ) const
inline

Definition at line 85 of file codec_audio.h.

References m_codecId.

Referenced by cSoftHdDevice::PlayAudio().

◆ Open()

void cAudioDecoder::Open ( AVCodecID  codecId,
AVCodecParameters *  par = nullptr,
AVRational  timebase = { .num = 1, .den = 90000 } 
)

Open and initiate the audio decoder.

Parameters
codecIdaudio codec id
paraudio codec parameters
timebasetimebase

Definition at line 73 of file codec_audio.cpp.

References L_CODEC, LOGDEBUG2, LOGERROR, LOGFATAL, m_codecId, m_currentHwNumChannels, m_currentHwSampleRate, m_currentNumChannels, m_currentPassthrough, m_currentSampleRate, m_passthroughMask, and m_pAudioCtx.

Referenced by cSoftHdDevice::PlayAudio(), and cSoftHdDevice::SetAudioCodec().

◆ SetPassthrough()

void cAudioDecoder::SetPassthrough ( int  mask)

Set audio pass-through mask.

Parameters
maskcodec to enable (AC-3, E-AC-3, DTS)

Definition at line 414 of file codec_audio.cpp.

References CODEC_AC3, CODEC_DTS, CODEC_EAC3, L_CODEC, LOGDEBUG2, and m_passthroughMask.

Referenced by cSoftHdDevice::SetPassthrough().

◆ UpdateFormat()

int cAudioDecoder::UpdateFormat ( void  )
private

Handle audio format changes.

Setup audio, if format changed

Returns
0 if new audio was correctly set up, otherwise return value of cSoftHdAudio::Setup()

Definition at line 284 of file codec_audio.cpp.

References CODEC_AC3, CODEC_DTS, CODEC_EAC3, L_SOUND, LOGDEBUG2, LOGERROR, m_currentHwNumChannels, m_currentHwSampleRate, m_currentNumChannels, m_currentPassthrough, m_currentSampleRate, m_passthroughMask, m_pAudio, m_pAudioCtx, m_spdifIndex, m_spdifRepeatCount, and cSoftHdAudio::Setup().

Referenced by Decode().

Member Data Documentation

◆ m_codecId

AVCodecID cAudioDecoder::m_codecId = AV_CODEC_ID_NONE
private

current codec id

Definition at line 90 of file codec_audio.h.

Referenced by Close(), FlushBuffers(), GetCodecId(), and Open().

◆ m_currentHwNumChannels

int cAudioDecoder::m_currentHwNumChannels
private

current number of hw channels

Definition at line 98 of file codec_audio.h.

Referenced by Decode(), Open(), and UpdateFormat().

◆ m_currentHwSampleRate

int cAudioDecoder::m_currentHwSampleRate
private

current hw sample rate

Definition at line 97 of file codec_audio.h.

Referenced by Decode(), DecodePassthrough(), Open(), and UpdateFormat().

◆ m_currentNumChannels

int cAudioDecoder::m_currentNumChannels
private

current number of channels

Definition at line 96 of file codec_audio.h.

Referenced by Decode(), Open(), and UpdateFormat().

◆ m_currentPassthrough

int cAudioDecoder::m_currentPassthrough
private

current passthrough mask

Definition at line 94 of file codec_audio.h.

Referenced by Decode(), Open(), and UpdateFormat().

◆ m_currentSampleRate

int cAudioDecoder::m_currentSampleRate
private

current sample rate

Definition at line 95 of file codec_audio.h.

Referenced by Decode(), Open(), and UpdateFormat().

◆ m_lastPts

int64_t cAudioDecoder::m_lastPts = AV_NOPTS_VALUE
private

last seen PTS

Definition at line 92 of file codec_audio.h.

Referenced by Close(), Decode(), and FlushBuffers().

◆ m_passthroughMask

int cAudioDecoder::m_passthroughMask
private

passthrough mask to be set

Definition at line 93 of file codec_audio.h.

Referenced by cAudioDecoder(), Decode(), DecodePassthrough(), Open(), SetPassthrough(), and UpdateFormat().

◆ m_pAudio

cSoftHdAudio* cAudioDecoder::m_pAudio
private

audio module

Definition at line 88 of file codec_audio.h.

Referenced by Decode(), DecodePassthrough(), and UpdateFormat().

◆ m_pAudioCtx

AVCodecContext* cAudioDecoder::m_pAudioCtx = nullptr
private

ffmpeg audio codec context

Definition at line 89 of file codec_audio.h.

Referenced by Close(), Decode(), DecodePassthrough(), FlushBuffers(), Open(), and UpdateFormat().

◆ m_pFrame

AVFrame* cAudioDecoder::m_pFrame
private

decoded ffmpeg audio frame

Definition at line 91 of file codec_audio.h.

Referenced by cAudioDecoder(), Decode(), and ~cAudioDecoder().

◆ m_spdifIndex

int cAudioDecoder::m_spdifIndex
private

index into SPDIF output buffer

Definition at line 100 of file codec_audio.h.

Referenced by DecodePassthrough(), and UpdateFormat().

◆ m_spdifOutput

uint16_t cAudioDecoder::m_spdifOutput[MAX_FRAME_SIZE *2]
private

SPDIF output buffer.

Definition at line 99 of file codec_audio.h.

Referenced by DecodePassthrough().

◆ m_spdifRepeatCount

int cAudioDecoder::m_spdifRepeatCount
private

SPDIF repeat counter.

Definition at line 101 of file codec_audio.h.

Referenced by DecodePassthrough(), and UpdateFormat().


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