29#include <libavfilter/avfilter.h>
32#include <alsa/asoundlib.h>
38#define NORMALIZE_MAX_INDEX 128
52 int Setup(AVCodecContext *,
int ,
int ,
int);
55 void Filter(AVFrame *, AVCodecContext *);
56 void Enqueue(uint16_t *,
int, AVFrame *);
69 void SetEq(
int[18],
int);
175 int AlsaSetup(
int channels,
int sample_rate,
int passthrough);
#define NORMALIZE_MAX_INDEX
number of average values
cSoftHdAudio - Audio class
void LazyInit(void)
Initialize audio output module.
cSoftHdAudio(cSoftHdDevice *)
cSoftHdAudio constructor
char * OpenAlsaDevice(const char *, int)
Open alsa device.
char * FindAlsaDevice(const char *, const char *, int)
Find alsa device giving some search hints.
bool m_appendAES
flag ato utomatic append AES
void XrunRecovery(void)
xrun recovery
void Filter(AVFrame *, AVCodecContext *)
Send audio frame to filter and enqueue it.
cSoftHdRingbuffer m_pRingbuffer
sample ring buffer
int64_t GetInputPtsMs(void)
int AlsaSetup(int channels, int sample_rate, int passthrough)
Setup alsa audio for requested format.
int Setup(AVCodecContext *, int, int, int)
Setup alsa.
void Enqueue(uint16_t *, int, AVFrame *)
Send audio data to ringbuffer.
int m_compressionMaxFactor
max. compression factor
cSoftHdDevice * m_pDevice
pointer to device
const char * m_pPCMDevice
PCM device name.
int GetPassthrough(void) const
int m_volume
current volume (0 .. 1000)
cAudioThread * m_pAudioThread
pointer to audio thread
virtual ~cSoftHdAudio(void)
cSoftHdAudio denstructor
void SetStereoDescent(int)
Set stereo loudness descent.
int64_t GetHardwareOutputPtsMs(void)
Get the hardware output PTS in milliseconds.
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
void SetVolume(int)
Set mixer volume (0-1000)
AVFilterContext * m_pBuffersrcCtx
bool m_alsaCanPause
hw supports pause
AVFilterGraph * m_pFilterGraph
int m_passthrough
passthrough mask
const int m_bytesPerSample
number of bytes per sample
const char * m_pMixerChannel
mixer channel name
unsigned int m_hwSampleRate
hardware sample rate in Hz
int64_t PtsToMs(int64_t pts)
IEventReceiver * m_pEventReceiver
pointer to event receiver
void ProcessEvents(void)
Process queued events and forward to event receiver.
int MsToFrames(int milliseconds)
std::vector< Event > m_eventQueue
event queue for incoming events
void DropSamplesOlderThanPtsMs(int64_t)
Drop samples older than the given PTS.
AVRational * m_pTimebase
pointer to AVCodecContext pkts_timebase
void SetAutoAES(bool appendAes)
static constexpr int AUDIO_MIN_BUFFER_FREE
Minimum free space in audio buffer 8 packets for 8 channels.
bool m_compression
flag to use compress volume
int64_t GetOutputPtsMs(void)
Get the output PTS of the ringbuffer.
bool m_normalize
flag to use volume normalize
AVFrame * FilterGetFrame(void)
Get frame from filter sink.
int m_filterChanged
filter has changed
void AlsaExit(void)
Cleanup alsa audio output module.
void SetCompression(bool, int)
Set volume compression parameters.
snd_mixer_elem_t * m_pAlsaMixerElem
alsa mixer element
void AlsaInit(void)
Initialize alsa audio output module.
void Compress(uint16_t *, int)
Compress audio.
int64_t m_inputPts
pts clock (last pts in ringbuffer)
int m_normalizeFactor
current normalize factor
void AlsaSetVolume(int)
Set alsa mixer volume (0-1000)
int64_t GetOutputPtsMsInternal(void)
cSoftHdConfig * m_pConfig
pointer to config
void Exit(void)
Cleanup audio output module.
int m_amplifier
software volume amplify factor
int GetUsedBytes(void)
Get used bytes in audio ringbuffer.
void SetPaused(bool)
Set audio playback paused state.
void AlsaInitMixer(void)
Initialize alsa mixer.
void SetSoftvol(bool softVolume)
const char * m_pPassthroughDevice
passthrough device name
void SetPassthrough(int)
Set audio passthrough mask.
int m_normalizeMaxFactor
max. normalize factor
bool m_alsaUseMmap
use mmap
void Normalize(uint16_t *, int)
Normalize audio.
int m_compressionFactor
current compression factor
int64_t MsToPts(int64_t ptsMs)
const int m_normalizeMinFactor
min. normalize factor
const int m_normalizeSamples
number of normalize samples
int m_filterReady
filter is ready
void SetEq(int[18], int)
Set equalizer bands.
int m_normalizeReady
index normalize counter
const char * m_pMixerDevice
mixer device name (not used)
uint32_t m_normalizeAverage[NORMALIZE_MAX_INDEX]
average of n last normalize sample blocks
bool CyclicCall(void)
Cyclic audio playback call.
void AlsaInitPCMDevice(void)
Search for an alsa pcm device and open it.
unsigned int m_hwNumChannels
number of hardware channels
bool m_initialized
class initialized
int FramesToMs(int frames)
int m_stereoDescent
volume descent for stereo
std::mutex m_mutex
mutex for thread safety
int m_alsaRatio
internal -> mixer ratio * 1000
void SetDownmix(int downMix)
int GetFreeBytes(void)
Get free 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 SoftAmplify(int16_t *, int)
Software amplifier.
void FlushAlsaBuffers(void)
Flush alsa buffers.
void SetNormalize(bool, int)
Set normalize volume parameters.
snd_pcm_t * m_pAlsaPCMHandle
alsa pcm handle
int m_downmix
set stereo downmix
int m_useEqualizer
flag to use equalizer
float m_equalizerBand[18]
equalizer band
snd_mixer_t * m_pAlsaMixer
alsa mixer handle
int m_normalizeIndex
index into normalize average table
int m_normalizeCounter
normalize sample counter
std::atomic< bool > m_paused
audio is paused
int CheckForFilterReady(AVCodecContext *)
Check if the filter has changed and is ready, init the filter if needed.
int InitFilter(AVCodecContext *)
Init filter.
void SetTimebase(AVRational *timebase)
void FlushBuffers(void)
Flush audio buffers.
bool m_softVolume
flag to use soft volume
cSoftHdRingbuffer - RingBuffer class
size_t FreeBytes(void)
Get free bytes in ring buffer.
SoftHdDevice config header file.
State machine and event header file.
Ringbuffer class header file.
Thread classes header file.