Bluetooth-alsa

Bluetooth audio for Linux

Overview | History | Future work | Download & build | Credits | Contact us


There are still limitations in the architecture that make complete desktop or handheld integration impossible. In particular, audio applications should not have to be individually configured back and forth between wired and wireless audio. We want a VOIP call in progress to be able to be easily switched to and away from a headset, another complicated interaction.

D-Bus

The BlueZ team has recently taken the approach to integrate with the desktop using the desktop bus. This allows for messages to the user to indicate for example when a bluetooth adapter becomes available or a new connection needs to be authorized.

D-Bus holds a lot of promise for dynamically routing audio between combinations of built-in and bluetooth audio.

Advanced architecture

The new design merges SCO, A2DP, and built-in (wired) audio devices from the application's point of view so there is a single default system-wide audio device.

Connection management and advanced controls like AVRCP are communicated using D-Bus and, optionally and to a lesser extent, the uinput device.

The diagram shows the daemon doing all bluetooth I/O but we haven't ruled out Fabien's latency optimization to have the daemon manage a file descriptor for the SCO channel that the plugin uses. In this case the audio plugin would in effect be doing direct bluetooth I/O.

  1. Audio stream
  2. Advanced interaction, such as indicating an incoming phone call
  3. D-Bus API for managing connections and routing
  4. PCM stream and more D-Bus interaction
  5. PCM stream to built-in audio
  6. Bluetooth i/o
  7. D-Bus signals (see below)
  8. Uinput signals

D-Bus proposed API


(*) denotes something I think we should remove but haven't confirmed

What we are still missing are the methods to indicate named pipes or
ipc or whatever for audio delivery or for handing over the sco file
descriptor.

Audio hierarchy (experimental)
==============================

Service		org.bluez
Interface	org.bluez.Audio
Object path	/org/bluez

Methods		array{string} ListAudioDevices()

			Returns list of bdaddrs for devices that
			report audio in their device class.
		
		string ConnectHeadset(string bdaddr)

			Connects the headset using HSP/HFP.

			Returns a string representing the HFP/HSP
			stream. Returns a NotSupported error if the
			profile is not supported.

		String ConnectSink(string bdaddr)

			Connects the headphones using A2DP.

			Returns a string representing the A2DP
			stream. Returns a NotSupported error if the
			profile is not supported.

		array{string} Connect(string bdaddr)*

			Connects the headset/headphones using A2DP or
			HSP/HFP or both. Returns the array of streams
			representing the successful connections.

                void Disconnect(string bdaddr)

			Disconnect all streams to the audio device.

		void DisconnectByStream(string stream)*

		array{string} ListConnectedStreams()

		string StreamAddress(string stream)

			Returns the bdaddr the indicated stream
			connects to.

		boolean IsHeadset(string stream)

			Return true if the stream represents a
			headset.

		boolean IsSink(string stream)

			Return true if the stream represents
			headphones.

		boolean IsPlaying(string stream)

			Return true if the stream is in a playing
			state.
			
		boolean IsPaused(string stream)

		void Play(string stream)

			Opens the audio stream. Called from the audio
			plugin or from the application if audio is
			routed somewhere other than the daemon (eg
			through PCM, direct to the DSP).

		void Stop(string stream)

		void Pause(string stream)

		void Resume(string stream)

		void SetTimeout(string stream, uint32 timeout)

			Set the idle Stop for the device.

			Stop the stream and emit a signal if timeout
			elapses without any audio being sent to the
			headset from an application. A value of 0
			indicates no idle stop; this is the default.

		uint32 GetTimeout(string stream)

		uint16 GetSpeakerGain(string stream)

		uint16 GetMicrophoneGain(string stream)

		void SetSpeakerGain(string stream, uint16 gain)

			Gain is 0..15

		void SetMicrophoneGain(string stream, uint16 gain)

			Gain is 0..15

		void IndicateCall(string stream)

			Indicate an incoming call on the headset
			connected to the stream.

		void CancelCall(string stream)

			Cancel the call on the headset connected to
                        the stream.

		uint16 GetDelay(string stream)

			Return the delay in ms from sending audio to
			the set and when it is heard.

		void SetDelay(string stream, uint16 delay)

			Set the delay for this headset.

		void AddBuiltInAudio(string stream)*

			Indicate that built-in audio should receive
			the stream in addition to the headset.

			The daemon only provides this state for use by
			(eg) the alsa/gst plugin. The daemon does not
			interact with built-in audio.

		void RemoveBuiltInAudio(string stream)*

Signals		void AudioDeviceAdded(string bdaddr)

			The device was bonded and reports audio in its
			device class.

		void AudioDeviceRemoved(string bdaddr)

			The device bonding was broken.

		Connected(string stream)
		
			Indicates the device was connected.

		Disconnected(string stream)

			Indicates the device was disconnected.

		void PlayRequested(string stream)

			An audio device requested the stream to
			(re)start.

		void StopRequested(string stream)

			An audio device requested the stream to stop.

		void PauseRequested(string stream)

			An audio device requested a pause in the
			stream.

		void NextTrackRequested(string stream)

			An audio device requested the next track.

		void PreviousTrackRequested(string stream)

			An audio device requested the previous track.

		void RedialRequested(string stream)

			The headset requested a redial.

		void VoiceCommandRequested(string stream)

			The headset requested a voice-command session.

		void Playing(string stream)

			Audio stream was started.

		void Stopped(string stream)

			Audio stream was stopped.

		void Paused(string stream)

			Audio stream was paused.

		void Resumed(string stream)

			Audio stream was resumed.

		void CallIndicated(string stream)

			An incoming call was indicated.

		void CallCanceled(string stream)

			Incoming call was canceled.

		void CallAnswered(string stream)

			User answered an incoming call.

		void CallRejected(string stream)

			User rejected an incoming call.

		void TimeoutChanged(string stream, uint16 timeout)

			Idle disconnect timeout changed.

		void SpeakerGainChanged(string stream, uint16 gain)

			The speaker gain changed.

		void MicrophoneGainChanged(string stream, uint16 gain)

			The microphone gain changed.

		void DelayChanged(string stream, uint16 delay)

			The delay value was changed for this set.

		void BuiltInAudioAdded(string stream)*

		void BuiltInAudioRemoved(string stream)*