src/audio/sun/SDL_sunaudio.c
changeset 6456 0a1bab689892
parent 6138 4c64952a58fb
child 6885 700f1b25f77f
equal deleted inserted replaced
6453:f71e3fdba072 6456:0a1bab689892
    51 #include "SDL_sunaudio.h"
    51 #include "SDL_sunaudio.h"
    52 
    52 
    53 /* Open the audio device for playback, and don't block if busy */
    53 /* Open the audio device for playback, and don't block if busy */
    54 #define OPEN_FLAGS	(O_WRONLY|O_NONBLOCK)
    54 #define OPEN_FLAGS	(O_WRONLY|O_NONBLOCK)
    55 
    55 
       
    56 #if defined(AUDIO_GETINFO) && !defined(AUDIO_GETBUFINFO) 
       
    57 #define AUDIO_GETBUFINFO AUDIO_GETINFO
       
    58 #endif
       
    59 
    56 /* Audio driver functions */
    60 /* Audio driver functions */
    57 static int DSP_OpenAudio(_THIS, SDL_AudioSpec * spec);
    61 static int DSP_OpenAudio(_THIS, SDL_AudioSpec * spec);
    58 static void DSP_WaitAudio(_THIS);
    62 static void DSP_WaitAudio(_THIS);
    59 static void DSP_PlayAudio(_THIS);
    63 static void DSP_PlayAudio(_THIS);
    60 static Uint8 *DSP_GetAudioBuf(_THIS);
    64 static Uint8 *DSP_GetAudioBuf(_THIS);
   127 
   131 
   128 #ifdef DEBUG_AUDIO
   132 #ifdef DEBUG_AUDIO
   129 void
   133 void
   130 CheckUnderflow(_THIS)
   134 CheckUnderflow(_THIS)
   131 {
   135 {
   132 #ifdef AUDIO_GETINFO
   136 #ifdef AUDIO_GETBUFINFO
   133     audio_info_t info;
   137     audio_info_t info;
   134     int left;
   138     int left;
   135 
   139 
   136     ioctl(audio_fd, AUDIO_GETINFO, &info);
   140     ioctl(audio_fd, AUDIO_GETBUFINFO, &info);
   137     left = (written - info.play.samples);
   141     left = (written - info.play.samples);
   138     if (written && (left == 0)) {
   142     if (written && (left == 0)) {
   139         fprintf(stderr, "audio underflow!\n");
   143         fprintf(stderr, "audio underflow!\n");
   140     }
   144     }
   141 #endif
   145 #endif
   143 #endif
   147 #endif
   144 
   148 
   145 void
   149 void
   146 DSP_WaitAudio(_THIS)
   150 DSP_WaitAudio(_THIS)
   147 {
   151 {
   148 #ifdef AUDIO_GETINFO
   152 #ifdef AUDIO_GETBUFINFO
   149 #define SLEEP_FUDGE	10      /* 10 ms scheduling fudge factor */
   153 #define SLEEP_FUDGE	10      /* 10 ms scheduling fudge factor */
   150     audio_info_t info;
   154     audio_info_t info;
   151     Sint32 left;
   155     Sint32 left;
   152 
   156 
   153     ioctl(audio_fd, AUDIO_GETINFO, &info);
   157     ioctl(audio_fd, AUDIO_GETBUFINFO, &info);
   154     left = (written - info.play.samples);
   158     left = (written - info.play.samples);
   155     if (left > fragsize) {
   159     if (left > fragsize) {
   156         Sint32 sleepy;
   160         Sint32 sleepy;
   157 
   161 
   158         sleepy = ((left - fragsize) / frequency);
   162         sleepy = ((left - fragsize) / frequency);