From alsa-user-owner@alsa.jcu.cz  Mon Sep 21 12:25:21 1998
Received: from gambit.kawo1.rwth-aachen.de (harryrat@gambit.kawo1.RWTH-Aachen.DE [134.130.50.8])
	by marvin.jcu.cz (8.8.8/8.8.8) with ESMTP id MAA24935
	for <alsa-user@jcu.cz>; Mon, 21 Sep 1998 12:23:13 +0200
From: harryrat@kawo1.rwth-aachen.de
Received: from localhost (harryrat@localhost)
	by gambit.kawo1.rwth-aachen.de (8.8.8/8.8.8) with SMTP id MAA03574
	for <alsa-user@jcu.cz>; Mon, 21 Sep 1998 12:22:54 +0200
Date: Mon, 21 Sep 1998 12:22:54 +0200 (CEST)
To: alsa-user@jcu.cz
Subject: pcm programming
Message-ID: <Pine.LNX.3.96.980921121530.3556B-100000@gambit.kawo1.rwth-aachen.de>
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

Sorry to post again my question, but I'm stuck and won't make it on my own:

ok, my very first sound program shall record something from the microphone
and then play the contence of the record buffer.

record and playback device are the same...
According to ALSA doc it is possible to open a device once in both
directions...

here's the important piece of code:

readbuffer = (char *)malloc( 80000 );
printf("%d\n", snd_pcm_read(pcmRecordHandle, readbuffer, 80000));
snd_pcm_close(pcmRecordHandle);
sleep(5);
printf("-->%d\n", snd_pcm_write(pcmPlaybackHandle, readbuffer, 80000));
snd_pcm_close(pcmPlaybackHandle);

in this version it works, sound is recorded and played back after the 5
sec pause...

BUT: if I don't close the record handle before playback, no sound
is played, silence...

readbuffer = (char *)malloc( 80000 );
printf("%d\n", snd_pcm_read(pcmRecordHandle, readbuffer, 80000));
sleep(5);
printf("-->%d\n", snd_pcm_write(pcmPlaybackHandle, readbuffer, 80000));
snd_pcm_close(pcmRecordHandle);
snd_pcm_close(pcmPlaybackHandle);

both operations (read/write) are (according to return values) successfull, 
complete buffer is used...initialisation of direction (not shown)
seems also be ok, no errors...

Card is a GUS PNP, (so sound module is snd-interwave)

Any ideas what I am doin wrong ?

Do I always have to close one direction in order to be able to use the
other ?

Thx, for any help,
		
	Harry 


