Audio Sink — Phone Side
A2DP Sink + AVRCP Controller. The display receives audio from a phone and acts as the remote control for the phone's media player.
The display is the Sink because audio flows in. The phone is the A2DP Source. If you are trying to
control a phone and reaching for AudioSourceServiceClient, you want this page instead.
Table of Contents
Capabilities
- Receive an A2DP audio stream from a phone
- Transport control: play, pause, next, previous, fast-forward, rewind
- Toggle shuffle and repeat
- Track metadata: title, artist, album, genre, plus player status and position
- Album art, retrieved over an OBEX/BIP session
- AVRCP absolute volume — set it locally, and be notified when the phone changes it

The audio itself does not pass through your application. This extension manages the Bluetooth transport and
gives you control and metadata, and MediaRelay sends a
connected phone's audio to its headset or the cabin. Selecting an output and platform volume belong to the
Audio extension.
An application using this profile therefore needs both extensions: this one to connect a phone and
drive its playback, and Ahsoka.Extensions.AudioManager to decide where that audio goes and how loud it is.
The Audio extension starts the platform's audio server, so without it in your application the connection
itself may fail. Add it in the OpenPV Developer Toolkit and reference the
Ahsoka.Extensions.AudioManager package in your application — the package reference is what the build
needs to publish.
Client
using Ahsoka.Core;
using Ahsoka.Services.Bluetooth.Profiles.AudioSink;
using Ahsoka.Services.Bluetooth.Proto;
var audioSinkClient = new AudioSinkServiceClient();
Dispatcher.Default.RegisterCallback<AhsokaClientBase<AudioSinkProfileMessageTypes.Ids>.AhsokaNotificationArgs>(
OnAudioSinkNotification,
audioSinkClient);
audioSinkClient.Start();
The adapter must declare AudioSinkProfileService in SupportedProfileServiceTypes, or this client
never reports anything. See Configuration Reference.
| Method | Purpose |
|---|---|
RequestConnectProfile(BluetoothDevicePairedInfo) |
Connect the profile (inherited) |
RequestDisconnectProfile(BluetoothDevicePairedInfo) |
Disconnect (inherited) |
SendMusicCommand(int adapterIndex, MediaControl command) |
Send a transport command |
SetVolume(int adapterIndex, uint volume) |
Set absolute volume |
| Notification | Payload |
|---|---|
ProfileConnectionStateChanged |
ProfileConnectionInfo |
AvrcpPlayerInfoChanged |
PlayerInfo |
AvrcpAlbumArtChanged |
AlbumArtInfo |
AvrcpVolumeChanged |
VolumeInfo |
ProfileConnectionStateChanged comes from BluetoothProfileMessageTypes.Ids, so compare it with
EnumToInt() — see Profile Connection Lifecycle.
Connecting
Offer the connection only to a device that can actually source A2DP, and use Class of Device to keep headsets out of your phone list:
bool isPhone =
device.SupportedProfiles.HasFlag(BluetoothProfilesFlags.A2dpSource) &&
IsDeviceClassOrUnknown(device, BluetoothMajorDeviceClass.DeviceClassPhone);
if (isPhone)
audioSinkClient.RequestConnectProfile(device);
Remember that a paired phone often connects on its own when it comes into range, so expect
StateConnected you did not ask for.
Controlling Playback
audioSinkClient.SendMusicCommand(adapterIndex, MediaControl.Play);
audioSinkClient.SendMusicCommand(adapterIndex, MediaControl.Next);
audioSinkClient.SendMusicCommand(adapterIndex, MediaControl.ToggleShuffle);
MusicCommandResponse comes back with AdapterIndex, the Command, and a Success flag.
MediaControl values usable here:
| Value | Effect |
|---|---|
Play, Pause |
Start and pause playback |
Next, Previous |
Track skip |
FastForward, Rewind |
Seek |
ToggleShuffle, ToggleRepeat |
Cycle the phone's shuffle and repeat modes |
VolumeUp, VolumeDown |
Relative volume intents — see Volume |
Not every phone honours every command. FastForward and Rewind in particular are commonly ignored,
and a phone may accept a command while its own app declines to act. Success reflects whether the
command was delivered, not whether the phone did something musically visible.
Track Metadata
AvrcpPlayerInfoChanged delivers PlayerInfo whenever the phone's player state changes:
if (e.TransportId == AudioSinkProfileMessageTypes.Ids.AvrcpPlayerInfoChanged
&& e.NotificationObject is PlayerInfo playerInfo
&& playerInfo.AdapterIndex == myAdapterIndex)
{
string title = playerInfo.Track?.Title;
string artist = playerInfo.Track?.Artist;
bool playing = playerInfo.Status == "playing";
}
| Property | Meaning |
|---|---|
AdapterIndex |
Which adapter — always check it |
Track |
SongInfo with Title, Artist, Album, Genre, TrackNumber, NumberOfTracks, Duration |
Status |
"playing", "paused", "stopped" |
Position |
Playback position in milliseconds |
Repeat, Shuffle |
Current modes, as strings |
Name, Type, Subtype |
Identifies the remote player |
Browsable, Searchable |
Whether the player advertises browsing and search |
Scan, Equalizer |
Further AVRCP player settings |
Track and its strings can be null or empty, and the phone may send partial updates — a status change
with no metadata, or metadata with no position. Treat every field as optional and merge updates rather
than replacing your whole model each time.
Note
Browsable and Searchable report what the phone advertises. The extension does not implement AVRCP
browsing or search, so these are informational only.
Album Art
Album art arrives separately from metadata, because it is fetched over an OBEX/BIP session rather than carried on the AVRCP link:
if (e.TransportId == AudioSinkProfileMessageTypes.Ids.AvrcpAlbumArtChanged
&& e.NotificationObject is AlbumArtInfo albumArt
&& albumArt.AdapterIndex == myAdapterIndex)
{
byte[] image = albumArt.AlbumArt ?? albumArt.Thumbnail;
}
AlbumArtInfo carries AdapterIndex, Thumbnail, and AlbumArt. Prefer AlbumArt and fall back to
Thumbnail — that is what the demo's Phone panel does, along with a placeholder image for when neither
arrives.
Album art is the most fragile part of this profile. It requires BlueZ Experimental = true, it depends
on the phone exposing a BIP image handle, and it arrives late — often well after the track metadata. Do
not block your UI on it, and always have a placeholder.
Volume
Two independent mechanisms, and which one you get depends on the remote device.
AVRCP absolute volume is the good one. VolumeInfo tells you both the level and whether it is
available at all:
if (e.TransportId == AudioSinkProfileMessageTypes.Ids.AvrcpVolumeChanged
&& e.NotificationObject is VolumeInfo volumeInfo
&& volumeInfo.AdapterIndex == myAdapterIndex)
{
if (volumeInfo.AbsoluteVolumeSupported)
ShowVolumeSlider(volumeInfo.Volume);
else
HideVolumeSlider();
}
Drive your volume UI's visibility from AbsoluteVolumeSupported. If it is false, setting a volume will
not work, and showing a slider that does nothing is worse than showing none — the demo panels add and
remove their volume buttons on exactly this flag.
To set it:
audioSinkClient.SetVolume(adapterIndex, 64);
Volume is the AVRCP scale, 0–127.
Relative volume intents (MediaControl.VolumeUp / VolumeDown) are the legacy fallback used by
devices without absolute volume. On the Sink side you can send them as commands, but a device that
supports absolute volume has no reason to act on them. Prefer SetVolume and treat the relative
commands as a compatibility path.
Gotchas
Check AdapterIndex on every notification. The profile service spans all adapters, so its
notifications reach every subscriber. Per-adapter UI must filter.
Metadata arrives in pieces, out of order relative to album art. Merge; do not replace.
No album art without Experimental = true in bluetooth.conf. See
Troubleshooting.
A phone advertising A2dpSink is not a headset. Some phones advertise both roles. Use Class of
Device to classify, profile flags to decide whether an action will work.
Absolute volume is a device capability, not a setting. You cannot enable it; you can only detect it.
Desktop Stack Behavior
The desktop AudioSink stub is one of the better-developed mocks. It simulates a connected phone and runs
a player-info loop that emits AvrcpPlayerInfoChanged with changing track data, so you can build and
debug metadata display, transport buttons, and volume handling with no phone present.
What it does not reproduce is real-device inconsistency: ignored commands, absent album art, missing absolute volume, and partial metadata. If your metadata display works on the desktop and looks wrong on hardware, that difference is where to look first.