[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Writing to /dev/dsp in Perl
At 07:56 PM 7/2/97 +0300, Alexander L. Belikoff wrote:
>Shlomi Fish <shlomi@slink.co.il> writes:
>
>>
>> Maybe I'll do some expereminting on it this evening and let you guys know
>> what happen later on. If not, maybe I should post the original message to
>> comp.lang.perl.misc or something.
>>
>> Shlomi Fish
>>
>>
>
>No, it's some crap with the sound driver. You actually have to try
>opening it TWICE *8-O . I had the same problem in C.
>
>Try to use some delay after the first (unsuccessful) attempt and try
>to open again.
Hmmm. It might work. I did some experimenting on it yesterday's evening and
here is my report:
The equivalent C code was successful in executing the open("/dev/dsp",
O_WRONLY) call, as I realized by debugging it with gdb. Also, a MOD tracker
that uses it runs prefectly smoothly.
"cat somefile.wav > /dev/dsp" from the shell worked too as well as "open
(AUDIO, '|cat > /dev/dsp')" in perl. However, the later syntax is not as
good as open(AUDIO, ">/dev/dsp") because I can't use ioctl() on the device.
I thought it might have to do with the effective/real user id premissions
stuff but POSIX::getuid(), POSIX::getgid() and POSIX::geteuid() all
returned the same user id: mine. Further more, when I tried to run the perl
script as root it didn't work either.
Finally, "open (O, '>/dev/cua3')" (My modem is on COM4) was successful.
Harvey Stein suggested that maybe the problem was caused by the fact that
the sound driver was loaded as a module. However, my sound card is a
ProAudio Spectrum 16 and its driver is hard-compiled in the kernel, and
initilized at the startup of Linux. So, unless I misunderstood Mr Stein's
remark, it can't be the cause. If someone here uses a SoundBlaster or some
other card, I ask him to test how the perl script runs with his sound card.
(make sure you have the valid file I/O permissions, first)
I'll try Alexander's suggestion to open it twice, but since the C code run
fine, I'm not sure if it is the problem. The only idea that I can think of
to figure what is really going on is to a debuggable perl interpreter with
gdb and see what happens on the perl open call. But that would be too much
time consuming to be worth the trouble, yet.
I'll let you guys know if there is any advancement.
Shlomi Fish
----------------------------------------------------------
Shlomi Fish Smart Link Ltd.
Home: shlomif@ibm.net
Work: shlomi@slink.co.il
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.
----------------------------------------------------------
References: