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