From 00e7d640c7b5cd7a70f45507ba8d5e1b6829e33d Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sat, 9 Mar 2019 15:24:02 +0100 Subject: [PATCH] Also test source pitch is positive and clarify error (resolves #1474) According to the OpenAL 1.1 specification AL_PITCH, values must be in the range (0.0f, any]. Though I guess any does not include infinity. --- src/modules/audio/wrap_Source.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/audio/wrap_Source.cpp b/src/modules/audio/wrap_Source.cpp index bda70a1d2..3a96f41fc 100644 --- a/src/modules/audio/wrap_Source.cpp +++ b/src/modules/audio/wrap_Source.cpp @@ -71,10 +71,11 @@ int w_Source_setPitch(lua_State *L) { Source *t = luax_checksource(L, 1); float p = (float)luaL_checknumber(L, 2); + if (p != p) + return luaL_error(L, "Pitch cannot be NaN."); if (p > std::numeric_limits::max() || - p < std::numeric_limits::min() || - p != p) - return luaL_error(L, "Pitch has to be finite and not NaN."); + p <= 0.0f) + return luaL_error(L, "Pitch has to be non-zero, positive, finite number."); t->setPitch(p); return 0; }