[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



Well, I posted my perl-Audio problem to Usenet, and I got this reply. IMO,
the only way to work around this problem while preserving all the
functionality of the audio device would be to use PerlXS.

	Shlomi Fish

>Date: 9 Jul 1997 08:32:42 -0000
>To: shlomi@slink.co.il
>Newsgroups: comp.os.linux.misc,comp.lang.perl
>From: pacman-will-proofread-your-bulk-mail-for-500-dollars@cqc.com
>X-planation-of-From-line: It's a real address. Send spam, please! I'll
bill you.
>Subject: Re: Failure to open the /dev/dsp character device with a perl script
>Organization: Internet In Your Pants
>X-Beavis: You will give me all your TP!
>
>In article <33c1e865.2584078@news.netvision.net.il>,
>Shlomi Fish <shlomi@slink.co.il> wrote:
>>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------
>



-----------------------------------------------------------------------------
Shlomi Fish                                Smart Link Ltd.
Home E-mail: shlomif@ibm.net               Work E-mail: shlomi@slink.co.il
Home Page: http://www.slink.co.il/~shlomi

The Bible dictates that "Thou shalt not seethe [=cook] a kid [= young goat]
in his mother's milk." To avoid possibility of breaking that regulation,
the Jewish tradition ruled that it also applies to female goats, to mature
goats, and to the meat and milk of two completely unrelated goats. It is
also forbidden to eat the meat with fresh milk, and it applies to beef and
mutten as well (including mixing the milk and meat of two different
beasts). Finally, chicken, which are incapable of milk production, may not
be eaten along with any mammal's milk either. 

We are fortunate that most mathematicians were not Jewish. Otherwise, it
would have been forbidden to divide by all numbers between -1 and 1.
-----------------------------------------------------------------------------


Follow-Ups: