From: Andre Noll Date: Fri, 6 Nov 2009 14:07:18 +0000 (+0100) Subject: Replace assertion for invalid audio formats by a runtime check. X-Git-Tag: v0.4.0~3^2~1 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=ec3c31a067e27d2ca38072ead146b37e97e22bb9;p=paraslash.git Replace assertion for invalid audio formats by a runtime check. In case one switches back and forth between different versions of para_server that support different audio formats, it may happen that the aft table contains entries for audio formats that are not supported by the version currently running. ATM, this causes para_server to die immediately because of the assertion in audio_format_name. Replace the assertion by a less draconian run time check that returns the string "???" if the number for an unknown audio file format is being looked up. --- diff --git a/afh_common.c b/afh_common.c index 8c0eed27..7d4ab089 100644 --- a/afh_common.c +++ b/afh_common.c @@ -208,9 +208,9 @@ int compute_afhi(const char *path, char *data, size_t size, int fd, */ const char *audio_format_name(int i) { - //PARA_NOTICE_LOG("array size: %u¸ requested: %d\n", ARRAY_SIZE(afl), i); - assert(i < 0 || i < ARRAY_SIZE(afl) - 1); - return i >= 0? afl[i].name : "(none)"; + if (i < 0 || i >= ARRAY_SIZE(afl) - 1) + return "???"; + return afl[i].name; } /**