I am re-writing my notification sound code in Battery Buddy, and there is a bug that needs to be fixed. I have a console-only C++ daemon that makes the sound using QSoundEffect, and the issue is that it doesn’t respect the ringtone volume setting, nor slient mode. There seems to be audioRole property in QML Audio and SoundEffect components, but nothing similar for pure C++…
How can I query the ringtone volume and if the device is in silent mode or not? I guess DBus is the answer here, but The Documentation doesn’t really help… com.jolla.ambienced perhaps?
I decided to dig up the source code of Nemo Notifications, and there is a property hint called sound-file which looks quite promising…
…but it seems that the commit that introduced it is mere four months old, so I bet it’s not in SFOS 3.4. Might explain why the documentation doesn’t mention it, either.
QMediaPlayer can play sounds and does provide setAudioRole, but it still doesn’t respect the ringtone volume or silent mode. I guess that doesn’t have the required effect, or there’s a bug in the system.
On the other hand, there is QSoundEffect::category() but I haven’t been able to find a list of available categories anywhere…
This task is getting a bit frustrating… Any pointers appreciated.
That set me onto the right path! But dang it was hard for me to find out anything remotely resembling documentation! I first finded any com.nokia.profiled files, ended up finding profiled.service systemd system service file, which in turn just starts /usr/bin/profiled (which outputs nothing with ´–help´). Armed with that binary name, I googled my way to its source code using which I was finally able to, uh, nothing. I don’t know DBus…
But then I found this lovely page in Maemo wiki! Using that as a template I was finally able to come up with something useful!
So far I have been able to set only general and silent. If the volume is not zero, the profile is general. If the Silent top-menu button is activated, or volume slider dragged to zero, the profile is switched to silent without the general volume getting set. So it’s a bit illogical, but at least I got that figured out before I got into actually writing the code for this!
[Quote=direc85]
I think I have earned a beer.
[/quote]
I’d even say, two!
I was not that desperate and only tried to check the interface with qdbusviewer which only revealed the signal, no methods!?
But thanks to WMO you found it “easily”!
Do not rely on profile being only general or silent!
When I just checked my profile was “ambience”!
Later when I modified ambience, ring tone level, ambience … it was only general or silent?
And
I was able to set profile manually to something different, e.g. bus-send --print-reply --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.set_profile string:meeting
But ad those profiles are not really supported but we have only this crippled ambience thing I would guess you are fine with profile ‘silent’ and any other value and its level.
Actually, no meaning should ever be attached to profile names, applications should basically just track values that are currently active.
While it is guaranteed that couple of profiles like “general” and “silent” always exist, in general what profiles are available / what keys profiles contain / what values they have in each profile depends on what kind of configuration files are installed on the device. And the situation can dynamically change if / when such configuration files are installed, removed or upgraded.
But do note that ambience system works by modifying profiles on the fly. IIRC “ambience” profile was/is used for that purpose. Basically this means that in sailfish profiles can no longer be used in the way they were designed to work in maemo/meego devices - except for that “you should not care about profile names” part.
There is also CLI utility profileclient (pkcon install profileclient ; profileclient -h) that can be used for inspecting current state / making and tracking changes. For example running “profileclient -T” in a shell while changing ambiences / adjusting ringing tone volume via volume keys shows what kind of changes happen under the hood.
Thanks for the details! I’ll simplify my code when I get back home accordingly.
It actually makes sense that there are no “profiles” per se but the ambience changing over time instead. Using the empty string is a nice way of accessing the current profile too. I’ll test both ways - Dbus and libprofile.h - to learn more, but I’ll keep the DBus method for now. I really need to learn to use it properly…