Skip to content

About

Audio Share can share Windows/Linux computer's audio to Android phone over network, so your phone becomes the speaker of computer. (You needn't buy a new speaker😄.)

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

510 Commits

Folders and files

Repository files navigation

Audio Share

metadata/en-US/images/icon.png

Latest fork release License Release workflow

This is the DataDrivenDNA fork of mkckr0/audio-share. It adds encrypted one-time pairing, nearby-PC discovery, reduced Android playback buffering, an optional native playback mode, and a phone-microphone return path. Fork clients and servers use a secure protocol that is incompatible with the original 0.3.x releases, so install matching builds from this repository.

Start with Windows setup. The documentation index links to protocol details, implementation records, and validation status and release gates.

Get the latest fork release on GitHub

Audio Share can share Windows/Linux computer's audio to Android phone over network, so your phone becomes the speaker of computer. (You needn't buy a new speaker😄.)

Screenshots

These screenshots show the original upstream interface. The fork's connection and microphone controls have since changed; see the usage instructions below.

docs/img/win_01.png  docs/img/win_02.png

metadata/en-US/images/phoneScreenshots/1.png  metadata/en-US/images/phoneScreenshots/2.png  metadata/en-US/images/phoneScreenshots/3.png
metadata/en-US/images/phoneScreenshots/4.png  metadata/en-US/images/phoneScreenshots/5.png

Requirements

  • A PC with Windows or Linux as the server.
  • The PC needs an available audio playback endpoint, either physical or virtual. Otherwise, follow the extra setup instructions.
  • The phone with Android 6.0(API 23)+.
  • The network (e.g. Wi-Fi or USB tethering) that the phone can connect with the PC.

Usage for Windows GUI

  • Download the matching Android APK and Windows server from the latest fork release. Android cannot install this fork over an upstream APK signed by a different key; uninstall the upstream app first if Android reports a signature conflict.
  • Run the Windows setup EXE, accept the administrator prompt, and restart if requested. It includes the virtual cable for phone microphone support. See Windows setup for portable ZIPs and updates.
  • Open AudioShareServer.exe, choose the PC playback device, and select Start Server.
  • On Android, open the connection chooser and select the PC under Nearby PCs. Select Pair phone on the PC and scan its one-time QR code when prompted. Then press Play.

Usage for Windows/Linux CMD

  • Download the audio-share-server-cmd-windows.zip for Windows, the audio-share-server-cmd-linux.tar.gz for Linux.
  • Uncompress the archive file.
  • On first setup, run as-cmd -b --pair, then enter the displayed address and pairing code under Enter details manually on Android. Later, run as-cmd -b. The server uses the first LAN address, port 65530, and the default audio endpoint unless you provide explicit arguments. Run as-cmd -h for all options.
  • The Windows will ask you to add firewall rules automatically while Linux won't. So if your Linux distribution enables firewall, you need to configure firewall manually.
  • Install the matching fork APK, pair once, and press Play. Nearby-PC discovery is currently available for Windows servers; Linux uses the printed pairing code or manual address entry.

Pair once, reconnect automatically

Install matching secure builds of the Android app and PC server from this fork. Original upstream 0.3.x builds cannot connect to these builds.

  1. Start the PC server and select Pair phone. For the CLI, start with --pair in addition to your normal arguments.
  2. On Android, tap Scan PC and point the camera at the QR code. The app fills in the address and connects. Camera images stay on the phone.
  3. Later connections authenticate automatically, including after restarting either device. The QR code expires after two minutes and enrolls one phone. Enter details manually remains available for CLI servers or phones without a camera.

The Android connection chooser lists Nearby PCs automatically while it is open. Start the Windows GUI or CLI server on the same local network, then tap its name. A saved PC connects using its current address and port; a new PC asks you to pair once. Refresh, Scan PC, and Enter details manually remain available. The Windows GUI displays a QR code; CLI servers print a code for manual entry. Discovery uses local mDNS and carries no pairing secrets. Guest Wi-Fi or routers that block multicast may prevent discovery, and Linux servers currently use manual setup. See discovery behavior and verification.

