src/audio/paudio/SDL_paudio.c
changeset 1336 3692456e7b0f
parent 1312 c9b51268668f
child 1338 604d73db6802
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
    80 	return(available);
    80 	return(available);
    81 }
    81 }
    82 
    82 
    83 static void Audio_DeleteDevice(SDL_AudioDevice *device)
    83 static void Audio_DeleteDevice(SDL_AudioDevice *device)
    84 {
    84 {
    85 	free(device->hidden);
    85 	SDL_free(device->hidden);
    86 	free(device);
    86 	SDL_free(device);
    87 }
    87 }
    88 
    88 
    89 static SDL_AudioDevice *Audio_CreateDevice(int devindex)
    89 static SDL_AudioDevice *Audio_CreateDevice(int devindex)
    90 {
    90 {
    91 	SDL_AudioDevice *this;
    91 	SDL_AudioDevice *this;
    92 
    92 
    93 	/* Initialize all variables that we clean on shutdown */
    93 	/* Initialize all variables that we clean on shutdown */
    94 	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
    94 	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
    95 	if ( this ) {
    95 	if ( this ) {
    96 		memset(this, 0, (sizeof *this));
    96 		SDL_memset(this, 0, (sizeof *this));
    97 		this->hidden = (struct SDL_PrivateAudioData *)
    97 		this->hidden = (struct SDL_PrivateAudioData *)
    98 				malloc((sizeof *this->hidden));
    98 				SDL_malloc((sizeof *this->hidden));
    99 	}
    99 	}
   100 	if ( (this == NULL) || (this->hidden == NULL) ) {
   100 	if ( (this == NULL) || (this->hidden == NULL) ) {
   101 		SDL_OutOfMemory();
   101 		SDL_OutOfMemory();
   102 		if ( this ) {
   102 		if ( this ) {
   103 			free(this);
   103 			SDL_free(this);
   104 		}
   104 		}
   105 		return(0);
   105 		return(0);
   106 	}
   106 	}
   107 	memset(this->hidden, 0, (sizeof *this->hidden));
   107 	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   108 	audio_fd = -1;
   108 	audio_fd = -1;
   109 
   109 
   110 	/* Set the function pointers */
   110 	/* Set the function pointers */
   111 	this->OpenAudio = Paud_OpenAudio;
   111 	this->OpenAudio = Paud_OpenAudio;
   112 	this->WaitAudio = Paud_WaitAudio;
   112 	this->WaitAudio = Paud_WaitAudio;
   455 	mixlen = spec->size;
   455 	mixlen = spec->size;
   456 	mixbuf = (Uint8 *)SDL_AllocAudioMem(mixlen);
   456 	mixbuf = (Uint8 *)SDL_AllocAudioMem(mixlen);
   457 	if ( mixbuf == NULL ) {
   457 	if ( mixbuf == NULL ) {
   458 		return -1;
   458 		return -1;
   459 	}
   459 	}
   460 	memset(mixbuf, spec->silence, spec->size);
   460 	SDL_memset(mixbuf, spec->silence, spec->size);
   461 
   461 
   462 	/*
   462 	/*
   463 	 * Set some paramters: full volume, first speaker that we can find.
   463 	 * Set some paramters: full volume, first speaker that we can find.
   464 	 * Ignore the other settings for now.
   464 	 * Ignore the other settings for now.
   465 	 */
   465 	 */
   496 	    return -1;
   496 	    return -1;
   497 	}
   497 	}
   498 
   498 
   499         /* Check to see if we need to use select() workaround */
   499         /* Check to see if we need to use select() workaround */
   500         { char *workaround;
   500         { char *workaround;
   501                 workaround = getenv("SDL_DSP_NOSELECT");
   501                 workaround = SDL_getenv("SDL_DSP_NOSELECT");
   502                 if ( workaround ) {
   502                 if ( workaround ) {
   503                         frame_ticks = (float)(spec->samples*1000)/spec->freq;
   503                         frame_ticks = (float)(spec->samples*1000)/spec->freq;
   504                         next_frame = SDL_GetTicks()+frame_ticks;
   504                         next_frame = SDL_GetTicks()+frame_ticks;
   505                 }
   505                 }
   506         }
   506         }