Annotation of uae/src/sd-solaris/sound.c, revision 1.1.1.4

1.1       root        1:  /* 
                      2:   * UAE - The Un*x Amiga Emulator
                      3:   * 
                      4:   * Support for Solaris sound
                      5:   * 
                      6:   * Copyright 1996, 1997 Manfred Thole
                      7:   */
                      8: 
                      9: #include "sysconfig.h"
                     10: #include "sysdeps.h"
                     11: 
                     12: #include "config.h"
                     13: #include "options.h"
                     14: #include "memory.h"
1.1.1.3   root       15: #include "events.h"
1.1       root       16: #include "custom.h"
                     17: #include "audio.h"
                     18: #include "gensound.h"
                     19: #include "sounddep/sound.h"
                     20: 
                     21: #if !defined HAVE_SYS_AUDIOIO_H
                     22: 
                     23: /* SunOS 4.1.x */
                     24: #include <sys/ioctl.h>
                     25: #include <sun/audioio.h>
                     26: #ifndef AUDIO_ENCODING_LINEAR
                     27: #define AUDIO_ENCODING_LINEAR (3)
                     28: #endif
                     29: 
                     30: #else
                     31: 
                     32: /* SunOS 5.x/NetBSD */
                     33: #include <sys/audioio.h>
                     34: #ifdef HAVE_SYS_IOCTL_H
                     35: #include <sys/ioctl.h>
                     36: #endif
                     37: #endif
                     38: 
                     39: int sndbufsize;
                     40: int sound_fd;
                     41: static int have_sound;
                     42: uae_u16 sndbuffer[44100];
                     43: uae_u16 *sndbufpt;
                     44: 
                     45: void close_sound(void)
                     46: {
                     47:     if (have_sound)
                     48:        close(sound_fd);
                     49: }
                     50: 
                     51: int setup_sound(void)
                     52: {
                     53:     sound_fd = open ("/dev/audio", O_WRONLY);
                     54:     have_sound = !(sound_fd < 0);
                     55:     if (!have_sound)
                     56:       return 0;
                     57: 
                     58:     sound_available = 1;
                     59:     return 1;
                     60: }
                     61: 
                     62: int init_sound (void)
                     63: {
                     64:     int rate, dspbits;
                     65: 
                     66:     struct audio_info sfd_info;
                     67: 
                     68:     if (currprefs.sound_maxbsiz < 128 || currprefs.sound_maxbsiz > 44100) {
                     69:        fprintf(stderr, "Sound buffer size %d out of range.\n", currprefs.sound_maxbsiz);
                     70:        currprefs.sound_maxbsiz = 8192;
                     71:     }
                     72: 
                     73:     rate = currprefs.sound_freq;
                     74:     dspbits = currprefs.sound_bits;
                     75:     AUDIO_INITINFO(&sfd_info);
                     76:     sfd_info.play.sample_rate = rate;
                     77:     sfd_info.play.channels = 1;
                     78:     sfd_info.play.precision = dspbits;
                     79:     sfd_info.play.encoding = (dspbits == 8 ) ? AUDIO_ENCODING_ULAW : AUDIO_ENCODING_LINEAR;
                     80:     if (ioctl(sound_fd, AUDIO_SETINFO, &sfd_info)) {
                     81:        fprintf(stderr, "Can't use sample rate %d with %d bits, %s!\n", rate, dspbits, (dspbits ==8) ? "ulaw" : "linear");
                     82:        return 0;
                     83:     }
1.1.1.4 ! root       84:     scaled_sample_evtime = (unsigned long)MAXHPOS_PAL * MAXVPOS_PAL * VBLANK_HZ_PAL * CYCLE_UNIT / rate;
1.1.1.3   root       85:     scaled_sample_evtime_ok = 1;
1.1       root       86: 
                     87:     init_sound_table16 ();
                     88: 
1.1.1.2   root       89:     if (dspbits == 8)
                     90:        sample_handler = sample_ulaw_handler;
                     91:     else
                     92:        sample_handler = sample16_handler;
1.1       root       93: 
                     94:     sndbufpt = sndbuffer;
                     95:     sound_available = 1;
                     96:     sndbufsize = currprefs.sound_maxbsiz;
                     97:     printf ("Sound driver found and configured for %d bits, %s at %d Hz, buffer is %d bytes\n", dspbits, (dspbits ==8) ? "ulaw" : "linear", rate, sndbufsize);
                     98:     return 1;
                     99: }
                    100: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.