Use Forget paired PC on Android or Forget phones on Windows to remove trust. Windows revocation also disconnects active phones. PC identity is protected with your Windows account via DPAPI; Android credentials use Android Keystore and are excluded from backup. Reinstalling the app or losing the PC identity requires pairing again. Never share pairing codes or identity files.

Encryption keeps the existing Opus and PCM24 audio settings and adds 36 bytes per UDP packet without adding an audio buffer. Pairing never turns on the microphone. See secure pairing and verification and wire protocol.

Use the phone as a PC microphone

This fork adds simultaneous PC sound → Android and Android microphone → Windows. Build/install the updated Android APK and Windows server together. Microphone recording stays off until you enable it on the phone.

  1. Run AudioShare-…-windows-x64-setup.exe. It includes the standard VB-CABLE driver and the required C++ runtime files. Accept Windows' administrator prompt and restart if requested. VB-CABLE is donationware; all participations are welcome at www.vb-cable.com.
  2. Open Audio Share and start the server. Fresh settings automatically select the cable destination and its microphone activity monitor. Existing settings, including a disabled microphone route, are preserved. PC sound continues using your normal playback device.
  3. In Android, select your PC under Nearby PCs or scan its pairing QR code. Press Play to hear PC sound. Select Automatic or Always on under Phone microphone, then allow microphone access. These controls work independently.
  4. In your calling or recording app, select CABLE Output as the microphone. Keep that app's sound output on the normal PC playback device.
  5. Use earphones connected to the phone to avoid speaker-to-microphone echo. Stop microphone in the app or notification ends microphone capture; PC sound can keep playing. If disconnected, the mic stays off until you start it again.

For the command-line server, as-cmd -l lists endpoint IDs. Use a separate destination for the phone mic:

.\as-cmd.exe -l
.\as-cmd.exe --list-mic-input
.\as-cmd.exe -b --mic-endpoint "<CABLE Input endpoint ID>" --mic-monitor-endpoint "<CABLE Output recording endpoint ID>"

Omit --mic-endpoint to disable microphone reception. --mic-monitor-endpoint enables Android's Automatic mode by observing when a PC app captures from the virtual cable. Only one phone may send microphone audio at a time. The return path currently requires Windows; Linux playback is unchanged. Control connections use TLS and both audio directions use authenticated encryption. Only paired devices can connect. Windows firewall rules allow Private networks and the local subnet. Bluetooth headset microphone selection and echo cancellation quality vary by phone and are not managed by this feature.

If a PC app cannot open CABLE Output, check Windows Settings → Privacy & security → Microphone → Let desktop apps access your microphone. This setting controls desktop microphone access generally. Build and device verification details are in validation status.

Configure Firewall Rules on Linux

Add rules

address=192.168.3.2 # change it.
port=65530 # change it.
sudo firewall-cmd --add-rich-rule="rule family=ipv4 destination address=$address port port=$port protocol=tcp accept"
sudo firewall-cmd --add-rich-rule="rule family=ipv4 destination address=$address port port=$port protocol=udp accept"
sudo firewall-cmd --runtime-to-permanent

Check rules

sudo firewall-cmd --list-rich-rules

Output:

rule family="ipv4" destination address="192.168.3.2" port port="65530" protocol="tcp" accept
rule family="ipv4" destination address="192.168.3.2" port port="65530" protocol="udp" accept

Remove rules

address=192.168.3.2 # change it.
port=65530 # change it.
sudo firewall-cmd --remove-rich-rule="rule family=ipv4 destination address=$address port port=$port protocol=tcp accept"
sudo firewall-cmd --remove-rich-rule="rule family=ipv4 destination address=$address port port=$port protocol=udp accept"
sudo firewall-cmd --runtime-to-permanent

