This repository has been archived by the owner on Aug 21, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new files for pulse2loopback bridge
- Loading branch information
Showing
3 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/bin/bash | ||
# Script to bridge/start pulseaudio into loopback mode | ||
|
||
INSTALL_PREFIX="X-PREFIX-X" | ||
|
||
# ---------------------------------------------- | ||
|
||
if [ ! -d ~/.pulse ]; then | ||
mkdir -p ~/.pulse | ||
fi | ||
|
||
if [ ! -f ~/.pulse/client.conf ]; then | ||
echo "autospawn = no" > ~/.pulse/client.conf | ||
else | ||
if (! cat ~/.pulse/client.conf | grep "autospawn = no" > /dev/null); then | ||
sed -i '/autospawn =/d' ~/.pulse/client.conf | ||
echo "autospawn = no" >> ~/.pulse/client.conf | ||
fi | ||
fi | ||
|
||
if [ ! -f ~/.pulse/daemon.conf ]; then | ||
echo "default-sample-format = float32le" > ~/.pulse/daemon.conf | ||
echo "realtime-scheduling = yes" >> ~/.pulse/daemon.conf | ||
echo "rlimit-rttime = -1" >> ~/.pulse/daemon.conf | ||
echo "exit-idle-time = -1" >> ~/.pulse/daemon.conf | ||
else | ||
if (! cat ~/.pulse/daemon.conf | grep "default-sample-format = float32le" > /dev/null); then | ||
sed -i '/default-sample-format = /d' ~/.pulse/daemon.conf | ||
echo "default-sample-format = float32le" >> ~/.pulse/daemon.conf | ||
fi | ||
if (! cat ~/.pulse/daemon.conf | grep "realtime-scheduling = yes" > /dev/null); then | ||
sed -i '/realtime-scheduling = /d' ~/.pulse/daemon.conf | ||
echo "realtime-scheduling = yes" >> ~/.pulse/daemon.conf | ||
fi | ||
if (! cat ~/.pulse/daemon.conf | grep "rlimit-rttime = -1" > /dev/null); then | ||
sed -i '/rlimit-rttime =/d' ~/.pulse/daemon.conf | ||
echo "rlimit-rttime = -1" >> ~/.pulse/daemon.conf | ||
fi | ||
if (! cat ~/.pulse/daemon.conf | grep "exit-idle-time = -1" > /dev/null); then | ||
sed -i '/exit-idle-time =/d' ~/.pulse/daemon.conf | ||
echo "exit-idle-time = -1" >> ~/.pulse/daemon.conf | ||
fi | ||
fi | ||
|
||
# ---------------------------------------------- | ||
|
||
case $1 in | ||
-h|--h|--help) | ||
echo "usage: $0 [command] | ||
-p, --play Playback mode only | ||
-h, --help Show this help menu | ||
--dummy Don't do anything, just create the needed files | ||
NOTE: | ||
When runned with no arguments, pulse2jack will | ||
activate PulseAudio with both playback and record modes. | ||
" | ||
exit | ||
;; | ||
|
||
--dummy) | ||
exit | ||
;; | ||
|
||
-p|--p|--play) | ||
FILE=$INSTALL_PREFIX/share/cadence/pulse2loopback/play.pa | ||
;; | ||
|
||
*) | ||
FILE=$INSTALL_PREFIX/share/cadence/pulse2loopback/play+rec.pa | ||
;; | ||
esac | ||
|
||
# ---------------------------------------------- | ||
|
||
IsPulseAudioRunning() | ||
{ | ||
PROCESS=`ps -u $USER | grep pulseaudio` | ||
if [ "$PROCESS" == "" ]; then | ||
false | ||
else | ||
true | ||
fi | ||
} | ||
|
||
if (IsPulseAudioRunning); then | ||
{ | ||
echo "PulseAudio is already running, make sure it outputs to Loopback" | ||
|
||
pactl load-module module-alsa-source source_name=input_loopback device=hw:Loopback > /dev/null | ||
pactl load-module module-alsa-sink sink_name=output_loopback device=hw:Loopback > /dev/null | ||
pacmd set-default-source input_loopback > /dev/null | ||
pacmd set-default-sink output_loopback > /dev/null | ||
|
||
echo "Done" | ||
} | ||
else | ||
{ | ||
if (`pulseaudio --daemonize --high-priority --realtime --disallow-module-loading --exit-idle-time=-1 --file=$FILE -n`); then | ||
echo "Initiated PulseAudio successfully!" | ||
else | ||
echo "Failed to initialize PulseAudio!" | ||
fi | ||
} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/pulseaudio -nF | ||
# | ||
# This file is part of PulseAudio, tuned to work for JACK input/output | ||
# | ||
# PulseAudio is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# PulseAudio is distributed in the hope that it will be useful, but | ||
# WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with PulseAudio; if not, write to the Free Software Foundation, | ||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
|
||
# This startup script is used only if PulseAudio is started per-user | ||
# (i.e. not in system mode) | ||
|
||
|
||
.fail | ||
|
||
### Automatically restore the volume of streams and devices | ||
load-module module-device-restore | ||
load-module module-stream-restore | ||
load-module module-card-restore | ||
|
||
### Load unix protocol | ||
load-module module-native-protocol-unix | ||
|
||
### Automatically move streams to the default sink if the sink they are | ||
### connected to dies, similar for sources | ||
load-module module-rescue-streams | ||
|
||
### Make sure we always have a sink around, even if it is a null sink. | ||
load-module module-always-sink | ||
|
||
### Load ALSA modules and set them to Loopback | ||
load-module module-alsa-source source_name=input device=hw:Loopback | ||
load-module module-alsa-sink sink_name=output device=hw:Loopback | ||
|
||
### Set as default source and sink | ||
set-default-source input | ||
set-default-sink output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/pulseaudio -nF | ||
# | ||
# This file is part of PulseAudio, tuned to work for JACK input/output | ||
# | ||
# PulseAudio is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# PulseAudio is distributed in the hope that it will be useful, but | ||
# WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with PulseAudio; if not, write to the Free Software Foundation, | ||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | ||
|
||
# This startup script is used only if PulseAudio is started per-user | ||
# (i.e. not in system mode) | ||
|
||
|
||
.fail | ||
|
||
### Automatically restore the volume of streams and devices | ||
load-module module-device-restore | ||
load-module module-stream-restore | ||
load-module module-card-restore | ||
|
||
### Load unix protocol | ||
load-module module-native-protocol-unix | ||
|
||
### Automatically move streams to the default sink if the sink they are | ||
### connected to dies, similar for sources | ||
load-module module-rescue-streams | ||
|
||
### Make sure we always have a sink around, even if it is a null sink. | ||
load-module module-always-sink | ||
|
||
### Load ALSA modules and set them to Loopback | ||
load-module module-alsa-sink sink_name=output device=hw:Loopback | ||
|
||
### Set as default sink | ||
set-default-sink output |