Interrupted Stream Remembers Volume, not Output Device
I am creating a sink to play the audio out my speakers and dump it to another output (creatively named record-play) and then use parec to monitor this sink and dump the audio over to an encoder. It works perfectly to record audio from twitch - I start the stream playing, go to pavucontrol, and select the stream from my browser to record-play.
Unfortunately, most times there's any break in the audio, I have to manually change the output device to the record-play sink. (To simulate this, just mute the tab for a few seconds - simulates audio dropping out.) The stream shows up in pavucontrol right away when audio resumes and remembers the volume level I had it set to, but usually does not remember the sink it was set to go to. Sometimes it does though, which is confusing as I've found no pattern to whether it does or not. It seems like it'll eventually remember more often after it happens several times, but this might be coincidence.
Conversely, if I'm using my browser and start playing audio in a different tab, many times it'll default to the record-play sink rather than being output to my speakers.
Any ideas?
The very simple shell script that I've pieced together from various online sources with my own tweaks that does this:
` #!/usr/bin/bash
if [ "$1" == "" ]; then
echo "You need a filename to save the MP3 to!"
exit
fi
DEFAULT_OUTPUT=$(/usr/bin/pacmd list-sinks | /usr/bin/grep -A1 "* index" | /usr/bin/grep -oP "<\K[^ >]+")
/usr/bin/pactl load-module module-combine-sink sink_name=record-play slaves=$DEFAULT_OUTPUT sink_properties=device.description="Record-Play"
/usr/bin/pavucontrol &
echo "Starting to record audio - direct stream to record to Record-Play... Break to stop."
/usr/bin/parec --format=s16le -d record-play.monitor | /usr/bin/lame -r --quiet -q 3 --lowpass 17 --abr 256 - "$1"
/usr/bin/sleep 5
/usr/bin/pactl unload-module module-combine-sink `
(Sorry - I've tried using the code tag & without; the newline characters don't appear for the script. Adding extra lines makes it more readable, though it looks stupid with the extra line between each.)