karlstav / cava

Cross-platform Audio Visualizer
MIT License
4.17k stars 232 forks source link

Keyboard controls are ignored when pausing PipeWire input #556

Closed gardk closed 6 months ago

gardk commented 6 months ago

Describe the bug

Title.

Found this cause I wanted cava to only visualize my music and not all desktop sounds :)

I've found that resizing the window causes the bars to actually reset, unless you pressed Q before doing so.

To Reproduce

Steps to reproduce the behavior:

  1. Have MPD (only source I've tested with) running in the background
  2. Run cava
  3. Using qpwgraph or similar, attach cava to MPD's output instead of the default sink
  4. Pause music

Expected behavior

Input should not be ignored and bars should return to zero.

Screenshots

This picture is from when the music is paused image

Desktop:

Terminal emulator Tested in kitty 0.33.1 and alacritty 0.13.2

karlstav commented 6 months ago

this might be intended behavior, not the key controls, those should work (if the sleep timer is not configured).

When the source is paused, there is no data coming in, i would have to add a function to reset the buffer to zero after some time without new input data. I think i already have it in the fifo input.

gardk commented 6 months ago

Yeah, the bars freezing does make sense actually, but it would be nice to have them reset to zero after some time :)

karlstav commented 6 months ago

was finally able to reproduce. The issue is that the main thread is waiting for the audio to terminate, but the on_process callback is not being fired. Need to think of some solution.

karlstav commented 6 months ago

I guess that was what this was for: 0d773076063dbd393dc9f7adfe78f9f5ca1dce0d will re-add it make some signal to the thread when terminating the audio.

gardk commented 6 months ago

You can make on_process keep firing by setting PW_KEY_NODE_ALWAYS_PROCESS, seems to fix this issue completely.

karlstav commented 6 months ago

it does! and then the bars also go down when pausing.

I will consider this resolved then, thanks @gardk for the contribution!