Skip to content

Commit fcbd55f

Browse files
authored
audiosource: init at 1.4 (#473776)
2 parents 9f6b189 + 101cace commit fcbd55f

File tree

3 files changed

+167
-0
lines changed

3 files changed

+167
-0
lines changed

maintainers/maintainer-list.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11047,6 +11047,11 @@
1104711047
githubId = 207392575;
1104811048
name = "Isaac Kabel";
1104911049
};
11050+
ikci = {
11051+
github = "ikcii";
11052+
githubId = 48479629;
11053+
name = "ikci";
11054+
};
1105011055
ikervagyok = {
1105111056
email = "ikervagyok@gmail.com";
1105211057
github = "ikervagyok";
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
lib,
3+
stdenv,
4+
fetchFromGitHub,
5+
fetchurl,
6+
makeWrapper,
7+
installShellFiles,
8+
python3,
9+
android-tools,
10+
pulseaudio,
11+
coreutils,
12+
}:
13+
14+
stdenv.mkDerivation (finalAttrs: {
15+
pname = "audiosource";
16+
version = "1.4";
17+
18+
src = fetchFromGitHub {
19+
owner = "gdzx";
20+
repo = "audiosource";
21+
tag = "v${finalAttrs.version}";
22+
hash = "sha256-SlX8gjs7X5jfoeU6pyk4n8f6oMJgneGVt0pmFs48+mQ=";
23+
};
24+
25+
patches = [
26+
# Removes build-related logic from the script that is unused in the package and fixes a small bug with adb args on new Android versions
27+
./unused-logic-removal-and-args-fix.patch
28+
];
29+
30+
postPatch = ''
31+
substituteInPlace audiosource \
32+
--replace-fail "@apkPath@" "$out/share/audiosource/audiosource.apk"
33+
'';
34+
35+
nativeBuildInputs = [
36+
makeWrapper
37+
installShellFiles
38+
];
39+
40+
installPhase = ''
41+
runHook preInstall
42+
43+
mkdir -p $out/bin $out/share/audiosource
44+
cp ${finalAttrs.passthru.apk} $out/share/audiosource/audiosource.apk
45+
46+
installBin audiosource
47+
48+
runHook postInstall
49+
'';
50+
51+
postFixup = ''
52+
wrapProgram $out/bin/audiosource \
53+
--prefix PATH : ${
54+
lib.makeBinPath [
55+
python3
56+
android-tools
57+
pulseaudio
58+
coreutils
59+
]
60+
}
61+
'';
62+
63+
passthru.apk = fetchurl {
64+
url = "https://github.com/gdzx/audiosource/releases/download/v${finalAttrs.version}/audiosource.apk";
65+
hash = "sha256-vDIF+NZ3JgTT67Dem4qeajWsA5m/MFt2nRDpWUqC9aU=";
66+
};
67+
68+
meta = {
69+
description = "Use an Android device as a USB microphone";
70+
homepage = "https://github.com/gdzx/audiosource";
71+
license = lib.licenses.mit;
72+
maintainers = with lib.maintainers; [ ikci ];
73+
mainProgram = "audiosource";
74+
platforms = lib.platforms.linux;
75+
sourceProvenance = with lib.sourceTypes; [
76+
fromSource
77+
binaryBytecode
78+
];
79+
};
80+
})
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
diff --git a/audiosource b/audiosource
2+
index b06127a..0bccddf 100755
3+
--- a/audiosource
4+
+++ b/audiosource
5+
@@ -2,15 +2,7 @@
6+
7+
set -eu
8+
9+
-AUDIOSOURCE_PROFILE=${AUDIOSOURCE_PROFILE:-debug}
10+
-
11+
-if [ "$AUDIOSOURCE_PROFILE" = 'release' ]; then
12+
- AUDIOSOURCE_DEFAULT_APK=app/build/outputs/apk/release/app-release.apk
13+
-else
14+
- AUDIOSOURCE_DEFAULT_APK=app/build/outputs/apk/debug/app-debug.apk
15+
-fi
16+
-
17+
-AUDIOSOURCE_APK=${AUDIOSOURCE_APK:-"$AUDIOSOURCE_DEFAULT_APK"}
18+
+AUDIOSOURCE_APK=${AUDIOSOURCE_APK:-"@apkPath@"}
19+
ANDROID_SERIAL=${ANDROID_SERIAL:-}
20+
21+
PYSOCAT="$(cat <<EOF
22+
@@ -81,22 +73,12 @@ install() {
23+
24+
echo '[+] Installing Audio Source'
25+
26+
- adb install -rtg "$AUDIOSOURCE_APK" || {
27+
+ adb install -r -t -g "$AUDIOSOURCE_APK" || {
28+
adb uninstall fr.dzx.audiosource
29+
- adb install -tg "$AUDIOSOURCE_APK"
30+
+ adb install -t -g "$AUDIOSOURCE_APK"
31+
}
32+
}
33+
34+
-_release() {
35+
- AUDIOSOURCE_PROFILE=release
36+
- AUDIOSOURCE_APK=app/build/outputs/apk/release/app-release.apk
37+
-
38+
- build
39+
-
40+
- cp -a "$AUDIOSOURCE_APK" audiosource.apk
41+
- sha256sum audiosource.apk > audiosource.apk.sha256
42+
-}
43+
-
44+
_unload() {
45+
for id in `pactl list modules short | sed -n "/module-pipe-source\tsource_name=$AUDIOSOURCE_NAME/p" | cut -f1`; do
46+
pactl unload-module "$id"
47+
@@ -146,7 +128,7 @@ volume() {
48+
49+
main_help() {
50+
cat <<-EOF
51+
- Usage: ./audiosource [-s SERIAL] COMMAND [ARGS...]
52+
+ Usage: audiosource [-s SERIAL] COMMAND [ARGS...]
53+
54+
Options:
55+
56+
@@ -154,15 +136,13 @@ main_help() {
57+
58+
Commands:
59+
60+
- build Build Audio Source APK (default: debug)
61+
- install Install Audio Source to Android device (default: debug)
62+
+ install Install Audio Source to Android device
63+
run Run Audio Source and start forwarding
64+
volume LEVEL Set volume to LEVEL (for example, 250%)
65+
66+
Environment:
67+
68+
- AUDIOSOURCE_APK APK path (default: app/build/outputs/apk/\$profile/app-\$profile.apk)
69+
- AUDIOSOURCE_PROFILE Build profile (debug or release, default: build)
70+
+ AUDIOSOURCE_APK APK path (default: @apkPath@)
71+
AUDIOSOURCE_NAME Name of the PulseAudio source (default: android-<serial-hash>)
72+
ANDROID_SERIAL Device serial number to connect to (default: unset)
73+
EOF
74+
@@ -200,7 +180,7 @@ main() {
75+
shift
76+
77+
case "$cmd" in
78+
- build|install|run|volume|_release)
79+
+ install|run|volume)
80+
"$cmd" "$@"
81+
;;
82+
*)

0 commit comments

Comments
 (0)