Skip to content

Add audio streaming from external devices via Bluetooth A2DP sink or WiFi hotspot (WIRED mode only)#1

Merged
Doezer merged 4 commits into
mainfrom
copilot/add-audio-streaming-feature
Nov 11, 2025
Merged

Add audio streaming from external devices via Bluetooth A2DP sink or WiFi hotspot (WIRED mode only)#1
Doezer merged 4 commits into
mainfrom
copilot/add-audio-streaming-feature

Conversation

Copilot AI commented Nov 11, 2025

Copy link
Copy Markdown
Contributor

Enables another Android phone to stream audio through Android Auto to car speakers. Useful for passengers sharing music control during drives.

⚠️ Important Limitation: Only works in WIRED mode (USB connection). In WIRELESS mode, both Bluetooth and WiFi are typically occupied by the car connection.

Two Streaming Methods Available

Method 1: Bluetooth A2DP Sink

When enabled (ENABLE_BT_AUDIO_SINK=1), the CarOS device receives audio via Bluetooth.

Limitation: May not work if Bluetooth is used for car audio/calls even in wired mode (common in many vehicles).

Method 2: WiFi Hotspot (Recommended)

When enabled (ENABLE_WIFI_AUDIO_HOTSPOT=1), the CarOS device creates a WiFi hotspot for audio streaming.

Advantages:

  • Works even when Bluetooth is occupied by car audio
  • Higher quality audio streaming
  • More reliable across different car models
  • Requires audio streaming app on emitting phone (SoundWire, AudioRelay, etc.)

Implementation

Configuration (caros_config.sh)

  • ENABLE_BT_AUDIO_SINK - Bluetooth A2DP sink option (default: disabled)
  • ENABLE_WIFI_AUDIO_HOTSPOT - WiFi hotspot option (default: disabled)
  • WIFI_AUDIO_HOTSPOT_SSID - Customizable hotspot name (default: "CarOS-Audio")
  • WIFI_AUDIO_HOTSPOT_PASSWORD - Customizable hotspot password (default: "caros123")
  • Follows existing config pattern with defaults, user config generation, and fallback values

Core functionality (service.sh)

  • enable_bt_audio_sink() / disable_bt_audio_sink(): Bluetooth A2DP sink management
  • enable_wifi_audio_hotspot() / disable_wifi_audio_hotspot(): WiFi hotspot management
  • Integrated into profile system:
    • WIRED: Enable both methods (if configured)
    • WIRELESS: NOT enabled (Bluetooth and WiFi already used by car connection)
    • IDLE: Disable both to save battery

Permissions (grant_permissions.sh)

  • Auto-grants Bluetooth (CONNECT, SCAN, ADVERTISE) and audio permissions when feature enabled

Technical Details

Bluetooth A2DP Sink:

setprop persist.bluetooth.a2dp_sink.enabled true
setprop bluetooth.device.class 0x240404  # Audio Sink class
cmd bluetooth_manager set-discoverability on
settings put global bluetooth_discoverable_timeout 0

WiFi Hotspot:

cmd wifi start-softap "$SSID" wpa2-psk "$PASSWORD"

Audio flow:

  • Bluetooth: Emitting phone → Bluetooth A2DP → CarOS system audio → Android Auto → Car speakers
  • WiFi: Emitting phone → WiFi hotspot → Audio streaming app → CarOS system audio → Android Auto → Car speakers

Why Two Methods?

Even in WIRED mode (USB connection), Bluetooth is often used by the car for audio and phone calls. This prevents the phone from acting as a Bluetooth A2DP sink simultaneously. The WiFi hotspot method provides a reliable alternative that works when Bluetooth is occupied.

Why WIRED Mode Only?

In WIRELESS mode, both Bluetooth and WiFi are typically used by Android Auto:

  • Bluetooth: Phone calls, initial pairing
  • WiFi: Data/video transmission

Neither interface is available for audio streaming in wireless mode.

Device Compatibility

Bluetooth method:

  • Requires hardware/firmware A2DP sink support
  • Works best on Android 10+, AOSP/LineageOS ROMs
  • May fail silently on unsupported devices

WiFi hotspot method:

  • Works on most Android devices with WiFi hotspot support
  • Requires audio streaming app on emitting phone (SoundWire, AudioRelay, AirMusic, etc.)
  • More reliable across different devices and car models

Both features disabled by default for maximum compatibility.

