static SDL_AudioDevice *Audio_CreateDevice(int devindex) { SDL_AudioDevice *this; if (LoadNASLibrary() < 0) { return NULL; } /* Initialize all variables that we clean on shutdown */ this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); if ( this ) { SDL_memset(this, 0, (sizeof *this)); this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc((sizeof *this->hidden)); } if ( (this == NULL) || (this->hidden == NULL) ) { SDL_OutOfMemory(); if ( this ) { SDL_free(this); } return NULL; } SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ this->OpenAudio = NAS_OpenAudio; this->WaitAudio = NAS_WaitAudio; this->PlayAudio = NAS_PlayAudio; this->GetAudioBuf = NAS_GetAudioBuf; this->CloseAudio = NAS_CloseAudio; this->free = Audio_DeleteDevice; return this; }
static int NAS_Init(SDL_AudioDriverImpl * impl) { if (LoadNASLibrary() < 0) { return 0; } else { AuServer *aud = NAS_AuOpenServer("", 0, NULL, 0, NULL, NULL); if (aud == NULL) { SDL_SetError("NAS: AuOpenServer() failed (no audio server?)"); return 0; } NAS_AuCloseServer(aud); } /* Set the function pointers */ impl->OpenDevice = NAS_OpenDevice; impl->PlayDevice = NAS_PlayDevice; impl->WaitDevice = NAS_WaitDevice; impl->GetDeviceBuf = NAS_GetDeviceBuf; impl->CloseDevice = NAS_CloseDevice; impl->Deinitialize = NAS_Deinitialize; impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: is this true? */ return 1; /* this audio target is available. */ }
static int Audio_Available(void) { if (LoadNASLibrary() == 0) { AuServer *aud = NAS_AuOpenServer("", 0, NULL, 0, NULL, NULL); if (!aud) { UnloadNASLibrary(); return 0; } NAS_AuCloseServer(aud); UnloadNASLibrary(); return 1; } return 0; }