473,545 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't simultaneously read/write from ossaudio dsp device

For an internet telephone application, I need to be able to read and
write data to and from /dev/dsp simultaneously. I wrote some code and
its not working. Anyone have any working code to do this? I am
assuming my card is full duplex, it is a built-in sound card on a new
dell 600m laptop, but I am not sure how to tell for sure. But I think
the problem is not so much my sound card, but that I am making some
fundamentally wrong assumption on the way to do this ;) Also I am
definitely a newbie when it comes to audio coding, so any corrections
or tips are welcome.

Here is some test code that is failing for me
--------------------------------------------------------

from twisted.interne t.task import LoopingCall
from twisted.interne t import reactor
import os, sys, wave, audioop

"""
While playing the contents of test1.wav, talk into the mic
and have the audio recorded into /tmp/out.wav
"""

def playnlisten_out ():
audio = wavin.readframe s(1024)
stereoaudio = audioop.tostere o(audio, 2, 1, 1)
dsp.write(stere oaudio)

def playnlisten_in( ):
audio = dsp.read(640)
wavout.write(au dio)

def both():
playnlisten_out ()
playnlisten_in( )

dsp = ossaudiodev.ope n('/dev/dsp', 'rw')

wavin = wave.open("test 1.wav", "r")
wavout = wave.open("/tmp/out.wav", "w")

both_loop = LoopingCall(bot h)
both_loop.start (0.02)

reactor.run()

------------ Actual behavior ------------------------

It fails with an error:

dsp.write(stere oaudio)
exceptions.IOEr ror: [Errno 19] No such device

If I comment either playnlisten_out () or playnlisten_in( ) then the
other function will work. They just don't work at the same time.

------------ Sys info ------------------------
box:~# lsmod | grep -i audio
i810_audio 30356 1
ac97_codec 16908 1 i810_audio
soundcore 9824 3 snd,i810_audio
box:~# lsmod | grep -i snd
snd_pcm_oss 48168 0
snd_mixer_oss 16640 1 snd_pcm_oss
snd_intel8x0m 18632 0
snd_intel8x0 33068 0
snd_ac97_codec 59268 2 snd_intel8x0m,s nd_intel8x0
snd_pcm 85412 3 snd_pcm_oss,snd _intel8x0m,snd_ intel8x0
snd_timer 23172 1 snd_pcm
snd_page_alloc 11144 3 snd_intel8x0m,s nd_intel8x0,snd _pcm
gameport 4736 1 snd_intel8x0
snd_mpu401_uart 7296 1 snd_intel8x0
snd_rawmidi 23232 1 snd_mpu401_uart
snd_seq_device 7944 1 snd_rawmidi
snd 50148 10
snd_pcm_oss,snd _mixer_oss,snd_ intel8x0m,snd_i ntel8x0,snd_ac9 7_codec,snd_pcm ,snd_timer,snd_ mpu401_uart,snd _rawmidi,snd_se q_device
soundcore 9824 3 snd,i810_audio

box:~# lspci
0000:00:1f.5 Multimedia audio controller: Intel Corp. 82801DB/DBL/DBM
(ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 01)

box:~# uname -a
Linux box 2.6.7-1-386 #1 Thu Jul 8 05:08:04 EDT 2004 i686 GNU/Linux

Mar 13 '06 #1
1 2525
I got it working! There was another thread http://tinyurl.com/pebqc on
this group where someone had the same problem. I changed my code to
the following:

from twisted.interne t.task import LoopingCall
from twisted.interne t import reactor
import os, sys, wave, audioop

"""
While playing the contents of test1.wav, talk into the mic
and have the audio recorded into /tmp/out.wav
"""

def playnlisten_out ():
audio = wavin.readframe s(1024)
stereoaudio = audioop.tostere o(audio, 2, 1, 1)
dspout.write(st ereoaudio)

def playnlisten_in( ):
audio = dspin.read(640)
wavout.write(au dio)

def both():
playnlisten_out ()
playnlisten_in( )

dspout = ossaudiodev.ope n('/dev/dsp', 'w') # 2 file handles
dspin = ossaudiodev.ope n('/dev/dsp', 'r')

wavin = wave.open("test 1.wav", "r")
wavout = wave.open("/tmp/out.wav", "w")

both_loop = LoopingCall(bot h)
both_loop.start (0.02)

reactor.run()

and it worked as expected. I did not need to mess around with
/dev/mixer.

Mar 13 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3790
by: Scott Chapman | last post by:
Hi! I'd like a "file" on the Linux box to actually be the input and output of a Python script. Anything written to the file would be sent to a database and anything read from the file would come from the database. I know how to do the database end of this but I'm not sure if a script can be hooked to a "file" transparently. The script...
8
14750
by: collinm | last post by:
hi we use linux and c language under bash i do echo -e \\000\\000\\000\\000\000\\001Z00\\002AA LINUX \\004 >/dev/ttyS2 that send command to a led display (alpha sign communication)
7
4417
by: Ritu | last post by:
Hi All, Can any body please tell me how i can write a device driver using CSharp. Thanks, Ritu
0
6968
by: Taran | last post by:
I am having this issue with both Visual C++ 6.0 and Visual Studio 2005 Beta 2. I have the SDK and DDK installed. I am trying to write a program to retrieve the EDID for a specific monitor in a multi-monitor system. I already know how to get this information from the registry, but I wish to get the EDID from the monitor directly. So far I...
3
1875
by: Sean Liong via .NET 247 | last post by:
Hi, Is there any possibilities Read/Write a the storage file from a client system from a ASP.net web application? I think using the activeX component able to achieve this but is there any other ways? -------------------------------- From: Sean Liong ----------------------- Posted by a user from .NET 247 (http://www.dotnet247.com/)
10
1440
by: Rich | last post by:
Hello, I have to read and write around one million records from an external data source to Sql Server2k every night. That's a lot of I/O. I am using VB6 for this (takes hours). I am connecting to the external data source with API's from its object library (as opposed to ODBC in which case I would just use DTS to pull this data) and just...
1
1833
by: Siegfried Heintze | last post by:
I have some cygwin cron jobs running under the Administrator account populating a MSAccess database that is simultaneously being queried by IIS/ASP.NET/C#. If I manually use windows explorer to allow everyone to read/write/delete the .mdl files created by the cygwin cron jobs, everything works. If I don't, IIS/ASP.NET cannot open the...
3
1354
by: markclinn | last post by:
I have a device in the field that I access by the stream method. I open the Stream and do the following: 1. stream.write a character to the device. 2. stream.read the information from the device. The problem is that when I am debugging and step through the code there is a long enough pause that I recieve the entire string. If I just run...
6
4633
by: brianrpsgt1 | last post by:
I am new to scripting. I am trying to read the settings from a serial device using Python. I have been able to successfully connect to the device and change baud rate settings, ect... with PySerial. I am trying to send a command to the serial device and capture the returned info, however, it is not working. Code is below: import serial...
0
7669
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7439
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5987
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4962
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3468
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.