Mercurial > hg > forks > pwpunix
view pwplib/snd-hpux.c @ 89:ea44e1d9eb7c default tip
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 25 May 2014 05:03:14 +0300 |
parents | 85671798fdb3 |
children |
line wrap: on
line source
#include "config.h" #ifdef DRIVE_HPUX #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/audio.h> #include "sound.h" struct { int fd; char buf[4096]; int buflgt; int freq; } pwp_hpuxsnd; static void hpuxsnd_loopflush(void) { for(;;) { struct audio_status bi; ioctl(pwp_hpuxsnd.fd, AUDIO_GET_STATUS, &bi); if (bi.transmit_exact_count > 3000)break; pwplib.player(); gb_genwave(pwp_hpuxsnd.buf, pwp_hpuxsnd.buflgt); write(pwp_hpuxsnd.fd, pwp_hpuxsnd.buf, pwp_hpuxsnd.buflgt); if (bi.transmit_buffer_count > 6000) break; } } static void hpuxsnd_restore(void) { close(pwp_hpuxsnd.fd); } int hpuxsnd_init(void) { pwp_hpuxsnd.fd = open("/dev/audio",O_WRONLY); if(pwp_hpuxsnd.fd<0)return 0; pwp_hpuxsnd.freq = 8000; pwp_hpuxsnd.buflgt = pwp_hpuxsnd.freq / TIMERHZ; ioctl(pwp_hpuxsnd.fd, AUDIO_SET_TXBUFSIZE, 2048); ioctl(pwp_hpuxsnd.fd, AUDIO_SET_SAMPLE_RATE, pwp_hpuxsnd.freq); ioctl(pwp_hpuxsnd.fd, AUDIO_SET_CHANNELS, AUDIO_CHANNEL_0|AUDIO_CHANNEL_1); ioctl(pwp_hpuxsnd.fd, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_LINEAR8BIT); pwpwrite("* HP-UX sound\n"); pwplib.sound = gb_sound; pwplib.loopflush = hpuxsnd_loopflush; gb_init(pwp_hpuxsnd.freq); pwplib_regdestr(hpuxsnd_restore); return 1; } #endif