Added a new source file, ss_song.c, to hold the old "event2" stream,
[ahxm.git] / out_sgi.c
blob77f8f733644e78f5b323bf4c6bed662a889b6c6b
1 /*
3 Ann Hell Ex Machina - Music Software
4 Copyright (C) 2003/2004 Angel Ortega <angel@triptico.com>
6 out_sgi.c - Output driver for SGI IRIX
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 http://www.triptico.com
26 #include "config.h"
27 #include <stdio.h>
28 #include "output.h"
30 #ifdef CONFOPT_SGI
32 #include <dmedia/audio.h>
33 #include "core.h"
35 /*******************
36 Data
37 ********************/
39 /* audio configuration */
40 static ALconfig ac;
42 /* audio port */
43 static ALport ap;
45 #ifndef SGI_BUFFER_SIZE
46 #define SGI_BUFFER_SIZE 2048
47 #endif
49 /*******************
50 Code
51 ********************/
53 static int _out_open_sgi(char * file)
55 ALpv p[2];
57 ac=alNewConfig();
59 if(!ac) return(-100);
61 if(alSetChannels(ac, _n_channels)==-1)
62 return(-101);
64 if(alSetWidth(ac, AL_SAMPLE_16)==-1)
65 return(-102);
67 if(alSetSampFmt(ac, AL_SAMPFMT_TWOSCOMP)==-1)
68 return(-103);
70 if(alSetQueueSize(ac, SGI_BUFFER_SIZE)==-1)
71 return(-104);
73 if(alSetDevice(ac, AL_DEFAULT_OUTPUT)==-1)
74 return(-105);
76 p[0].param=AL_MASTER_CLOCK;
77 p[0].value.i=AL_CRYSTAL_MCLK_TYPE;
78 p[1].param=AL_RATE;
79 p[1].value.ll=alDoubleToFixed((double)_frequency);
81 if(alSetParams(alGetDevice(ac), p, 2)==-1)
82 return(-106);
84 ap=alOpenPort("Ann Hell Ex Machina", "w", ac);
86 if(!ap) return(-107);
88 return(SGI_BUFFER_SIZE);
92 static int _out_write_sgi(short int * buffer, int size)
94 alWriteFrames(ap, buffer, size / _n_channels);
95 return(0);
99 static int _out_close_sgi(void)
101 alClosePort(ap);
102 alFreeConfig(ac);
104 return(0);
108 /* driver */
110 struct _output_driver _out_driver_sgi=
111 { "sgi", NULL, _out_open_sgi, _out_write_sgi, _out_close_sgi };
113 #else /* CONFOPT_SGI */
115 struct _output_driver _out_driver_sgi=
116 { "sgi", NULL, NULL, NULL, NULL };
118 #endif /* CONFOPT_SGI */