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.