|
vdr-plugin-softhddevice-drm-gles 1.6.4-d0291bb
|
Fill Level Low Pass Filter. More...
#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 |
Fill Level Low Pass Filter.
Definition at line 20 of file filllevel.h.
| Enumerator | |
|---|---|
| UNINITIALIZED | |
| SETTLING | |
| SETTLED | |
Definition at line 34 of file filllevel.h.
|
inline |
Definition at line 28 of file filllevel.h.
References m_bufferFillLevelFramesAvg, and m_mutex.
Referenced by cSoftHdAudio::ClockDriftCompensation().
|
inline |
Definition at line 25 of file filllevel.h.
References m_mutex, and m_writtenToAlsaFrames.
|
inline |
Definition at line 24 of file filllevel.h.
References m_mutex, and m_receivedFrames.
|
inline |
Definition at line 31 of file filllevel.h.
References m_mutex, m_state, and SETTLED.
Referenced by cSoftHdAudio::ClockDriftCompensation().
Definition at line 26 of file filllevel.h.
References m_mutex, and m_receivedFrames.
Referenced by cSoftHdAudio::Enqueue().
Resets the filter state.
Definition at line 18 of file filllevel.cpp.
References m_bufferFillLevelFramesAvg, m_frameCounter, m_state, and UNINITIALIZED.
Referenced by cSoftHdAudio::DropSamplesOlderThanPtsMs(), and cSoftHdAudio::FlushBuffers().
Resets the received and written frames counters.
Definition at line 28 of file filllevel.cpp.
References m_receivedFrames, and m_writtenToAlsaFrames.
Referenced by cSoftHdAudio::FlushBuffers().
Definition at line 29 of file filllevel.h.
References m_minBufferSizeFrames, and m_mutex.
Converts the filter state to a string representation.
| state | The state to convert |
Definition at line 84 of file filllevel.cpp.
References SETTLED, SETTLING, and UNINITIALIZED.
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 48 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().
Definition at line 27 of file filllevel.h.
References m_mutex, and m_writtenToAlsaFrames.
Referenced by cSoftHdAudio::DropSamplesOlderThanPtsMs(), and cSoftHdAudio::SendAudio().
|
staticconstexprprivate |
Definition at line 41 of file filllevel.h.
Referenced by UpdateAvgBufferFillLevel().
|
staticconstexprprivate |
Definition at line 40 of file filllevel.h.
Referenced by UpdateAvgBufferFillLevel().
|
private |
Definition at line 48 of file filllevel.h.
Referenced by GetBufferFillLevelFramesAvg(), Reset(), and UpdateAvgBufferFillLevel().
|
private |
Definition at line 49 of file filllevel.h.
Referenced by UpdateAvgBufferFillLevel().
|
private |
Definition at line 51 of file filllevel.h.
Referenced by UpdateAvgBufferFillLevel().
|
private |
Definition at line 50 of file filllevel.h.
Referenced by Reset(), and UpdateAvgBufferFillLevel().
|
private |
Definition at line 52 of file filllevel.h.
Referenced by SetMinBufferSizeFrames(), and UpdateAvgBufferFillLevel().
|
private |
Definition at line 44 of file filllevel.h.
Referenced by GetBufferFillLevelFramesAvg(), GetFramesPlayed(), GetFramesReceived(), IsSettled(), ReceivedFrames(), SetMinBufferSizeFrames(), UpdateAvgBufferFillLevel(), and WroteFrames().
|
private |
Definition at line 46 of file filllevel.h.
Referenced by GetFramesReceived(), ReceivedFrames(), ResetFramesCounters(), and UpdateAvgBufferFillLevel().
|
private |
Definition at line 45 of file filllevel.h.
Referenced by IsSettled(), Reset(), and UpdateAvgBufferFillLevel().
|
private |
Definition at line 47 of file filllevel.h.
Referenced by GetFramesPlayed(), ResetFramesCounters(), UpdateAvgBufferFillLevel(), and WroteFrames().
|
staticconstexprprivate |
Definition at line 42 of file filllevel.h.
Referenced by UpdateAvgBufferFillLevel().