After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 160340 - [PATCH] gnome-sound-recorder can not play files
[PATCH] gnome-sound-recorder can not play files
Status: RESOLVED FIXED
Product: gnome-media
Classification: Deprecated
Component: Gnome-Sound-Recorder
unspecified
Other Linux
: Normal normal
: 2.9.91
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 146046 158925 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-12-03 12:51 UTC by Archana Shah
Modified: 2005-02-06 17:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch using the second approach (3.21 KB, patch)
2004-12-10 14:13 UTC, Archana Shah
none Details | Review
Patch which provides a generic solution (3.89 KB, patch)
2005-02-01 12:53 UTC, Archana Shah
accepted-commit_now Details | Review

Description Archana Shah 2004-12-03 12:51:52 UTC
Launch gnome-sound-recorder (Application->Multimedia->Sound Recorder)
Open some file and click on Play

Expected behaviour: it should play the file

Bug: It throws up an error dialog stating
"OSS device is already in use by another program"
Comment 1 Archana Shah 2004-12-03 13:02:11 UTC
I tried doing fuser /dev/dsp, but it does not show me any output.

Investigating further, I found out that esd is running on that machine.

To reproduce this problem:
1. Launch gnome-sound-properties (Application->Desktop Preferences->Sound)
2. Enable Sound server startup and Sound for events
This will launch esd (Esound Daemon)
Make sure that esd is running now(ps -ef | grep esd)

3. Launch Application->Multimedia->Sound Recorder and Open some file
4. Give any file name and click on Play
It gives the error.

esd has /dev/dsp opened in Write mode. So when gnome-sound-recorder tries to
open it in Write mode, he gets the EBUSY error and he throws up this dialog.
This is from gst-plugins/sys/oss/gstosselement.c (gst_osselement_open_audio). 

It should rather try again to open the device. So when esd releaves it, it will
get it and can play the file.
~
~

Comment 2 Archana Shah 2004-12-08 06:55:14 UTC
Ronald,

I can think of 2 ways to solve this bug.

If file opening fails and error is EBUSY then:

1. Find out the file that esd is going to play for a button click event.
Calculcate the time that this file will take to play. Do a sleep for that amount
of time + 1 second. After this time is over, try again to open the device.

2. Just put a timer of 4 seconds(emperical, 2 seconds of the click event sound +
2 seconds) and then try again to open the device, if it fails to open this time,
then throw up the error dialog.

Please suggest in case there can be any other way out.
Comment 3 Archana Shah 2004-12-10 14:13:19 UTC
Created attachment 34700 [details] [review]
Patch using the second approach

Attached is a patch which uses second approach mentioned above.

It keeps trying to get the device so that as soon as esd releases the device,
it gets it. If it does not get the device in 5 seconds, it times out and throws
up the error dialog.
Comment 4 Ronald Bultje 2004-12-10 14:46:36 UTC
Hm, so is esd launched on g-s-r startup then? Or is there another specific
reason that we'd want to wait 5 seconds instead of erroring out?

I'm not directly against the approach, but it's rather odd...
Comment 5 Archana Shah 2004-12-13 08:48:38 UTC
Ronald,

When we enable "Enable sound server startup" option in gnome-sound-properties
then esd is started. 

The problem mentioned in this bug report happens when the above option is
enabled along with "Sound for events" option in gnome-sound-properties

So when the "play button" is clicked, esd plays a wav file to indicate that
"play button" is clicked. During this time esd holds the audio device
(/dev/dsp). So when  g-s-r tries to open the audio device it gets EBUSY error
and hence this problem.

Since the wav files associated with the button click events are mostly around 2
to 3 seconds I am doing a wait for 5 seconds before erroring out. But if the
device is freed before 5 seconds g-s-r starts playing the file. 

Okay to commit with 5 second timeout ?

Ofcourse if we use esdsink instead of osssink, it becomes sequential as esd is
the one that services our request.
Comment 6 Ronald Bultje 2004-12-13 11:46:15 UTC
Ah, ok, I see. That's a really cool explanation for students on what a race
condition is. ;). Go ahead and apply if you've tested it, it seems fine to me.

Thanks!
Comment 7 Archana Shah 2004-12-20 13:55:23 UTC
Hi,

Sorry for late responding.
I do not have commit access. Could you please commit this patch.
Comment 8 Stephane Loeuillet 2004-12-22 12:32:59 UTC
*** Bug 146046 has been marked as a duplicate of this bug. ***
Comment 9 Stephane Loeuillet 2004-12-22 12:39:02 UTC
*** Bug 158925 has been marked as a duplicate of this bug. ***
Comment 10 Balamurali Viswanathan 2005-01-21 08:38:13 UTC
Moving this bug to gstreamer as the patch is for gst-plugins
Comment 11 Ronald Bultje 2005-01-21 10:07:59 UTC
Whoops... Right, forgot it's GStreamer... Ehm... Which reminds me, this is very
OSS specific. You could do a similar approach to g-s-r, in the state change from
NULL to READY (or PLAYING, in which case you can split it in two). Then, it'd
work for all of OSS, ALSA and SunAudio at once...

What do you think?
Comment 12 Ronald Bultje 2005-01-25 17:45:12 UTC
Archana, can you please tell me if you think my last comment is a better idea?
It'd work accross soundsystems...
Comment 13 Archana Shah 2005-01-27 09:19:10 UTC
Ronald, I am looing into how we can implement it in a generic way. Will update
the report in a day or two with the findings.
Comment 14 Ronald Bultje 2005-01-27 09:57:16 UTC
Thanks, I'll reopen the bug for the generic solution then.
Comment 15 Archana Shah 2005-02-01 12:51:38 UTC
Please review the attached patch for the generic solution.

Now, I have added a timeout function of 3 seconds if we encounter EBUSY error
while trying to get the device. This function will try to get the device again
and if we dont get it this time also, we will throw up the error dialog. You may
also want to test it.
 
Comment 16 Archana Shah 2005-02-01 12:53:34 UTC
Created attachment 36817 [details] [review]
Patch which provides a generic solution
Comment 17 Ronald Bultje 2005-02-01 15:09:36 UTC
Comment on attachment 36817 [details] [review]
Patch which provides a generic solution

Looks good, basically what I had in mind. Go ahead and apply, please.
Comment 18 Ronald Bultje 2005-02-06 17:32:39 UTC
I noticed this was applied, so closing bug...