<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: lsof &#124;grep snd &#8212; how to free a Linux sound device</title>
	<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/</link>
	<description>Diary of my Linux journeys. Everything Linux by Kamil Wójcicki</description>
	<pubDate>Sun, 21 Mar 2010 01:35:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: Aistis</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-681</link>
		<author>Aistis</author>
		<pubDate>Thu, 25 Feb 2010 16:57:58 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-681</guid>
		<description>I luv this tutorial.. OneMegaThanksToYou !!!</description>
		<content:encoded><![CDATA[<p>I luv this tutorial.. OneMegaThanksToYou !!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: theme</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-652</link>
		<author>theme</author>
		<pubDate>Thu, 18 Jun 2009 14:28:21 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-652</guid>
		<description>Kamil:  completely agree with you, that is a so dirty solution, but as you point it works. The pitty is that Matlab/java and/or Alsa team doen't manage to fix it. Let's hope they get any solution. Linux is for work and have fun and multitasking system so, we should be able to do both, working with matlab while enjoying great music.


Anyway thanks for the tip, i liked itvery much, sorry for the absence but i've been working in other issues, and now i've already focused again in matlab  : )

THNX again ;)</description>
		<content:encoded><![CDATA[<p>Kamil:  completely agree with you, that is a so dirty solution, but as you point it works. The pitty is that Matlab/java and/or Alsa team doen&#039;t manage to fix it. Let&#039;s hope they get any solution. Linux is for work and have fun and multitasking system so, we should be able to do both, working with matlab while enjoying great music.</p>
<p>Anyway thanks for the tip, i liked itvery much, sorry for the absence but i&#039;ve been working in other issues, and now i&#039;ve already focused again in matlab  : )</p>
<p>THNX again <img src='http://linux.dsplabs.com.au/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamil</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-643</link>
		<author>Kamil</author>
		<pubDate>Sat, 09 May 2009 02:07:25 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-643</guid>
		<description>Hi Dimitris, in all likelihood your sound card can play and record at the same time, f.e. I can use, at the same time, &lt;b&gt;mplayer&lt;/b&gt; for playback and &lt;b&gt;gnome-sound-recorder&lt;/b&gt; for recording, without errors. The only thing that can get tricky are the mixer settings. Try un-muting all devices using &lt;b&gt;alsamixer&lt;/b&gt; and set all the volumes to maximum to get started.</description>
		<content:encoded><![CDATA[<p>Hi Dimitris, in all likelihood your sound card can play and record at the same time, f.e. I can use, at the same time, <b>mplayer</b> for playback and <b>gnome-sound-recorder</b> for recording, without errors. The only thing that can get tricky are the mixer settings. Try un-muting all devices using <b>alsamixer</b> and set all the volumes to maximum to get started.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitris</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-642</link>
		<author>Dimitris</author>
		<pubDate>Fri, 08 May 2009 20:49:33 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-642</guid>
		<description>Any solution for me?</description>
		<content:encoded><![CDATA[<p>Any solution for me?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamil</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-638</link>
		<author>Kamil</author>
		<pubDate>Fri, 01 May 2009 11:44:16 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-638</guid>
		<description>Good question, lets try a few things... if I play music using &lt;b&gt;mplayer&lt;/b&gt; and then use say &lt;b&gt;play&lt;/b&gt; (a &lt;b&gt;sox&lt;/b&gt; based playback script) to play another audio file. Both play fine.

If I play music using &lt;b&gt;mplayer&lt;/b&gt; and the start &lt;b&gt;matlab&lt;/b&gt; and try to play any audio (even after &lt;b&gt;mplayer&lt;/b&gt; finished) it fails like so:
&lt;i&gt;
&gt;&gt; x=wavread('sp10.wav');
Warning: The playback thread did not start within one second. 
&gt; In audioplayer.playblocking at 35
  In audiovideo/private/playsnd at 16
  In sound at 46
  In soundsc at 48
&gt;&gt; Unable to open the audio device for playback: javax.sound.sampled.LineUnavailableException: Audio Device Unavailable
&lt;/i&gt;

To get it to work, I have to quit &lt;b&gt;matlab&lt;/b&gt; and start it again. On the other hand, if I start &lt;b&gt;matlab&lt;/b&gt; first and then try to play audio using &lt;b&gt;mplayer&lt;/b&gt;, then &lt;b&gt;mplayer&lt;/b&gt; fails to play &#8212; it simply sits there with the following prompt: &lt;i&gt;Starting playback...&lt;/i&gt;

Ok, so as mentioned previously it is &lt;b&gt;matlab&lt;/b&gt;'s java based playback libs that simply requires exclusive access to the audio device. A bit of googling confirms that this is a common problem, and that java and/or alsa are at fault for not handling these things nicely.

Alright, if I had to do it, then my hack would be as follows. I would create a &lt;b&gt;matlab&lt;/b&gt; wrapper function file called &lt;b&gt;&lt;a href="http://linux.dsplabs.com.au/files/p25-alsa/play.m" rel="follow" style="text-decoration: underline;" rel="nofollow"&gt;play.m&lt;/a&gt;&lt;/b&gt; somewhere in &lt;b&gt;matlab&lt;/b&gt;'s path. The content of &lt;b&gt;&lt;a href="http://linux.dsplabs.com.au/files/p25-alsa/play.m" rel="follow" style="text-decoration: underline;" rel="nofollow"&gt;play.m&lt;/a&gt;&lt;/b&gt; would be something like this:

&lt;b&gt;
% Saves audio data to a wav file before playback.
%
% audio     - audio samples
% fs        - sampling rate (Hz) [default: 8000]
% nbits     - precision (bits) [default: 16]
% wavfile   - filename for the wav file [default: '/tmp/tmp.wav']
%
% usage: play(audio, fs, nbits, wavfile)

function play(audio, fs, nbits, wavfile)

    % parse input arguments or use defaults
    switch(nargin)
        case 1, wavfile='/tmp/tmp.wav'; nbits=16; fs=8000;
        case 2, wavfile='/tmp/tmp.wav'; nbits=16; 
        case 3, wavfile='/tmp/tmp.wav';
        case 4,
        otherwise, error(sprintf('usage: play(audio, 8000, 16, ''/tmp/tmp.wav''\ntype: help play for further details...'));
    end

    % save audio to file, scale prior to writing to avoid clipping
    audio = 0.999*audio/max(abs(audio));
    wavwrite(audio, fs, nbits, wavfile);
    
    % playback the audio
    if(exist(wavfile, 'file'))
        syscmd = sprintf('mplayer %s', wavfile); % uses mplayer for playback
        %syscmd = sprintf('play %s', wavfile);   % uses sox play for playback
        system(syscmd);
    else
        error(sprintf('%s: file not found.', wavfile));
    end

% EOF
&lt;/b&gt;

In &lt;b&gt;matlab&lt;/b&gt;, help play gives the following:
&lt;i&gt;
&gt;&gt; help play
  Saves audio data to a wav file before playback.
 
  audio     - audio samples
  fs        - sampling rate (Hz) [default: 8000]
  nbits     - precision (bits) [default: 16]
  wavfile   - filename for the wav file [default: '/tmp/tmp.wav']
 
  usage: play(audio, fs, nbits, wavfile)
&lt;b&gt;Overloaded methods:
       audiorecorder/play
       audioplayer/play
&lt;/b&gt;&lt;/i&gt;
So make sure that your &lt;b&gt;&lt;a href="http://linux.dsplabs.com.au/files/p25-alsa/play.m" rel="follow" style="text-decoration: underline;" rel="nofollow"&gt;play.m&lt;/a&gt;&lt;/b&gt; is in the path before the other ones, or call it something else...

Ok, it is not pretty, but it works.

Kamil</description>
		<content:encoded><![CDATA[<p>Good question, lets try a few things&#8230; if I play music using <b>mplayer</b> and then use say <b>play</b> (a <b>sox</b> based playback script) to play another audio file. Both play fine.</p>
<p>If I play music using <b>mplayer</b> and the start <b>matlab</b> and try to play any audio (even after <b>mplayer</b> finished) it fails like so:<br />
<i><br />
>> x=wavread(&#039;sp10.wav&#039;);<br />
Warning: The playback thread did not start within one second.<br />
> In audioplayer.playblocking at 35<br />
  In audiovideo/private/playsnd at 16<br />
  In sound at 46<br />
  In soundsc at 48<br />
>> Unable to open the audio device for playback: javax.sound.sampled.LineUnavailableException: Audio Device Unavailable<br />
</i></p>
<p>To get it to work, I have to quit <b>matlab</b> and start it again. On the other hand, if I start <b>matlab</b> first and then try to play audio using <b>mplayer</b>, then <b>mplayer</b> fails to play &mdash; it simply sits there with the following prompt: <i>Starting playback&#8230;</i></p>
<p>Ok, so as mentioned previously it is <b>matlab</b>&#039;s java based playback libs that simply requires exclusive access to the audio device. A bit of googling confirms that this is a common problem, and that java and/or alsa are at fault for not handling these things nicely.</p>
<p>Alright, if I had to do it, then my hack would be as follows. I would create a <b>matlab</b> wrapper function file called <b><a href="http://linux.dsplabs.com.au/files/p25-alsa/play.m" rel="follow" style="text-decoration: underline;" rel="nofollow">play.m</a></b> somewhere in <b>matlab</b>&#039;s path. The content of <b><a href="http://linux.dsplabs.com.au/files/p25-alsa/play.m" rel="follow" style="text-decoration: underline;" rel="nofollow">play.m</a></b> would be something like this:</p>
<p><b><br />
% Saves audio data to a wav file before playback.<br />
%<br />
% audio     - audio samples<br />
% fs        - sampling rate (Hz) [default: 8000]<br />
% nbits     - precision (bits) [default: 16]<br />
% wavfile   - filename for the wav file [default: &#039;/tmp/tmp.wav&#039;]<br />
%<br />
% usage: play(audio, fs, nbits, wavfile)</p>
<p>function play(audio, fs, nbits, wavfile)</p>
<p>    % parse input arguments or use defaults<br />
    switch(nargin)<br />
        case 1, wavfile=&#039;/tmp/tmp.wav&#039;; nbits=16; fs=8000;<br />
        case 2, wavfile=&#039;/tmp/tmp.wav&#039;; nbits=16;<br />
        case 3, wavfile=&#039;/tmp/tmp.wav&#039;;<br />
        case 4,<br />
        otherwise, error(sprintf(&#039;usage: play(audio, 8000, 16, &#034;/tmp/tmp.wav&#034;\ntype: help play for further details&#8230;&#039;));<br />
    end</p>
<p>    % save audio to file, scale prior to writing to avoid clipping<br />
    audio = 0.999*audio/max(abs(audio));<br />
    wavwrite(audio, fs, nbits, wavfile);</p>
<p>    % playback the audio<br />
    if(exist(wavfile, &#039;file&#039;))<br />
        syscmd = sprintf(&#039;mplayer %s&#039;, wavfile); % uses mplayer for playback<br />
        %syscmd = sprintf(&#039;play %s&#039;, wavfile);   % uses sox play for playback<br />
        system(syscmd);<br />
    else<br />
        error(sprintf(&#039;%s: file not found.&#039;, wavfile));<br />
    end</p>
<p>% EOF<br />
</b></p>
<p>In <b>matlab</b>, help play gives the following:<br />
<i><br />
>> help play<br />
  Saves audio data to a wav file before playback.</p>
<p>  audio     - audio samples<br />
  fs        - sampling rate (Hz) [default: 8000]<br />
  nbits     - precision (bits) [default: 16]<br />
  wavfile   - filename for the wav file [default: &#039;/tmp/tmp.wav&#039;]</p>
<p>  usage: play(audio, fs, nbits, wavfile)<br />
<b>Overloaded methods:<br />
       audiorecorder/play<br />
       audioplayer/play<br />
</b></i><br />
So make sure that your <b><a href="http://linux.dsplabs.com.au/files/p25-alsa/play.m" rel="follow" style="text-decoration: underline;" rel="nofollow">play.m</a></b> is in the path before the other ones, or call it something else&#8230;</p>
<p>Ok, it is not pretty, but it works.</p>
<p>Kamil</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: theme</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-637</link>
		<author>theme</author>
		<pubDate>Fri, 01 May 2009 09:36:08 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-637</guid>
		<description>First of all,this post is awsome and i've learned great and useful things but, i wonder if there's any way to be able to work with matlab (playing sounds) and listening music with another program (f.i. firefox and streaming) without having to kill one of both.</description>
		<content:encoded><![CDATA[<p>First of all,this post is awsome and i&#039;ve learned great and useful things but, i wonder if there&#039;s any way to be able to work with matlab (playing sounds) and listening music with another program (f.i. firefox and streaming) without having to kill one of both.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dimitris</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-634</link>
		<author>Dimitris</author>
		<pubDate>Thu, 23 Apr 2009 17:10:36 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-634</guid>
		<description>Indeed it worked!
This means that i can't hear music at the same time that
i want to  speak with the microphone? 

I had this problem for a long time, and after i used the commands above
for the first time my aMSN closed alone, and when i reopened it (without music)
the recording and the camera, worked properly. But when i re opened music
i had again the same error "   Could not gain access to /dev/dsp for writing." .
Do i have to follow this procedure every time that i open the music?

PLz answer to my mail or here...
Thanks in advance</description>
		<content:encoded><![CDATA[<p>Indeed it worked!<br />
This means that i can&#039;t hear music at the same time that<br />
i want to  speak with the microphone? </p>
<p>I had this problem for a long time, and after i used the commands above<br />
for the first time my aMSN closed alone, and when i reopened it (without music)<br />
the recording and the camera, worked properly. But when i re opened music<br />
i had again the same error &#034;   Could not gain access to /dev/dsp for writing.&#034; .<br />
Do i have to follow this procedure every time that i open the music?</p>
<p>PLz answer to my mail or here&#8230;<br />
Thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamil</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-604</link>
		<author>Kamil</author>
		<pubDate>Wed, 21 Jan 2009 03:00:02 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-604</guid>
		<description>Kim, take a look at: &lt;a href="http://linux.dsplabs.com.au/no-volume-control-gstreamer-plugins-and-or-devices-found-no-sound-or-voume-control-bug-on-ubuntu-p31/" rel="nofollow"&gt;http://linux.dsplabs.com.au/no-volume-control-gstreamer-plugins-and-or-devices-found-no-sound-or-voume-control-bug-on-ubuntu-p31/&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Kim, take a look at: <a href="http://linux.dsplabs.com.au/no-volume-control-gstreamer-plugins-and-or-devices-found-no-sound-or-voume-control-bug-on-ubuntu-p31/" rel="nofollow">http://linux.dsplabs.com.au/no-volume-control-gstreamer-plugins-and-or-devices-found-no-sound-or-voume-control-bug-on-ubuntu-p31/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kim</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-603</link>
		<author>Kim</author>
		<pubDate>Tue, 20 Jan 2009 22:32:12 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-603</guid>
		<description>I have no idea what Im doing here, I keep getting "no volume control gstreamer plugins and or devices found" as an error message when I click on my speaker icon!! Can anyone explain in LAYMEN terms how I fix this pleeeease????</description>
		<content:encoded><![CDATA[<p>I have no idea what Im doing here, I keep getting &#034;no volume control gstreamer plugins and or devices found&#034; as an error message when I click on my speaker icon!! Can anyone explain in LAYMEN terms how I fix this pleeeease????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wallace Silva</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-580</link>
		<author>Wallace Silva</author>
		<pubDate>Thu, 04 Dec 2008 15:43:51 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-580</guid>
		<description>solution in my pc
i did have to install libsnack to alsa

# apt-get install libsnack2-alsa

and solved.

tks.</description>
		<content:encoded><![CDATA[<p>solution in my pc<br />
i did have to install libsnack to alsa</p>
<p># apt-get install libsnack2-alsa</p>
<p>and solved.</p>
<p>tks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cynthia</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-556</link>
		<author>cynthia</author>
		<pubDate>Tue, 28 Oct 2008 12:23:11 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-556</guid>
		<description>wow!  I've been searching the net to find solution to this problem.  My transcription software sometimes runs and sometimes not.  A hassle when transcription assignment arrives; but this article saved me!  Thanks a lot and more power for giving this support!</description>
		<content:encoded><![CDATA[<p>wow!  I&#039;ve been searching the net to find solution to this problem.  My transcription software sometimes runs and sometimes not.  A hassle when transcription assignment arrives; but this article saved me!  Thanks a lot and more power for giving this support!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: craig</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-542</link>
		<author>craig</author>
		<pubDate>Fri, 17 Oct 2008 17:40:05 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-542</guid>
		<description>Thanks a bunch, I always resorted to closing down every program, or even rebooting.  More uptime for me now!</description>
		<content:encoded><![CDATA[<p>Thanks a bunch, I always resorted to closing down every program, or even rebooting.  More uptime for me now!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miguel</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-294</link>
		<author>Miguel</author>
		<pubDate>Tue, 01 Jul 2008 22:11:02 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-294</guid>
		<description>Excellent!... It worked!...
I had to do one step more: locating the program lsof using the command: whereis.</description>
		<content:encoded><![CDATA[<p>Excellent!&#8230; It worked!&#8230;<br />
I had to do one step more: locating the program lsof using the command: whereis.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamil</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-260</link>
		<author>Kamil</author>
		<pubDate>Fri, 25 Apr 2008 03:20:47 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-260</guid>
		<description>what is the laptop model number and what is the sound card type? since your audio device is does not get detected by default it will be a fair bit trickier to get it to work... where I would start is googling to see if others have done it... for example I would search for "linux audio dell 9300 audigy sound blaster".</description>
		<content:encoded><![CDATA[<p>what is the laptop model number and what is the sound card type? since your audio device is does not get detected by default it will be a fair bit trickier to get it to work&#8230; where I would start is googling to see if others have done it&#8230; for example I would search for &#034;linux audio dell 9300 audigy sound blaster&#034;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-258</link>
		<author>Anonymous</author>
		<pubDate>Fri, 25 Apr 2008 01:03:02 +0000</pubDate>
		<guid>http://linux.dsplabs.com.au/lsof-grep-snd-how-to-free-a-linux-sound-device-p25/#comment-258</guid>
		<description>when i run this command:

cat /proc/asound/cards

the output is:

no soundcars

But i belive that i have sound card coz my laptop sound is working when i use windows

help me</description>
		<content:encoded><![CDATA[<p>when i run this command:</p>
<p>cat /proc/asound/cards</p>
<p>the output is:</p>
<p>no soundcars</p>
<p>But i belive that i have sound card coz my laptop sound is working when i use windows</p>
<p>help me</p>
]]></content:encoded>
	</item>
</channel>
</rss>
