Date: Thu, 17 Feb 2000 05:11:51 -0500 From: "Thimble Smith" <tim@mysql.com> To: current@freebsd.org Subject: ViBRA16X and /dev/dsp Message-ID: <20000217051151.T2611@threads.polyesthetic.msg>
next in thread | raw e-mail | index | archive | help
Hi. I'm still trying to figure out why /dev/dsp isn't working with
my ViBRA16X card. I wrote a little program to test the device. The
trouble is, I don't know what I'm doing and have not found much in
the way of documentation. I'm hoping someone can give me a hint, so
I can figure out what's going wrong.
If I'm way off topic and just annoying everyone, please let me know
and I'll just shut up until either I learn more or someone else deals
with it. :)
Being optimistic, here's my program:
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define BUFSZ 1024
int
main()
{
int audio_fd;
unsigned char audio_buf[BUFSZ];
int format = AFMT_U8;
int speed = 8000;
ssize_t written;
if ((audio_fd = open("/dev/dsp", O_WRONLY, 0)) == -1) {
perror("/dev/dsp");
exit(EXIT_FAILURE);
}
if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format) == -1) {
perror("SETFMT");
exit(EXIT_FAILURE);
}
if (format != AFMT_U8) {
fprintf(stderr, "AFMT_U8 is unsupported (try 0x%02x)\n", format);
exit(EXIT_FAILURE);
}
if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &speed) == -1) {
perror("SPEED");
exit(EXIT_FAILURE);
}
if (speed != 8000)
fprintf(stderr, "warning: speed == %d\n", speed);
/* let's give this a shot! */
/* OK, so this doesn't seem to be doing what I want - I'm trying to
just play some tone - anything - to test if the thing is working
or not. I was hoping this simple thing might be close enough to
a sound file that it would play something. But obviously I'm
being naive.
What should I put into the buffer to get it to play? Do I need
to write the buffer many times to the device in order to hear
anything? */
memset(audio_buf, 0xaa, BUFSZ);
fprintf(stderr, "getting ready to write to the device\n");
written = write(audio_fd, audio_buf, BUFSZ);
if (written != BUFSZ)
fprintf(stderr, "only wrote %d of %d bytes\n", written, BUFSZ);
fprintf(stderr, "getting ready to close the device\n");
close(audio_fd);
fprintf(stderr, "Done.\n");
return EXIT_SUCCESS;
}
When I run the program, I hear a pop; just as if I'd done
$ echo "foo" > /dev/dsp; but I hear nothing that sounds like a tone.
There are no warnings printed, though.
Thanks for any help,
Tim
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000217051151.T2611>
