src/audio/dmedia/SDL_irixaudio.c
changeset 903 6e6248801043
parent 605 6399f4e90211
child 1312 c9b51268668f
equal deleted inserted replaced
902:99f439d6ee4a 903:6e6248801043
    26 static char rcsid =
    26 static char rcsid =
    27  "@(#) $Id$";
    27  "@(#) $Id$";
    28 #endif
    28 #endif
    29 
    29 
    30 /* Allow access to a raw mixing buffer (For IRIX 6.5 and higher) */
    30 /* Allow access to a raw mixing buffer (For IRIX 6.5 and higher) */
       
    31 /* patch for IRIX 5 by Georg Schwarz 18/07/2004 */
    31 
    32 
    32 #include <stdlib.h>
    33 #include <stdlib.h>
    33 
    34 
    34 #include "SDL_endian.h"
    35 #include "SDL_endian.h"
    35 #include "SDL_timer.h"
    36 #include "SDL_timer.h"
    37 #include "SDL_audiomem.h"
    38 #include "SDL_audiomem.h"
    38 #include "SDL_audio_c.h"
    39 #include "SDL_audio_c.h"
    39 #include "SDL_irixaudio.h"
    40 #include "SDL_irixaudio.h"
    40 
    41 
    41 
    42 
       
    43 #ifndef AL_RESOURCE /* as a test whether we use the old IRIX audio libraries */
       
    44 #define OLD_IRIX_AUDIO
       
    45 #define alClosePort(x) ALcloseport(x)
       
    46 #define alFreeConfig(x) ALfreeconfig(x)
       
    47 #define alGetFillable(x) ALgetfillable(x)
       
    48 #define alNewConfig() ALnewconfig()
       
    49 #define alOpenPort(x,y,z) ALopenport(x,y,z)
       
    50 #define alSetChannels(x,y) ALsetchannels(x,y)
       
    51 #define alSetQueueSize(x,y) ALsetqueuesize(x,y)
       
    52 #define alSetSampFmt(x,y) ALsetsampfmt(x,y)
       
    53 #define alSetWidth(x,y) ALsetwidth(x,y)
       
    54 #endif
       
    55 
    42 /* Audio driver functions */
    56 /* Audio driver functions */
    43 static int AL_OpenAudio(_THIS, SDL_AudioSpec *spec);
    57 static int AL_OpenAudio(_THIS, SDL_AudioSpec *spec);
    44 static void AL_WaitAudio(_THIS);
    58 static void AL_WaitAudio(_THIS);
    45 static void AL_PlayAudio(_THIS);
    59 static void AL_PlayAudio(_THIS);
    46 static Uint8 *AL_GetAudioBuf(_THIS);
    60 static Uint8 *AL_GetAudioBuf(_THIS);
   135 }
   149 }
   136 
   150 
   137 static int AL_OpenAudio(_THIS, SDL_AudioSpec *spec)
   151 static int AL_OpenAudio(_THIS, SDL_AudioSpec *spec)
   138 {
   152 {
   139 	ALconfig audio_config;
   153 	ALconfig audio_config;
       
   154 #ifdef OLD_IRIX_AUDIO
       
   155 	long audio_param[2];
       
   156 #else
   140 	ALpv audio_param;
   157 	ALpv audio_param;
       
   158 #endif
   141 	int width;
   159 	int width;
   142 
   160 
   143 	/* Determine the audio parameters from the AudioSpec */
   161 	/* Determine the audio parameters from the AudioSpec */
   144 	switch ( spec->format & 0xFF ) {
   162 	switch ( spec->format & 0xFF ) {
   145 
   163 
   163 
   181 
   164 	/* Update the fragment size as size in bytes */
   182 	/* Update the fragment size as size in bytes */
   165 	SDL_CalculateAudioSpec(spec);
   183 	SDL_CalculateAudioSpec(spec);
   166 
   184 
   167 	/* Set output frequency */
   185 	/* Set output frequency */
       
   186 #ifdef OLD_IRIX_AUDIO
       
   187 	audio_param[0] = AL_OUTPUT_RATE;
       
   188 	audio_param[1] = spec->freq;
       
   189 	if( ALsetparams(AL_DEFAULT_DEVICE, audio_param, 2) < 0 ) {
       
   190 #else
   168 	audio_param.param = AL_RATE;
   191 	audio_param.param = AL_RATE;
   169 	audio_param.value.i = spec->freq;
   192 	audio_param.value.i = spec->freq;
   170 	if( alSetParams(AL_DEFAULT_OUTPUT, &audio_param, 1) < 0 ) {
   193 	if( alSetParams(AL_DEFAULT_OUTPUT, &audio_param, 1) < 0 ) {
       
   194 #endif
   171 		SDL_SetError("alSetParams failed");
   195 		SDL_SetError("alSetParams failed");
   172 		return(-1);
   196 		return(-1);
   173 	}
   197 	}
   174 
   198 
   175 	/* Open the audio port with the requested frequency */
   199 	/* Open the audio port with the requested frequency */