Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 24 Nov 2017, 09:24
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » System
Co-existence of Multiple Sound Applications - asound_include
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [11 Posts]  
Author Message
rerwin


Joined: 24 Aug 2005
Posts: 1845
Location: Maine, USA

PostPosted: Tue 27 Dec 2016, 14:49    Post subject:  Co-existence of Multiple Sound Applications - asound_include
Subject description: Managing the ".asound" file among competing programs, using "includes".
 

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
asound_include-0.3.pet
Description  Maintains /root/.asound as list of "includes" of programs' specifications that would otherwise
overlay or delete the others' set.
pet

 Download 
Filename  asound_include-0.3.pet 
Filesize  893 Bytes 
Downloaded  58 Time(s) 
asound_include_patches-0.1.pet
Description  Adapts pmusic, pequalizer & puppybt to co-exist with their sound configurations
pet

 Download 
Filename  asound_include_patches-0.1.pet 
Filesize  60.54 KB 
Downloaded  61 Time(s) 

Last edited by rerwin on Wed 28 Dec 2016, 13:35; edited 2 times in total
Back to top
View user's profile Send private message 
rerwin


Joined: 24 Aug 2005
Posts: 1845
Location: Maine, USA

PostPosted: Tue 27 Dec 2016, 14:50    Post subject:  

The patches for co-existence:
pequalizer:
Code:
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

pmusic:
Code:
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

puppybt:
Code:
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>
Back to top
View user's profile Send private message 
rerwin


Joined: 24 Aug 2005
Posts: 1845
Location: Maine, USA

PostPosted: Tue 27 Dec 2016, 15:01    Post subject:  

reserved
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 6509
Location: Valåmoen, Norway

PostPosted: Wed 28 Dec 2016, 16:50    Post subject:  

I have added a similar function as your asound_include into pMusic, but it wouldn't work until I modified the asoundrc.pequalizer from
Code:
 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;
}
to
Code:
 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;
}
Moved # from line 18 to 14

Thank you for your work !
Sigmund

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
zigbert


Joined: 29 Mar 2006
Posts: 6509
Location: Valåmoen, Norway

PostPosted: Thu 29 Dec 2016, 16:01    Post subject:  

Is Micko informed about this?
_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
rerwin


Joined: 24 Aug 2005
Posts: 1845
Location: Maine, USA

PostPosted: Thu 29 Dec 2016, 19:19    Post subject:  

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
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 6509
Location: Valåmoen, Norway

PostPosted: Fri 30 Dec 2016, 02:22    Post subject:  

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:
Code:
      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

Deactivate pEqualizer in /usr/local/pmusic/func:
Code:
   #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

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
fr33land

Joined: 25 Jun 2015
Posts: 52

PostPosted: Fri 30 Dec 2016, 20:09    Post subject:  

This issue is resolved in the PuppyBT thread.
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 6509
Location: Valåmoen, Norway

PostPosted: Sat 31 Dec 2016, 05:41    Post subject:  

I have to wait for Mick to update pEqualizer to ensure compatibility in pMusic.

Thank you both!

_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
fr33land

Joined: 25 Jun 2015
Posts: 52

PostPosted: Sat 31 Dec 2016, 06:34    Post subject:  

zigbert wrote:
I have to wait for Mick to update pEqualizer to ensure compatibility in pMusic.

Neither of you needs to change anything.
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 6509
Location: Valåmoen, Norway

PostPosted: Sat 31 Dec 2016, 09:15    Post subject:  

Your patch changes the code in /usr/local/pmusic/func and /usr/local/pmusic/pmusic. If the user later updates to a more recent pMusic, your code will be reset, and bluetooth will fail... ?
_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [11 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » System
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1066s ][ Queries: 14 (0.0089s) ][ GZIP on ]