<div>Hi all,</div><div><br></div><div>I have some notes below I made about using the Pulse Audio asynchronous API. If you have a minute would you mind casting your eyes over my proposed strategy. Any comments are very welcome.</div>
<div><br></div><div>thx,</div><div>Conor</div><div><br></div><div><br></div><div>1. To obtain the volume of primary Output Device.</div><div> ans: Fetch the sink info via pa_context_get_sink_info_by_index(). The return value will contain volume data type (pa_cvolume).</div>
<div> </div><div>2.Differentiate between headphone volume if plugged in and speaker volume </div><div> ans: Detect headphone connection - PulseAudio intend to expose jack-sensing once it becomes available to them from below. Its in the pipeline apparently. I need to do some more investigation around this. Some devices expose individual headphone volumes as opposed to speaker volumes others don't. </div>
<div> </div><div>3. Detect no output devices(sinks)</div><div> ans: pa_context_get_sink_info_list - if the returned array is empty then there are no output devices.</div><div> </div><div>4. If the sound is muted and some exterior application attempts to play sound then flag it</div>
<div> ans: Subscribe to the PA_SUBSCRIPTION_EVENT_SINK_INPUT event and on the callback check to see if that sink is muted (boolean). Note if the client application is paused, the sink is then muted and the client app is restart the event will not be triggered. This might be not satisfy UI spec requirements. Check with MPT. </div>
<div> </div><div>5. Ability to mute all output sinks.</div><div> ans: pa_context_set_sink_mute_by_index()- iterate through all sinks returned via pa_context_get_sink_info_list(). Maybe there is a mute all switch - could not see it in the docs right now - will ask on #pa on freenode.</div>
<div> </div><div>6. Unmute all outputs and return to previous volumes.</div><div> ans: PA's module-stream-restore - more investigation. Apparently this will store previous volumes of all sinks and restore them when required.</div>
<div> </div><div>7. Set individual output volumes to 0 (distinct from mute)</div><div> pa_context_set_sink_volume_by_index() or by name.</div><div> </div><div>8. Set individual outputs volumes to max.</div><div> ans: Set the sink (output device) in question to PA_VOLUME_NORM.</div>
<div> pa_cvolume_reset() - should do this for the sink in question. PA_VOLUME_NORM roughly corresponds to 0DB => MAX volume without clipping. </div>