30#include <libavcodec/avcodec.h>
31#include <libavfilter/avfilter.h>
34#include <vdr/thread.h>
ALSA Output Device Header File.
Audio Manipulation Interface Header File.
void SetPassthroughMask(int mask)
int GetPassthroughMask(void) const
void SetAutoAES(bool appendAes)
int64_t PtsToMs(int64_t pts, double timebase)
void SetDownmix(int downMix)
Fill Level Low Pass Filter.
void LazyInit(void)
Initialize audio output module (alsa)
AVRational m_timebase
AVCodecContext pkts_timebase.
bool SendPause(void)
Write pause to passthrough device.
void ResetHwDelayBaseline(void)
Reset the hw delay baseline.
virtual void Action(void)
Audio thread loop, started with Start().
void Filter(AVFrame *, AVCodecContext *)
Send audio frame to filter and enqueue it.
cSoftHdRingbuffer m_pRingbuffer
sample ring buffer
int m_pitchAdjustFrameCounter
counter for pitch adjustment frames
int64_t GetInputPtsMs(void)
cSoftHdDevice * m_pDevice
pointer to device
int m_volume
current volume (0 .. 1000)
void SetHwDelayBaseline(void)
Set the hw delay baseline.
void SetStereoDescent(int)
Set stereo loudness descent.
void SetTimebase(AVRational timebase)
int GetUsedRingbufferMs(void)
Get used ms in audio ringbuffer.
int64_t GetHardwareOutputPtsMs(void)
Get the hardware output PTS in milliseconds.
int Setup(AVRational, int, int, bool)
Alsa setup wrapper.
std::mutex m_pauseMutex
mutex for a safe thread pausing
int64_t GetHardwareOutputPtsTimebaseUnits(void)
Get the hardware output PTS in timebase units.
AVFilterContext * m_pBuffersinkCtx
cPidController m_pidController
PID controller for clock drift compensation with tuning values coming from educated guesses.
void SetVolume(int)
Set mixer volume (0-1000)
void SetEqualizer(bool, int[18])
Set equalizer bands.
AVFilterContext * m_pBuffersrcCtx
AVFilterGraph * m_pFilterGraph
const char * m_pMixerChannel
mixer channel name
cBufferFillLevelLowPassFilter m_fillLevel
low pass filter for the buffer fill level
IEventReceiver * m_pEventReceiver
pointer to event receiver
void ProcessEvents(void)
Process queued events and forward them to event receiver.
int GetAvResyncBorderMs(void)
std::vector< Event > m_eventQueue
event queue for incoming events
bool SendAudio(int)
Write regular audio data from the ringbuffer to the hardware.
void DropSamplesOlderThanPtsMs(int64_t)
Drop samples older than the given PTS.
void Enqueue(const uint16_t *, int, int64_t)
Send audio data to ringbuffer.
void SetAutoAES(bool appendAes)
static constexpr int AUDIO_MIN_BUFFER_FREE
Minimum free space in audio buffer 8 packets for 8 channels.
int64_t GetOutputPtsMs(void)
Get the output PTS of the ringbuffer.
AVFrame * FilterGetFrame(void)
Get frame from filter sink.
void ClockDriftCompensation(void)
Calculate clock drift compensation.
int m_filterChanged
filter has changed
void SetCompression(bool, int)
Set volume compression parameters.
void Stop(void)
Stop the thread.
int64_t m_inputPts
pts clock (last pts in ringbuffer)
int64_t GetOutputPtsMsInternal(void)
cSoftHdConfig * m_pConfig
pointer to config
std::atomic< double > m_pitchPpm
pitch adjustment in ppm. Positive values are faster
void Exit(void)
Cleanup audio output module (alsa)
void SetPaused(bool)
Set audio playback pause state.
int GetPassthroughMask(void) const
void SetSoftvol(bool softVolume)
int64_t GetHardwareOutputDelayMs(void)
Get the hardware delay in milliseconds.
void SetPassthroughMask(int mask)
bool m_useEqualizer
flag to use equalizer
int m_spdifBurstSize
size of the current spdif burst
int m_filterReady
filter is ready
const char * m_pMixerDevice
mixer device name (not used)
void DropAlsaBuffers(void)
Drop alsa buffers.
cAlsaDevice m_alsa
alsa device
bool CyclicCall(void)
Cyclic audio playback call.
int m_hwBaseline
saves the hw delay (pause bursts) once a real audio frame to correctly do the AV-Sync
bool m_initialized
class initialized
int m_stereoDescent
volume descent for stereo
std::mutex m_mutex
mutex for thread safety
static constexpr int AV_SYNC_BORDER_MS
absolute max a/v difference in ms which should trigger a resync
int m_packetCounter
packet counter for logging
void SetDownmix(int downMix)
int GetUsedRingbufferBytes(void)
Get used bytes in audio ringbuffer.
static constexpr unsigned RINGBUFFER_SIZE
default ring buffer size ~2s 8ch 16bit (3 * 5 * 7 * 8)
void EnqueueFrame(AVFrame *)
Place samples in audio output queue.
void FlushAlsaBuffers(void)
Flush alsa buffers.
void SetNormalize(bool, int)
Set normalize volume parameters.
bool m_useNormalizer
flag to use volume normalize
static constexpr int BYTES_PER_SAMPLE
number of bytes per sample
std::chrono::steady_clock::time_point m_lastPidInvocation
last time the PID controller was invoked
std::atomic< bool > m_paused
audio is paused
std::mutex m_queueMutex
mutex for queue safety
cAudioProcessor m_audioProcessor
bool m_firstRealAudioReceived
false, as long as no real audio was sent - used to trigger the baseline set
int CheckForFilterReady(AVCodecContext *)
Check if the filter has changed and is ready, init the filter if needed.
int InitFilter(AVCodecContext *)
Init audio filters.
void RebuildPauseBurst(int)
Rebuild the pause spdif burst with the size of the last recognized normal spdif audio if size changed...
std::vector< uint16_t > m_pauseBurst
holds the burst data itself
void EnqueueSpdif(const uint16_t *, int, int64_t pts)
Enqueue prepared spdif bursts in audio output queue.
void FlushBuffers(void)
Flush audio buffers.
bool m_useCompressor
flag to use compress volume
bool m_softVolume
flag to use soft volume
Output Device Implementation.
Ringbuffer (FIFO) Implementation.
size_t FreeBytes(void)
Get free bytes in ring buffer.
State Machine and Event Header File.
Low-pass Filter for Audio Buffer Fill Level Measurement Header File.
std::string BuildChannelMapFilter(const AVChannelLayout &)
Build the "|"-separated mappings list for the channelmap filter.
PID (proportional, integral, derivative) Controller Header File.
Audio Ringbuffer Header File.