Re: [linux-audio-dev] I need help! I can't handle the problem about full-duplex (playback & record) programming

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] I need help! I can't handle the problem about full-duplex (playback & record) programming
From: Pascal Haakmat (a.haakmat_AT_chello.nl)
Date: Mon Dec 16 2002 - 15:52:01 EET


15/12/02 20:14, leo zhu wrote:

> Hi, Haakmat,
>
> I'm so glad to see your reply. But I'm still wondering
> how I can implement the full duplex operation on sound
> card, i.e. playback and record audio on the same card
> at same time. I don't think it's a good idea that
> reopen the device when switch between reading and
> writting, because I found it sometime took much time
> to open the device and that means the quality wouldn't
> be good. Do u have another solution to it? Anybody
> have experience with it ? I really need suggestion
> about it and I also believe there must be some tricks
> which I havn't understood.

I think you're confused. What I mean is that you can open /dev/dsp
twice, once for reading and once for writing, simultaneously. Then you
have one handle for reading and one handle for writing:

record_fd = open("/dev/dsp", O_RDONLY);
play_fd = open("/dev/dsp", O_WRONLY);

while(...) {
    r = read(record_fd, buf, count);
    store_recorded_bytes(buf, r);
    fill_playback_buffer(buf, count);
    write(play_fd, buf, count);
}

close(record_fd);
close(play_fd);

I.e. you don't need to close()/open() every time you switch between
reading and writing. The loop approach is crude but it works. You
might also look at ALSA which has a more sophisticated architecture.
In my experience the ALSA drivers are not as good as the (non-free)
OSS ones though.

Pascal.


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Mon Dec 16 2002 - 16:02:55 EET