About Audio Format

There are two kinds of audio format:

  • Capture audio format
  • Transfer audio format

Under Android Audio → PC audio quality, choose High-quality Opus or Uncompressed PCM, 24-bit. The saved choice applies the next time PC audio starts. Opus is the default: 48 kHz, 5 ms packets, 510 kbit/s stereo or 192 kbit/s mono, bounded jitter buffering and packet-loss concealment. PCM24 uses RTP L24, 48 kHz and 2.5 ms packets, with 2.304 Mbit/s stereo payload and no lossy audio encoding. PCM needs a stable connection; lost samples cannot use Opus concealment. The status identifies the selected mode.

Update both ends for PCM24. An unsupported server or capture format produces an error instead of silently substituting a different quality mode. The phone microphone remains independent, using Opus at 192 kbit/s mono, including automatic mode. See the Opus implementation and verification and PCM24 specification. Resampling, app effects and the phone/headset can still affect final sound; PCM24 transport does not guarantee bit-perfect device output.

When a compatible secure server or capture format does not support Opus, playback can use uncompressed PCM over encrypted UDP and retain the capture format. The app labels this Started · legacy PCM. This does not permit connections to older plaintext servers. An explicit PCM24 selection never silently falls back. The PCM formats below describe device capture and the legacy PCM path.

Try native playback is an opt-in Android setting. It uses Oboe only when Android grants its LowLatency performance mode, otherwise playback uses AudioTrack. The tested Bluetooth route did not grant LowLatency or demonstrate a latency improvement; see the native playback experiment.

You can open server.log to see the transfer audio format.

[2024-10-26 14:52:48.967] [info] AudioFormat:
encoding: ENCODING_PCM_16BIT
channels: 2
sample_rate: 44100

As shown above, the encoding is 16 bit integer PCM, the channel count is 2, and sample rate is 44.1kHz.

On Android, AudioTrack API only support the PCM audio formats listed below:

ENCODING_PCM_FLOAT
ENCODING_PCM_8BIT
ENCODING_PCM_16BIT
ENCODING_PCM_24BIT_PACKED
ENCODING_PCM_32BIT

https://developer.android.com/reference/android/media/AudioFormat#encoding

Audio Share support these 5 kinds of PCM format, but whether specific format is available depends on the audio endpoint.

On Windows, the default capture audio format depends on the audio endpoint's default format. You may change it by setting Sound Panel(mmsys.cpl). In Sound Panel's Playback tab, right click one available endpoint, and open Properties Panel, and select Advanced tab, and change Default Format and click Apply. This can be also done in Realtek Audio Console, if you use a Realtek audio card. The capture audio format must has the same channels and sample rate with the audio endpoint. So if you want to change them, you can only open Sound Panel and set default format. To be compatible with Linux, the as-cmd can still set the --channels or --sample-rate on Windows. However, it will fallback to the proper audio format, because it doesn't support the expected in most cases.

https://learn.microsoft.com/en-us/windows/win32/coreaudio/device-formats

On Linux, the default capture audio format could have been given by PipeWire completely. However, the default audio encoding may be planar, such as SPA_AUDIO_FORMAT_F32P. Android's AudioTrack can't play it. So the default audio encoding is forced to SPA_AUDIO_FORMAT_F32_LE(32 bit float PCM with little endian). The default channels and sample rate are untouched and given by PipeWire.

Note that decrease the encoding bitwise or sample rate can decrease network bandwidth, but can also increase the blank noise, also known as audio loss.

About Volume

The final volume that you hear is affected by the following volume:

  • PC system volume.
  • Audio player volume on PC.
  • Android system media volume.
  • "Audio Volume" on Android app.
  • "Loudness Enhancer" on Android app.

