Fixed debug code to print correct values SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Tue, 13 Oct 2009 09:24:05 +0000
branchSDL-1.2
changeset 4331a24454ed4ac4
parent 4330 33570eec2d4f
child 4332 67e799ffcadf
Fixed debug code to print correct values
Passed a meaningful value to snd_pcm_sw_params_set_start_threshold()
src/audio/alsa/SDL_alsa_audio.c
     1.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Tue Oct 13 08:42:40 2009 +0000
     1.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Tue Oct 13 09:24:05 2009 +0000
     1.3 @@ -59,7 +59,6 @@
     1.4  static void *alsa_handle = NULL;
     1.5  static int alsa_loaded = 0;
     1.6  
     1.7 -static int (*SDL_snd_pcm_open)(snd_pcm_t **pcm, const char *name, snd_pcm_stream_t stream, int mode);
     1.8  static int (*SDL_NAME(snd_pcm_open))(snd_pcm_t **pcm, const char *name, snd_pcm_stream_t stream, int mode);
     1.9  static int (*SDL_NAME(snd_pcm_close))(snd_pcm_t *pcm);
    1.10  static snd_pcm_sframes_t (*SDL_NAME(snd_pcm_writei))(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size);
    1.11 @@ -73,12 +72,13 @@
    1.12  static int (*SDL_NAME(snd_pcm_hw_params_set_access))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t access);
    1.13  static int (*SDL_NAME(snd_pcm_hw_params_set_format))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val);
    1.14  static int (*SDL_NAME(snd_pcm_hw_params_set_channels))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int val);
    1.15 +static int (*SDL_NAME(snd_pcm_hw_params_get_channels))(const snd_pcm_hw_params_t *params, unsigned int *val);
    1.16  static int (*SDL_NAME(snd_pcm_hw_params_set_rate_near))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
    1.17  static int (*SDL_NAME(snd_pcm_hw_params_set_period_size_near))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir);
    1.18 -static int (*SDL_NAME(snd_pcm_hw_params_get_channels))(const snd_pcm_hw_params_t *params, unsigned int *val);
    1.19 -static snd_pcm_sframes_t (*SDL_NAME(snd_pcm_hw_params_get_period_size))(const snd_pcm_hw_params_t *params);
    1.20 +static int (*SDL_NAME(snd_pcm_hw_params_get_period_size))(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir);
    1.21  static int (*SDL_NAME(snd_pcm_hw_params_set_periods_near))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
    1.22 -static int (*SDL_NAME(snd_pcm_hw_params_get_periods))(snd_pcm_hw_params_t *params);
    1.23 +static int (*SDL_NAME(snd_pcm_hw_params_get_periods))(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir);
    1.24 +static int (*SDL_NAME(snd_pcm_hw_params_get_buffer_size))(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val);
    1.25  static int (*SDL_NAME(snd_pcm_hw_params))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params);
    1.26  /*
    1.27  */
    1.28 @@ -114,6 +114,7 @@
    1.29  	{ "snd_pcm_hw_params_get_period_size",	(void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_period_size)	},
    1.30  	{ "snd_pcm_hw_params_set_periods_near",	(void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_periods_near)	},
    1.31  	{ "snd_pcm_hw_params_get_periods",	(void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_periods)	},
    1.32 +	{ "snd_pcm_hw_params_get_buffer_size",	(void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_buffer_size) },
    1.33  	{ "snd_pcm_hw_params",	(void**)(char*)&SDL_NAME(snd_pcm_hw_params)	},
    1.34  	{ "snd_pcm_sw_params_current",	(void**)(char*)&SDL_NAME(snd_pcm_sw_params_current)	},
    1.35  	{ "snd_pcm_sw_params_set_start_threshold",	(void**)(char*)&SDL_NAME(snd_pcm_sw_params_set_start_threshold)	},
    1.36 @@ -485,14 +486,15 @@
    1.37  	}
    1.38  
    1.39  /* This is useful for debugging... */
    1.40 -/*
    1.41 -{ snd_pcm_sframes_t bufsize; int fragments;
    1.42 -   bufsize = SDL_NAME(snd_pcm_hw_params_get_period_size)(hwparams);
    1.43 -   fragments = SDL_NAME(snd_pcm_hw_params_get_periods)(hwparams);
    1.44 +#if 0
    1.45 +{ snd_pcm_uframes_t bufsize; snd_pcm_sframes_t persize; unsigned int periods; int dir;
    1.46 +   SDL_NAME(snd_pcm_hw_params_get_buffer_size)(hwparams, &bufsize);
    1.47 +   SDL_NAME(snd_pcm_hw_params_get_period_size)(hwparams, &persize, &dir);
    1.48 +   SDL_NAME(snd_pcm_hw_params_get_periods)(hwparams, &periods, &dir);
    1.49  
    1.50 -   fprintf(stderr, "ALSA: bufsize = %ld, fragments = %d\n", bufsize, fragments);
    1.51 +   fprintf(stderr, "ALSA: period size = %ld, periods = %u, buffer size = %lu\n", persize, periods, bufsize);
    1.52  }
    1.53 -*/
    1.54 +#endif
    1.55  
    1.56  	/* Set the software parameters */
    1.57  	snd_pcm_sw_params_alloca(&swparams);
    1.58 @@ -502,7 +504,7 @@
    1.59  		ALSA_CloseAudio(this);
    1.60  		return(-1);
    1.61  	}
    1.62 -	status = SDL_NAME(snd_pcm_sw_params_set_start_threshold)(pcm_handle, swparams, 0);
    1.63 +	status = SDL_NAME(snd_pcm_sw_params_set_start_threshold)(pcm_handle, swparams, 1);
    1.64  	if ( status < 0 ) {
    1.65  		SDL_SetError("Couldn't set start threshold: %s", SDL_NAME(snd_strerror)(status));
    1.66  		ALSA_CloseAudio(this);