FreeBSD Bugzilla – Attachment 11656 Details for
Bug 22874
newpcm CS461x sound problems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
full-duplex-blocking-audio-test3.c
full-duplex-blocking-audio-test3.c (text/plain; charset=us-ascii), 3.14 KB, created by
oh
on 2000-11-19 11:45:56 UTC
(
hide
)
Description:
full-duplex-blocking-audio-test3.c
Filename:
MIME Type:
Creator:
oh
Created:
2000-11-19 11:45:56 UTC
Size:
3.14 KB
patch
obsolete
>#include <sys/soundcard.h> >#include <sys/ioctl.h> > >#include <fcntl.h> >#include <inttypes.h> >#include <stdio.h> >#include <sysexits.h> >#include <unistd.h> > >#define SAMPLE_BLKSZ 1024 > >#define AUDIO_IOCTL(fd, cmd, val) \ > if (ioctl((fd), (cmd), (val)) < 0) { \ > fprintf(stderr, "Failed %s - line %d\n",#cmd, __LINE__); \ > exit(EX_UNAVAILABLE); \ > } > > >static void progress() { > const char sym[]="-\\|/"; > static int n; > > int m = n % (sizeof(sym) - 1); > > if (n == 0) { > printf(" "); > } > printf("%c%c", '\b', sym[m]); > fflush(stdout); > > n++; >} > >int main(int argc, char *argv[]) >{ > char *thedev = "/dev/audio"; > uint16_t buf[SAMPLE_BLKSZ]; > int c, fd, rlen, wlen, rate = 8000; > > while((c = getopt(argc, argv, "f:r:")) != -1) { > switch(c) { > case 'f': > thedev = optarg; > break; > case 'r': > rate = atoi(optarg); > break; > default: > fprintf(stderr, > "%s -f flag specifies audio device to test.\n", > argv[0]); > exit(EX_USAGE); > } > } > > fd = open(thedev, O_RDWR); > if (fd > 0) { > snd_chan_param pa; > struct snd_size sz; > audio_buf_info abi; > snd_capabilities sc; > int fragsz; > > AUDIO_IOCTL(fd, AIOGCAP, &sc); > printf("Device Caps:\n\tSample rates: %d -- %d Hz\n", > sc.rate_min, sc.rate_max); > printf("\tFormats: 0x%08x\n\tDMA buffer size: %d bytes\n", > sc.formats, sc.bufsize); > printf("\tMixers: 0x%08x Inputs: 0x%08x\n", sc.mixers, sc.inputs); > printf("\tLevels: %d (left), %d (right)\n", sc.left, sc.right); > > pa.play_rate = rate; > pa.play_format = AFMT_S16_LE; > pa.rec_rate = rate; > pa.rec_format = AFMT_S16_LE; > AUDIO_IOCTL(fd, AIOSFMT, &pa); > fprintf(stdout, "Set play rate %d fmt %d\n", pa.play_rate, pa.play_format); > fprintf(stdout, "Set record rate %d fmt %d\n", pa.rec_rate, pa.rec_format); > AUDIO_IOCTL(fd, AIOGFMT, &pa); > fprintf(stdout, "Got play rate %d fmt %d\n", pa.play_rate, pa.play_format); > fprintf(stdout, "Got record rate %d fmt %d\n", pa.rec_rate, pa.rec_format); > > > /* Put device in block mode and set block size */ > sz.play_size = SAMPLE_BLKSZ; > sz.rec_size = SAMPLE_BLKSZ; > /* AUDIO_IOCTL(fd, AIOSSIZE, &sz); */ > AUDIO_IOCTL(fd, AIOGSIZE, &sz); > > fprintf(stdout, "Block size requested %d, play %d, rec %d\n", > SAMPLE_BLKSZ, sz.play_size, sz.rec_size); > > /* Set large number of fragment */ > fragsz = SAMPLE_BLKSZ; > AUDIO_IOCTL(fd, SNDCTL_DSP_SETFRAGMENT, &fragsz); > > AUDIO_IOCTL(fd, SNDCTL_DSP_GETOSPACE, &abi); > fprintf(stdout, > "Output buffer status: frags %d frags total %d fragsize %d bytes %d\n", > abi.fragments, abi.fragstotal, abi.fragsize, abi.bytes); > > > AUDIO_IOCTL(fd, SNDCTL_DSP_GETISPACE, &abi); > fprintf(stdout, > "Input buffer status: frags %d frags total %d fragsize %d bytes %d\n", > abi.fragments, abi.fragstotal, abi.fragsize, abi.bytes); > > > memset(buf, 0, sizeof(buf) / sizeof(buf[0])); > while((rlen = read(fd, buf, sizeof(buf))) > 0) { > fprintf(stderr, "Read %d\n", rlen); > progress(); > wlen = write(fd, buf, rlen); > if (wlen != rlen) { > fprintf(stderr, "write failed %d != %d\n", wlen, rlen); > exit(EX_IOERR); > } > } > } else { > fprintf(stderr, "Could not open %s O_RDWR\n", thedev); > exit(EX_OSFILE); > } > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 22874
: 11656