vdr-plugin-softhddevice-drm-gles 1.4.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
cAudioDecoder Class Reference

cAudioDecoder - Audio decoder class More...

#include <codec_audio.h>

Collaboration diagram for cAudioDecoder:
Collaboration graph
[legend]

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

Detailed Description

cAudioDecoder - Audio decoder class

Definition at line 74 of file codec_audio.h.

Constructor & Destructor Documentation

◆ cAudioDecoder()

cAudioDecoder::cAudioDecoder ( cSoftHdAudio audio)

Audio decoder class constructor.

Parameters
audioaudio module

Definition at line 48 of file codec_audio.cpp.

References AV_NOPTS_VALUE, CODEC_AC3, CODEC_DTS, CODEC_EAC3, CODEC_PCM, cSoftHdAudio::GetPassthrough(), L_CODEC, LOGDEBUG2, LOGFATAL, m_lastPts, m_passthroughMask, m_pAudio, m_pAudioCtx, and m_pFrame.

◆ ~cAudioDecoder()

cAudioDecoder::~cAudioDecoder ( void  )
virtual

Audio decoder class destructor.

Definition at line 67 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 126 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 151 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 416 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 83 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 81 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 (PCM, AC-3, E-AC-3, DTS)

Definition at line 431 of file codec_audio.cpp.

References CODEC_AC3, CODEC_DTS, CODEC_EAC3, CODEC_PCM, 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 300 of file codec_audio.cpp.

References CODEC_AC3, CODEC_DTS, CODEC_EAC3, CODEC_PCM, 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 88 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 96 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 95 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 94 of file codec_audio.h.

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

◆ m_currentPassthrough

int cAudioDecoder::m_currentPassthrough
private

current passthrough mask

Definition at line 92 of file codec_audio.h.

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

◆ m_currentSampleRate

int cAudioDecoder::m_currentSampleRate
private

current sample rate

Definition at line 93 of file codec_audio.h.

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

◆ m_lastPts

int64_t cAudioDecoder::m_lastPts
private

last seen PTS

Definition at line 90 of file codec_audio.h.

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

◆ m_passthroughMask

int cAudioDecoder::m_passthroughMask
private

passthrough mask to be set

Definition at line 91 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 86 of file codec_audio.h.

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

◆ m_pAudioCtx

AVCodecContext* cAudioDecoder::m_pAudioCtx
private

ffmpeg audio codec context

Definition at line 87 of file codec_audio.h.

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

◆ m_pFrame

AVFrame* cAudioDecoder::m_pFrame
private

decoded ffmpeg audio frame

Definition at line 89 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 98 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 97 of file codec_audio.h.

Referenced by DecodePassthrough().

◆ m_spdifRepeatCount

int cAudioDecoder::m_spdifRepeatCount
private

SPDIF repeat counter.

Definition at line 99 of file codec_audio.h.

Referenced by DecodePassthrough(), and UpdateFormat().


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