Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Mar 2001 18:27:26 +0900
From:      Mamoru Iwaki <iwaki@bc.niigata-u.ac.jp>
To:        freebsd-stable@FreeBSD.ORG
Subject:   how to use sound device in full-duplex ?
Message-ID:  <20010319092728.5637.qmail@pikachu.bsp.bc.niigata-u.ac.jp>
In-Reply-To: <20010224181126K.iwaki@bc.niigata-u.ac.jp>
References:  <20010224181126K.iwaki@bc.niigata-u.ac.jp>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi, 

I'd like to know the way how I can use sound device in full-duplex.  

I want to input sound stream with audio device and immediately
output the stream into the same audio device for playback, without
waiting for the end of input stream.  I mean, it should simply make
echoback of input, as fast as possible.  For the purpose, I wrote
the following program.  

From: Mamoru Iwaki <iwaki@bc.niigata-u.ac.jp>
Subject: sound driver kills kernel silently
Date: Sat, 24 Feb 2001 18:11:26 +0900

> [PROGRAM]
> #include <stdio.h>
> #include <fcntl.h>
> #include <sys/types.h>
> #include <sys/uio.h>
> #include <unistd.h>
> 
> #define DEV_IN	"/dev/dsp"
> #define DEV_OUT	DEV_IN
> #define BUFLEN	1
> 
> int main(void) {
>  int fdi, fdo;
>  char x[BUFLEN];
> 
>  if ((fdi = open(DEV_IN, O_RDONLY)) == -1) {
>     perror("File open failure for read: " DEV_IN);
>     exit(1);
>  }
> 
>  if ((fdo = open(DEV_IN, O_WRONLY)) == -1) {
>     perror("File open failure for write: " DEV_IN);
>     exit(1);
>  }
> 
>  while (read(fdi, &x, sizeof(x)) > 0) write(fdo, &x, sizeof(x));
> 
>  return 0;
> }

It has worked the last December, but not for now.  It causes the
following messages and no sound:

pcm0: record overrun, dumping 8128 bytes
pcm0: record overrun, dumping 8100 bytes
pcm0: record overrun, dumping 8076 bytes

When audio device is opened in read-write mode, it still not works.  

Are there any ideas to make the above simple echoback audio program
with full-duplex property.  

Thanks.

[ENVIRONMENT]
% uname -a
FreeBSD mi000.merlin.gs.niigata-u.ac.jp 4.3-BETA FreeBSD 4.3-BETA #0: Mon Mar 19 16:32:24 JST 2001     root@mi000.merlin.gs.niigata-u.ac.jp:/usr/obj/amd/mi004/home2/FreeBSD-src/stable4/src/sys/MI  i386

% cat /dev/sndstat 
FreeBSD Audio Driver (newpcm) Mar 19 2001 16:30:59
Installed devices:
pcm0: <SB16 DSP 4.16> at io 0x220 irq 5 drq 1:5 (1p/1r channels duplex)
---
-----
Mamoru IWAKI   (iwaki@bc.niigata-u.ac.jp)
Graduate School of Science and Technology, Niigata University

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010319092728.5637.qmail>