pipewire/spa/plugins/bluez5/player.h
Pauli Virtanen 4b831021fb bluez5: add a dummy AVRCP player as a workaround
Some devices (Bose Mini Soundlink II, Air 1 Plus, ...) don't enable
AVRCP volume control, or fail to enable it before a hardware button is
pressed.  However, these devices appear to enable it, if an AVRCP player
is present.

As a workaround, register a dummy AVRCP player for each adapter. It only
displays the current transport acquisition state as playing/stopped, but
just its presence appears to be enough to make devices behave.

Multiple AVRCP players interfere with each other, as BlueZ uses the one
registered earliest as the default player. So add also a config option
for disabling this. (It's not common to have mpris-proxy etc. running,
so defaulting to true should be OK.)

See pipewire#1157
2021-10-10 16:24:41 +03:00

52 lines
2 KiB
C

/* Spa Bluez5 AVRCP Player
*
* Copyright © 2021 Pauli Virtanen
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef SPA_BLUEZ5_PLAYER_H_
#define SPA_BLUEZ5_PLAYER_H_
enum spa_bt_player_state {
SPA_BT_PLAYER_STOPPED,
SPA_BT_PLAYER_PLAYING,
};
/**
* Dummy AVRCP player.
*
* Some headsets require an AVRCP player to be present, before their
* AVRCP volume synchronization works. To work around this, we
* register a dummy player that does nothing.
*/
struct spa_bt_player {
enum spa_bt_player_state state;
};
struct spa_bt_player *spa_bt_player_new(void *dbus_connection, struct spa_log *log);
void spa_bt_player_destroy(struct spa_bt_player *player);
int spa_bt_player_set_state(struct spa_bt_player *player,
enum spa_bt_player_state state);
int spa_bt_player_register(struct spa_bt_player *player, const char *adapter_path);
int spa_bt_player_unregister(struct spa_bt_player *player, const char *adapter_path);
#endif