From alsa-user-owner@alsa.jcu.cz  Mon Sep 14 20:21:39 1998
Received: from entry.jcu.cz (perex@entry.jcu.cz [160.217.1.111])
	by marvin.jcu.cz (8.8.8/8.8.8) with SMTP id UAA05364;
	Mon, 14 Sep 1998 20:19:36 +0200
Date: Mon, 14 Sep 1998 20:19:36 +0200 (MET DST)
From: Jaroslav Kysela <perex@jcu.cz>
To: harryrat@kawo1.rwth-aachen.de
cc: alsa-user@jcu.cz
Subject: Re: coding question
In-Reply-To: <Pine.LNX.3.96.980909195243.649B-100000@gambit.kawo1.rwth-aachen.de>
Message-ID: <Pine.LNX.3.96.980914201619.3911D-100000@entry.jcu.cz>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Reply-To: alsa-user@alsa.jcu.cz
Sender: alsa-user-owner@alsa.jcu.cz
Precedence: list

On Wed, 9 Sep 1998 harryrat@kawo1.rwth-aachen.de wrote:

> Hi there !
> 
> I'm new to ALSA sound programming ...ergh...actually new to sound
> programming at all (:
> 
> question is :
> 
> As doc said, I can open the same device for every direction simultaniously
> (Record & Playback)

If hardware supports this. If you have some simple chip (ESS1688 for
example) full duplex doesn't work, of course.

> What I now did was (after setting up devices) to record from PCM into a
> buffer and play the buffer after that...
> 
> 
>  snd_pcm_read(pcmRecordHandle, readbuffer, 80000);
>  snd_pcm_write(pcmPlaybackHandle, readbuffer, 80000);
>  snd_pcm_close(pcmPlaybackHandle);
>  snd_pcm_close(pcmRecordHandle);

Are you sure, that handles are valid? Soundcard?

> well...this way I get no output...but if I close the record direction
> before playback it works fine...
> 
>  snd_pcm_read(pcmRecordHandle, readbuffer, 80000); 
>  snd_pcm_close(pcmRecordHandle);  
>  snd_pcm_write(pcmPlaybackHandle, readbuffer, 80000);
>  snd_pcm_close(pcmPlaybackHandle);
>  
> 
> Is this the only way ?

No, both ways are correct.

> If yes, what's the advantage of being able to open one device in both
> directions ?

Two indenpended application can share same hardware (Speak Freely for
example).

						Jaroslav

-----
Jaroslav Kysela <perex@jcu.cz>
Academic Computer Centre, University of South Bohemia
Branisovska 31, C. Budejovice, CZ-370 05 Czech Republic


