1. 26 Apr, 2020 8 commits
  2. 15 Apr, 2020 1 commit
    • pali's avatar
      bluetooth: Implement A2DP codec switching and backchannel support · efef94a8
      pali authored
      Some A2DP codecs (like FastStream or aptX Low Latency) are bi-directional
      and can be used for both music playback and audio calls. This patch
      implements usage of backchannel if A2DP codec provided by pulseaudio API
      supports it.
      
      A2DP codec switching needs new version of bluez as older version does not
      provide needed org.freedesktop.DBus.ObjectManager and RegisterApplication
      DBus APIs.
      
      Pulseaudio use for each A2DP codec separate pulseaudio profile, therefore
      codec switching is implemented via changing pulseaudio profile and
      currently used A2DP codec is visible in pulseaudio profile.
      
      Getting list of supported codecs by remote device is supported only by new
      version of bluez daemon.
      
      If old bluez version is detected then only one SBC codec is supported.
      efef94a8
  3. 14 Apr, 2020 1 commit
  4. 19 Mar, 2020 1 commit
  5. 02 Jul, 2019 1 commit
    • Frédéric Danis's avatar
      bluetooth: Fix crash when disabling Bluetooth adapter · f89d64b9
      Frédéric Danis authored and Tanu Kaskinen's avatar Tanu Kaskinen committed
      This crash occurs when PA is connected to a phone through the oFono
      backend.
      When disabling the Bluetooth adapter, pa_bluetooth_device is removed before
      hf_audio_card. Both keep refs on pa_bluetooth_transport. Those removal will
      call pa_bluetooth_transport_free() from device_free() (bluez5-util.c) and
      hf_audio_card_free() (backend-ofono.c).
      In the end, the call to pa_bluetooth_transport_free() calls
      pa_hasmap_remove() through pa_bluetooth_transport_unlink(), but since
      memory has already been freed, the second try results in a segfault.
      
      Triggering hf_audio_card removal during pa_bluetooth_device removal allows
      hf_audio_card to be freed at the right time.
      f89d64b9
  6. 12 Apr, 2019 2 commits
    • pali's avatar
      bluetooth: Modular API for A2DP codecs · 106aa914
      pali authored and Tanu Kaskinen's avatar Tanu Kaskinen committed
      This patch introduce new modular API for bluetooth A2DP codecs. Its
      benefits are:
      
      * bluez5-util and module-bluez5-device does not contain any codec specific
        code, they are codec independent.
      
      * For adding new A2DP codec it is needed just to adjust one table in
        a2dp-codec-util.c file. All codec specific functions are in separate
        codec file.
      
      * Support for backchannel (microphone voice). Some A2DP codecs (like
        FastStream or aptX Low Latency) are bi-directional and can be used for
        both music playback and audio call.
      
      * Support for more configurations per codec. This allows to implement low
        quality mode of some codec together with high quality.
      
      Current SBC codec implementation was moved from bluez5-util and
      module-bluez5-device to its own file and converted to this new A2DP API.
      106aa914
    • pali's avatar
      bluetooth: Update a2dp-codecs.h from upstream bluez project · e8c4638f
      pali authored and Tanu Kaskinen's avatar Tanu Kaskinen committed
      e8c4638f
  7. 20 Jan, 2018 1 commit
    • Tanu Kaskinen's avatar
      bluetooth: don't send unsolicted replies to the endpoint Release() call · df79abe7
      Tanu Kaskinen authored
      It was reported that PulseAudio causes error messages in syslog from
      dbus-daemon:
      
      Jan 14 04:51:32 gentoo dbus-daemon[2492]: [system] Rejected send message, 2 matched rules; type="error", sender=":1.15" (uid=1000 pid=2864 comm="/usr/bin/pulseaudio --start --log-target=syslog ") interface="(unset)" member="(unset)" error name="org.bluez.MediaEndpoint1.Error.NotImplemented" requested_reply="0" destination=":1.1" (uid=0 pid=2670 comm="/usr/libexec/bluetooth/bluetoothd ")
      
      The default policy on the system bus is to not let any method call
      replies through if they have not been requested, and apparently
      bluetoothd doesn't want replies to the Release() call.
      
      This also changes the reply type from error to normal reply. The "not
      implemented" error didn't make sense to me. We don't do any cleanup in
      the Release() handler, probably because there's nothing to do. If there
      is some cleanup that we should do, then it's a serious bug not to do it.
      
      BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=104646
      df79abe7
  8. 09 Oct, 2017 1 commit
  9. 05 Sep, 2017 1 commit
  10. 17 Jul, 2017 1 commit
    • Tanu Kaskinen's avatar
      fix dbus message leaks · abdd14d5
      Tanu Kaskinen authored
      I reviewed all places that call
      dbus_connection_send_with_reply_and_block(), and found several places
      where dbus messages aren't properly unreffed.
      abdd14d5
  11. 21 Apr, 2017 1 commit
    • Georg Chini's avatar
      bluez5-util: Fix segfault during shutdown of daemon · ce9ea846
      Georg Chini authored
      If a HFP audio gateway was connected via the ofono backend, pulse would
      segfault during shutdown of the daemon. pa_bluetooth_discovery_unref()
      removed the devices and transports before the ofono backend was freed.
      Because the ofono backend keeps its own list of transports, transport_free()
      was then called during termination of the ofono backend with an invalid
      transport. Bug reported by Andrew Hlynskyi.
      
      This patch moves the termination of the ofono and native backends before
      freeing the devices.
      ce9ea846
  12. 30 Mar, 2017 1 commit
  13. 28 Mar, 2017 1 commit
    • Tanu Kaskinen's avatar
      bluez5-util: fix profile waiting logic · cb78d6f5
      Tanu Kaskinen authored
      There were two bugs in the old logic. The first one:
      
      If a device has two profiles, the old code would start the wait timer
      when the first profile connects, but when the second profile connects,
      the timer would not get stopped and the CONNECTION_CHANGED hook would
      not get fired, because the code for that was inside an if block that
      only gets executed when the first profile connects. As a result,
      module-bluez5-device loading would always be delayed until the wait
      timeout expires.
      
      The second bug:
      
      A crash was observed in device_start_waiting_for_profiles(). That
      function is called whenever the connected profile count changes from 0
      to 1. The function also has an assertion that checks that the timer is
      not running when the function is called. That assertion crashed in the
      following scenario with a headset that supports HSP and A2DP:
      
      1. First HSP gets connected. The timer is started.
      
      2. Then HSP gets disconnected for some reason. The timer is still
      running.
      
      3. Then A2DP gets connected. device_start_waiting_for_profiles() is
      called, because the connected profile count changed from 0 to 1 again.
      The timer is already running, so the assertion fails.
      
      First I thought I'd remove the assertion from
      device_start_waiting_for_profiles() and just restart the timer on the
      second call, but then I figured that when the device returns to the
      "everything disconnected" state in step 2, it would be better to stop
      the timer. The purpose of the timer is to delay the notification of the
      device becoming connected, but if the device becomes disconnected during
      the waiting period, the notification doesn't make sense any more, and
      therefore the timer doesn't make sense either.
      
      BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=100237
      cb78d6f5
  14. 14 Mar, 2017 1 commit
  15. 11 Mar, 2017 1 commit
    • Georg Chini's avatar
      bluetooth: use native and ofono backends in parallel with headset=auto · adc2e8cd
      Georg Chini authored
      This patch changes the behavior of the headset=auto switch for module-bluez5-discover.
      With headset=auto now both backends will be active at the same time for the AG role and
      the switching between the backends is only done for the HS role.
      headset=ofono and headset=native remain unchanged.
      
      This allows to use old HSP only headsets while running ofono and to have headset support
      via pulseaudio if ofono is started with the --noplugin=hfp_ag_bluez5 option.
      adc2e8cd
  16. 10 Aug, 2016 4 commits
    • Tanu Kaskinen's avatar
      bluetooth: refactor BlueZ 4 transport state setting · 83ac6c5a
      Tanu Kaskinen authored
      Add transport_set_state() that encapsulates changing the variable,
      logging and firing the change hook.
      
      I also made a cosmetic change to the corresponding BlueZ 5 log
      message so that both messages have the format that I like.
      83ac6c5a
    • Tanu Kaskinen's avatar
      bluetooth: unify BlueZ 4 and BlueZ 5 UUID handling · 52a9ee61
      Tanu Kaskinen authored
      A hashmap is more convenient than a linked list for storing the UUIDs,
      so change the BlueZ 4 code accordingly.
      
      Rename the BlueZ 4 UUID constants to match the BlueZ 5 naming.
      
      The only changes to the BlueZ 5 code are the addition of one comment
      and making another comment a bit clearer.
      52a9ee61
    • Tanu Kaskinen's avatar
      bluetooth: update device's valid flag after parsing properties · 570288cc
      Tanu Kaskinen authored
      The properties_received flag affects whether the device should be
      considered valid, so let's update the valid flag after setting the
      properties_received flag.
      
      There's a call to device_update_valid() anyway later when setting
      the device adapters, so this change isn't strictly necessary, but
      this makes it more obvious that the code is correct (and less
      fragile).
      570288cc
    • Tanu Kaskinen's avatar
      bluetooth: wait for all profiles to connect before creating card · d9b885e0
      Tanu Kaskinen authored
      The CONNECTION_CHANGED hook is used to notify the discovery module
      about new and removed devices. When a bluetooth device connects, the
      hook used to be called immediately when the first profile connected.
      That meant that only one profile was marked as available during the
      card creation, other profiles would get marked as available later.
      
      That makes it hard for module-card-restore to restore the saved
      profile, if the saved profile becomes available with some delay.
      module-card-restore has a workaround for this problem, but that turned
      out to interfere with module-bluetooth-policy, so the workaround will
      be removed in the next patch.
      
      The BlueZ 4 code doesn't need changes, because we use the
      org.bluez.Audio interface to get a notification when all profiles are
      connected.
      d9b885e0
  17. 14 Jan, 2015 1 commit
  18. 03 Dec, 2014 1 commit
  19. 14 Nov, 2014 3 commits
  20. 31 Oct, 2014 1 commit
  21. 19 Oct, 2014 1 commit
    • Tanu Kaskinen's avatar
      bluetooth: Move stuff to pa_bluetooth_transport_put/unlink() · 0df4d56c
      Tanu Kaskinen authored
      This should not have any effect on behaviour. The goal is to align
      with the pattern that I think we should follow:
      
      Object initialization:
       - put() is the place to create references from other objects to the
         newly created object. In this case, adding the transport to
         discovery->transports was moved from new() to put, and adding the
         transport to device->transports was moved from set_state() to
         put().
      
      Object destruction:
       - unlink() undoes put() and removes all references from other objects
         to the object being unlinked. In this case setting the
         device->transports pointer to NULL was moved from set_state() to
         unlink(), and setting the discovery->transports pointer to NULL was
         moved from free() to unlink().
       - free() undoes new(), but also calls unlink() so that object owners
         don't need to remember to call unlink() before free().
      0df4d56c
  22. 10 Sep, 2014 2 commits
  23. 08 Sep, 2014 2 commits
  24. 22 Aug, 2014 2 commits