src/audio/dma/SDL_dmaaudio.c
changeset 1336 3692456e7b0f
parent 1312 c9b51268668f
child 1338 604d73db6802
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
    91 	return(available);
    91 	return(available);
    92 }
    92 }
    93 
    93 
    94 static void Audio_DeleteDevice(SDL_AudioDevice *device)
    94 static void Audio_DeleteDevice(SDL_AudioDevice *device)
    95 {
    95 {
    96 	free(device->hidden);
    96 	SDL_free(device->hidden);
    97 	free(device);
    97 	SDL_free(device);
    98 }
    98 }
    99 
    99 
   100 static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   100 static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   101 {
   101 {
   102 	SDL_AudioDevice *this;
   102 	SDL_AudioDevice *this;
   103 
   103 
   104 	/* Initialize all variables that we clean on shutdown */
   104 	/* Initialize all variables that we clean on shutdown */
   105 	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
   105 	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   106 	if ( this ) {
   106 	if ( this ) {
   107 		memset(this, 0, (sizeof *this));
   107 		SDL_memset(this, 0, (sizeof *this));
   108 		this->hidden = (struct SDL_PrivateAudioData *)
   108 		this->hidden = (struct SDL_PrivateAudioData *)
   109 				malloc((sizeof *this->hidden));
   109 				SDL_malloc((sizeof *this->hidden));
   110 	}
   110 	}
   111 	if ( (this == NULL) || (this->hidden == NULL) ) {
   111 	if ( (this == NULL) || (this->hidden == NULL) ) {
   112 		SDL_OutOfMemory();
   112 		SDL_OutOfMemory();
   113 		if ( this ) {
   113 		if ( this ) {
   114 			free(this);
   114 			SDL_free(this);
   115 		}
   115 		}
   116 		return(0);
   116 		return(0);
   117 	}
   117 	}
   118 	memset(this->hidden, 0, (sizeof *this->hidden));
   118 	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   119 	audio_fd = -1;
   119 	audio_fd = -1;
   120 
   120 
   121 	/* Set the function pointers */
   121 	/* Set the function pointers */
   122 	this->OpenAudio = DMA_OpenAudio;
   122 	this->OpenAudio = DMA_OpenAudio;
   123 	this->WaitAudio = DMA_WaitAudio;
   123 	this->WaitAudio = DMA_WaitAudio;
   426 	if ( dma_buf == MAP_FAILED ) {
   426 	if ( dma_buf == MAP_FAILED ) {
   427 		SDL_SetError("DMA memory map failed");
   427 		SDL_SetError("DMA memory map failed");
   428 		dma_buf = NULL;
   428 		dma_buf = NULL;
   429 		return(-1);
   429 		return(-1);
   430 	}
   430 	}
   431 	memset(dma_buf, spec->silence, dma_len);
   431 	SDL_memset(dma_buf, spec->silence, dma_len);
   432 
   432 
   433 	/* Check to see if we need to use select() workaround */
   433 	/* Check to see if we need to use select() workaround */
   434 	{ char *workaround;
   434 	{ char *workaround;
   435 		workaround = getenv("SDL_DSP_NOSELECT");
   435 		workaround = SDL_getenv("SDL_DSP_NOSELECT");
   436 		if ( workaround ) {
   436 		if ( workaround ) {
   437 			frame_ticks = (float)(spec->samples*1000)/spec->freq;
   437 			frame_ticks = (float)(spec->samples*1000)/spec->freq;
   438 			next_frame = SDL_GetTicks()+frame_ticks;
   438 			next_frame = SDL_GetTicks()+frame_ticks;
   439 		}
   439 		}
   440 	}
   440 	}