PromyLOPh / pianobar

Console-based pandora.com player
http://6xq.net/pianobar/
Other
1.74k stars 321 forks source link

[macos] High CPU usage in 'coreaudiod' while pianobar is running #692

Open bhartshorn opened 4 years ago

bhartshorn commented 4 years ago

Subject of the issue

CPU usage of coreaudiod process sits at 6.5-8% while pianobar is running. CPU usage of this process drops to 0.0% on the same machine when pianobar is closed. While writing this issue, I noticed this is normal behavior for audio output on MacOS. It would be good if the audio device was released when playback is paused.

Your environment

Steps to reproduce

Should reproduce on any recent version of macos, I've noticed the problem for quite a while, but just narrowed it down to pianobar. The behavior persists even when playback is paused, any time pianobar is open. (I tend to just leave it open but paused)

Expected behaviour

I tested the Apple Music app, coreaudiod has similar CPU usage while it is playing audio. It seems this is 'normal' when an application is using the audio device. However, when playback is paused in Music, coreaudiod usage returns to 0, unlike pianobar.

Actual behaviour

It seems pianobar (probably libao?) holds the audio device open, possibly outputting silence, while playback is paused, thus keeping CPU usage of the audio daemon high.

I realize this might be an upstream issue with libao, but I wanted to make you aware. Thanks for maintaining this awesome software.

PromyLOPh commented 4 years ago

It should be noted pulseaudio on Linux behaves the same (although CPU usage is much lower on my PC, ~2% when playing, 0.7% when paused).

Fact is, getting audio output right is hard. Very hard. In the past I though about forking a helper process that contols a media player like mpv. Is this a viable option on OSX as well?