|
vdr-plugin-softhddevice-drm-gles 1.6.7
|
Audio Interface. More...
#include <audio.h>
Public Member Functions | |
| cSoftHdAudio (cSoftHdDevice *) | |
| Create a new audio context. | |
| void | LazyInit (void) |
| Initialize audio output module (alsa) | |
| void | Exit (void) |
| Cleanup audio output module (alsa) | |
| int | Setup (AVRational, int, int, bool) |
| Alsa setup wrapper. | |
| void | SetPaused (bool) |
| Set audio playback pause state. | |
| bool | IsPaused (void) |
| void | Filter (AVFrame *, AVCodecContext *) |
| Send audio frame to filter and enqueue it. | |
| void | EnqueueSpdif (const uint16_t *, int, int64_t pts) |
| Enqueue prepared spdif bursts in audio output queue. | |
| bool | IsBufferFull (void) |
| void | FlushBuffers (void) |
| Flush audio buffers. | |
| int | GetUsedRingbufferBytes (void) |
| Get used bytes in audio ringbuffer. | |
| int | GetUsedRingbufferMs (void) |
| Get used ms in audio ringbuffer. | |
| int64_t | GetHardwareOutputPtsMs (void) |
| Get the hardware output PTS in milliseconds. | |
| int64_t | GetHardwareOutputDelayMs (void) |
| Get the hardware delay in milliseconds. | |
| int64_t | GetHardwareOutputPtsTimebaseUnits (void) |
| Get the hardware output PTS in timebase units. | |
| bool | HasInputPts (void) |
| int64_t | GetInputPtsMs (void) |
| int64_t | GetOutputPtsMs (void) |
| Get the output PTS of the ringbuffer. | |
| int | GetAvResyncBorderMs (void) |
| void | SetVolume (int) |
| Set mixer volume (0-1000) | |
| void | SetSoftvol (bool softVolume) |
| void | SetNormalize (bool, int) |
| Set normalize volume parameters. | |
| void | SetCompression (bool, int) |
| Set volume compression parameters. | |
| void | SetEqualizer (bool, int[18]) |
| Set equalizer bands. | |
| void | SetStereoDescent (int) |
| Set stereo loudness descent. | |
| void | SetPassthroughMask (int mask) |
| void | SetAutoAES (bool appendAes) |
| void | SetTimebase (AVRational timebase) |
| void | SetDownmix (int downMix) |
| int | GetPassthroughMask (void) const |
| void | DropSamplesOlderThanPtsMs (int64_t) |
| Drop samples older than the given PTS. | |
| void | ClockDriftCompensation (void) |
| Calculate clock drift compensation. | |
| void | ResetHwDelayBaseline (void) |
| Reset the hw delay baseline. | |
| void | SetHwDelayBaseline (void) |
| Set the hw delay baseline. | |
Protected Member Functions | |
| virtual void | Action (void) |
| Audio thread loop, started with Start(). | |
Private Member Functions | |
| void | Enqueue (const uint16_t *, int, int64_t) |
| Send audio data to ringbuffer. | |
| void | EnqueueFrame (AVFrame *) |
| Place samples in audio output queue. | |
| bool | SendAudio (int) |
| Write regular audio data from the ringbuffer to the hardware. | |
| bool | SendPause (void) |
| Write pause to passthrough device. | |
| void | RebuildPauseBurst (int) |
| Rebuild the pause spdif burst with the size of the last recognized normal spdif audio if size changed. | |
| void | Stop (void) |
| Stop the thread. | |
| void | FlushAlsaBuffers (void) |
| Flush alsa buffers. | |
| void | DropAlsaBuffers (void) |
| Drop alsa buffers. | |
| bool | CyclicCall (void) |
| Cyclic audio playback call. | |
| void | ProcessEvents (void) |
| Process queued events and forward them to event receiver. | |
| int | InitFilter (AVCodecContext *) |
| Init audio filters. | |
| AVFrame * | FilterGetFrame (void) |
| Get frame from filter sink. | |
| int | CheckForFilterReady (AVCodecContext *) |
| Check if the filter has changed and is ready, init the filter if needed. | |
| std::string | BuildChannelMapFilter (const AVChannelLayout &) |
| Build the "|"-separated mappings list for the channelmap filter. | |
| int64_t | GetOutputPtsMsInternal (void) |
Private Attributes | |
| cSoftHdDevice * | m_pDevice |
| pointer to device | |
| cSoftHdConfig * | m_pConfig |
| pointer to config | |
| cAlsaDevice | m_alsa |
| alsa device | |
| IEventReceiver * | m_pEventReceiver |
| pointer to event receiver | |
| cBufferFillLevelLowPassFilter | m_fillLevel |
| low pass filter for the buffer fill level | |
| cPidController | m_pidController {3, 0.005, 0, 1000} |
| PID controller for clock drift compensation with tuning values coming from educated guesses. | |
| std::chrono::steady_clock::time_point | m_lastPidInvocation |
| last time the PID controller was invoked | |
| int | m_packetCounter = 0 |
| packet counter for logging | |
| bool | m_initialized = false |
| class initialized | |
| std::mutex | m_mutex |
| mutex for thread safety | |
| std::mutex | m_pauseMutex |
| mutex for a safe thread pausing | |
| std::mutex | m_queueMutex |
| mutex for queue safety | |
| std::vector< Event > | m_eventQueue |
| event queue for incoming events | |
| std::atomic< double > | m_pitchPpm = 0 |
| pitch adjustment in ppm. Positive values are faster | |
| int | m_pitchAdjustFrameCounter = 0 |
| counter for pitch adjustment frames | |
| int | m_volume = 0 |
| current volume (0 .. 1000) | |
| int | m_stereoDescent |
| volume descent for stereo | |
| AVRational | m_timebase |
| AVCodecContext pkts_timebase. | |
| int64_t | m_inputPts = AV_NOPTS_VALUE |
| pts clock (last pts in ringbuffer) | |
| std::atomic< bool > | m_paused = true |
| audio is paused | |
| bool | m_softVolume |
| flag to use soft volume | |
| int | m_spdifBurstSize = 0 |
| size of the current spdif burst | |
| std::vector< uint16_t > | m_pauseBurst |
| holds the burst data itself | |
| int | m_hwBaseline = 0 |
| saves the hw delay (pause bursts) once a real audio frame to correctly do the AV-Sync | |
| bool | m_firstRealAudioReceived = false |
| false, as long as no real audio was sent - used to trigger the baseline set | |
| cAudioProcessor | m_audioProcessor |
| bool | m_useNormalizer |
| flag to use volume normalize | |
| bool | m_useCompressor |
| flag to use compress volume | |
| bool | m_useEqualizer |
| flag to use equalizer | |
| const char * | m_pMixerDevice = nullptr |
| mixer device name (not used) | |
| const char * | m_pMixerChannel |
| mixer channel name | |
| int | m_filterChanged = 0 |
| filter has changed | |
| int | m_filterReady = 0 |
| filter is ready | |
| AVFilterGraph * | m_pFilterGraph = nullptr |
| AVFilterContext * | m_pBuffersrcCtx |
| AVFilterContext * | m_pBuffersinkCtx |
| cSoftHdRingbuffer | m_pRingbuffer {RINGBUFFER_SIZE} |
| sample ring buffer | |
Static Private Attributes | |
| static constexpr int | AUDIO_MIN_BUFFER_FREE = 3072 * 8 * 8 |
| Minimum free space in audio buffer 8 packets for 8 channels. | |
| static constexpr int | AV_SYNC_BORDER_MS = 5000 |
| absolute max a/v difference in ms which should trigger a resync | |
| static constexpr int | BYTES_PER_SAMPLE = 2 |
| number of bytes per sample | |
| static constexpr unsigned | RINGBUFFER_SIZE = 3 * 5 * 7 * 8 * 2 * 1000 |
| default ring buffer size ~2s 8ch 16bit (3 * 5 * 7 * 8) | |
| cSoftHdAudio::cSoftHdAudio | ( | cSoftHdDevice * | device | ) |
Create a new audio context.
Definition at line 52 of file audio.cpp.
References cSoftHdConfig::ConfigAudioCompression, cSoftHdConfig::ConfigAudioEq, cSoftHdConfig::ConfigAudioEqBand, cSoftHdConfig::ConfigAudioMaxCompression, cSoftHdConfig::ConfigAudioMaxNormalize, cSoftHdConfig::ConfigAudioNormalize, cSoftHdConfig::ConfigAudioStereoDescent, m_pConfig, SetCompression(), SetEqualizer(), SetNormalize(), and SetStereoDescent().
Audio thread loop, started with Start().
Tries to periodically send frames to the hardware and checks for events (underruns)
Definition at line 993 of file audio.cpp.
References CyclicCall(), LOGDEBUG, and ProcessEvents().
|
private |
Check if the filter has changed and is ready, init the filter if needed.
| ctx | AVCodec audio decoding context |
| 1 | error, init failed |
| 0 | filter initiated |
Definition at line 646 of file audio.cpp.
References InitFilter(), L_SOUND, LOGDEBUG2, m_filterChanged, m_filterReady, and m_pFilterGraph.
Referenced by Filter().
Calculate clock drift compensation.
Uses a PID controller to adjust the playback pitch based on the audio buffer fill level. This keeps the buffer level constant and compensates for clock drift between the sender and the audio hardware.
Also updates the low-pass filter for the buffer fill level.
Definition at line 1179 of file audio.cpp.
References cAlsaDevice::FramesToMsDouble(), cAlsaDevice::GetAvailableBufferFrames(), cBufferFillLevelLowPassFilter::GetBufferFillLevelFramesAvg(), cAlsaDevice::GetBufferSizeFrames(), cPidController::GetDTerm(), cPidController::GetITerm(), cPidController::GetPTerm(), cPidController::GetTargetValue(), cAlsaDevice::IsPassthroughActive(), cBufferFillLevelLowPassFilter::IsSettled(), L_SOUND, LOGDEBUG2, m_alsa, m_fillLevel, m_lastPidInvocation, m_packetCounter, m_pidController, m_pitchPpm, cPidController::SetTargetValue(), cPidController::Update(), and cBufferFillLevelLowPassFilter::UpdateAvgBufferFillLevel().
Referenced by cSoftHdDevice::PlayAudio().
Cyclic audio playback call.
Handles audio output to ALSA, writing samples from the ring buffer to the hardware when space is available.
If passthrough is enabled, the thread continues sending data (pause bursts) even if audio playback is paused. This prevents, that the AV-Receiver looses the lock and may switch to PCM instead.
Definition at line 1031 of file audio.cpp.
References AUDIO, cAlsaDevice::FramesToBytes(), cAlsaDevice::GetAvailableBufferFrames(), cAlsaDevice::HandleError(), cAlsaDevice::IsPassthroughActive(), m_alsa, m_eventQueue, m_mutex, m_paused, m_pauseMutex, m_queueMutex, m_spdifBurstSize, SendAudio(), SendPause(), and cAlsaDevice::WaitUntilReady().
Referenced by Action().
Drop alsa buffers.
Definition at line 977 of file audio.cpp.
References cAlsaDevice::FlushBuffers(), m_alsa, m_audioProcessor, cAudioProcessor::ResetCompressor(), and cAudioProcessor::ResetNormalizer().
Referenced by Setup().
Drop samples older than the given PTS.
Removes audio samples from the ringbuffer that have a presentation timestamp older than the specified ptsMs.
| ptsMs | presentation timestamp in milliseconds - samples older than this will be dropped |
Definition at line 421 of file audio.cpp.
References cAlsaDevice::FramesToBytes(), GetOutputPtsMsInternal(), HasInputPts(), L_AV_SYNC, LOGDEBUG2, m_alsa, m_fillLevel, m_mutex, m_pidController, m_pRingbuffer, cAlsaDevice::MsToFrames(), cSoftHdRingbuffer::ReadAdvance(), cBufferFillLevelLowPassFilter::Reset(), cPidController::Reset(), Timestamp2String(), cSoftHdRingbuffer::UsedBytes(), and cBufferFillLevelLowPassFilter::WroteFrames().
Referenced by cVideoRender::DisplayFrame(), and cSoftHdDevice::OnEventReceived().
Send audio data to ringbuffer.
| buffer | data buffer |
| count | number of bytes in data buffer |
| pts | pts to set |
Definition at line 527 of file audio.cpp.
References AV_NOPTS_VALUE, AV_SYNC_BORDER_MS, cAlsaDevice::BytesToFrames(), cAlsaDevice::FramesToBytes(), cAlsaDevice::FramesToPts(), cAlsaDevice::IsPassthroughActive(), L_AV_SYNC, LOGDEBUG2, LOGERROR, m_alsa, m_eventQueue, m_fillLevel, m_inputPts, m_mutex, m_pitchAdjustFrameCounter, m_pitchPpm, m_pRingbuffer, m_queueMutex, m_timebase, cAlsaDevice::PtsToMs(), cBufferFillLevelLowPassFilter::ReceivedFrames(), Timestamp2String(), and cSoftHdRingbuffer::Write().
Referenced by EnqueueFrame(), and EnqueueSpdif().
Place samples in audio output queue.
| frame | audio frame |
Definition at line 453 of file audio.cpp.
References BYTES_PER_SAMPLE, cAudioProcessor::Compress(), Enqueue(), m_audioProcessor, m_useCompressor, m_useNormalizer, and cAudioProcessor::Normalize().
Referenced by Filter().
Enqueue prepared spdif bursts in audio output queue.
Wrapper for Enqueue(), but builds a new pause burst if necessary
| buffer | data buffer |
| count | number of bytes in data buffer |
| pts | pts of the buffer |
Definition at line 511 of file audio.cpp.
References Enqueue(), m_pauseMutex, and RebuildPauseBurst().
Referenced by cAudioDecoder::Passthrough().
Cleanup audio output module (alsa)
This currently also stops the audio thread.
Definition at line 949 of file audio.cpp.
References cAlsaDevice::Exit(), L_SOUND, LOGDEBUG2, m_alsa, m_initialized, m_pFilterGraph, and Stop().
Referenced by cSoftHdDevice::OnEnteringState().
| void cSoftHdAudio::Filter | ( | AVFrame * | inframe, |
| AVCodecContext * | ctx | ||
| ) |
Send audio frame to filter and enqueue it.
| inframe | incoming audio frame to be filtered |
| ctx | AVCodec audio decoding context |
| 1 | error, send again |
| 0 | running |
Definition at line 679 of file audio.cpp.
References CheckForFilterReady(), EnqueueFrame(), FilterGetFrame(), L_SOUND, LOGDEBUG2, LOGERROR, m_filterChanged, and m_pBuffersrcCtx.
Referenced by cAudioDecoder::DecodePCM().
Get frame from filter sink.
Definition at line 613 of file audio.cpp.
References LOGERROR, and m_pBuffersinkCtx.
Referenced by Filter().
Flush alsa buffers.
Definition at line 966 of file audio.cpp.
References cAlsaDevice::FlushBuffers(), m_alsa, m_audioProcessor, cAudioProcessor::ResetCompressor(), and cAudioProcessor::ResetNormalizer().
Referenced by FlushBuffers().
Flush audio buffers.
Flush the alsa buffers and reset audio: pts, ringbuffer, pidController, fillLevel
Definition at line 722 of file audio.cpp.
References AV_NOPTS_VALUE, FlushAlsaBuffers(), L_SOUND, LOGDEBUG2, m_fillLevel, m_filterChanged, m_initialized, m_inputPts, m_mutex, m_pidController, m_pRingbuffer, cBufferFillLevelLowPassFilter::Reset(), cPidController::Reset(), cSoftHdRingbuffer::Reset(), and cBufferFillLevelLowPassFilter::ResetFramesCounters().
Referenced by cSoftHdDevice::FlushAudio().
Definition at line 73 of file audio.h.
References AV_SYNC_BORDER_MS.
Referenced by cVideoRender::FrameDropNecessary().
Get the hardware delay in milliseconds.
Definition at line 815 of file audio.cpp.
References AV_NOPTS_VALUE, cAlsaDevice::FramesToMs(), cAlsaDevice::GetHwDelayFrames(), cAlsaDevice::IsRunning(), m_alsa, m_inputPts, and m_mutex.
Referenced by cVideoRender::LogDroppedDuped().
Get the hardware output PTS in milliseconds.
Calculates the presentation timestamp of audio currently being output by the hardware by accounting for ALSA/kernel buffer delays. This represents the PTS of the audio that is actually being played right now.
Definition at line 795 of file audio.cpp.
References AV_NOPTS_VALUE, cAlsaDevice::FramesToMs(), cAlsaDevice::GetHwDelayFrames(), GetOutputPtsMsInternal(), cAlsaDevice::IsRunning(), m_alsa, m_hwBaseline, m_inputPts, and m_mutex.
Referenced by cSoftHdPlayer::Action(), cVideoRender::DisplayFrame(), GetHardwareOutputPtsTimebaseUnits(), and cSoftHdPlayer::Play().
Get the hardware output PTS in timebase units.
Definition at line 832 of file audio.cpp.
References AV_NOPTS_VALUE, GetHardwareOutputPtsMs(), m_alsa, m_timebase, and cAlsaDevice::MsToPts().
Referenced by cSoftHdDevice::GetSTC().
Definition at line 71 of file audio.h.
References m_alsa, m_inputPts, m_timebase, and cAlsaDevice::PtsToMs().
Referenced by cSoftHdDevice::IsBufferingThresholdReached(), and cVideoRender::LogDroppedDuped().
Get the output PTS of the ringbuffer.
Calculates the presentation timestamp of the next audio sample that will be output from the ringbuffer. This is the input PTS minus the duration of audio currently buffered in the ringbuffer.
Note: This does not account for ALSA/kernel buffer delays. For the actual hardware output PTS, use GetHardwareOutputPtsMs() instead.
Definition at line 774 of file audio.cpp.
References GetOutputPtsMsInternal(), and m_mutex.
Referenced by cSoftHdDevice::GetFirstAudioPtsMsToPlay(), cSoftHdDevice::GetFirstVideoPtsMsToPlay(), cSoftHdDevice::IsBufferingThresholdReached(), and cSoftHdDevice::OnEventReceived().
Definition at line 781 of file audio.cpp.
References cAlsaDevice::BytesToFrames(), cAlsaDevice::FramesToMs(), m_alsa, m_inputPts, m_pRingbuffer, m_timebase, cAlsaDevice::PtsToMs(), and cSoftHdRingbuffer::UsedBytes().
Referenced by DropSamplesOlderThanPtsMs(), GetHardwareOutputPtsMs(), and GetOutputPtsMs().
Definition at line 87 of file audio.h.
References cAlsaDevice::GetPassthroughMask(), and m_alsa.
Get used bytes in audio ringbuffer.
Definition at line 745 of file audio.cpp.
References m_mutex, m_pRingbuffer, and cSoftHdRingbuffer::UsedBytes().
Referenced by cVideoRender::LogDroppedDuped().
Get used ms in audio ringbuffer.
Definition at line 755 of file audio.cpp.
References cAlsaDevice::BytesToFrames(), cAlsaDevice::FramesToMs(), m_alsa, m_mutex, m_pRingbuffer, and cSoftHdRingbuffer::UsedBytes().
Referenced by cVideoRender::LogDroppedDuped().
Definition at line 70 of file audio.h.
References AV_NOPTS_VALUE, and m_inputPts.
Referenced by DropSamplesOlderThanPtsMs(), cSoftHdDevice::IsBufferingThresholdReached(), and cSoftHdDevice::OnEventReceived().
|
private |
Init audio filters.
The following alsa filters are set:
| 0 | everything ok |
| 1 | didn't support channels, downmix set -> scrap this frame, test next |
| -1 | something gone wrong |
Definition at line 204 of file audio.cpp.
References BuildChannelMapFilter(), cAlsaDevice::GetDownmix(), cAudioProcessor::GetEqualizerOptions(), cAlsaDevice::GetHwNumChannels(), cAlsaDevice::GetHwSampleRate(), L_SOUND, LOGDEBUG2, LOGERROR, LOGWARNING, m_alsa, m_audioProcessor, m_filterChanged, m_filterReady, m_pBuffersinkCtx, m_pBuffersrcCtx, m_pFilterGraph, m_useEqualizer, and Setup().
Referenced by CheckForFilterReady().
Definition at line 62 of file audio.h.
References AUDIO_MIN_BUFFER_FREE, cSoftHdRingbuffer::FreeBytes(), and m_pRingbuffer.
Referenced by cSoftHdDevice::PlayAudio(), cSoftHdDevice::PlayAudioPkts(), and cSoftHdDevice::Poll().
Definition at line 59 of file audio.h.
References m_paused.
Referenced by cVideoRender::FrameDropNecessary().
Initialize audio output module (alsa)
The init is done lazily as soon as there is a STOP->PLAY state change or the mediaplayer wants to play video or audio.
This function can safely be called anytime, because it does nothing, if the init has already be done.
Definition at line 933 of file audio.cpp.
References cAlsaDevice::Init(), LOGFATAL, m_alsa, and m_initialized.
Referenced by cSoftHdDevice::OnEventReceived(), cSoftHdDevice::PlayAudioPkts(), and cSoftHdDevice::PlayVideoPkts().
Process queued events and forward them to event receiver.
Definition at line 1161 of file audio.cpp.
References m_eventQueue, m_pEventReceiver, m_queueMutex, and IEventReceiver::OnEventReceived().
Referenced by Action().
Rebuild the pause spdif burst with the size of the last recognized normal spdif audio if size changed.
| size | spdif burst size in bytes |
Definition at line 479 of file audio.cpp.
References L_SOUND, LOGDEBUG2, m_pauseBurst, and m_spdifBurstSize.
Referenced by EnqueueSpdif().
Reset the hw delay baseline.
Definition at line 1149 of file audio.cpp.
References L_SOUND, LOGDEBUG2, m_firstRealAudioReceived, m_hwBaseline, and m_mutex.
Referenced by cSoftHdDevice::OnEnteringState(), cSoftHdDevice::OnEventReceived(), and cSoftHdDevice::OnLeavingState().
Write regular audio data from the ringbuffer to the hardware.
| freeAlsaBufferFrames | number of frames that can be written to the hardware |
| true | if data was written or the write should be scheduled again immediately |
| false | if no data was written |
Definition at line 1085 of file audio.cpp.
References cAudioProcessor::Amplify(), cAlsaDevice::BytesToFrames(), cAlsaDevice::CheckWrittenFrames(), cAlsaDevice::FramesToBytes(), cSoftHdRingbuffer::GetReadPointer(), cAlsaDevice::IsPassthroughActive(), m_alsa, m_audioProcessor, m_fillLevel, m_pRingbuffer, m_softVolume, m_volume, cSoftHdRingbuffer::ReadAdvance(), cAlsaDevice::Write(), and cBufferFillLevelLowPassFilter::WroteFrames().
Referenced by CyclicCall().
Write pause to passthrough device.
Definition at line 1119 of file audio.cpp.
References cAlsaDevice::BytesToFrames(), cAlsaDevice::CheckWrittenFrames(), m_alsa, m_pauseBurst, m_spdifBurstSize, and cAlsaDevice::Write().
Referenced by CyclicCall().
Definition at line 84 of file audio.h.
References m_alsa, and cAlsaDevice::SetAutoAES().
Referenced by cMenuSetupSoft::Store().
Set volume compression parameters.
| enable | true, turn on compression |
| maxfac | max. factor of compression / 1000 |
Definition at line 894 of file audio.cpp.
References m_audioProcessor, m_useCompressor, and cAudioProcessor::SetCompressor().
Referenced by cSoftHdAudio(), and cMenuSetupSoft::Store().
Definition at line 86 of file audio.h.
References m_alsa, and cAlsaDevice::SetDownmix().
Referenced by cMenuSetupSoft::Store().
Set equalizer bands.
| enable | set using equalizer |
| band | setting frequenz bands |
Definition at line 906 of file audio.cpp.
References m_audioProcessor, m_filterChanged, m_useEqualizer, and cAudioProcessor::SetEqualizer().
Referenced by cSoftHdAudio(), and cMenuSetupSoft::Store().
Set the hw delay baseline.
Definition at line 1131 of file audio.cpp.
References cAlsaDevice::FramesToMs(), cAlsaDevice::GetHwDelayFrames(), cAlsaDevice::IsPassthroughActive(), L_SOUND, LOGDEBUG2, m_alsa, m_firstRealAudioReceived, and m_hwBaseline.
Referenced by cSoftHdDevice::OnEventReceived(), and cSoftHdDevice::OnLeavingState().
Set normalize volume parameters.
| enable | true, turn on normalize |
| maxfac | max. factor of normalize / 1000 |
Definition at line 882 of file audio.cpp.
References m_audioProcessor, m_useNormalizer, and cAudioProcessor::SetNormalizer().
Referenced by cSoftHdAudio(), and cMenuSetupSoft::Store().
Definition at line 83 of file audio.h.
References m_alsa, and cAlsaDevice::SetPassthroughMask().
Referenced by cSoftHdDevice::SetPassthroughMask().
Set audio playback pause state.
| pause | true to pause, false to resume |
Definition at line 868 of file audio.cpp.
References L_SOUND, LOGDEBUG2, m_paused, and m_pauseMutex.
Referenced by cSoftHdDevice::Clear(), cVideoRender::FrameDropNecessary(), cSoftHdDevice::OnEnteringState(), cSoftHdDevice::OnEventReceived(), and cSoftHdDevice::OnLeavingState().
Definition at line 76 of file audio.h.
References m_softVolume.
Referenced by cMenuSetupSoft::Store().
Set stereo loudness descent.
| delta | value (/1000) to reduce stereo volume |
Definition at line 918 of file audio.cpp.
References m_stereoDescent, m_volume, and SetVolume().
Referenced by cSoftHdAudio(), and cMenuSetupSoft::Store().
|
inline |
Definition at line 85 of file audio.h.
References m_timebase.
Referenced by cAudioDecoder::Passthrough().
| int cSoftHdAudio::Setup | ( | AVRational | timebase, |
| int | samplerate, | ||
| int | channels, | ||
| bool | passthrough | ||
| ) |
Alsa setup wrapper.
only used for passthrough atm, setting up PCM goes via Filter()
| timebase | codec timebase |
| samplerate | stream samplerate |
| channels | stream nb of channels |
| passthrough | passthrough enabled |
| 0 | everything ok |
| -1 | something gone wrong in AlsaSetup |
| 1 | no parameter change, no setup needed |
Definition at line 582 of file audio.cpp.
References cSoftHdConfig::ConfigAudioDownmix, DropAlsaBuffers(), cAlsaDevice::GetDownmix(), cAlsaDevice::GetHwNumChannels(), cAlsaDevice::GetHwSampleRate(), cAlsaDevice::IsPassthroughActive(), LOGERROR, m_alsa, m_pConfig, m_timebase, cAlsaDevice::Setup(), and Stop().
Referenced by cAudioDecoder::CheckUpdateFormat(), and InitFilter().
Set mixer volume (0-1000)
| volume | volume (0 .. 1000) |
Definition at line 846 of file audio.cpp.
References cAlsaDevice::GetHwNumChannels(), cAlsaDevice::IsPassthroughActive(), m_alsa, m_audioProcessor, m_softVolume, m_stereoDescent, m_volume, cAudioProcessor::SetAmplifier(), and cAlsaDevice::SetVolume().
Referenced by cSoftHdDevice::OnEventReceived(), SetStereoDescent(), and cSoftHdDevice::SetVolumeDevice().
Minimum free space in audio buffer 8 packets for 8 channels.
Definition at line 98 of file audio.h.
Referenced by IsBufferFull().
absolute max a/v difference in ms which should trigger a resync
Definition at line 99 of file audio.h.
Referenced by Enqueue(), and GetAvResyncBorderMs().
|
private |
alsa device
Definition at line 104 of file audio.h.
Referenced by BuildChannelMapFilter(), ClockDriftCompensation(), CyclicCall(), DropAlsaBuffers(), DropSamplesOlderThanPtsMs(), Enqueue(), Exit(), FlushAlsaBuffers(), GetHardwareOutputDelayMs(), GetHardwareOutputPtsMs(), GetHardwareOutputPtsTimebaseUnits(), GetInputPtsMs(), GetOutputPtsMsInternal(), GetPassthroughMask(), GetUsedRingbufferMs(), InitFilter(), LazyInit(), SendAudio(), SendPause(), SetAutoAES(), SetDownmix(), SetHwDelayBaseline(), SetPassthroughMask(), Setup(), and SetVolume().
|
private |
Definition at line 145 of file audio.h.
Referenced by DropAlsaBuffers(), EnqueueFrame(), FlushAlsaBuffers(), InitFilter(), SendAudio(), SetCompression(), SetEqualizer(), SetNormalize(), and SetVolume().
|
private |
event queue for incoming events
Definition at line 116 of file audio.h.
Referenced by CyclicCall(), Enqueue(), and ProcessEvents().
|
private |
low pass filter for the buffer fill level
Definition at line 106 of file audio.h.
Referenced by ClockDriftCompensation(), DropSamplesOlderThanPtsMs(), Enqueue(), FlushBuffers(), and SendAudio().
|
private |
filter has changed
Definition at line 155 of file audio.h.
Referenced by CheckForFilterReady(), Filter(), FlushBuffers(), InitFilter(), and SetEqualizer().
|
private |
filter is ready
Definition at line 156 of file audio.h.
Referenced by CheckForFilterReady(), and InitFilter().
false, as long as no real audio was sent - used to trigger the baseline set
Definition at line 131 of file audio.h.
Referenced by ResetHwDelayBaseline(), and SetHwDelayBaseline().
|
private |
saves the hw delay (pause bursts) once a real audio frame to correctly do the AV-Sync
Definition at line 130 of file audio.h.
Referenced by GetHardwareOutputPtsMs(), ResetHwDelayBaseline(), and SetHwDelayBaseline().
class initialized
Definition at line 112 of file audio.h.
Referenced by Exit(), FlushBuffers(), and LazyInit().
|
private |
pts clock (last pts in ringbuffer)
Definition at line 124 of file audio.h.
Referenced by Enqueue(), FlushBuffers(), GetHardwareOutputDelayMs(), GetHardwareOutputPtsMs(), GetInputPtsMs(), GetOutputPtsMsInternal(), and HasInputPts().
|
private |
last time the PID controller was invoked
Definition at line 108 of file audio.h.
Referenced by ClockDriftCompensation().
|
private |
mutex for thread safety
Definition at line 113 of file audio.h.
Referenced by CyclicCall(), DropSamplesOlderThanPtsMs(), Enqueue(), FlushBuffers(), GetHardwareOutputDelayMs(), GetHardwareOutputPtsMs(), GetOutputPtsMs(), GetUsedRingbufferBytes(), GetUsedRingbufferMs(), and ResetHwDelayBaseline().
|
private |
packet counter for logging
Definition at line 109 of file audio.h.
Referenced by ClockDriftCompensation().
|
private |
holds the burst data itself
Definition at line 129 of file audio.h.
Referenced by RebuildPauseBurst(), and SendPause().
audio is paused
Definition at line 125 of file audio.h.
Referenced by CyclicCall(), IsPaused(), and SetPaused().
|
private |
mutex for a safe thread pausing
Definition at line 114 of file audio.h.
Referenced by CyclicCall(), EnqueueSpdif(), and SetPaused().
|
private |
Definition at line 159 of file audio.h.
Referenced by FilterGetFrame(), and InitFilter().
|
private |
Definition at line 158 of file audio.h.
Referenced by Filter(), and InitFilter().
|
private |
pointer to config
Definition at line 103 of file audio.h.
Referenced by cSoftHdAudio(), and Setup().
|
private |
|
private |
|
private |
Definition at line 157 of file audio.h.
Referenced by CheckForFilterReady(), Exit(), and InitFilter().
|
private |
PID controller for clock drift compensation with tuning values coming from educated guesses.
Definition at line 107 of file audio.h.
Referenced by ClockDriftCompensation(), DropSamplesOlderThanPtsMs(), and FlushBuffers().
|
private |
|
private |
pitch adjustment in ppm. Positive values are faster
Definition at line 117 of file audio.h.
Referenced by ClockDriftCompensation(), and Enqueue().
|
private |
sample ring buffer
Definition at line 167 of file audio.h.
Referenced by DropSamplesOlderThanPtsMs(), Enqueue(), FlushBuffers(), GetOutputPtsMsInternal(), GetUsedRingbufferBytes(), GetUsedRingbufferMs(), IsBufferFull(), and SendAudio().
|
private |
mutex for queue safety
Definition at line 115 of file audio.h.
Referenced by CyclicCall(), Enqueue(), and ProcessEvents().
|
private |
flag to use soft volume
Definition at line 127 of file audio.h.
Referenced by SendAudio(), SetSoftvol(), and SetVolume().
|
private |
size of the current spdif burst
Definition at line 128 of file audio.h.
Referenced by CyclicCall(), RebuildPauseBurst(), and SendPause().
|
private |
volume descent for stereo
Definition at line 121 of file audio.h.
Referenced by SetStereoDescent(), and SetVolume().
|
private |
AVCodecContext pkts_timebase.
Definition at line 122 of file audio.h.
Referenced by Enqueue(), GetHardwareOutputPtsTimebaseUnits(), GetInputPtsMs(), GetOutputPtsMsInternal(), SetTimebase(), and Setup().
|
private |
flag to use compress volume
Definition at line 147 of file audio.h.
Referenced by EnqueueFrame(), and SetCompression().
|
private |
flag to use equalizer
Definition at line 148 of file audio.h.
Referenced by InitFilter(), and SetEqualizer().
|
private |
flag to use volume normalize
Definition at line 146 of file audio.h.
Referenced by EnqueueFrame(), and SetNormalize().
|
private |
current volume (0 .. 1000)
Definition at line 120 of file audio.h.
Referenced by SendAudio(), SetStereoDescent(), and SetVolume().