Script to fix sound for skype-oss and "exclusive mode"

OSS specific Linux discussion (x86/amd64)

Moderators: hannu, dev, cesium

igorzwx
Known Member
Posts: 1256
Joined: Sun Jun 28, 2009 9:31 pm

Script to fix sound for skype-oss and "exclusive mode"

Postby igorzwx » Sun Feb 08, 2015 3:06 am

If you are using "skype_oss_wrapper" or "exclusive" mode, you may need a magic tool to kill all "audio-terrorists", such as adobe-flashplugin and the like.

This magic instrument should be able
(1) to kill adobe-flashplugin without killing browsers,
(2) to fix all problems with a mouse click.

To create such a magic tool, you can simply modify the native script "killprocs.sh"

Code: Select all

$ cat freesound.sh
#!/bin/bash

# Script to free the sound device for "skype_oss_wrapper" and/or "exclusive mode", e.g. "ossplay -R"
# Source: /usr/lib/oss/scripts/killprocs.sh

# Step 1: Kill programs which are using OSS devices

PROCS="`fuser /dev/mixer* /dev/dsp* /dev/audio* /dev/sequencer /dev/music /dev/midi* 2>/dev/null`"

if test "$PROCS " = " "
then
   exit 0
fi

for pid in $PROCS
do
   # ps ax|grep "^ *$pid "
   # echo killing $pid
   kill -9 $pid
done

wait

# Step 2: Relaunch the OSS Mixer GUI daemon
ossxmix -b &

# Pop-up notifications for MATE desktop
# See: http://mate-desktop.org/blog/2013-01-20-changes-to-mate-notification-daemon/

killall mate-notification-daemon -q

icon=/opt/scripts/icons/freesound48.xpm

notify-send "   Sound device is free" --icon=$icon -t 5000

exit 0


Save it as "freesound.sh" and make it executable

Code: Select all

$ chmod +x freesound.sh


If you do not use pop-up notifications, you may comment them out.

Copy freesound.sh to your script folder

Code: Select all

$ sudo cp freesound.sh /opt/scripts


Create a symbolic link:

Code: Select all

$ sudo ln -s /opt/scripts/freesound.sh /usr/bin/freesound


Unzip icons and copy them to your script folder

Code: Select all

$ sudo cp -r icons /opt/scripts


Now we can create a launcher for freesound

Code: Select all

$ echo "[Desktop Entry]
Name=freesound
Comment=Free sound device for "exclusive mode"
Exec=freesound
Icon=/opt/scripts/icons/freesound24.xpm
Terminal=false
Type=Application
Encoding=UTF-8
Categories=AudioVideo;" > freesound.desktop


You can view it on terminal

Code: Select all

$ cat freesound.desktop


or open it with a text editor of your choice

Code: Select all

$ pluma freesound.desktop


To enable this "application launcher", you can copy it to /usr/share/applications/

Code: Select all

$ sudo cp freesound.desktop /usr/share/applications/


It will appear in the "Application Menu", and you can drag and drop it to panel.

Now you can test it with browsers/adobe-flash, etc.

How to use:
1. Run "freesound" with a mouse click.
2. Then you can run "skype_oss_wrapper", or "ossplay -R", or "pcm_play -e", or DeadBeef in exclusive mode.
Attachments
icons.tar.gz
(9.01 KiB) Downloaded 836 times
freesound.desktop.tar.gz
(282 Bytes) Downloaded 836 times

cwpjr
Member
Posts: 38
Joined: Tue Jan 14, 2014 4:18 pm

Re: Script to fix sound for skype-oss and "exclusive mode"

Postby cwpjr » Thu Feb 26, 2015 8:32 pm

Nice clean example. I learned a lot. Thanks!

igorzwx
Known Member
Posts: 1256
Joined: Sun Jun 28, 2009 9:31 pm

Re: Script to fix sound for skype-oss and "exclusive mode"

Postby igorzwx » Fri Jan 06, 2017 3:34 pm

A simple solution:

Code: Select all

$ cat killaudio.sh
#!/bin/bash

# Script to free the sound device for "skype_oss_wrapper" and/or "exclusive mode", e.g. "ossplay -R"

# 1: "find" will find all audio devices of OSS4
# 2: "fuser" will kill all audio apps
# 3: The OSS Mixer GUI daemon (ossxmix) will be restarted

killall -q ossxmix
fuser -ks $(find /dev/oss -type c 2>/dev/null) 2>/dev/null
ossxmix -b &

exit 0



Audio apps can also be killed in interactive mode with one command:

Code: Select all

$ fuser -ikv $(find /dev/oss -type c 2>/dev/null)

__________________________________

See also:

Code: Select all

$ man find
$ man fuser


Code: Select all

$ man find | grep -A5 '\-type c$' | grep -v '^$\|block'
       -type c
              File is of type c:
              c      character (unbuffered) special


Unix Device file
_https://en.wikipedia.org/wiki/Unix_file_types#Device_file
Character devices
_https://en.wikipedia.org/wiki/Device_file#Character_devices

Code: Select all

$ fuser --help
  -a,--all              display unused files too
  -i,--interactive      ask before killing (ignored without -k)
  -k,--kill             kill processes accessing the named file
  -s,--silent           silent operation
  -v,--verbose          verbose output
  -w,--writeonly        kill only processes with write access


Return to “Linux”

Who is online

Users browsing this forum: No registered users and 3 guests