'Twas brillig, and Brendon Costa at 06/04/10 07:48 did gyre and gimble: > Hi all, > > I have started using pulse audio for some app development. In our > existing application which I am porting to Linux, we ask the OS for a > list of the devices, including which of those devices is the default > device. This information is used to show a list of audio devices to a > user that they can choose one from the list (two seperate lists one > for input and one for output). The list starts with the systems > default device selected initially. > > With PA I can successfully enumerate the sources/sinks, however I seem > to find out which source or sink is the system default. For example > there does not seem to be a field in pa_sink_info or pa_source_info > structures for the default device. How can I find which device is the > default? pa_context_get_server_info(); It's info struct contains the relevant fields for default sink and source. Note however that changing this value will not immediate affect any running streams. It will only take effect when the stream is torn down and recreated. This is something I don't personally like (not to mention causes me extra support overhead telling people this over and over). I've documented my opinions on the current (relatively minor) routing problems in PA here: http://colin.guthr.ie/2010/02/this-is-the-route-to-hell/ > Note: I understand the usual way to open a stream using the default > device is to pass a NULL for the dev field in say > pa_stream_connect_playback() and PA selects the default. I need to do > things differently and be able to show the user which device is > default rather than asking PA to open the default. And bear in mind that your request to use a device may or may not be honoured by the server. Users can still use a PA mixer (pavucontrol, kmix etc.) to move the stream to their chosen device). If at all possible, please keep this approach. It's far better to have a GUI application that respects the concept of a "central mixer". Users know where to go to make changes and don't have to dig through application specific config systems to find the obscure settings panel that allows then to change things... they just go to their mixer and can make the changes there. PA will remember the choice they made for next time. That said you may have good reason and if so, fair enough, but like I say, it's very much worth thinking about. If you absolutely must take this approach, you may be interested in the stream flags that relate to NOMOVE or similar (can't remember off hand the exact flag but it prevents the stream being moved to another device). HTHs Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/]