Skip to content

PulseAudio plugin: drain stream upon closing; change codestyle - #1405

Merged
flyingmutant merged 5 commits into
cmus:masterfrom
ihy123:pulse_fix
Aug 25, 2025
Merged

flyingmutant merged 5 commits into
cmus:masterfrom
ihy123:pulse_fix

Conversation

@ihy123

@ihy123 ihy123 commented Feb 10, 2025

Copy link
Copy Markdown
Contributor

I noticed that PulseAudio plugin stops playback before the stream has ended (at least 0.2 sec remains), so here's the fix.

@gavtroy

gavtroy commented Feb 10, 2025

Copy link
Copy Markdown
Collaborator

There's a history to why it's not drained, see 7adf497. At a glance it seems like this would reintroduce the "hang at quit while paused" issue? The information that the stream stops early is interesting though, it's not something I've noticed.

@ihy123

ihy123 commented Feb 11, 2025

Copy link
Copy Markdown
Contributor Author

You're right. I thing the following algorithm will solve it:

  1. is stream corked or suspended or state != ready?
  2. If it is then just quit
  3. If it is not then drain the stream.

Also we can add a time event (pa_context_rttime_new) to stop draining after some time.
Determine the time using
pa_bytes_to_usec(pa_context_get_tile_size()).

I don't think adding a timeout is necessary though since we know that the stream is not paused.

I use pipewire with pulseaudio frontend, so it might handle closing differently.

@ihy123

ihy123 commented Feb 11, 2025

Copy link
Copy Markdown
Contributor Author

I realized that I shouldn't have removed the pa_ namespace from function names because it makes debug logging less informative.

Looks like at this point it's better to rewrite commit history. But will github accept git push -f or creating another pull request is required? This is my first pull request so I don't know.

Aside from this mess, all mentioned issues are fixed.

@gavtroy

gavtroy commented Feb 12, 2025

Copy link
Copy Markdown
Collaborator

push -f is okay. For the record it probably would have been better to keep the refactoring in a separate PR to make it easier to review and potentially object to (although it looks fine to me).

@ihy123
ihy123 force-pushed the pulse_fix branch 3 times, most recently from 0714534 to c713341 Compare February 12, 2025 17:32
@ihy123

ihy123 commented Feb 12, 2025

Copy link
Copy Markdown
Contributor Author

Ok, so I added pulse_ namespace to most functions and cleaned up commit history. All done

@pgaskin
pgaskin self-requested a review February 13, 2025 04:46
@pgaskin

pgaskin commented Feb 13, 2025

Copy link
Copy Markdown
Member

Upon a first glance, it seems sane enough, and the commits are split well. I'll do some testing later this week.

@pgaskin

pgaskin commented Feb 18, 2025

Copy link
Copy Markdown
Member

Playback and pause/stop works fine for me in Termux (with PulseAudio 17.0) and Fedora 41 (with PipeWire 1.2.7). Still need to test exiting in various conditions.

@pgaskin pgaskin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well on PW and PA, LGTM.

@pgaskin

pgaskin commented Aug 20, 2025

Copy link
Copy Markdown
Member

@flyingmutant rebase merge?

@flyingmutant
flyingmutant merged commit b8c4df8 into cmus:master Aug 25, 2025
@flyingmutant

Copy link
Copy Markdown
Member

Thanks! In the future, it is probably best to avoid "style" reworks because they make history/blame harder to follow, and also make the review itself harder (although in this case the commits are well-split indeed).

@ihy123

ihy123 commented Aug 28, 2025

Copy link
Copy Markdown
Contributor Author

Oh, I didn't think of the review process. I agree that style changes were unnecessary for this one and will avoid such changes in the future.

@ihy123
ihy123 deleted the pulse_fix branch September 9, 2025 15:14
@BrewTestBot BrewTestBot mentioned this pull request Oct 28, 2026
1 task done
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Nov 2, 2026
https://build.opensuse.org/request/show/1394501
by user mia + anag_factory
- Update to 2.13.0
  * Set the minimum requested AAudio buffer capacity
    gh#cmus/cmus#1386
  * Check for libavutil pkg-config
    gh#cmus/cmus#1388
  * Add sort by duration
    gh#cmus/cmus#1440
  * Respect scroll_offset setting when resizing window
    gh#cmus/cmus#1413
  * Try to fallback to any plugin upon failure to init output
    plugin
    gh#cmus/cmus#1416
  * PulseAudio bugfixes and APPLICATION_ID
    gh#cmus/cmus#1405
  * ip/ffmpeg fixes and ffmpeg 8.0 support
    gh#cmus/cmus#1444
  * CUE handling improvements and replaygain/genre support
    gh#cmus/cmus#1406
  * Fix for missing Icecast streaming bitrate display.
    gh#cmus/cmus#1451
  * op/mixer_alsa: alsamixer's volume scale; setting mixer control
    like aplay does it
    gh#cmus/cmus#1445
  * ip/ffmpeg: fix seeking and
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

Successfully merging this pull request may close these issues.

4 participants