# HG changeset patch # User Eugene Zagidullin # Date 1203115001 -10800 # Node ID 684a26ccca54f163f5a5af87b355c685aa9f3b9d # Parent 763d8f49612bfd713208baa761cfe16d8248f77e check input fmt thoughtfully diff -r 763d8f49612b -r 684a26ccca54 src/alsa/audio.c --- a/src/alsa/audio.c Fri Feb 15 21:52:09 2008 +0900 +++ b/src/alsa/audio.c Sat Feb 16 01:36:41 2008 +0300 @@ -80,7 +80,6 @@ }; static struct snd_format *inputf = NULL; -static struct snd_format *effectf = NULL; static struct snd_format *outputf = NULL; static int alsa_setup(struct snd_format *f); @@ -287,8 +286,6 @@ g_free(inputf); inputf = NULL; - g_free(effectf); - effectf = NULL; g_free(outputf); outputf = NULL; @@ -730,8 +727,7 @@ int alsa_open(AFormat fmt, int rate, int nch) { debug("Opening device"); - inputf = snd_format_from_xmms(fmt, rate, nch); - effectf = snd_format_from_xmms(fmt, rate, nch); + if((inputf = snd_format_from_xmms(fmt, rate, nch)) == NULL) return 0; if (alsa_cfg.debug) snd_output_stdio_attach(&logs, stdout, 0); @@ -779,6 +775,7 @@ { struct snd_format *f = g_malloc(sizeof(struct snd_format)); size_t i; + int found = 0; f->xmms_format = fmt; f->format = SND_PCM_FORMAT_UNKNOWN; @@ -788,9 +785,15 @@ { printf("match!\n"); f->format = format_table[i].alsa; + found = 1; break; } + if(!found) { + g_free(f); + return NULL; + } + /* Get rid of _NE */ for (i = 0; i < sizeof(format_table) / sizeof(format_table[0]); i++) if (format_table[i].alsa == f->format) @@ -820,6 +823,7 @@ g_free(outputf); outputf = snd_format_from_xmms(f->xmms_format, f->rate, f->channels); + if(outputf == NULL) return -1; debug("Opening device: %s", alsa_cfg.pcm_device); /* FIXME: Can snd_pcm_open() return EAGAIN? */