From alsa-devel-owner@alsa.jcu.cz  Sat Oct 17 22:29:15 1998
Received: from sandy.force9.co.uk (root@197.hiper01.shef.dialup.force9.net [195.166.142.197])
	by marvin.jcu.cz (8.9.1a/8.9.1) with ESMTP id WAA07027
	for <alsa-devel@jcu.cz>; Sat, 17 Oct 1998 22:29:06 +0200
Received: (from chrisb@localhost)
	by sandy.force9.co.uk (8.8.5/8.8.5) id VAA11205
	for alsa-devel@jcu.cz; Sat, 17 Oct 1998 21:26:59 +0100
From: Chris Butler <chrisb@sandy.force9.co.uk>
Message-Id: <199810172026.VAA11205@sandy.force9.co.uk>
Subject: pchn -> voices == 0 - bug resolved
To: alsa-devel@jcu.cz
Date: Sat, 17 Oct 1998 21:26:59 +0100 (BST)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=ELM908656019-11200-0_
Content-Transfer-Encoding: 7bit
Reply-To: alsa-devel@alsa.jcu.cz
Sender: alsa-devel-owner@alsa.jcu.cz
Precedence: list


--ELM908656019-11200-0_
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Hi!

I've tracked down the bug that caused pchn -> voices to be zero.

The structure is allocated with (snd_)calloc, which causes everything
to be zeroed out, and the playback & record channels are not
initialised in snd_pcm1_new_device. This is why it only oopses when
the first application to use the device tries to use it without
setting the channels (like Quake does).

The patch below resolves this (it calls snd_pcm1_clear_channel from
snd_pcm1_new_device).

It also removes some un-needed debugging code from lowlevel/sb/sb8.c

Chris Butler
<chrisb@sandy.force9.co.uk>

PS: Jaroslav - is it possible for me to have write access to CVS? If
    so, should I put alsa-lib++ in there as well?


--ELM908656019-11200-0_
Content-Type: text/plain
Content-Disposition: inline; filename="/tmp/alsa-pcm1_native.patch"
Content-Transfer-Encoding: 7bit

Index: kernel/pcm1/pcm1_native.c
===================================================================
RCS file: /home/alsa/cvsroot/alsa-driver/kernel/pcm1/pcm1_native.c,v
retrieving revision 1.10
diff -u -r1.10 pcm1_native.c
--- pcm1_native.c	1998/09/15 09:12:01	1.10
+++ pcm1_native.c	1998/10/17 20:20:27
@@ -1878,6 +1878,8 @@
   pcm1 -> flags = SND_PCM1_LFLG_NONE;
   pcm1 -> card = card;
   pcm1 -> pcm = pcm;
+  snd_pcm1_clear_channel( &pcm1 -> playback );
+  snd_pcm1_clear_channel( &pcm1 -> record );
   snd_sleep_prepare( pcm1, playback );
   snd_sleep_prepare( pcm1, record );
   snd_mutex_prepare( pcm1, open );
@@ -1942,5 +1944,4 @@
 {
   snd_pcm_notify( &snd_pcm1_notify, 1 );
   snd_control_unregister_ioctl( snd_pcm1_control_ioctl );
-}
- 
\ No newline at end of file
+} 
Index: lowlevel/sb/sb8.c
===================================================================
RCS file: /home/alsa/cvsroot/alsa-driver/lowlevel/sb/sb8.c,v
retrieving revision 1.2
diff -u -r1.2 sb8.c
--- sb8.c	1998/08/25 15:35:45	1.2
+++ sb8.c	1998/10/17 20:20:27
@@ -86,9 +86,6 @@
         }
       }
       pchn -> real_rate = (256000000 / (65536 - (codec -> speed8 << 8))) / pchn -> voices;
-#if 0
-      snd_printd( "snd_sb8_compute_rate: rate = %u, pchn->real_rate = %u\n", rate, pchn->real_rate );
-#endif
       break;
     default:
       snd_printd( "unknown hardware for sb8 compute rate!!!\n" );

--ELM908656019-11200-0_
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit



--ELM908656019-11200-0_--