Documentation

  • README: Feature overview, usage instructions for both methods, limitations
  • EXAMPLES: Configuration examples for Bluetooth and WiFi methods
  • FAQ: Troubleshooting, app recommendations, method comparison
  • CHANGELOG: Feature documented in Unreleased section
Original prompt

Add a way to have another android phone connect to the phone running CarOs and stream its audio to it, so that the audio of the emmiting phone is broadcasted on the CarOS phone. The idea is to have music sent from the emitting phone and to have it play on android auto (on the car sound)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Doezer <11655673+Doezer@users.noreply.github.com>
Copilot AI changed the title [WIP] Add audio streaming from emitting phone to CarOs Add Bluetooth A2DP sink mode for audio streaming from external devices Nov 11, 2025
Copilot AI requested a review from Doezer November 11, 2025 13:12
@Doezer

Doezer commented Nov 11, 2025

Copy link
Copy Markdown
Owner

@copilot It won't work because the phone that uses car OS bluetooth is already used by the car

Co-authored-by: Doezer <11655673+Doezer@users.noreply.github.com>

Copilot AI commented Nov 11, 2025

Copy link
Copy Markdown
Contributor Author

@copilot It won't work because the phone that uses car OS bluetooth is already used by the car

You're absolutely correct! Fixed in commit d02ac64.

The feature now only enables in WIRED mode (USB connection) where Bluetooth is free. In WIRELESS mode, Bluetooth is already occupied by the car connection, so it can't simultaneously act as an audio receiver.

Alternatives considered for WIRELESS mode:

  • WiFi Direct/Hotspot: Conflicts with wireless Android Auto (which uses WiFi)
  • Network streaming: Requires WiFi (same conflict)
  • USB: Not practical for phone-to-phone

Current solution: Feature only works in WIRED mode. Users who want audio sharing in wireless mode should either switch to wired Android Auto or use third-party apps (SoundWire, AudioRelay, etc.).

Documentation updated to clarify this limitation in README, FAQ, and CHANGELOG.

Copilot AI changed the title Add Bluetooth A2DP sink mode for audio streaming from external devices Add Bluetooth A2DP sink mode for audio streaming from external devices (WIRED mode only) Nov 11, 2025
@Doezer

Doezer commented Nov 11, 2025

Copy link
Copy Markdown
Owner

@copilot Even in wired mode, the bluetooth is used for audio connection between the car and the phone
And the wifi is not used, at least in my situation with my Audi A3 from 2018...
Maybe just add the ability to use Wifi for this functionality, in addition to the bluetooth way (in case some users might use it)

Co-authored-by: Doezer <11655673+Doezer@users.noreply.github.com>

Copilot AI commented Nov 11, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Even in wired mode, the bluetooth is used for audio connection between the car and the phone
And the wifi is not used, at least in my situation with my Audi A3 from 2018...
Maybe just add the...

You're absolutely right! Added WiFi hotspot as an alternative in commit c2839f1.

Issue: Even in wired mode, Bluetooth is often used for car audio/calls, preventing A2DP sink.

Solution: New WiFi hotspot option (ENABLE_WIFI_AUDIO_HOTSPOT=1) that:

  • Creates configurable WiFi hotspot (SSID/password)
  • Works when WiFi is not used by car (typical in wired mode)
  • Requires audio streaming app on emitting phone (SoundWire, AudioRelay, etc.)

Config example:

ENABLE_WIFI_AUDIO_HOTSPOT=1
WIFI_AUDIO_HOTSPOT_SSID="CarOS-Audio"
WIFI_AUDIO_HOTSPOT_PASSWORD="caros123"

Both methods available - users can choose based on what works for their setup. WiFi hotspot recommended since it avoids Bluetooth conflicts.

Copilot AI changed the title Add Bluetooth A2DP sink mode for audio streaming from external devices (WIRED mode only) Add audio streaming from external devices via Bluetooth A2DP sink or WiFi hotspot (WIRED mode only) Nov 11, 2025
@Doezer Doezer marked this pull request as ready for review November 11, 2025 14:06
@Doezer Doezer merged commit 758161a into main Nov 11, 2025
2 checks passed
@Doezer Doezer added this to Questarr Nov 22, 2025
@Doezer Doezer moved this to Backlog in Questarr Nov 22, 2025
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Questarr Nov 22, 2025
@Doezer Doezer removed this from Questarr Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants