src/audio/sun/SDL_sunaudio.c
branchSDL-1.2
changeset 6455 15c8ee21197b
parent 6137 4720145f848b
equal deleted inserted replaced
6411:ec7ccf5ee3dd 6455:15c8ee21197b
    45 #include "SDL_sunaudio.h"
    45 #include "SDL_sunaudio.h"
    46 
    46 
    47 /* Open the audio device for playback, and don't block if busy */
    47 /* Open the audio device for playback, and don't block if busy */
    48 #define OPEN_FLAGS	(O_WRONLY|O_NONBLOCK)
    48 #define OPEN_FLAGS	(O_WRONLY|O_NONBLOCK)
    49 
    49 
       
    50 #if defined(AUDIO_GETINFO) && !defined(AUDIO_GETBUFINFO) 
       
    51 #define AUDIO_GETBUFINFO AUDIO_GETINFO
       
    52 #endif
       
    53 
    50 /* Audio driver functions */
    54 /* Audio driver functions */
    51 static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec);
    55 static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec);
    52 static void DSP_WaitAudio(_THIS);
    56 static void DSP_WaitAudio(_THIS);
    53 static void DSP_PlayAudio(_THIS);
    57 static void DSP_PlayAudio(_THIS);
    54 static Uint8 *DSP_GetAudioBuf(_THIS);
    58 static Uint8 *DSP_GetAudioBuf(_THIS);
   117 };
   121 };
   118 
   122 
   119 #ifdef DEBUG_AUDIO
   123 #ifdef DEBUG_AUDIO
   120 void CheckUnderflow(_THIS)
   124 void CheckUnderflow(_THIS)
   121 {
   125 {
   122 #ifdef AUDIO_GETINFO
   126 #ifdef AUDIO_GETBUFINFO
   123 	audio_info_t info;
   127 	audio_info_t info;
   124 	int left;
   128 	int left;
   125 
   129 
   126 	ioctl(audio_fd, AUDIO_GETINFO, &info);
   130 	ioctl(audio_fd, AUDIO_GETBUFINFO, &info);
   127 	left = (written - info.play.samples);
   131 	left = (written - info.play.samples);
   128 	if ( written && (left == 0) ) {
   132 	if ( written && (left == 0) ) {
   129 		fprintf(stderr, "audio underflow!\n");
   133 		fprintf(stderr, "audio underflow!\n");
   130 	}
   134 	}
   131 #endif
   135 #endif
   132 }
   136 }
   133 #endif
   137 #endif
   134 
   138 
   135 void DSP_WaitAudio(_THIS)
   139 void DSP_WaitAudio(_THIS)
   136 {
   140 {
   137 #ifdef AUDIO_GETINFO
   141 #ifdef AUDIO_GETBUFINFO
   138 #define SLEEP_FUDGE	10		/* 10 ms scheduling fudge factor */
   142 #define SLEEP_FUDGE	10		/* 10 ms scheduling fudge factor */
   139 	audio_info_t info;
   143 	audio_info_t info;
   140 	Sint32 left;
   144 	Sint32 left;
   141 
   145 
   142 	ioctl(audio_fd, AUDIO_GETINFO, &info);
   146 	ioctl(audio_fd, AUDIO_GETBUFINFO, &info);
   143 	left = (written - info.play.samples);
   147 	left = (written - info.play.samples);
   144 	if ( left > fragsize ) {
   148 	if ( left > fragsize ) {
   145 		Sint32 sleepy;
   149 		Sint32 sleepy;
   146 
   150 
   147 		sleepy = ((left - fragsize)/frequency);
   151 		sleepy = ((left - fragsize)/frequency);