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

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

unix.superglobalmegacorp.com

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