Allow simultaneous passthrough for multiple devices#23
Allow simultaneous passthrough for multiple devices#23gdzx merged 25 commits intogdzx:masterfrom CameronMParker:feature-multi-mic
Conversation
Merge install flag fix
…' into feature-multi-mic
| install [-s SERIAL] Install Audio Source to Android device (default: debug) | ||
| run [-s SERIAL] [-n NAME] Run Audio Source and start forwarding | ||
| volume NAME LEVEL Set volume to LEVEL (for example, 250%) |
There was a problem hiding this comment.
The flag should be on the root command instead of being repeated on all the subcommands (like adb [-s serial] <command>. But I think it's better to remove it entirely because it is possible to set it with ANDROID_SERIAL=whatever which is functionally equivalent to passing the -s option to adb, so this is just a matter of documenting that it works and generating a name from it.
| AUDIOSOURCE_NAME=${AUDIOSOURCE_NAME:-android} | ||
| AUDIOSOURCE_PIPE=${AUDIOSOURCE_PIPE:-/tmp/audiosource} | ||
| AUDIOSOURCE_SOCKET=${AUDIOSOURCE_SOCKET:-audiosource} | ||
| AUDIOSOURCE_NAME=${AUDIOSOURCE_NAME:-audiosource$(uuidgen)} |
There was a problem hiding this comment.
The name should be stable, because if you adjust the volume or other settings in pavucontrol, they would be lost if you launch it again. One way of doing that would be deriving a short identifier from the sha256 sum of the serial (e.g. audiosource-82ab264).
| $ ./audiosource run -s SERIAL_ONE 1> /dev/null & | ||
| $ ./audiosource run -s SERIAL_TWO 1> /dev/null & |
There was a problem hiding this comment.
| $ ./audiosource run -s SERIAL_ONE 1> /dev/null & | |
| $ ./audiosource run -s SERIAL_TWO 1> /dev/null & | |
| $ ANDROID_SERIAL=serial1 ./audiosource run 1> /dev/null & | |
| $ ANDROID_SERIAL=serial2 ./audiosource run 1> /dev/null & |
| @@ -141,33 +150,31 @@ run() { | |||
|
|
|||
| echo '[+] Forwarding audio' | |||
There was a problem hiding this comment.
The name of source could be printed here.
|
I've updated the code according to your feedback. Let me know if there are still any changes that need to be made. |
- Remove -n option (name can be set with $AUDIOSOURCE_NAME). - Export $ANDROID_SERIAL and remove adb $opts. - Add contextual usage errors.
|
Hi @CameronMParker, Thank you for your changes. I added a few of my own. Could you check that everything works properly for your use case? Best regards, |
|
Everything works great! I encountered an error while running |
|
What was the bug? I cannot reproduce. |
| pactl load-module module-pipe-source source_name="$AUDIOSOURCE_NAME" channels=1 format=s16 rate=44100 file="/tmp/$AUDIOSOURCE_NAME" | ||
|
|
||
| echo "[+] Waiting for device $ANDROID_SERIAL" | ||
| echo "[+] Waiting for device $AUDIOSOURCE_NAME" |
There was a problem hiding this comment.
Should be $ANDROID_SERIAL as it may not be obvious which device you are waiting for based on the source name if for instance you left the serial set in the environment.
|
If you're running the default |
|
Weird, I have a completely different behavior (with $ ANDROID_SERIAL='' adb shell # no device
adb: no devices/emulators found
$ ANDROID_SERIAL='' adb shell # single device
android:/ $
$ ANDROID_SERIAL='foo' adb shell
adb: device 'foo' not foundCan you send me the output of |
|
|
|
||
| shift $((OPTIND-1)) | ||
|
|
||
| export ANDROID_SERIAL="$serial" |
There was a problem hiding this comment.
Export conditionally like this?
ANDROID_SERIAL="$serial"
# Empty ANDROID_SERIAL seems to cause the following issue with ADB: `error: device '' not found`.
[ -n "$ANDROID_SERIAL" ] && export ANDROID_SERIAL
Same as you except the kernel version 🤷 |
|
Moving the initial declaration of |
|
I changed to export |
|
Everything seems to be fine now. |
This PR would allow Audio Source to forward multiple Android devices to PulseAudio.
Context
Because each invocation of
audiosourceuses the same socket, device, and pipe names, it is only possible to connect one Android device to PulseAudio. This PR, however, adds both a random UUID to the default device name and allows the user to supply an optional device name. Both of these solutions prevent socket naming collisions and allow you to run multipleaudiosourcejobs at the same time.Example
A user could connect a Galaxy device and a Pixel device and select between the two with
pactl set-default-source.A user could also bounce the inputs down into one PulseAudio sink so they could monitor or record from multiple devices at the same time.
Changes
installandruncommands have been updated to use optional flags instead of positional flags.volumecommand now requires a device name.