Repository navigation
feat(player): measure the bitrate while the track plays - #26
Conversation
The format chip showed the tags' bitrate, the whole file's average: a FLAC that opens on a quiet passage read the same low figure through its loud middle. The decoder now sums the compressed bytes and frames of the packets it decodes (waveflow-core's new `ActiveStream::packets_read`) and takes a reading per second of audio, due when that second plays, as the spectrum frames are. The tags' figure shows until the first reading; a pause keeps the last one, a seek starts the window afresh. DSD keeps its tags, its rate is constant. Bumps waveflow-core to 14ff457b (WaveFlow #997), which adds the tally.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Calcul et mise en file des mesures src/audio/bitrate.rs, src/audio/mod.rs |
BitrateMeter calcule le débit sur des fenêtres d’au moins une seconde d’audio. BitrateQueue conserve au plus 32 mesures associées à leur position de lecture. Les tests couvrent le calcul, la réinitialisation et la sélection des mesures arrivées à échéance. |
Production et synchronisation des mesures src/audio/decoder.rs, src/audio/state.rs, Cargo.toml |
La session de décodage mesure les paquets lus et met les résultats en file selon les échantillons attendus. SharedPlayback récupère les mesures dues et vide la file lors de la réinitialisation de l’horloge. La révision Git de waveflow-core est mise à jour. |
Affichage du débit mesuré src/app.rs, docs/ARCHITECTURE.md |
L’application met à jour le débit affiché pendant la lecture. Elle privilégie cette mesure au débit moyen des métadonnées et la réinitialise au changement ou à l’effacement du morceau. La documentation décrit aussi le comportement en pause et avant la première mesure. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant Session
participant BitrateMeter
participant SharedPlayback
participant QuickPlayApp
Session->>BitrateMeter: fournit les paquets lus et le taux d’échantillonnage
BitrateMeter->>Session: retourne une mesure disponible
Session->>SharedPlayback: met en file la mesure et sa position d’échéance
QuickPlayApp->>SharedPlayback: récupère la mesure due pendant la lecture
SharedPlayback->>QuickPlayApp: retourne la mesure due
Possibly related PRs
- InstaZDLL/waveflow-quickplay#9 : cette PR modifie l’intégration du décodeur avec
ActiveStream, dont le chemin de décodage utilisé ici. - InstaZDLL/waveflow-quickplay#4 : cette PR introduit
ActiveStream, que cette PR utilise pour mesurer les paquets lus. - InstaZDLL/waveflow-quickplay#14 : cette PR modifie le comptage de
samples_played, utilisé ici pour déterminer l’échéance des mesures.
Suggested labels: type: feat, scope: ui, scope: deps, scope: docs, size: m
Merge Risk: 
Low · up to 12a5c
-
Seeking can temporarily show the previous position’s bitrate. Playback is unaffected, so the change is mergeable with awareness of this limitation.
Security architecture risk: 
Low · up to 12a5c
-
The inspected application changes keep bitrate measurements inside the player, with bounded memory use and no identified expansion of privileges or external access. The accompanying playback-library update could not be fully verified, so some uncertainty remains.
Retained concerns
No architecture-level concerns identified.Security review details
-
Security Blast Radius
- inferred — The inspected application-side exposure is confined to the existing player process and its playback display. No new tenant, service, credential, or persistent-data authority was identified in this flow. This conclusion does not establish the exposure of uninspected changes in the updated playback library.
Trust Boundaries and Controls
- observed — The decoder produces readings and the UI consumes them under the shared queue mutex. Queue insertion and seek cleanup occur on the decoder thread, preventing a pre-seek producer operation from running after that seek's cleanup. A UI value already consumed can remain visible, but consuming a value cannot reinsert it into the queue.
Resilience and Maintainability Implications
- observed — The bitrate queue holds at most 32 readings and evicts the oldest at capacity. Consumption removes superseded due readings. The audio callback does not acquire the new queue mutex, limiting memory growth and avoiding a new lock dependency on the real-time output path.
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Description check
-
Explanation
La description explique clairement le problème, la solution, les changements techniques et les tests réalisés. Elle ne reprend pas tous les intitulés du modèle et ne fournit pas de checklist complète ni de lien GitHub formel, mais les informations principales sont présentes et suffisamment détaillées.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 10 functions across 5 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Why
The bitrate chip showed the tags' figure, which lofty computes as the whole file's average and which never moves. A FLAC that opens on a quiet passage showed the same low number through its loud middle (reported: 524 kbps where the music runs around 1574 kbps).
What
14ff457b(feat(core): count the bytes and frames a stream has decoded WaveFlow#997), which addsActiveStream::packets_read: running totals of the compressed bytes and source frames of the packets decoded.src/audio/bitrate.rs:BitrateMeterturns two readings of those totals into kbps once they hold a second of audio;BitrateQueueholds each reading until the output clock reaches it, as the spectrum frames wait.docs/ARCHITECTURE.md: one bullet on how the chip is measured.Tested
cargo fmt --check,cargo clippy --locked --all-targets -- -D warnings,cargo test --locked(78 tests, 4 new) on Windows.ffprobe -show_packetssums (about 660).\localhost\J$\…).Summary by CodeRabbit