Exemple #1
0
static SDL_AudioDevice *Audio_CreateDevice(int devindex)
{
	SDL_AudioDevice *this;

	/* Initialize all variables that we clean on shutdown */
	LoadESDLibrary();
	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
	if ( this ) {
		memset(this, 0, (sizeof *this));
		this->hidden = (struct SDL_PrivateAudioData *)
				malloc((sizeof *this->hidden));
	}
	if ( (this == NULL) || (this->hidden == NULL) ) {
		SDL_OutOfMemory();
		if ( this ) {
			free(this);
		}
		return(0);
	}
	memset(this->hidden, 0, (sizeof *this->hidden));
	audio_fd = -1;

	/* Set the function pointers */
	this->OpenAudio = ESD_OpenAudio;
	this->WaitAudio = ESD_WaitAudio;
	this->PlayAudio = ESD_PlayAudio;
	this->GetAudioBuf = ESD_GetAudioBuf;
	this->CloseAudio = ESD_CloseAudio;

	this->free = Audio_DeleteDevice;

	return this;
}
Exemple #2
0
static int
ESD_Init(SDL_AudioDriverImpl * impl)
{
    if (LoadESDLibrary() < 0) {
        return 0;
    } else {
        int connection = 0;

        /* Don't start ESD if it's not running */
        SDL_setenv("ESD_NO_SPAWN", "1", 0);

        connection = SDL_NAME(esd_open_sound) (NULL);
        if (connection < 0) {
            UnloadESDLibrary();
            SDL_SetError("ESD: esd_open_sound failed (no audio server?)");
            return 0;
        }
        SDL_NAME(esd_close) (connection);
    }

    /* Set the function pointers */
    impl->OpenDevice = ESD_OpenDevice;
    impl->PlayDevice = ESD_PlayDevice;
    impl->WaitDevice = ESD_WaitDevice;
    impl->GetDeviceBuf = ESD_GetDeviceBuf;
    impl->CloseDevice = ESD_CloseDevice;
    impl->Deinitialize = ESD_Deinitialize;
    impl->OnlyHasDefaultOutputDevice = 1;

    return 1;   /* this audio target is available. */
}
Exemple #3
0
static int Audio_Available(void)
{
	int connection;
	int available;

	available = 0;
	if ( LoadESDLibrary() < 0 ) {
		return available;
	}
	connection = SDL_NAME(esd_open_sound)(NULL);
	if ( connection >= 0 ) {
		available = 1;
		SDL_NAME(esd_close)(connection);
	}
	UnloadESDLibrary();
	return(available);
}