So, I'll answer my own question: Here's what happens: In src/modules/bluetooth/bluetooth-util.c: 1) found_device() calls org.bluez.Device.GetProperties. 2) get_properties_reply() parses the first properties, then calls parse_device_property(). 3) parse_device_property() sees that the device has interface A2DP_SINK_UUID, so it calls org.bluez.AudioSink.GetProperties asynchronously. 4) get_properties_reply() calls its callback, load_module_for_device() (in src/modules/bluetooth/module-bluetooth-discover.c). This callback loads module-bluetooth-device, which creates the audio card. The problem is that in my configuration, the answer to org.bluez.AudioSink.GetProperties does not come before load_module_for_device() is called. In that case, the device is instantiated with its properties half loaded (device->audio_state == connected but device->audio_sink_state == invalid_state), hence no profile is selected. The fact that we are dealing with a concurrency issue was why I could not reproduce this with my other system. I don't have any system where I can compile and test the latest version, so I don't know if this problem was fixed since 0.9.21. Should I create a proper bug report? Erwan Martin. On 30/1/2012 12:20 AM, Erwan Martin wrote: > Hi list, > > I'm trying to use pulseaudio with a bluetooth a2dp connection (with > module-bluetooth-device and module-bluetooth-discover; i.e. without > alsa). > > My problem is that the A2DP profile is not automatically selected for > the bluetooth card when pulseaudio is loaded when the a2dp connection > is already active. > Here is the relevant log part: > > # pulsaudio -C -vvvv > [...] > D: module-bluetooth-discover.c: Loading module-bluetooth-device > address="DE:AD:BE:EF:00:00" > path="/org/bluez/1062/hci0/dev_DE:AD:BA:BE:00:00" > I: module-card-restore.c: Restoring profile for card > bluez_card.DE:AD:BA:BE:00:00. > I: card.c: Created 1 "bluez_card.DE:AD:BA:BE:00:00" > W: module-bluetooth-device.c: Default profile not connected, selecting > off profile > D: module-bluetooth-device.c: Connected to the bluetooth audio service > I: module.c: Loaded "module-bluetooth-device" (index: #17; argument: > "address="DE:AD:BE:EF:00:00" > path="/org/bluez/1062/hci0/dev_DE:AD:BA:BE:00:00""). > > If I restart the bluetooth stack and create the a2dp connection after > pulseaudio is loaded (using dbus commands), then the profile gets > selected, the sink is created and the audio streams: > > D: bluetooth-util.c: dbus: interface=org.freedesktop.DBus, > path=/org/freedesktop/DBus, member=NameOwnerChanged > D: bluetooth-util.c: Bluetooth daemon disappeared. > D: module-bluetooth-discover.c: Unloading module for > /org/bluez/1643/hci0/dev_DE:AD:BA:BE:00:00 > D: module-console-kit.c: dbus: interface=org.freedesktop.DBus, > path=/org/freedesktop/DBus, member=NameOwnerChanged > D: module-bluetooth-device.c: dbus: interface=org.freedesktop.DBus, > path=/org/freedesktop/DBus, member=NameOwnerChanged > I: module.c: Unloading "module-bluetooth-device" (index: #17). > I: card.c: Freed 1 "bluez_card.DE:AD:BA:BE:00:00" > I: module.c: Unloaded "module-bluetooth-device" (index: #17). > D: bluetooth-util.c: dbus: interface=org.freedesktop.DBus, > path=/org/freedesktop/DBus, member=NameOwnerChanged > D: bluetooth-util.c: Bluetooth daemon appeared. > D: module-console-kit.c: dbus: interface=org.freedesktop.DBus, > path=/org/freedesktop/DBus, member=NameOwnerChanged > D: bluetooth-util.c: dbus: interface=org.bluez.Manager, path=/, > member=AdapterAdded > D: bluetooth-util.c: Adapter /org/bluez/1670/hci0 created > D: module-console-kit.c: dbus: interface=org.bluez.Manager, path=/, > member=AdapterAdded > D: bluetooth-util.c: dbus: interface=org.bluez.AudioSink, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: module-console-kit.c: dbus: interface=org.bluez.AudioSink, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: bluetooth-util.c: dbus: interface=org.bluez.Audio, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: module-console-kit.c: dbus: interface=org.bluez.Audio, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: bluetooth-util.c: dbus: interface=org.bluez.Device, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: module-console-kit.c: dbus: interface=org.bluez.Device, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: bluetooth-util.c: dbus: interface=org.bluez.AudioSink, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: module-console-kit.c: dbus: interface=org.bluez.AudioSink, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: bluetooth-util.c: dbus: interface=org.bluez.AudioSink, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: module-console-kit.c: dbus: interface=org.bluez.AudioSink, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: bluetooth-util.c: dbus: interface=org.bluez.Audio, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: module-bluetooth-discover.c: Loading module-bluetooth-device > address="DE:AD:BE:EF:00:00" > path="/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00" > I: module-card-restore.c: Restoring profile for card > bluez_card.DE:AD:BA:BE:00:00. > I: card.c: Created 2 "bluez_card.DE:AD:BA:BE:00:00" > D: module-bluetooth-device.c: Connected to the bluetooth audio service > D: module-bluetooth-device.c: Sending BT_REQUEST -> BT_GET_CAPABILITIES > D: module-bluetooth-device.c: Trying to receive message from audio > service... > D: module-bluetooth-device.c: Received BT_RESPONSE <- BT_GET_CAPABILITIES > D: module-bluetooth-device.c: Payload size is 39 6 > D: module-bluetooth-device.c: Sending BT_REQUEST -> BT_GET_CAPABILITIES > D: module-bluetooth-device.c: Trying to receive message from audio > service... > D: module-bluetooth-device.c: Received BT_RESPONSE <- BT_GET_CAPABILITIES > D: module-bluetooth-device.c: Payload size is 13 6 > D: module-bluetooth-device.c: Got device capabilities > D: module-bluetooth-device.c: Sending BT_REQUEST -> BT_OPEN > D: module-bluetooth-device.c: Trying to receive message from audio > service... > D: module-bluetooth-device.c: Received BT_RESPONSE <- BT_OPEN > D: module-bluetooth-device.c: Sending BT_REQUEST -> BT_SET_CONFIGURATION > D: module-bluetooth-device.c: Trying to receive message from audio > service... > D: module-bluetooth-device.c: Received BT_RESPONSE <- > BT_SET_CONFIGURATION > I: module-bluetooth-device.c: SBC parameters: > I: module-bluetooth-device.c: allocation=0 > I: module-bluetooth-device.c: subbands=1 > I: module-bluetooth-device.c: blocks=3 > I: module-bluetooth-device.c: bitpool=53 > D: module-bluetooth-device.c: Connection to the device configured > D: module-bluetooth-device.c: Got the stream socket > I: sink.c: Created sink 1 "bluez_sink.DE:AD:BA:BE:00:00" with sample > spec s16le 2ch 44100Hz and channel map front-left,front-right > I: sink.c: bluetooth.protocol = "a2dp" > I: sink.c: device.description = "DOESNOTMATTER" > I: sink.c: device.string = "DE:AD:BE:EF:00:00" > I: sink.c: device.api = "bluez" > I: sink.c: device.class = "sound" > I: sink.c: device.bus = "bluetooth" > I: sink.c: bluez.path = "/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00" > I: sink.c: bluez.class = "0x3e010c" > I: sink.c: bluez.name = "DOESNOTMATTER" > I: sink.c: device.icon_name = "audio-card-bluetooth" > I: source.c: Created source 2 "bluez_sink.DE:AD:BA:BE:00:00.monitor" > with sample spec s16le 2ch 44100Hz and channel map front-left,front-right > I: source.c: device.description = "Monitor of DOESNOTMATTER" > I: source.c: device.class = "monitor" > I: source.c: device.string = "DE:AD:BE:EF:00:00" > I: source.c: device.api = "bluez" > I: source.c: device.bus = "bluetooth" > I: source.c: bluez.path = > "/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00" > I: source.c: bluez.class = "0x3e010c" > I: source.c: bluez.name = "DOESNOTMATTER" > I: source.c: device.icon_name = "audio-card-bluetooth" > D: module-bluetooth-device.c: IO Thread starting up > I: core-util.c: Successfully enabled SCHED_RR scheduling for thread, > with priority 4, which is lower than the requested 5. > D: module-bluetooth-device.c: Sending BT_REQUEST -> BT_START_STREAM > D: module-bluetooth-device.c: Trying to receive message from audio > service... > D: module-bluetooth-device.c: Received BT_RESPONSE <- BT_START_STREAM > D: module-bluetooth-device.c: Trying to receive message from audio > service... > D: module-bluetooth-device.c: Received BT_RESPONSE <- BT_NEW_STREAM > D: module-bluetooth-device.c: Stream properly set up, we're ready to > roll! > D: module-bluetooth-device.c: Using SBC encoder implementation: MMX > D: module-suspend-on-idle.c: Sink bluez_sink.DE:AD:BA:BE:00:00 becomes > idle, timeout in 5 seconds. > I: module.c: Loaded "module-bluetooth-device" (index: #18; argument: > "address="DE:AD:BE:EF:00:00" > path="/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00""). > D: module-console-kit.c: dbus: interface=org.bluez.Audio, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: bluetooth-util.c: dbus: interface=org.bluez.AudioSink, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: module-console-kit.c: dbus: interface=org.bluez.AudioSink, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: module-bluetooth-device.c: dbus: interface=org.bluez.AudioSink, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: bluetooth-util.c: dbus: interface=org.bluez.AudioSink, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: module-console-kit.c: dbus: interface=org.bluez.AudioSink, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > D: module-bluetooth-device.c: dbus: interface=org.bluez.AudioSink, > path=/org/bluez/1670/hci0/dev_DE:AD:BA:BE:00:00, member=PropertyChanged > > What bothers me is that I have a second computer with the same > configuration which is working right (a2dp is automatically selected > when pulseaudio is started). > > Any help would be greatly apreciated. > > $ uname -a > Linux debian 2.6.32-5-amd64 #1 SMP Mon Jan 16 16:22:28 UTC 2012 x86_64 > GNU/Linux > > $ dpkg -l | grep pulse > ii libpulse0 0.9.21-3+squeeze1 > PulseAudio client libraries > ii pulseaudio 0.9.21-3+squeeze1 > PulseAudio sound server > ii pulseaudio-module-bluetooth 0.9.21-3+squeeze1 > Bluetooth module for PulseAudio sound server > > $ dpkg -l | grep bluez > ii bluez 4.66-3 > Bluetooth tools and daemons > > Erwan Martin. > > _______________________________________________ > pulseaudio-discuss mailing list > pulseaudio-discuss at lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss >