# HG changeset patch # User Jason Rohrer # Date 1290490751 25200 # Branch SDL-1.2 # Node ID 7146b49a0a90327ba7072f87bde64a22d3eb8073 # Parent 0d4756e57224ac45d2e1636b3121f7f3dc5ee97e Extra debugging print-outs for fixing ALSA buffer sizing issue. diff -r 0d4756e57224 -r 7146b49a0a90 src/audio/alsa/SDL_alsa_audio.c --- a/src/audio/alsa/SDL_alsa_audio.c Sun Sep 19 08:56:53 2010 -0700 +++ b/src/audio/alsa/SDL_alsa_audio.c Mon Nov 22 22:39:11 2010 -0700 @@ -31,7 +31,6 @@ #include "../SDL_audiomem.h" #include "../SDL_audio_c.h" #include "SDL_alsa_audio.h" - #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC #include "SDL_name.h" #include "SDL_loadso.h" @@ -74,10 +73,14 @@ 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); 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); 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); +static int (*SDL_NAME(snd_pcm_hw_params_get_period_size_min))(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir); +static int (*SDL_NAME(snd_pcm_hw_params_get_period_size_max))(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir); 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); static int (*SDL_NAME(snd_pcm_hw_params_get_periods))(const snd_pcm_hw_params_t *params, unsigned int *val, int *dir); static int (*SDL_NAME(snd_pcm_hw_params_set_buffer_size_near))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val); static int (*SDL_NAME(snd_pcm_hw_params_get_buffer_size))(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val); +static int (*SDL_NAME(snd_pcm_hw_params_get_buffer_size_min))(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val); +static int (*SDL_NAME(snd_pcm_hw_params_get_buffer_size_max))(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val); static int (*SDL_NAME(snd_pcm_hw_params))(snd_pcm_t *pcm, snd_pcm_hw_params_t *params); /* */ @@ -112,10 +115,14 @@ { "snd_pcm_hw_params_set_rate_near", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_rate_near) }, { "snd_pcm_hw_params_set_period_size_near", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_period_size_near) }, { "snd_pcm_hw_params_get_period_size", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_period_size) }, + { "snd_pcm_hw_params_get_period_size_min", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_period_size_min) }, + { "snd_pcm_hw_params_get_period_size_max", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_period_size_max) }, { "snd_pcm_hw_params_set_periods_near", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_periods_near) }, { "snd_pcm_hw_params_get_periods", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_periods) }, { "snd_pcm_hw_params_set_buffer_size_near", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_set_buffer_size_near) }, { "snd_pcm_hw_params_get_buffer_size", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_buffer_size) }, + { "snd_pcm_hw_params_get_buffer_size_min", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_buffer_size_min) }, + { "snd_pcm_hw_params_get_buffer_size_max", (void**)(char*)&SDL_NAME(snd_pcm_hw_params_get_buffer_size_max) }, { "snd_pcm_hw_params", (void**)(char*)&SDL_NAME(snd_pcm_hw_params) }, { "snd_pcm_sw_params_current", (void**)(char*)&SDL_NAME(snd_pcm_sw_params_current) }, { "snd_pcm_sw_params_set_start_threshold", (void**)(char*)&SDL_NAME(snd_pcm_sw_params_set_start_threshold) }, @@ -559,6 +566,39 @@ } spec->freq = rate; + if( getenv("SDL_AUDIO_ALSA_DEBUG") ){ + + snd_pcm_uframes_t buffer_size_min; + snd_pcm_uframes_t buffer_size_max; + snd_pcm_uframes_t period_size_min; + snd_pcm_uframes_t period_size_max; + int dir; + int err; + + err = SDL_NAME(snd_pcm_hw_params_get_buffer_size_min)( + hwparams, + &buffer_size_min); + err = SDL_NAME(snd_pcm_hw_params_get_buffer_size_max)( + hwparams, + &buffer_size_max); + dir=0; + err = SDL_NAME(snd_pcm_hw_params_get_period_size_min)( + hwparams, + &period_size_min,&dir); + dir=0; + err = SDL_NAME(snd_pcm_hw_params_get_period_size_max)( + hwparams, + &period_size_max,&dir); + fprintf( stderr, + "ALSA: buffer min/max = %d/%d, period min/max = %d/%d\n", + buffer_size_min, buffer_size_max, + period_size_min, period_size_max ); + fprintf( stderr, + "ALSA: requested buffer size = %d\n", + spec->samples ); + } + + /* Set the buffer size, in samples */ if ( ALSA_set_period_size(this, spec, hwparams, 0) < 0 && ALSA_set_buffer_size(this, spec, hwparams, 0) < 0 ) { # HG changeset patch # User Jason Rohrer # Date 1290491132 25200 # Branch SDL-1.2 # Node ID e738d749fa076372eab03bdb8fb7c5c260c4e414 # Parent 7146b49a0a90327ba7072f87bde64a22d3eb8073 Cleaned up my debug output code a bit. diff -r 7146b49a0a90 -r e738d749fa07 src/audio/alsa/SDL_alsa_audio.c --- a/src/audio/alsa/SDL_alsa_audio.c Mon Nov 22 22:39:11 2010 -0700 +++ b/src/audio/alsa/SDL_alsa_audio.c Mon Nov 22 22:45:32 2010 -0700 @@ -566,39 +566,43 @@ } spec->freq = rate; - if( getenv("SDL_AUDIO_ALSA_DEBUG") ){ + + if( getenv("SDL_AUDIO_ALSA_DEBUG") ){ + snd_pcm_uframes_t buffer_size_min; + snd_pcm_uframes_t buffer_size_max; + snd_pcm_uframes_t period_size_min; + snd_pcm_uframes_t period_size_max; + int dir; - snd_pcm_uframes_t buffer_size_min; - snd_pcm_uframes_t buffer_size_max; - snd_pcm_uframes_t period_size_min; - snd_pcm_uframes_t period_size_max; - int dir; - int err; - - err = SDL_NAME(snd_pcm_hw_params_get_buffer_size_min)( - hwparams, - &buffer_size_min); - err = SDL_NAME(snd_pcm_hw_params_get_buffer_size_max)( - hwparams, - &buffer_size_max); - dir=0; - err = SDL_NAME(snd_pcm_hw_params_get_period_size_min)( - hwparams, - &period_size_min,&dir); - dir=0; - err = SDL_NAME(snd_pcm_hw_params_get_period_size_max)( - hwparams, - &period_size_max,&dir); - fprintf( stderr, - "ALSA: buffer min/max = %d/%d, period min/max = %d/%d\n", - buffer_size_min, buffer_size_max, - period_size_min, period_size_max ); - fprintf( stderr, - "ALSA: requested buffer size = %d\n", - spec->samples ); - } + SDL_NAME(snd_pcm_hw_params_get_buffer_size_min)( + hwparams, + &buffer_size_min); - + SDL_NAME(snd_pcm_hw_params_get_buffer_size_max)( + hwparams, + &buffer_size_max); + + dir=0; + SDL_NAME(snd_pcm_hw_params_get_period_size_min)( + hwparams, + &period_size_min,&dir); + + dir=0; + SDL_NAME(snd_pcm_hw_params_get_period_size_max)( + hwparams, + &period_size_max,&dir); + + fprintf( stderr, + "ALSA: buffer min/max = %d/%d, period min/max = %d/%d\n", + buffer_size_min, buffer_size_max, + period_size_min, period_size_max ); + + fprintf( stderr, + "ALSA: requested buffer size = %d\n", + spec->samples ); + } + + /* Set the buffer size, in samples */ if ( ALSA_set_period_size(this, spec, hwparams, 0) < 0 && ALSA_set_buffer_size(this, spec, hwparams, 0) < 0 ) {