Failure to open the /dev/dsp character device with a perl script

Failure to open the /dev/dsp character device with a perl script

Post by Shlomi Fi » Wed, 09 Jul 1997 04:00:00



I am running a Linux on a P166 with 16 MB RAM + 20-30MB swap. The
kernel version is 2.0.29. I have a ProAudio Spectrum 16 soundcard
installed and the kernel is compiled to support it. I have perl
version 5.002 or 5.003 installed on my system.

I have tried to write a perl script that will play digital audio by
using the /dev/dsp device. However, when I initiate the
open (AUDIO, ">/dev/dsp") it fails and $! (the perl error variable)
contains the text "operation not permitted".

The equivalent C code works in a perfect manner, and I have valid
permissions to perform that operation. sysopen() doesn't work either
and fails from the same reason. Moreover, opening "/dev/cua3" (my
modem's serial port) was successful in perl.

At the moment I have no clue why it happens and how to overcome it. I
posted the problem to the Israeli Linux UG mailing list, but none of
its members could come with any solution. One should try this code
with a sound card other than ProAudio Spectrum 16 (like SB/Pro/16).
Also, if one has the means to debug the perl interpreter and/or the
Linux kernel it may also prove fruitfull.

E-mail please.

        Shlomi Fish

 
 
 

Failure to open the /dev/dsp character device with a perl script

Post by pacman-will-proofread-your-bulk-mail-for-500-doll.. » Thu, 10 Jul 1997 04:00:00




>I have tried to write a perl script that will play digital audio by
>using the /dev/dsp device. However, when I initiate the
>open (AUDIO, ">/dev/dsp") it fails and $! (the perl error variable)
>contains the text "operation not permitted".

The problem seems to be that perl refuses to open files it cannot seek.
I don't know how to fix this, without hacking the perl source or hacking the
sound driver to allow seeks. I can suggest a workaround for it though:

  open(AUDIO, "|cat > /dev/dsp")

This isn't exactly elegant, and cat's internal buffering might cause some
problems, but it seems to work.

Linux kernel people: wouldn't ENOSYS be a better errno for seeking a sound
device? or maybe ESPIPE...

Perl people: why should perl barf on unseekable devices? (especially when
using sysopen!)

The details:

%strace perl -e 'open(AUDIO, ">/dev/dsp") or die $!; print AUDIO "foo" while(1);'
[...]
open("/dev/dsp", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFCHR|0660, st_rdev=makedev(14, 3), ...}) = 0
fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
fcntl(4, F_GETFL)                       = 0x1 (flags O_WRONLY)
fstat(4, {st_mode=S_IFCHR|0660, st_rdev=makedev(14, 3), ...}) = 0
mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40007000
ioctl(4, TCGETS, 0xbffffa20)            = -1 EINVAL (Invalid argument)
lseek(4, 0, SEEK_CUR)                   = -1 EPERM (Operation not permitted)
close(4)                                = 0

%perl -v

This is perl, version 5.003 with EMBED
        built under linux at Jun 27 1996 02:01:55
        + suidperl security patch
[...]

%uname -a
Linux londo 2.0.28 #1 Sat Jan 25 00:30:26 EST 1997 i486
--
Alan Curry
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d? s++:-- a-- C++ UB+++L++++ P+ L+++>++++ E--- W-- N++ o K? w--- O? M--
V? PS+ PE+ Y+ PGP-(--) t* 5++ X+++ R- tv++ b-- DI- D++ G+++ !e h! r-->+++ y?
------END GEEK CODE BLOCK------

 
 
 

Failure to open the /dev/dsp character device with a perl script

Post by Pavel Kouznetso » Fri, 11 Jul 1997 04:00:00


Hi!

Quote:> I have tried to write a perl script that will play digital audio by
> using the /dev/dsp device. However, when I initiate the
> open (AUDIO, ">/dev/dsp") it fails and $! (the perl error variable)
> contains the text "operation not permitted".

Try open(AUDIO, "+>/dev/dsp"). It opens the device and looks like you''ll
be able to write to it. The difference is that in this case perl doesn't
make lseek after open.

HTH

Pavel

 
 
 

1. device /dev/dsp can't be opened (No such device) (with onbaord via soundcard)

Hi there Ive been getting the abovementioned message for a long time
now. It pops up as soon as I Log in. Ive been getting it on Redhat
7.2, 7.3 and now 8.0 as well.

I have a on-board via soundcard, lspci lists the device as follows:
00:11.5 Multimedia audio controller: VIA Technologies, Inc. VT8233
AC97 Audio Controller (rev 30)

And my /etc/modules.conf file looks as follows:
alias parport_lowlevel parport_pc
alias eth0 3c59x
alias sound-slot-0 via82cxxx_audio
post-install sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -L
pre-remove sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -S
alias usb-controller usb-uhci

Can anyone help with this one?

Many Thanks

Derek Pienaar

2. Aix3.2, How and How much to upgrade from 3.1.5?

3. device /dev/dsp can't be opened (No such device) (with onbaord soundcard)

4. <?> Mysterious X errors in CDE <?>

5. sox: Can't open output file '/dev/dsp': No such device

6. curious: why does X turn text console red?

7. /dev/dsp cannot be opened: no such device

8. Question: NFS V3 for Linux?

9. Can't open /dev/dsp device busy!

10. /dev/dsp, /dev/audio, /dev/midi., /dev/sndsta

11. Execute a sh script under perl and sh: sh script; perl script?

12. sound applications can't open /dev/dsp initially when using KDE

13. Can't open /dev/dsp!