Co-existence of Multiple Sound Applications - asound_include
Co-existence of Multiple Sound Applications - asound_include
When more than one program uses file /root/.asound to control audio operations, they can impact each other undesirably. Each program apparently assumes it is the only user of that file. That assumption limits Puppy's ability to reliably support sound applications. But there is a relatively simple way to avoid catastrophic damage: use .asound as a set of pointers to the versions of that file needed by each application.
Instead of each program replacing the entire .asource file -- and excluding other uses of it -- each program can have its own .asound file (~/.asound.PROGRAMNAME or /usr/local/PROGRAMNAME/asound), with its name placed in the main .asound file as an "included" file, specified with angle brackets as, say, "<~/.asound.PROGRAMNAME>".
The sound-related programs that currently conflict in their use of .asound are pmusic/pequalizer and puppybt. They cannot operate concurrently without damaging the other. If there are other such programs, please identify them to me here.
To facilitate adaptation of programs to use this technique, I have created the service script, 'asound_include', which handles the management of the "include" lines in .asource. To demonstrate how the programs might be adapted to this concept, I offer a "patch" package that modifies the code that accesses .asound, to use the service. The package can be installed to convert the programs and relocate their .asound files, and can later be uninstalled to restore the original configurations. The installation and uninstallation should be done only when pmusic, pequalizer and puppybt are not executing. The patch package should work on any recent puppy containing the subject programs.
While this way of operating avoids damage to other sound programs, consideration should be given to the use of the "default device", since the programs use it differently. To allow them to work together, the pequalizer is set by the patch package to not be the default device (an allowed option).
In the next message, I list the contents of the patch files, to show how straightforward and simple the modifications are. I hope these two packages will enable developers to work out any issues of operation among multiple programs that need the .asound file.
Richard
Instead of each program replacing the entire .asource file -- and excluding other uses of it -- each program can have its own .asound file (~/.asound.PROGRAMNAME or /usr/local/PROGRAMNAME/asound), with its name placed in the main .asound file as an "included" file, specified with angle brackets as, say, "<~/.asound.PROGRAMNAME>".
The sound-related programs that currently conflict in their use of .asound are pmusic/pequalizer and puppybt. They cannot operate concurrently without damaging the other. If there are other such programs, please identify them to me here.
To facilitate adaptation of programs to use this technique, I have created the service script, 'asound_include', which handles the management of the "include" lines in .asource. To demonstrate how the programs might be adapted to this concept, I offer a "patch" package that modifies the code that accesses .asound, to use the service. The package can be installed to convert the programs and relocate their .asound files, and can later be uninstalled to restore the original configurations. The installation and uninstallation should be done only when pmusic, pequalizer and puppybt are not executing. The patch package should work on any recent puppy containing the subject programs.
While this way of operating avoids damage to other sound programs, consideration should be given to the use of the "default device", since the programs use it differently. To allow them to work together, the pequalizer is set by the patch package to not be the default device (an allowed option).
In the next message, I list the contents of the patch files, to show how straightforward and simple the modifications are. I hope these two packages will enable developers to work out any issues of operation among multiple programs that need the .asound file.
Richard
- Attachments
-
- asound_include-0.3.pet
- Maintains /root/.asound as list of "includes" of programs' specifications that would otherwise
overlay or delete the others' set. - (893 Bytes) Downloaded 259 times
-
- asound_include_patches-0.1.pet
- Adapts pmusic, pequalizer & puppybt to co-exist with their sound configurations
- (60.54 KiB) Downloaded 238 times
Last edited by rerwin on Wed 28 Dec 2016, 17:35, edited 2 times in total.
The patches for co-existence:
pequalizer:
pmusic:
puppybt:
pequalizer:
Code: Select all
diff -ru /tmp/pequalizer-0.9.0/usr/local/pequalizer/pequalizer pequalizer-0.9.0-include/usr/local/pequalizer/pequalizer
--- /tmp/pequalizer-0.9.0/usr/local/pequalizer/pequalizer 2012-11-03 05:27:44.000000000 -0400
+++ pequalizer-0.9.0-include/usr/local/pequalizer/pequalizer 2016-12-24 20:50:41.000000000 -0500
@@ -34,8 +34,8 @@
export TEXTDOMAIN=pequalizer
#enable alsaequal
-[ ! -f $HOME/.asoundrc.bak ] && \
-cat > $HOME/.asoundrc.bak << _EQ
+[ ! -f $HOME/.asoundrc.pequalizer ] && \
+cat > $HOME/.asoundrc.pequalizer << _EQ
ctl.equal {
type equal;
}
@@ -49,16 +49,16 @@
slave.pcm "plug:dmix"
}
-#pcm.equal {
+pcm.equal {
# Or if you want the equalizer to be your
# default soundcard uncomment the following
# line and comment the above line.
-pcm.!default {
+#pcm.!default {
type plug;
slave.pcm plugequal;
}
_EQ
-mv -f $HOME/.asoundrc.bak $HOME/.asoundrc
+asound_include -a ~/.asoundrc.pequalizer
#setup working dirs
mkdir /tmp/eq 2> /dev/null
@@ -204,5 +204,5 @@
<vbox>
'$GUI_EMBEDDED'
</vbox>
- <action signal="delete-event">mv -f $HOME/.asoundrc $HOME/.asoundrc.bak</action>
+ <action signal="delete-event">asound_include -r ~/.asoundrc.pequalizer</action>
</window>' | gtkdialog -s
Code: Select all
diff -ru /tmp/pmusic-5.2.6/usr/local/pmusic/func pmusic-5.2.6-include/usr/local/pmusic/func
--- /tmp/pmusic-5.2.6/usr/local/pmusic/func 2016-11-04 13:11:15.000000000 -0400
+++ pmusic-5.2.6-include/usr/local/pmusic/func 2016-12-24 20:28:15.000000000 -0500
@@ -664,7 +664,7 @@
#remove play-icon in playlist
sed -i "s/gtk-media-play//" $WORKDIR/playlist
#deactivate equalizer
- mv -f $HOME/.asoundrc $HOME/.asoundrc.bak 2>> $STDERR
+ asound_include -r ~/.asoundrc.pequalizer
#remove temporary cd-audio files
rm $WORKDIR/*.wav 2>> $STDERR
rm $WORKDIR/*.inf 2>> $STDERR
diff -ru /tmp/pmusic-5.2.6/usr/local/pmusic/pmusic pmusic-5.2.6-include/usr/local/pmusic/pmusic
--- /tmp/pmusic-5.2.6/usr/local/pmusic/pmusic 2016-10-27 02:51:37.000000000 -0400
+++ pmusic-5.2.6-include/usr/local/pmusic/pmusic 2016-12-24 20:27:12.000000000 -0500
@@ -529,7 +529,7 @@
[[ "$(<$WORKDIR/xml_pmusic)" != *'<window'* ]] && echo '<window allow-shrink="true" icon-name="pmusic" default_height="'$WINDOW_HEIGHT'" default_width="'$WINDOW_WIDTH'">'"$(<$WORKDIR/xml_pmusic)" > $WORKDIR/xml_pmusic
fi
#start pequalizer if included in gui
- case ${GUI} in *pequalizer/preset*) mv -f $HOME/.asoundrc.bak $HOME/.asoundrc 2>> $STDERR;; esac
+ case ${GUI} in *pequalizer/preset*) asound_include -a ~/.asoundrc.pequalizer;; esac
#dump xml code
if [ "$DUMP_GTK" = "true" ]; then cat $WORKDIR/xml_pmusic${XML_SUFFIX}; $APPDIR/func -quit; exit 0; fi
#run gui
Code: Select all
diff -ru puppybt_tahr-2.1/usr/sbin/puppybt puppybt_tahr-2.1-include/usr/sbin/puppybt
--- puppybt_tahr-2.1/usr/sbin/puppybt 2016-12-14 19:07:09.000000000 -0500
+++ puppybt_tahr-2.1-include/usr/sbin/puppybt 2016-12-25 10:43:12.120031465 -0500
@@ -118,24 +118,24 @@
export -f REPAIR
EDITASOUND () {
-defaulttexteditor ~/.asoundrc
+defaulttexteditor ~/.asoundrc.puppybt
}
export -f EDITASOUND
SETDEFAULT1 ()
{
-sed -i 's/^#defaults/defaults/' ~/.asoundrc
-sed -i 's/^pcm.!default/#pcm.!default/' ~/.asoundrc
-sed -i 's/^ctl.!default/#ctl.!default/' ~/.asoundrc
+sed -i 's/^#defaults/defaults/' ~/.asoundrc.puppybt
+sed -i 's/^pcm.!default/#pcm.!default/' ~/.asoundrc.puppybt
+sed -i 's/^ctl.!default/#ctl.!default/' ~/.asoundrc.puppybt
Xdialog --title " " --msgbox "Audio device set to internal" 0 0
}
export -f SETDEFAULT1
SETDEFAULT2 ()
{
-sed -i 's/^defaults/#defaults/' ~/.asoundrc
-sed -i 's/^#pcm.!default/pcm.!default/' ~/.asoundrc
-sed -i 's/^#ctl.!default/ctl.!default/' ~/.asoundrc
+sed -i 's/^defaults/#defaults/' ~/.asoundrc.puppybt
+sed -i 's/^#pcm.!default/pcm.!default/' ~/.asoundrc.puppybt
+sed -i 's/^#ctl.!default/ctl.!default/' ~/.asoundrc.puppybt
Xdialog --title " " --msgbox "Audio device set to btheadset" 0 0
}
export -f SETDEFAULT2
@@ -243,6 +243,7 @@
##########################
+asound_include -a ~/.asoundrc.puppybt
export DIALOG="
<window title=\"PuppyBT v2.1\">
<vbox>
@@ -309,7 +310,7 @@
</frame>
<frame>
<hbox>
- <text><label>$(gettext 'Edit /root/.asoundrc')</label></text>
+ <text><label>$(gettext 'Edit /root/.asoundrc.puppybt')</label></text>
<button>
<label>\" \"</label>
<action>EDITASOUND &</action>
I have added a similar function as your asound_include into pMusic, but it wouldn't work until I modified the asoundrc.pequalizer fromtoMoved # from line 18 to 14
Thank you for your work !
Sigmund
Code: Select all
ctl.equal {
type equal;
}
pcm.plugequal {
type equal;
# Modify the line below if you don't
# want to use sound card 0.
#slave.pcm "plughw:0,0";
# or if you want to use with multiple applications output to dmix
slave.pcm "plug:dmix"
}
pcm.equal {
# Or if you want the equalizer to be your
# default soundcard uncomment the following
# line and comment the above line.
#pcm.!default {
type plug;
slave.pcm plugequal;
}
Code: Select all
ctl.equal {
type equal;
}
pcm.plugequal {
type equal;
# Modify the line below if you don't
# want to use sound card 0.
#slave.pcm "plughw:0,0";
# or if you want to use with multiple applications output to dmix
slave.pcm "plug:dmix"
}
#pcm.equal {
# Or if you want the equalizer to be your
# default soundcard uncomment the following
# line and comment the above line.
pcm.!default {
type plug;
slave.pcm plugequal;
}
Thank you for your work !
Sigmund
Sigmund,
Thank you for trying this approach.
Regarding the "default" change, that is the issue that needs to be worked out. Either pequalizer or puppybt can be the default, but not at the same time. Maybe we need a coordinated or consistent way to switch the default, so pmusic and puppybt can set it only when they are used.
ATM I do not know enough about the "asound" business to offer an intelligent solution. Ideally, pequalizer should be able to output to a BT headset/speaker. But would require some redesign, to make them work together.
Right now, though, there needs to be a simple way to set one or the other. Maybe "includes" could help with that, using one or a set of files for only setting the default device.
I have not consulted Micko, but have communicated with the puppybt developer.
Richard
Thank you for trying this approach.
Regarding the "default" change, that is the issue that needs to be worked out. Either pequalizer or puppybt can be the default, but not at the same time. Maybe we need a coordinated or consistent way to switch the default, so pmusic and puppybt can set it only when they are used.
ATM I do not know enough about the "asound" business to offer an intelligent solution. Ideally, pequalizer should be able to output to a BT headset/speaker. But would require some redesign, to make them work together.
Right now, though, there needs to be a simple way to set one or the other. Maybe "includes" could help with that, using one or a set of files for only setting the default device.
I have not consulted Micko, but have communicated with the puppybt developer.
Richard
I suggest the following code in pMusic to support both todays pEqualizer and the include-mechanism.
If this looks sane, I'll include it into the upcoming pMusic-5.2.7.
Actiavte pEqualizer in /usr/local/pmusic/pmusic:
Deactivate pEqualizer in /usr/local/pmusic/func:
If this looks sane, I'll include it into the upcoming pMusic-5.2.7.
Actiavte pEqualizer in /usr/local/pmusic/pmusic:
Code: Select all
if [ -f $HOME/.asoundrc.pequalizer ]; then #using include-mechanism
[ ! grep -F ".asoundrc.pequalizer>" ~/.asoundrc ] || echo "<~/.asoundrc.pequalizer>" >> ~/.asoundrc
else
mv -f $HOME/.asoundrc.bak $HOME/.asoundrc 2>> $STDERR
fi
Code: Select all
#deactivate equalizer
if [ -f $HOME/.asoundrc.pequalizer ]; then #using include-mechanism
cat $HOME/.asoundrc | grep -vF '.asoundrc.pequalizer' > $HOME/.asoundrc
else
mv -f $HOME/.asoundrc $HOME/.asoundrc.bak 2>> $STDERR
fi