They are all independent. If you max the volume of your PC and audio player, and still feel it's not enough, but don't want to change the Android system volume, you can increase "Loudness Enhancer" on app's Settings. It won't affect the system volume. The "Audio Volume" on app can decrease the volume you hear without changing system volume.

Too much loudness will hurt your ear!!! "Loudness Enhancer" has a limit of 3000mB. It's enough for most cases. If you still need more loudness, just directly change Android system volume.

Extra Setups for "No Audio Endpoint"

For Windows

Method 1: Make audio endpoint available when speaker doesn't plug in

Realtek sound card can make audio endpoint available when speaker doesn't plug in. Just open Realtek Audio Console, select "Device advanced settings" tab, and switch on "Disable front panel front popup dialog" option. Then the audio endpoint will show up. Other sound card may have similar options. If you can't find, then turn to Method 2.

Method 2: Install a third-party virtual audio device driver

The Windows setup EXE includes the standard VB-CABLE virtual audio driver. See Windows setup. Keep the endpoint used for PC playback separate from the phone microphone destination: routing both through the same cable can feed PC sound into the receiving app's microphone.

For Linux

Thanks to PipeWire, it's very easy for Linux to create a virtual audio endpoint, even without a root privilege. Just copy the below config to ~/.config/pipewire/pipewire.conf.d/audio-share-sink.conf

context.objects = [
    {   factory = adapter
        args = {
           factory.name     = support.null-audio-sink
           node.name        = "Audio Share Sink"
           media.class      = Audio/Sink
           object.linger    = true
           audio.position   = [ FL FR ]
           priority.session = 1009
           priority.driver  = 1009
           monitor.channel-volumes = true
           monitor.passthrough = true
        }
    }
]

Then run systemctl --user restart pipewire to restart the PipeWire service.

Finally, you can see the added endpoint "Audio Share Sink".

[abc@localhost ~]$ as-cmd -l
[2024-03-17 22:46:14.563] [info] pipewire header_version: 0.3.48, library_version: 0.3.67
endpoint_list:
        * id: 30   name: Audio Share Sink
total: 1

Known Issues

The quick settings tile can't start playback directly

Restrictions on starting a foreground service from the background

Turns off or ignore battery optimizations can let it work.

Compile from source

  • Android App

    • Install JDK 17 manually or through Android Studio.
    • Android Studio will import all dependencies automatically.
  • Server MFC

    • vcpkg is required for install dependencies.
    • Run vcpkg install openssl opus asio protobuf spdlog[wchar] wil nlohmann-json to install deps. The vcpkg triplet is x64-windows-static-md.
    • Visual Studio 2022 with "Desktop development with C++" workload and "C++ MFC for latest v143 build tools (x86 & x64)" option is required for compiling.
  • Server CMD

    • CMake and a compiler support C++20 is required. Linux also need libpipewire-dev or pipewire-devel.
    • Run the CMake commands below from server-core/, where CMakePresets.json is located. On Windows, use an x64 Visual Studio developer shell with Ninja available.
    • Install vcpkg, and set the VCPKG_ROOT environment variable. It is required by CMakePresets.json.
    • Run vcpkg install openssl opus asio protobuf cxxopts to install deps. The vcpkg triplet is x64-windows-static-md for Windows, x64-linux for Linux. In addition, Windows need run vcpkg install spdlog[wchar] wil, and Linux need run vcpkg install spdlog.
    • Run cmake --preset linux-Release to configure.
    • Run cmake --build --preset linux-Release to build. The as-cmd is located at out/install/linux-Release/bin/as-cmd.
    • For Windows, replace linux to windows in previous two steps.

License

This project is licensed under the Apache-2.0 license .

   Copyright 2022-2024 mkckr0 <https://github.com/mkckr0>

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

FOSSA Status

Used Third-party Libraries

Sponsors

About

Audio Share can share Windows/Linux computer's audio to Android phone over network, so your phone becomes the speaker of computer. (You needn't buy a new speaker😄.)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages