src/audio/pulseaudio/SDL_pulseaudio.c
changeset 6933 e56ed2eb139e
parent 6885 700f1b25f77f
child 6934 3ce238619067
equal deleted inserted replaced
6932:361bebe92c66 6933:e56ed2eb139e
   203     SDL_PULSEAUDIO_SYM(pa_strerror);
   203     SDL_PULSEAUDIO_SYM(pa_strerror);
   204     return 0;
   204     return 0;
   205 }
   205 }
   206 
   206 
   207 
   207 
       
   208 /* Check to see if we can connect to PulseAudio */
       
   209 static SDL_bool
       
   210 CheckPulseAudioAvailable()
       
   211 {
       
   212     pa_simple *s;
       
   213     pa_sample_spec ss;
       
   214 
       
   215     ss.format = PA_SAMPLE_S16NE;
       
   216     ss.channels = 1;
       
   217     ss.rate = 22050;
       
   218 
       
   219     s = PULSEAUDIO_pa_simple_new(NULL, "SDL", PA_STREAM_PLAYBACK, NULL,
       
   220                                  "Test", &ss, NULL, NULL, NULL);
       
   221     if (s) {
       
   222         PULSEAUDIO_pa_simple_free(s);
       
   223         return SDL_TRUE;
       
   224     } else {
       
   225         return SDL_FALSE;
       
   226     }
       
   227 }
       
   228 
   208 /* This function waits until it is possible to write a full sound buffer */
   229 /* This function waits until it is possible to write a full sound buffer */
   209 static void
   230 static void
   210 PULSEAUDIO_WaitDevice(_THIS)
   231 PULSEAUDIO_WaitDevice(_THIS)
   211 {
   232 {
   212     struct SDL_PrivateAudioData *h = this->hidden;
   233     struct SDL_PrivateAudioData *h = this->hidden;
   474 PULSEAUDIO_Deinitialize(void)
   495 PULSEAUDIO_Deinitialize(void)
   475 {
   496 {
   476     UnloadPulseAudioLibrary();
   497     UnloadPulseAudioLibrary();
   477 }
   498 }
   478 
   499 
   479 
       
   480 static int
   500 static int
   481 PULSEAUDIO_Init(SDL_AudioDriverImpl * impl)
   501 PULSEAUDIO_Init(SDL_AudioDriverImpl * impl)
   482 {
   502 {
   483     if (LoadPulseAudioLibrary() < 0) {
   503     if (LoadPulseAudioLibrary() < 0) {
       
   504         return 0;
       
   505     }
       
   506 
       
   507     if (!CheckPulseAudioAvailable()) {
   484         return 0;
   508         return 0;
   485     }
   509     }
   486 
   510 
   487     /* Set the function pointers */
   511     /* Set the function pointers */
   488     impl->OpenDevice = PULSEAUDIO_OpenDevice;
   512     impl->OpenDevice = PULSEAUDIO_OpenDevice;