|
vdr-plugin-softhddevice-drm-gles 1.6.2
|
Audio and Alsa Interface. More...
Classes | |
| class | cSoftHdAudio |
| Audio Interface. More... | |
| class | cPidController |
| PID Controller. More... | |
| class | cSoftHdRingbuffer |
| Ringbuffer (FIFO) Implementation. More... | |
Typedefs | |
| typedef volatile int | atomic_t |
| Atomic Wrapper Macros. | |
Audio and Alsa Interface.
This file defines cSoftHdAudio, which holds all functions we need to deal with audio, e.g.handling the audio stream and sending it to hardware.
| #define atomic_add | ( | val, | |
| ptr | |||
| ) | __atomic_add_fetch(ptr, val, __ATOMIC_SEQ_CST) |
Definition at line 32 of file ringbuffer.h.
| #define atomic_dec | ( | ptr | ) | __atomic_sub_fetch(ptr, 1, __ATOMIC_SEQ_CST) |
Definition at line 31 of file ringbuffer.h.
| #define atomic_inc | ( | ptr | ) | __atomic_add_fetch(ptr, 1, __ATOMIC_SEQ_CST) |
Definition at line 30 of file ringbuffer.h.
| #define atomic_read | ( | ptr | ) | __atomic_load_n(ptr, __ATOMIC_SEQ_CST) |
Definition at line 29 of file ringbuffer.h.
| #define atomic_set | ( | ptr, | |
| val | |||
| ) | __atomic_store_n(ptr, val, __ATOMIC_SEQ_CST) |
Definition at line 28 of file ringbuffer.h.
| #define atomic_sub | ( | val, | |
| ptr | |||
| ) | __atomic_sub_fetch(ptr, val, __ATOMIC_SEQ_CST) |
Definition at line 33 of file ringbuffer.h.
Audio thread loop, started with Start().
Tries to periodically send frames to the hardware and checks for events (underruns)
Definition at line 1199 of file audio.cpp.
References cSoftHdAudio::CyclicCall(), LOGDEBUG, and cSoftHdAudio::ProcessEvents().
Cleanup the alsa audio output module.
Definition at line 1815 of file audio.cpp.
References cSoftHdAudio::m_pAlsaMixer, cSoftHdAudio::m_pAlsaMixerElem, and cSoftHdAudio::m_pAlsaPCMHandle.
Referenced by cSoftHdAudio::Exit().
Initialize the alsa audio output module.
Definition at line 1799 of file audio.cpp.
References cSoftHdAudio::AlsaInitMixer(), cSoftHdAudio::AlsaInitPCMDevice(), and AlsaNoopCallback().
Referenced by cSoftHdAudio::LazyInit().
Initialize alsa mixer.
Definition at line 1607 of file audio.cpp.
References L_SOUND, LOGDEBUG2, LOGERROR, cSoftHdAudio::m_alsaRatio, cSoftHdAudio::m_pAlsaMixer, cSoftHdAudio::m_pAlsaMixerElem, cSoftHdAudio::m_pMixerChannel, and cSoftHdAudio::m_pMixerDevice.
Referenced by cSoftHdAudio::AlsaInit().
Search for an alsa pcm device and open it.
Definition at line 1528 of file audio.cpp.
References cSoftHdAudio::FindAlsaDevice(), L_SOUND, LOGDEBUG2, LOGERROR, LOGFATAL, LOGINFO, LOGWARNING, cSoftHdAudio::m_pAlsaPCMHandle, cSoftHdAudio::m_passthrough, cSoftHdAudio::m_pPassthroughDevice, cSoftHdAudio::m_pPCMDevice, and cSoftHdAudio::OpenAlsaDevice().
Referenced by cSoftHdAudio::AlsaInit().
|
static |
Empty log callback.
Definition at line 1787 of file audio.cpp.
Referenced by cSoftHdAudio::AlsaInit().
Setup alsa audio for requested format.
| channels | Channels requested |
| sample_rate | SampleRate requested |
| passthrough | use pass-through (AC-3, ...) device |
| 0 | everything ok |
| -1 | something gone wrong |
Definition at line 1683 of file audio.cpp.
References cSoftHdAudio::DropAlsaBuffers(), L_SOUND, LOGDEBUG2, LOGERROR, LOGINFO, LOGWARNING, cSoftHdAudio::m_alsaBufferSizeFrames, cSoftHdAudio::m_alsaUseMmap, cSoftHdAudio::m_downmix, cSoftHdAudio::m_hwNumChannels, cSoftHdAudio::m_hwSampleRate, cSoftHdAudio::m_pAlsaPCMHandle, cSoftHdAudio::MsToFrames(), and cSoftHdAudio::Stop().
Referenced by cSoftHdAudio::InitFilter(), and cSoftHdAudio::Setup().
Set alsa mixer volume (0-1000)
| volume | volume (0 .. 1000) |
Definition at line 1661 of file audio.cpp.
References cSoftHdAudio::m_alsaRatio, cSoftHdAudio::m_pAlsaMixer, and cSoftHdAudio::m_pAlsaMixerElem.
Referenced by cSoftHdAudio::SetVolume().
Build a pause spdif burst with the size of the last recognized normal spdif audio.
Definition at line 634 of file audio.cpp.
References IEC61937_NULL, IEC61937_PREAMBLE1, IEC61937_PREAMBLE2, cSoftHdAudio::m_pauseBurst, and cSoftHdAudio::m_spdifBurstSize.
Referenced by cSoftHdAudio::EnqueueSpdif().
|
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 785 of file audio.cpp.
References cSoftHdAudio::InitFilter(), L_SOUND, LOGDEBUG2, cSoftHdAudio::m_filterChanged, cSoftHdAudio::m_filterReady, and cSoftHdAudio::m_pFilterGraph.
Referenced by cSoftHdAudio::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 1837 of file audio.cpp.
References cSoftHdAudio::FramesToMsDouble(), cBufferFillLevelLowPassFilter::GetBufferFillLevelFramesAvg(), cPidController::GetDTerm(), cPidController::GetITerm(), cPidController::GetPTerm(), cPidController::GetTargetValue(), cBufferFillLevelLowPassFilter::IsSettled(), L_SOUND, LOGDEBUG2, LOGWARNING, cSoftHdAudio::m_alsaBufferSizeFrames, cSoftHdAudio::m_fillLevel, cSoftHdAudio::m_lastPidInvocation, cSoftHdAudio::m_packetCounter, cSoftHdAudio::m_pAlsaPCMHandle, cSoftHdAudio::m_passthrough, cSoftHdAudio::m_pidController, cSoftHdAudio::m_pitchPpm, cPidController::SetTargetValue(), cPidController::Update(), and cBufferFillLevelLowPassFilter::UpdateAvgBufferFillLevel().
Referenced by cSoftHdDevice::PlayAudio().
Compress audio samples.
| samples | sample buffer |
| count | number of bytes in sample buffer |
Definition at line 233 of file audio.cpp.
References L_SOUND, LOGDEBUG2, cSoftHdAudio::m_bytesPerSample, cSoftHdAudio::m_compressionFactor, and cSoftHdAudio::m_compressionMaxFactor.
Referenced by cSoftHdAudio::EnqueueFrame().
Create a PID Controller.
| kp | Proportional gain |
| ki | Integral gain |
| kd | Derivative gain |
| maxOutput | Max allowed output value (absolute) |
Definition at line 36 of file pidcontroller.cpp.
References cPidController::integralGain, cPidController::maxIntegral, and cPidController::maxOutput.
| cSoftHdAudio::cSoftHdAudio | ( | cSoftHdDevice * | device | ) |
Create a new audio context.
Definition at line 61 of file audio.cpp.
References cSoftHdConfig::ConfigAudioCompression, cSoftHdConfig::ConfigAudioEq, cSoftHdConfig::ConfigAudioEqBand, cSoftHdConfig::ConfigAudioMaxCompression, cSoftHdConfig::ConfigAudioMaxNormalize, cSoftHdConfig::ConfigAudioNormalize, cSoftHdConfig::ConfigAudioStereoDescent, cSoftHdAudio::m_pConfig, cSoftHdAudio::SetCompression(), cSoftHdAudio::SetEq(), cSoftHdAudio::SetNormalize(), and cSoftHdAudio::SetStereoDescent().
| cSoftHdRingbuffer::cSoftHdRingbuffer | ( | size_t | size | ) |
cSoftHdRingbuffer constructor
Init a new ring buffer
| size | Size of the ring buffer |
Definition at line 36 of file ringbuffer.cpp.
References atomic_set, LOGFATAL, cSoftHdRingbuffer::m_filled, cSoftHdRingbuffer::m_pBuffer, cSoftHdRingbuffer::m_pBufferEnd, cSoftHdRingbuffer::m_pReadPointer, and cSoftHdRingbuffer::m_pWritePointer.
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 1237 of file audio.cpp.
References cSoftHdAudio::HandleError(), L_SOUND, LOGDEBUG2, LOGERROR, cSoftHdAudio::m_mutex, cSoftHdAudio::m_pAlsaPCMHandle, cSoftHdAudio::m_passthrough, cSoftHdAudio::m_paused, cSoftHdAudio::m_pauseMutex, cSoftHdAudio::m_spdifBurstSize, cSoftHdAudio::SendAudio(), and cSoftHdAudio::SendPause().
Referenced by cSoftHdAudio::Action().
Drop alsa buffers.
Definition at line 1134 of file audio.cpp.
References cSoftHdAudio::FlushAlsaBuffersInternal().
Referenced by cSoftHdAudio::AlsaSetup().
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 576 of file audio.cpp.
References cSoftHdAudio::GetOutputPtsMsInternal(), cSoftHdAudio::HasInputPts(), L_AV_SYNC, LOGDEBUG2, cSoftHdAudio::m_fillLevel, cSoftHdAudio::m_mutex, cSoftHdAudio::m_pAlsaPCMHandle, cSoftHdAudio::m_pidController, cSoftHdAudio::m_pRingbuffer, cSoftHdAudio::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 |
| frame | decoded frame (used to get frame parameters) |
Definition at line 677 of file audio.cpp.
References AV_NOPTS_VALUE, cSoftHdAudio::AV_SYNC_BORDER_MS, L_AV_SYNC, LOGDEBUG2, LOGERROR, cSoftHdAudio::m_eventQueue, cSoftHdAudio::m_fillLevel, cSoftHdAudio::m_inputPts, cSoftHdAudio::m_mutex, cSoftHdAudio::m_pAlsaPCMHandle, cSoftHdAudio::m_pitchAdjustFrameCounter, cSoftHdAudio::m_pitchPpm, cSoftHdAudio::m_pRingbuffer, cSoftHdAudio::PtsToMs(), cBufferFillLevelLowPassFilter::ReceivedFrames(), Timestamp2String(), and cSoftHdRingbuffer::Write().
Referenced by cSoftHdAudio::EnqueueFrame(), and cSoftHdAudio::EnqueueSpdif().
Place samples in audio output queue.
| frame | audio frame |
Definition at line 608 of file audio.cpp.
References cSoftHdAudio::Compress(), cSoftHdAudio::Enqueue(), cSoftHdAudio::m_bytesPerSample, cSoftHdAudio::m_compression, cSoftHdAudio::m_normalize, cSoftHdAudio::Normalize(), and ReorderAudioFrame().
Referenced by cSoftHdAudio::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 |
| frame | decoded frame (used to get frame parameters) |
Definition at line 655 of file audio.cpp.
References cSoftHdAudio::BuildPauseBurst(), cSoftHdAudio::Enqueue(), L_SOUND, LOGDEBUG2, cSoftHdAudio::m_pauseBurst, cSoftHdAudio::m_pauseMutex, and cSoftHdAudio::m_spdifBurstSize.
Referenced by cAudioDecoder::DecodePassthrough().
Cleanup audio output module (alsa)
This currently also stops the audio thread.
Definition at line 1090 of file audio.cpp.
References cSoftHdAudio::AlsaExit(), L_SOUND, LOGDEBUG2, cSoftHdAudio::m_initialized, cSoftHdAudio::m_pFilterGraph, and cSoftHdAudio::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 818 of file audio.cpp.
References cSoftHdAudio::CheckForFilterReady(), cSoftHdAudio::EnqueueFrame(), cSoftHdAudio::FilterGetFrame(), L_SOUND, LOGDEBUG2, LOGERROR, cSoftHdAudio::m_filterChanged, and cSoftHdAudio::m_pBuffersrcCtx.
Referenced by cAudioDecoder::Decode().
Get frame from filter sink.
Definition at line 752 of file audio.cpp.
References LOGERROR, and cSoftHdAudio::m_pBuffersinkCtx.
Referenced by cSoftHdAudio::Filter().
|
private |
Find alsa device giving some search hints.
| devname | interface identification (e.g. "pcm") |
| hint | string to compare with device name hints |
| passthrough | set, if we want a passthrough device |
Definition at line 1492 of file audio.cpp.
References LOGWARNING, and cSoftHdAudio::OpenAlsaDevice().
Referenced by cSoftHdAudio::AlsaInitPCMDevice().
Flush alsa buffers.
Definition at line 1126 of file audio.cpp.
References cSoftHdAudio::FlushAlsaBuffersInternal().
Referenced by cSoftHdAudio::FlushBuffers().
Flush alsa buffers internally.
| drop | force a snd_pcm_drop of the audio frames already in the kernel |
Definition at line 1144 of file audio.cpp.
References L_SOUND, LOGDEBUG2, LOGERROR, cSoftHdAudio::m_compressionFactor, cSoftHdAudio::m_compressionMaxFactor, cSoftHdAudio::m_normalizeAverage, cSoftHdAudio::m_normalizeCounter, cSoftHdAudio::m_normalizeFactor, cSoftHdAudio::m_normalizeReady, cSoftHdAudio::m_pAlsaPCMHandle, cSoftHdAudio::m_passthrough, and cSoftHdAudio::NORMALIZE_MAX_INDEX.
Referenced by cSoftHdAudio::DropAlsaBuffers(), and cSoftHdAudio::FlushAlsaBuffers().
Flush audio buffers.
Flush the alsa buffers and reset audio: pts, ringbuffer, pidController, fillLevel
Definition at line 861 of file audio.cpp.
References AV_NOPTS_VALUE, cSoftHdAudio::FlushAlsaBuffers(), L_SOUND, LOGDEBUG2, cSoftHdAudio::m_fillLevel, cSoftHdAudio::m_filterChanged, cSoftHdAudio::m_initialized, cSoftHdAudio::m_inputPts, cSoftHdAudio::m_mutex, cSoftHdAudio::m_pidController, cSoftHdAudio::m_pRingbuffer, cBufferFillLevelLowPassFilter::Reset(), cPidController::Reset(), cSoftHdRingbuffer::Reset(), and cBufferFillLevelLowPassFilter::ResetFramesCounters().
Referenced by cSoftHdDevice::FlushAudio().
Get free bytes in ring buffer.
Definition at line 281 of file ringbuffer.cpp.
References atomic_read, cSoftHdRingbuffer::m_filled, and cSoftHdRingbuffer::m_size.
Referenced by cSoftHdAudio::IsBufferFull().
Get the hardware delay in milliseconds.
Definition at line 945 of file audio.cpp.
References AV_NOPTS_VALUE, cSoftHdAudio::FramesToMs(), cSoftHdAudio::m_hwSampleRate, cSoftHdAudio::m_inputPts, cSoftHdAudio::m_mutex, and cSoftHdAudio::m_pAlsaPCMHandle.
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 923 of file audio.cpp.
References AV_NOPTS_VALUE, cSoftHdAudio::FramesToMs(), cSoftHdAudio::GetOutputPtsMsInternal(), cSoftHdAudio::m_hwBaseline, cSoftHdAudio::m_hwSampleRate, cSoftHdAudio::m_inputPts, cSoftHdAudio::m_mutex, and cSoftHdAudio::m_pAlsaPCMHandle.
Referenced by cSoftHdPlayer::Action(), cVideoRender::DisplayFrame(), cSoftHdAudio::GetHardwareOutputPtsTimebaseUnits(), and cSoftHdPlayer::Play().
Get the hardware output PTS in timebase units.
Definition at line 964 of file audio.cpp.
References AV_NOPTS_VALUE, cSoftHdAudio::GetHardwareOutputPtsMs(), and cSoftHdAudio::MsToPts().
Referenced by cSoftHdDevice::GetSTC().
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 902 of file audio.cpp.
References cSoftHdAudio::GetOutputPtsMsInternal(), and cSoftHdAudio::m_mutex.
Referenced by cSoftHdDevice::GetFirstAudioPtsMsToPlay(), cSoftHdDevice::GetFirstVideoPtsMsToPlay(), cSoftHdDevice::IsBufferingThresholdReached(), and cSoftHdDevice::OnEventReceived().
Definition at line 909 of file audio.cpp.
References cSoftHdAudio::FramesToMs(), cSoftHdAudio::m_inputPts, cSoftHdAudio::m_pAlsaPCMHandle, cSoftHdAudio::m_pRingbuffer, cSoftHdAudio::PtsToMs(), and cSoftHdRingbuffer::UsedBytes().
Referenced by cSoftHdAudio::DropSamplesOlderThanPtsMs(), cSoftHdAudio::GetHardwareOutputPtsMs(), and cSoftHdAudio::GetOutputPtsMs().
Get read pointer and used bytes at this position of ring buffer.
| [out] | rp | Read pointer is placed here |
Definition at line 256 of file ringbuffer.cpp.
References atomic_read, cSoftHdRingbuffer::m_filled, cSoftHdRingbuffer::m_pBufferEnd, and cSoftHdRingbuffer::m_pReadPointer.
Referenced by cSoftHdAudio::SendAudio().
Get used bytes in audio ringbuffer.
Definition at line 884 of file audio.cpp.
References cSoftHdAudio::m_pRingbuffer, and cSoftHdRingbuffer::UsedBytes().
Referenced by cVideoRender::LogDroppedDuped().
Get write pointer and free bytes at this position of ring buffer.
| [out] | wp | Write pointer is placed here |
Definition at line 151 of file ringbuffer.cpp.
References atomic_read, cSoftHdRingbuffer::m_filled, cSoftHdRingbuffer::m_pBufferEnd, cSoftHdRingbuffer::m_pWritePointer, and cSoftHdRingbuffer::m_size.
Handle an alsa error.
Definition at line 1111 of file audio.cpp.
References AUDIO, LOGERROR, cSoftHdAudio::m_eventQueue, cSoftHdAudio::m_pAlsaPCMHandle, and cSoftHdAudio::m_passthrough.
Referenced by cSoftHdAudio::CyclicCall().
|
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 401 of file audio.cpp.
References cSoftHdAudio::AlsaSetup(), L_SOUND, LOGDEBUG2, LOGERROR, LOGWARNING, cSoftHdAudio::m_downmix, cSoftHdAudio::m_equalizerBand, cSoftHdAudio::m_filterChanged, cSoftHdAudio::m_filterReady, cSoftHdAudio::m_hwNumChannels, cSoftHdAudio::m_hwSampleRate, cSoftHdAudio::m_pBuffersinkCtx, cSoftHdAudio::m_pBuffersrcCtx, cSoftHdAudio::m_pFilterGraph, cSoftHdAudio::m_pTimebase, and cSoftHdAudio::m_useEqualizer.
Referenced by cSoftHdAudio::CheckForFilterReady().
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 1075 of file audio.cpp.
References cSoftHdAudio::AlsaInit(), and cSoftHdAudio::m_initialized.
Referenced by cSoftHdDevice::OnEventReceived(), cSoftHdDevice::PlayAudioPkts(), and cSoftHdDevice::PlayVideoPkts().
Normalize audio samples.
| samples | sample buffer |
| count | number of bytes in sample buffer |
Definition at line 152 of file audio.cpp.
References L_SOUND, LOGDEBUG2, cSoftHdAudio::m_bytesPerSample, cSoftHdAudio::m_normalizeAverage, cSoftHdAudio::m_normalizeCounter, cSoftHdAudio::m_normalizeFactor, cSoftHdAudio::m_normalizeIndex, cSoftHdAudio::m_normalizeMaxFactor, cSoftHdAudio::m_normalizeMinFactor, cSoftHdAudio::m_normalizeReady, cSoftHdAudio::m_normalizeSamples, and cSoftHdAudio::NORMALIZE_MAX_INDEX.
Referenced by cSoftHdAudio::EnqueueFrame().
Opens an alsa device.
| device | alsa device to be opened |
| passthrough | set, if this is a passthrough device |
Definition at line 1440 of file audio.cpp.
References L_SOUND, LOGDEBUG2, LOGWARNING, cSoftHdAudio::m_appendAES, and cSoftHdAudio::m_pAlsaPCMHandle.
Referenced by cSoftHdAudio::AlsaInitPCMDevice(), and cSoftHdAudio::FindAlsaDevice().
Process queued events and forward them to event receiver.
Definition at line 1424 of file audio.cpp.
References cSoftHdAudio::m_eventQueue, cSoftHdAudio::m_pEventReceiver, and IEventReceiver::OnEventReceived().
Referenced by cSoftHdAudio::Action().
Read from a ring buffer.
| buf | buffer of cnt bytes to be read |
| cnt | Number of bytes to be read |
Definition at line 215 of file ringbuffer.cpp.
References atomic_read, atomic_sub, cSoftHdRingbuffer::m_filled, cSoftHdRingbuffer::m_pBuffer, cSoftHdRingbuffer::m_pBufferEnd, and cSoftHdRingbuffer::m_pReadPointer.
Advance read pointer in ring buffer.
| cnt | Number of bytes to be advanced |
Definition at line 178 of file ringbuffer.cpp.
References atomic_read, atomic_sub, cSoftHdRingbuffer::m_filled, cSoftHdRingbuffer::m_pBuffer, cSoftHdRingbuffer::m_pBufferEnd, and cSoftHdRingbuffer::m_pReadPointer.
Referenced by cSoftHdAudio::DropSamplesOlderThanPtsMs(), and cSoftHdAudio::SendAudio().
Reorder audio frame.
ffmpeg L R C Ls Rs -> alsa L R Ls Rs C ffmpeg L R C LFE Ls Rs -> alsa L R Ls Rs C LFE ffmpeg L R C LFE Ls Rs Rl Rr -> alsa L R Ls Rs C LFE Rl Rr
| buf[IN,OUT] | sample buffer |
| size | size of sample buffer in bytes |
| channels | number of channels interleaved in sample buffer |
Definition at line 95 of file audio.cpp.
Referenced by cSoftHdAudio::EnqueueFrame().
Reset the internal state (integral sum and error history).
Definition at line 99 of file pidcontroller.cpp.
References cPidController::dTerm, cPidController::firstRun, cPidController::integralSum, cPidController::iTerm, cPidController::previousError, and cPidController::pTerm.
Referenced by cSoftHdAudio::DropSamplesOlderThanPtsMs(), cSoftHdAudio::FlushBuffers(), and cPidController::Update().
Reset ring buffer pointers.
Definition at line 59 of file ringbuffer.cpp.
References atomic_set, cSoftHdRingbuffer::m_filled, cSoftHdRingbuffer::m_pBuffer, cSoftHdRingbuffer::m_pReadPointer, and cSoftHdRingbuffer::m_pWritePointer.
Referenced by cSoftHdAudio::FlushBuffers().
Reset the hw delay baseline.
Definition at line 1412 of file audio.cpp.
References L_SOUND, LOGDEBUG2, cSoftHdAudio::m_firstRealAudioReceived, cSoftHdAudio::m_hwBaseline, and cSoftHdAudio::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 1298 of file audio.cpp.
References cSoftHdRingbuffer::GetReadPointer(), L_SOUND, LOGDEBUG2, LOGERROR, LOGWARNING, cSoftHdAudio::m_alsaUseMmap, cSoftHdAudio::m_fillLevel, cSoftHdAudio::m_pAlsaPCMHandle, cSoftHdAudio::m_passthrough, cSoftHdAudio::m_pRingbuffer, cSoftHdAudio::m_softVolume, cSoftHdAudio::m_volume, cSoftHdRingbuffer::ReadAdvance(), cSoftHdAudio::SoftAmplify(), and cBufferFillLevelLowPassFilter::WroteFrames().
Referenced by cSoftHdAudio::CyclicCall().
Write pause to passthrough device.
Definition at line 1358 of file audio.cpp.
References LOGERROR, LOGWARNING, cSoftHdAudio::m_alsaUseMmap, cSoftHdAudio::m_pAlsaPCMHandle, cSoftHdAudio::m_pauseBurst, and cSoftHdAudio::m_spdifBurstSize.
Referenced by cSoftHdAudio::CyclicCall().
Set volume compression parameters.
| enable | true, turn on compression |
| maxfac | max. factor of compression / 1000 |
Definition at line 1027 of file audio.cpp.
References cSoftHdAudio::m_compression, cSoftHdAudio::m_compressionFactor, and cSoftHdAudio::m_compressionMaxFactor.
Referenced by cSoftHdAudio::cSoftHdAudio(), and cMenuSetupSoft::Store().
Set equalizer bands.
| band | setting frequenz bands |
| onoff | set using equalizer |
Definition at line 319 of file audio.cpp.
References cSoftHdAudio::m_equalizerBand, cSoftHdAudio::m_filterChanged, and cSoftHdAudio::m_useEqualizer.
Referenced by cSoftHdAudio::cSoftHdAudio(), and cMenuSetupSoft::Store().
Set the hw delay baseline.
Definition at line 1392 of file audio.cpp.
References cSoftHdAudio::FramesToMs(), L_SOUND, LOGDEBUG2, cSoftHdAudio::m_firstRealAudioReceived, cSoftHdAudio::m_hwBaseline, cSoftHdAudio::m_pAlsaPCMHandle, and cSoftHdAudio::m_passthrough.
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 1015 of file audio.cpp.
References cSoftHdAudio::m_normalize, and cSoftHdAudio::m_normalizeMaxFactor.
Referenced by cSoftHdAudio::cSoftHdAudio(), and cMenuSetupSoft::Store().
Set audio passthrough mask.
| mask | passthrough mask (as a bitmask) |
Definition at line 1056 of file audio.cpp.
References cSoftHdAudio::m_passthrough, and cSoftHdAudio::m_pitchPpm.
Referenced by cSoftHdDevice::SetPassthroughMask().
Set audio playback pause state.
| pause | true to pause, false to resume |
Definition at line 1001 of file audio.cpp.
References L_SOUND, LOGDEBUG2, cSoftHdAudio::m_paused, and cSoftHdAudio::m_pauseMutex.
Referenced by cSoftHdDevice::Clear(), cVideoRender::DisplayFrame(), cSoftHdDevice::OnEnteringState(), cSoftHdDevice::OnEventReceived(), and cSoftHdDevice::OnLeavingState().
Set stereo loudness descent.
| delta | value (/1000) to reduce stereo volume |
Definition at line 1045 of file audio.cpp.
References cSoftHdAudio::m_stereoDescent, cSoftHdAudio::m_volume, and cSoftHdAudio::SetVolume().
Referenced by cSoftHdAudio::cSoftHdAudio(), and cMenuSetupSoft::Store().
| int cSoftHdAudio::Setup | ( | AVCodecContext * | ctx, |
| int | samplerate, | ||
| int | channels, | ||
| int | passthrough | ||
| ) |
Alsa setup wrapper.
only used for passthrough atm, setting up PCM alsa goes via Filter()
| AudioCtx | AVCodec audio decoding context |
| 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 729 of file audio.cpp.
References cSoftHdAudio::AlsaSetup(), LOGERROR, cSoftHdAudio::m_downmix, cSoftHdAudio::m_hwNumChannels, cSoftHdAudio::m_hwSampleRate, and cSoftHdAudio::m_pTimebase.
Referenced by cAudioDecoder::UpdateFormat().
Set mixer volume (0-1000)
| volume | volume (0 .. 1000) |
Definition at line 978 of file audio.cpp.
References cSoftHdAudio::AlsaSetVolume(), cSoftHdAudio::m_amplifier, cSoftHdAudio::m_hwNumChannels, cSoftHdAudio::m_passthrough, cSoftHdAudio::m_softVolume, cSoftHdAudio::m_stereoDescent, and cSoftHdAudio::m_volume.
Referenced by cSoftHdDevice::OnEventReceived(), cSoftHdAudio::SetStereoDescent(), and cSoftHdDevice::SetVolumeDevice().
Amplify the samples in software.
| samples | sample buffer |
| count | number of bytes in sample buffer |
Definition at line 290 of file audio.cpp.
References cSoftHdAudio::m_amplifier, cSoftHdAudio::m_bytesPerSample, and cSoftHdAudio::m_volume.
Referenced by cSoftHdAudio::SendAudio().
Stop the thread.
Definition at line 1217 of file audio.cpp.
References LOGDEBUG.
Referenced by cSoftHdAudio::AlsaSetup(), and cSoftHdAudio::Exit().
Calculate the new output value.
| currentValue | The current value |
| dt | The time elapsed since the last update (seconds) |
Definition at line 56 of file pidcontroller.cpp.
References cPidController::derivativeGain, cPidController::dTerm, cPidController::firstRun, cPidController::integralGain, cPidController::integralSum, cPidController::iTerm, LOGWARNING, cPidController::maxIntegral, cPidController::maxOutput, cPidController::previousError, cPidController::proportionalGain, cPidController::pTerm, cPidController::Reset(), and cPidController::targetValue.
Referenced by cSoftHdAudio::ClockDriftCompensation().
Get used bytes in ring buffer.
Definition at line 291 of file ringbuffer.cpp.
References atomic_read, and cSoftHdRingbuffer::m_filled.
Referenced by cSoftHdAudio::DropSamplesOlderThanPtsMs(), cSoftHdAudio::GetOutputPtsMsInternal(), and cSoftHdAudio::GetUsedBytes().
Write to a ring buffer.
| buf | buffer of cnt bytes to be written |
| cnt | Number of bytes in buffer |
Definition at line 110 of file ringbuffer.cpp.
References atomic_add, atomic_read, cSoftHdRingbuffer::m_filled, cSoftHdRingbuffer::m_pBuffer, cSoftHdRingbuffer::m_pBufferEnd, cSoftHdRingbuffer::m_pWritePointer, and cSoftHdRingbuffer::m_size.
Referenced by cSoftHdAudio::Enqueue().
Advance write pointer in ring buffer.
| cnt | Number of bytes to be adavanced |
Definition at line 73 of file ringbuffer.cpp.
References atomic_add, atomic_read, cSoftHdRingbuffer::m_filled, cSoftHdRingbuffer::m_pBuffer, cSoftHdRingbuffer::m_pBufferEnd, cSoftHdRingbuffer::m_pWritePointer, and cSoftHdRingbuffer::m_size.
| cSoftHdRingbuffer::~cSoftHdRingbuffer | ( | void | ) |
cSoftHdRingbuffer destructor
Definition at line 51 of file ringbuffer.cpp.
References cSoftHdRingbuffer::m_pBuffer.