Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect averager updates at start #390

Open
pavhofman opened this issue Jan 17, 2025 · 4 comments
Open

Incorrect averager updates at start #390

pavhofman opened this issue Jan 17, 2025 · 4 comments

Comments

@pavhofman
Copy link
Contributor

pavhofman commented Jan 17, 2025

If target_level is larger than chunk, then playback will initially sleep for several chunk times (corresponding to the target_level time). Meanwhile the chunks queue up between Processing and Playback. When playback wakes up, it will correctly write several of the queued chunks to the device buffer without sleeping in between, because there is enough avail. However, every write the averager gets updated with the momentary delays which are not relevant at that moment yet. As a result the initial values in the averager distort the average, IMO. Here is a relevant trace log, grepped for the trace message:

2025-01-16 12:48:52.488090 TRACE [src/countertimer.rs:153] Averager: added value 2048, nb. 1
2025-01-16 12:48:52.488458 TRACE [src/countertimer.rs:153] Averager: added value 4096, nb. 2
2025-01-16 12:48:52.489908 TRACE [src/countertimer.rs:153] Averager: added value 6144, nb. 3
2025-01-16 12:48:52.529865 TRACE [src/countertimer.rs:153] Averager: added value 6144, nb. 4
2025-01-16 12:48:52.571786 TRACE [src/countertimer.rs:153] Averager: added value 6144, nb. 5

Perhaps values should start being added to the averager after the incoming queue is empty, i.e. after the initial "flood" of chunks is written somehow? Thanks for considering.

@HEnquist
Copy link
Owner

I plan to add the frames of any waiting chunk to the buffer level calculation. That should take care of this. And it should also help when using a target_level close to the buffer size.

@pavhofman
Copy link
Contributor Author

Thanks, that sounds like a good way. Just IMO only the chunks which will fit into the buffer in the sequence of writes before the soundcard goes to sleep should be counted, because those will be part of the buffer fill after that sequence.

@HEnquist
Copy link
Owner

The case when the playback device goes to sleep isn't very well handled now, and won't really be improved by the changes I have in mind here. It would need some logic of it's own, to drop the old chunks in the queue when waking up.

@HEnquist
Copy link
Owner

See #391

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants