vdr-plugin-softhddevice-drm-gles 1.6.4-d0291bb
filllevel.h
Go to the documentation of this file.
1// SPDX-License-Identifier: AGPL-3.0-or-later
2
10#ifndef FILLLEVEL_H
11#define FILLLEVEL_H
12
13#include <mutex>
14
21public:
22 void Reset();
24 int GetFramesReceived() { std::lock_guard<std::mutex> lock(m_mutex); return m_receivedFrames; }
25 int GetFramesPlayed() { std::lock_guard<std::mutex> lock(m_mutex); return m_writtenToAlsaFrames; }
26 void ReceivedFrames(int count) { std::lock_guard<std::mutex> lock(m_mutex); m_receivedFrames += count; }
27 void WroteFrames(int count) { std::lock_guard<std::mutex> lock(m_mutex); m_writtenToAlsaFrames += count; }
28 double GetBufferFillLevelFramesAvg() { std::lock_guard<std::mutex> lock(m_mutex); return m_bufferFillLevelFramesAvg; }
29 void SetMinBufferSizeFrames(int size) { std::lock_guard<std::mutex> lock(m_mutex); m_minBufferSizeFrames = size; }
31 bool IsSettled() { std::lock_guard<std::mutex> lock(m_mutex); return m_state == SETTLED; }
32
33private:
39
40 constexpr static double FLOATING_AVERAGE_ALPHA_SETTLING = 0.02;
41 constexpr static double FLOATING_AVERAGE_ALPHA_NORMAL = 0.002;
42 constexpr static int SETTLING_DURATION_PACKETS = 30 / 0.16; // 30 seconds with one packet every 160ms
43
44 std::mutex m_mutex;
53
54 const char* StateToString(State d);
55};
56
57#endif
Fill Level Low Pass Filter.
Definition filllevel.h:20
void ResetFramesCounters()
Resets the received and written frames counters.
Definition filllevel.cpp:28
void UpdateAvgBufferFillLevel(int)
Updates the buffer fill level average.
Definition filllevel.cpp:48
static constexpr double FLOATING_AVERAGE_ALPHA_NORMAL
Definition filllevel.h:41
const char * StateToString(State d)
Converts the filter state to a string representation.
Definition filllevel.cpp:84
void ReceivedFrames(int count)
Definition filllevel.h:26
static constexpr double FLOATING_AVERAGE_ALPHA_SETTLING
Definition filllevel.h:40
static constexpr int SETTLING_DURATION_PACKETS
Definition filllevel.h:42
void WroteFrames(int count)
Definition filllevel.h:27
void SetMinBufferSizeFrames(int size)
Definition filllevel.h:29
void Reset()
Resets the filter state.
Definition filllevel.cpp:18