C++ Monitoring OSS/mixer

Is there a way to listen for volume changes? I wrote an OSS service for Quickshell, which relies on manual controls refresh. It would be nice to drive signals through events, but kqueue cannot listen for mixers, and devd does not emit any mixer-related events.

 
Take a look at how mixertui does this. I'm guessing it polls the mixer controls. Run two instances of mixertui, change one of the volume controls in one mixertui instance, and see the change also take place in the other instance. If so, you can model your code after mixertui.
 
Take a look at how mixertui does this. I'm guessing it polls the mixer controls. Run two instances of mixertui, change one of the volume controls in one mixertui instance, and see the change also take place in the other instance. If so, you can model your code after mixertui.
I am trying to avoid polling, (in this case) this should be done in the QML if required (better control, less code to maintain).
 
Polling isn't as bad as it sounds. Most of the time these controls don't change. Somewhere between 5 and 30 times a second should be more than enough. You could write a polling agent that fires the events you desire when the agent detects changes.
 
Polling isn't as bad as it sounds. Most of the time these controls don't change. Somewhere between 5 and 30 times a second should be more than enough. You could write a polling agent that fires the events you desire when the agent detects changes.
I am not saying it is bad (tho I always tend to avoid it). It's just out of scope here. QS does not poll anything, so if the user wants to poll audio values, it has to be done at the QML level. Timer is a perfect component for polling, and my module has refresh() just for this:
Code:
MouseArea {
    id: hoverDetector
    anchors.fill: parent
    hoverEnabled: true

    onEntered: {
        OSS.refresh();
        volumeMenu.show = true;
    }

    onExited: {
        volumeMenu.timer.start();
    }

    onClicked: {
        if (root.control) {
            root.control.muted = !root.control.muted;
        }
    }
}
 
When op clarified "loudness or muteness of the source" that precludes "kernel event trapping" and moved into the realm of DSP programming and pattern filtering of PCM data. loudness of a PCM signal is directly related to the amplitude of the PCM values being sent/received and is a function of the mean/average of their amplitude. That type of analysis is not a function of OSS or kernel drivers: ie looking for quiet spots in an audio stream. So, it becomes a user mode programming problem, addressed through a sound pipeline.
 
When op clarified "loudness or muteness of the source" that precludes "kernel event trapping" and moved into the realm of DSP programming and pattern filtering of PCM data. loudness of a PCM signal is directly related to the amplitude of the PCM values being sent/received and is a function of the mean/average of their amplitude. That type of analysis is not a function of OSS or kernel drivers: ie looking for quiet spots in an audio stream. So, it becomes a user mode programming problem, addressed through a sound pipeline.
okay to be more clear, i am looking for a way to "subscribe" to `mixer` changes (which are sound levels (loudness in this context) and mute states). DSP would be a completely different (higher) level. the linked pull request should highlight the scope i am in.
 
okay to be more clear, i am looking for a way to "subscribe" to `mixer` changes (which are sound levels (loudness in this context) and mute states). DSP would be a completely different (higher) level. the linked pull request should highlight the scope i am in.
OK. That makes it clear what you are trying to do. IMHO, as much as I don't like the linux sound daemons infrastructure, their way of handling things would make your job much easier: a sound daemon that ALL OSS must go thru, and where you can intercept and/or filter sound related functions.
 
Back
Top