From f0b63f92493a2cf8f48ba7c05eff8d2f105c3a24 Mon Sep 17 00:00:00 2001 From: Sam Lantinga <slouken@libsdl.org> Date: Wed, 25 Nov 2009 06:00:00 +0000 Subject: [PATCH] Add error messages for failure cases --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404232 --- src/audio/SDL_audiocvt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index 50a86aa3..620a4ab3 100644 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -837,7 +837,8 @@ SDL_BuildAudioTypeCVT(SDL_AudioCVT * cvt, } if (filter == NULL) { - return -1; /* Still no matching converter?! */ + SDL_SetError("No conversion available for these formats"); + return -1; } } @@ -930,7 +931,8 @@ SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, int dst_channels, } if (filter == NULL) { - return -1; /* Still no matching converter?! */ + SDL_SetError("No conversion available for these rates"); + return -1; } } @@ -969,16 +971,19 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt, * !!! FIXME: good in practice as it sounds in theory, though. */ - /* there are no unsigned types over 16 bits, so catch this upfront. */ + /* there are no unsigned types over 16 bits, so catch this up front. */ if ((SDL_AUDIO_BITSIZE(src_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(src_fmt))) { + SDL_SetError("Invalid source format"); return -1; } if ((SDL_AUDIO_BITSIZE(dst_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(dst_fmt))) { + SDL_SetError("Invalid destination format"); return -1; } /* prevent possible divisions by zero, etc. */ if ((src_rate == 0) || (dst_rate == 0)) { + SDL_SetError("Source or destination rate is zero"); return -1; } #ifdef DEBUG_CONVERT -- 2.18.1