farinjini writes
I wrote a small program in C++ to change my audio volume. It is called like so ./AlsaVolume 50 for example. However onvolumechange doesn’t call this program as expected.
Kind regards, I’m really enjoying using your program.
joerg-krause writes
Did you set the full absolute path, e.g. /home/yourname/AlsaVolume, to onvolumechange
?
farinjini writes
Yes I did
onvolumechange = /home/pi/documents/vGDB/AlsaVolume/AlsaVolume
farinjini writes
Some further info,
I set log level to 4 and captured the log messages when I change the volume on my control point.
joerg-krause writes
> src/mpdcli.cxx:103::mpd_run_set_volume(M_CONN, volume) failed: problems setting volume
> src/mpdcli.cxx:106::mpd_run_set_volume(M_CONN, volume) server error: 52
Looks like a MPD error.
farinjini writes
From my understanding (reading the docs), upmpdcli should not be trying to set the volume on mpd (if that’s where the problem is from), it should just invoke the app specified with the new volume level as the 1st parameter.
joerg-krause writes
Maybe it’s related to this issue: https://www.lesbonscomptes.com/upmpdcli/github-issues/upmpdcli-html/issue-1.html
medoc92 writes
From a quick look at the code, this is not what happens. If setting the volume fails, the onvolume command is not called.
If
On Mon, 08 Feb 2016 07:39:53 -0800, Alhassan Abdulkadir notifications@github.com wrote:
> From my understanding (reading the docs), upmpdcli should not be trying to set the volume on mpd (if that's where the problem is from), it should just invoke the app specified with the new volume level as the 1st parameter.
>
> ---
>
> Reply to this email directly or view it on GitHub:
> https://www.lesbonscomptes.com/upmpdcli/github-issues/upmpdcli-html/issue-26.html#issuecomment-181416304
farinjini writes
OK, I’ll look at the source and make modifications that work for me. Thanks and great work. Closing this now.
medoc92 writes
Reopening, because there is a valid case for having a more adaptable approach for onvolumechange, another user would like to use this to actually perform the volume change (with a script, and because mpd apparently can’t do it for some reason).
Joerg, if you are around, what was your original purpose for this hook ?
joerg-krause writes
I use it on an embedded system for storing the new volume immediately to the UBI flash filesystem as both alsactl and the UBI system write to flash with some seconds delay. So, in case of a power-cut the new volume setting will be lost otherwise.
Another use case is to trigger the new volume to a LCD display attached to the device.
A common issue is that upmpdcli does not run as root, so if some actions requires root priviliges sudo has to be used for calling the script and the user upmpdcli has to be member of the sudo group.
medoc92 writes
The following commit should allow replacing controlling the volume through mpd with an external script:
Set externalvolumecontrol in the config, and possibly define getexternalvolume as a script to retrieve the volume value. If externalvolumecontrol is set, onvolumechange is executed instead of calling mpd, and is supposed to perform the volume change.
When externalvolumecontrol is not set (the default), things work just as before (the onvolumechange script gets called if the mpd volume change succeeds).