From owner-FreeBSD-tech-jp@jp.freebsd.org  Wed Nov 28 00:32:47 2001
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id AAA92727;
	Wed, 28 Nov 2001 00:32:47 +0900 (JST)
	(envelope-from owner-FreeBSD-tech-jp@jp.FreeBSD.org)
Received: from solder.dyndns.org (f194122.ap.plala.or.jp [202.212.194.122])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with SMTP id AAA92717
	for <FreeBSD-tech-jp@jp.freebsd.org>; Wed, 28 Nov 2001 00:32:46 +0900 (JST)
	(envelope-from t-ogawa@triaez.kaisei.org)
Received: (qmail 91266 invoked from network); 27 Nov 2001 15:32:15 -0000
Received: from localhost (HELO gandalf.middle.earth) (127.0.0.1)
  by localhost with SMTP; 27 Nov 2001 15:32:15 -0000
Date: Wed, 28 Nov 2001 00:32:15 +0900
Message-ID: <86bsho8c1s.wl.t-ogawa@triaez.kaisei.org>
From: OGAWA Takaya <t-ogawa@triaez.kaisei.org>
To: FreeBSD-users-jp@jp.freebsd.org
Cc: FreeBSD-tech-jp@jp.freebsd.org
In-Reply-To: <20011127.192731.71098974.yoshiaki@kt.rim.or.jp>
References: <011127140855.M0203975@psun0.phys.kyushu-u.ac.jp>
	<861yik7e6a.wl.t-ogawa@triaez.kaisei.org>
	<20011127.192731.71098974.yoshiaki@kt.rim.or.jp>
User-Agent: Wanderlust/2.7.6 (Too Funky) XEmacs/21.4 (Civil Service)
MIME-Version: 1.0 (generated by EMIKO 1.14.1 - "Choanoflagellata")
Content-Type: multipart/mixed;
 boundary="Multipart_Wed_Nov_28_00:32:15_2001-1"
Reply-To: FreeBSD-tech-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+010328
X-Sequence: FreeBSD-tech-jp 3238
Subject: [FreeBSD-tech-jp 3238] Re: [FreeBSD-users-jp 65838] Re: emiclock's "myu"-file for Luigi's new pcm driver?
Errors-To: owner-FreeBSD-tech-jp@jp.freebsd.org
Sender: owner-FreeBSD-tech-jp@jp.freebsd.org
X-Originator: t-ogawa@triaez.kaisei.org

--Multipart_Wed_Nov_28_00:32:15_2001-1
Content-Type: text/plain; charset=ISO-2022-JP

$B>.@n$G$9!#(B

$B$;$C$+$/$@$+$i>/$7D4$Y$F$_$^$7$?!#(B

At Tue, 27 Nov 2001 19:27:31 +0900 (JST),
uchikawa yoshiaki wrote:
> $B$?$H$($P$G$9$,(B myu.au$B$d(B myu.snd $B$N%U%!%$%k$r(B
> 
>  % cat myu.au myu.au > myu.au.tmp
> 
> $B$H$$$&$h$&$J6q9g$K$D$J$2$FBg$-$5$rA}$d$7$?$b$N$r;H$C$F$_$?$i$I$&$G$9$+(B?
> $BK\Ev$O%X%C%@$NItJ,$r:o=|$9$k$J$j$9$Y$-$G$9$,!"$"$C$F$b;(2;$K$J$kDxEY$G(B
> $B$9$N$G$"$s$^$j5$$K$7$J$/$F$b$$$$$O$:$G$9!#(B

$B3N$+$K!"$D$J$2$F$_$k$H:F@8$5$l$^$9!#(B
$B$?$@$D$J$2$?2s?tJ,$-$C$A$j:F@8$5$l$J$$$G8e$m$,$H$.$l$k(B
$B$h$&$J46$8$G$9$M!#(B

$B@0M}$9$k$H!"(B

1.emiclock $B$G(B myu.au $B$,:F@8$5$l$:!"(B
  ioctl(SNDCTL_DSP_SYNC) $B$G(B sleep() $B$7$?$^$^5/$-$F$3$J$$(B

  - pcm channel $B$K$O(B softbuf $B$H(B hardbuf $B$,$"$C$F!"(B
    softbuf $B$,(B hardbuf $B$N6u$-MFNL0J>e$KKd$^$i$J$$$H(B
    $B:F@8F0:n$,;O$^$i$J$$(B (CHN_F_TRIGGERED $B$,(B $BN)$?$J$$(B)

  - SNDCTL_DSP_SYNC $B$O(B softbuf $B$,$[$\40A4$K6u$/$^$GBT(B
    $B$D$@$1$G$"$j!":F@8F0:n$,%H%j%,$5$l$?$+$I$&$+$r8+$F(B
    $B$$$J$$(B

  - $B$h$C$F!"Hs>o$K>.$5$$2;@<%G!<%?$r:F@8$5$;$h$&$H$7$?(B
    $B>l9g!":F@8F0:n$,%H%j%,$5$l$J$$$^$^BT$A$KF~$C$F$7$^(B
    $B$$!"%G%C%I%m%C%/$K$J$k(B

$B$H$$$&LdBj$,$"$k$h$&$G$9!#(B

$B$=$l$+$i!"(B

2.cat myu.au myu.au myu.au > /dev/audio $B$O(B cat $B$7$?2s(B
  $B?tJ,$-$C$A$j:F@8$5$l$J$$(B

  - dsp_close() $B$O8F$P$l$?;~E@$G(B dma $B$r;_$a!"(Bsoftbuf
    $B$H(B hardbuf $B$K$"$k%P%C%U%!$NFbMF$rA4It<N$F$k!J!*!K(B

$B$H$$$&$N$b$"$k$_$?$$$G$9!#(B

$B2r7h:v$H$7$F$O!"A0<T(B(1.)$B$KBP$7$F(B

1-a. emiclock $B$,(B ioctl() $B$N(B API $B$r;H$&J}K!$,0-$$$N$G(B
     emiclock $B$rD>$9(B
1-b. $B%I%i%$%PB&$N(B SNDCTL_DSP_SYNC $B$N5sF0$,0-$$$N$GD>$9(B

$B8e<T(B(2.) $B$KBP$7$F(B

2-a. cat $B$J$s$+;H$&$N$,0-$$$N$G(B cat $B$O$"$-$i$a$k(B
2-b. $B%I%i%$%PB&$N(B close() $B;~$N5sF0$,0-$$$N$GD>$9(B

$B$H$$$&$N$,9M$($i$l$^$9$M!#(B

$B$R$H$^$:(B 1-b. $B$N%"%W%m!<%A$G!"(BSNDCTL_DSP_SYNC $B$,Mh$?$H(B
$B$-$K:F@8F0:n$,(B softbuf $B$N;D$j$rL52;$GKd$a$F6/@)E*$K:F(B
$B@8F0:n$r;O$a$5$;$k$h$&$K$7$F$_$^$7$?!J%Q%C%A$r$D$1$^$9!K(B
$B$,!"$3$l$@$H$"$?$j$^$($G$9$,L50UL#$K(Bsoftbuf$B$ND9$5J,$N(B
$BL52;$,A^F~$5$l$F$7$^$$$^$9!#(B

# $B!D$H$$$&OC$O$^$H$a$F(B -multimedia $B$KEj$2$?J}$,$$$$$N(B
# $B$+$J!#(B

----------
$B$*$,$o(B $B$?$+$d(B
t-ogawa@triaez.kaisei.org

--Multipart_Wed_Nov_28_00:32:15_2001-1
Content-Type: application/octet-stream; type=patch
Content-Disposition: attachment; filename="sndctl_dsp_sync.patch"
Content-Transfer-Encoding: 7bit

--- sys/dev/sound/pcm/buffer.h.orig	Tue Nov 27 23:47:35 2001
+++ sys/dev/sound/pcm/buffer.h	Tue Nov 27 23:47:47 2001
@@ -46,6 +46,7 @@
 void sndbuf_reset(struct snd_dbuf *b);
 void sndbuf_clear(struct snd_dbuf *b, unsigned int length);
 void sndbuf_fillsilence(struct snd_dbuf *b);
+void sndbuf_padsilence(struct snd_dbuf *b);
 
 u_int32_t sndbuf_getfmt(struct snd_dbuf *b);
 int sndbuf_setfmt(struct snd_dbuf *b, u_int32_t fmt);
--- sys/dev/sound/pcm/buffer.c.orig	Tue Nov 27 23:44:51 2001
+++ sys/dev/sound/pcm/buffer.c	Tue Nov 27 23:47:24 2001
@@ -218,6 +218,25 @@
 }
 
 void
+sndbuf_padsilence(struct snd_dbuf *b)
+{
+	int i;
+	u_char data, *p;
+
+	if (b->fmt & AFMT_SIGNED)
+		data = 0x00;
+	else
+		data = 0x80;
+
+	i = sndbuf_getfreeptr(b);
+	p = sndbuf_getbuf(b);
+	while (i < b->bufsize)
+		p[i++] = data;
+	b->rp = 0;
+	b->rl = b->bufsize;
+}
+
+void
 sndbuf_reset(struct snd_dbuf *b)
 {
 	b->hp = 0;
--- sys/dev/sound/pcm/channel.c.orig	Tue Nov 27 22:49:21 2001
+++ sys/dev/sound/pcm/channel.c	Tue Nov 27 23:48:17 2001
@@ -507,6 +507,10 @@
     	struct snd_dbuf *bs = c->bufsoft;
 
 	CHN_LOCKASSERT(c);
+	if (c->direction == PCMDIR_PLAY && !(c->flags & CHN_F_TRIGGERED)) {
+		sndbuf_padsilence(bs);
+		chn_start(c, 0);
+	}
     	for (;;) {
 		rdy = (c->direction == PCMDIR_PLAY)? sndbuf_getfree(bs) : sndbuf_getready(bs);
 		if (rdy <= threshold) {

--Multipart_Wed_Nov_28_00:32:15_2001-1--
