]> git.lizzy.rs Git - plan9front.git/commitdiff
audio: fill up last buffer with silence on close
authorcinap_lenrek <cinap_lenrek@localhost>
Sun, 3 Jul 2011 04:33:13 +0000 (06:33 +0200)
committercinap_lenrek <cinap_lenrek@localhost>
Sun, 3 Jul 2011 04:33:13 +0000 (06:33 +0200)
sys/src/9/pc/audioac97.c

index 193d31e8af21f98bc2c0c455f729690b773e413a..e0732dd6b0a7a24eb6998e3e93d8d1df05075c88 100644 (file)
@@ -326,6 +326,20 @@ ac97write(Audio *adev, void *vp, long n, vlong)
        return p - (uchar*)vp;
 }
 
+static void
+ac97close(Audio *adev)
+{
+       Ctlr *ctlr;
+       Ring *ring;
+       uchar z[1];
+
+       z[0] = 0;
+       ctlr = adev->ctlr;
+       ring = &ctlr->outring;
+       while(ring->wi % Blocksize)
+               ac97write(adev, z, sizeof(z), 0);
+}
+
 static Pcidev*
 ac97match(Pcidev *p)
 {
@@ -499,6 +513,7 @@ Found:
        ac97mixreset(adev, ac97mixw, ac97mixr);
 
        adev->write = ac97write;
+       adev->close = ac97close;
        adev->buffered = ac97buffered;
        adev->status = ac97status;