|
vdr-plugin-softhddevice-drm-gles 1.5.9-20e15de
|
#include <filllevel.h>
Public Member Functions | |
| void | Reset () |
| Resets the filter state. | |
| void | ResetFramesCounters () |
| Resets the received and written frames counters. | |
| int | GetFramesReceived () |
| int | GetFramesPlayed () |
| void | ReceivedFrames (int count) |
| void | WroteFrames (int count) |
| double | GetBufferFillLevelFramesAvg () |
| void | SetMinBufferSizeFrames (int size) |
| void | UpdateAvgBufferFillLevel (int) |
| Updates the buffer fill level average. | |
| bool | IsSettled () |
Private Types | |
| enum | State { UNINITIALIZED , SETTLING , SETTLED } |
Private Member Functions | |
| const char * | StateToString (State d) |
| Converts the filter state to a string representation. | |
Private Attributes | |
| std::mutex | m_mutex |
| State | m_state = UNINITIALIZED |
| int | m_receivedFrames = 0 |
| int | m_writtenToAlsaFrames = 0 |
| double | m_bufferFillLevelFramesAvg = 0 |
| double | m_bufferFillLevelFramesTargetValue = 0 |
| int | m_frameCounter = 0 |
| double | m_floatingAverageAlpha = FLOATING_AVERAGE_ALPHA_NORMAL |
| int | m_minBufferSizeFrames = 0 |
Static Private Attributes | |
| static constexpr double | FLOATING_AVERAGE_ALPHA_SETTLING = 0.02 |
| static constexpr double | FLOATING_AVERAGE_ALPHA_NORMAL = 0.002 |
| static constexpr int | SETTLING_DURATION_PACKETS = 30 / 0.16 |
Definition at line 23 of file filllevel.h.
|
private |
| Enumerator | |
|---|---|
| UNINITIALIZED | |
| SETTLING | |
| SETTLED | |
Definition at line 37 of file filllevel.h.
|
inline |
Definition at line 31 of file filllevel.h.
References m_bufferFillLevelFramesAvg, and m_mutex.
Referenced by cSoftHdAudio::ClockDriftCompensation().
|
inline |
Definition at line 28 of file filllevel.h.
References m_mutex, and m_writtenToAlsaFrames.
|
inline |
Definition at line 27 of file filllevel.h.
References m_mutex, and m_receivedFrames.
|
inline |
Definition at line 34 of file filllevel.h.
References m_mutex, m_state, and SETTLED.
Referenced by cSoftHdAudio::ClockDriftCompensation().
|
inline |
Definition at line 29 of file filllevel.h.
References m_mutex, and m_receivedFrames.
Referenced by cSoftHdAudio::Enqueue().
| void cBufferFillLevelLowPassFilter::Reset | ( | ) |
Resets the filter state.
Definition at line 26 of file filllevel.cpp.
References m_bufferFillLevelFramesAvg, m_frameCounter, m_state, and UNINITIALIZED.
Referenced by cSoftHdAudio::DropSamplesOlderThanPtsMs(), and cSoftHdAudio::FlushBuffers().
| void cBufferFillLevelLowPassFilter::ResetFramesCounters | ( | ) |
Resets the received and written frames counters.
Definition at line 37 of file filllevel.cpp.
References m_receivedFrames, and m_writtenToAlsaFrames.
Referenced by cSoftHdAudio::FlushBuffers().
|
inline |
Definition at line 32 of file filllevel.h.
References m_minBufferSizeFrames, and m_mutex.
|
private |
Converts the filter state to a string representation.
| state | The state to convert |
Definition at line 92 of file filllevel.cpp.
References SETTLED, SETTLING, and UNINITIALIZED.
| void cBufferFillLevelLowPassFilter::UpdateAvgBufferFillLevel | ( | int | hardwareBufferFillLevelFrames | ) |
Updates the buffer fill level average.
Calculates the current buffer fill level based on received frames, written frames, and the hardware buffer fill level. Applies a low-pass filter (exponential moving average) to smooth the value. This is necessary, because the packets coming from VDR have a few milliseconds jitter.
Handles state transitions:
| hardwareBufferFillLevelFrames | Current fill level reported by the hardware (ALSA) |
Definition at line 57 of file filllevel.cpp.
References FLOATING_AVERAGE_ALPHA_NORMAL, FLOATING_AVERAGE_ALPHA_SETTLING, m_bufferFillLevelFramesAvg, m_bufferFillLevelFramesTargetValue, m_floatingAverageAlpha, m_frameCounter, m_minBufferSizeFrames, m_mutex, m_receivedFrames, m_state, m_writtenToAlsaFrames, SETTLED, SETTLING, SETTLING_DURATION_PACKETS, and UNINITIALIZED.
Referenced by cSoftHdAudio::ClockDriftCompensation().
|
inline |
Definition at line 30 of file filllevel.h.
References m_mutex, and m_writtenToAlsaFrames.
Referenced by cSoftHdAudio::CyclicCall(), and cSoftHdAudio::DropSamplesOlderThanPtsMs().
|
staticconstexprprivate |
Definition at line 44 of file filllevel.h.
Referenced by UpdateAvgBufferFillLevel().
|
staticconstexprprivate |
Definition at line 43 of file filllevel.h.
Referenced by UpdateAvgBufferFillLevel().
|
private |
Definition at line 51 of file filllevel.h.
Referenced by GetBufferFillLevelFramesAvg(), Reset(), and UpdateAvgBufferFillLevel().
|
private |
Definition at line 52 of file filllevel.h.
Referenced by UpdateAvgBufferFillLevel().
|
private |
Definition at line 54 of file filllevel.h.
Referenced by UpdateAvgBufferFillLevel().
|
private |
Definition at line 53 of file filllevel.h.
Referenced by Reset(), and UpdateAvgBufferFillLevel().
|
private |
Definition at line 55 of file filllevel.h.
Referenced by SetMinBufferSizeFrames(), and UpdateAvgBufferFillLevel().
|
private |
Definition at line 47 of file filllevel.h.
Referenced by GetBufferFillLevelFramesAvg(), GetFramesPlayed(), GetFramesReceived(), IsSettled(), ReceivedFrames(), SetMinBufferSizeFrames(), UpdateAvgBufferFillLevel(), and WroteFrames().
|
private |
Definition at line 49 of file filllevel.h.
Referenced by GetFramesReceived(), ReceivedFrames(), ResetFramesCounters(), and UpdateAvgBufferFillLevel().
|
private |
Definition at line 48 of file filllevel.h.
Referenced by IsSettled(), Reset(), and UpdateAvgBufferFillLevel().
|
private |
Definition at line 50 of file filllevel.h.
Referenced by GetFramesPlayed(), ResetFramesCounters(), UpdateAvgBufferFillLevel(), and WroteFrames().
|
staticconstexprprivate |
Definition at line 45 of file filllevel.h.
Referenced by UpdateAvgBufferFillLevel().