How to find the latest created bluetooth sink/source via event hook?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

'Twas brillig, and Lin, Mengdong at 18/05/11 04:43 did gyre and gimble:
> I?m developing an routing module to automatically set a new created
> Bluetooth sink as the default sink when a Bluetooth headset is connected.

Please note that there already exists a module called
module-switch-on-connect which does this task, but for all new sinks,
not just BT sinks. I suspect it would be trivial to modify it to accept
arguments which control things (e.g.
device_types="all|bluetooth|usb|network" - or a combination of those
i.e. device_types="bluetooth,usb") rather than create a whole new
module. If you want your work upstreamed, I would personally take this
approach as I'd rather not get too much duplication of code in different
modules.

> So I need to get the new BT sink when it?s created.

Just so you know, I will am intending on shaking up the routing system
in PA after v1 is released which will hopefully make this kind of thing
easier to implement and manage. Feel free to ask if you want more
details, but essentially the routing will be based on priority lists of
devices rather than just setting a single device to use.


> But when I hook event ? PA_CORE_HOOK_SINK_NEW?, I found that the sink
> pointer for the callback function is **not** the real sink pointer value.

Correct. This hook is fired before the sink is created to allow you to
modify critical details about the sink before it is created.

If you want a hook that informs you *after* the sink is created, then
you can use PA_CORE_HOOK_SINK_PUT as shown in module-switch-on-connect.c
code.

> So could anyone share some hint on how to find the new created
> sink/source? Shall I iterate the core?s sink/source list and compare
> pointers in sink/source state change callback function?

I suspect the *_PUT hook is what you want :)

Cheers

Col

-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]




[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux