mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-17 08:56:49 -05:00
alsa: use dynamic bandwidth
This commit is contained in:
parent
3d3d86fd24
commit
0f7a3bdb2a
1 changed files with 4 additions and 3 deletions
|
|
@ -68,6 +68,7 @@ struct dll {
|
||||||
double T;
|
double T;
|
||||||
double b, c;
|
double b, c;
|
||||||
double n0;
|
double n0;
|
||||||
|
int count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct state {
|
struct state {
|
||||||
|
|
@ -156,7 +157,7 @@ static inline void dll_bandwidth(struct dll *dll, double period, double rate, do
|
||||||
static inline void dll_init(struct dll *dll, double period, double rate, double bandwidth)
|
static inline void dll_init(struct dll *dll, double period, double rate, double bandwidth)
|
||||||
{
|
{
|
||||||
dll->T = 1000000.0 / rate;
|
dll->T = 1000000.0 / rate;
|
||||||
dll->n0 = 0.0;
|
dll->count = 0;
|
||||||
dll_bandwidth(dll, period, rate, bandwidth);
|
dll_bandwidth(dll, period, rate, bandwidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,12 +165,12 @@ static inline double dll_update(struct dll *dll, double system_time, double peri
|
||||||
{
|
{
|
||||||
double e;
|
double e;
|
||||||
|
|
||||||
if (dll->n0 == 0.0) {
|
if (dll->count++ == 0) {
|
||||||
dll->n0 = system_time;
|
dll->n0 = system_time;
|
||||||
} else {
|
} else {
|
||||||
dll->n0 += period * dll->T;
|
dll->n0 += period * dll->T;
|
||||||
e = system_time - dll->n0;
|
e = system_time - dll->n0;
|
||||||
dll->n0 += dll->b * e;
|
dll->n0 += SPA_MAX(dll->b, 1.0 / dll->count) * e;
|
||||||
dll->T += dll->c * e;
|
dll->T += dll->c * e;
|
||||||
}
|
}
|
||||||
return dll->n0;
|
return dll->n0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue