diff --git a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c index 4551b12926..afdbec46b8 100644 --- a/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c +++ b/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c @@ -1705,12 +1705,15 @@ static JSBool teletone_generate(JSContext *cx, JSObject *obj, uintN argc, jsval } } else { - if (switch_core_session_read_frame(session, &read_frame, -1, 0) != SWITCH_STATUS_SUCCESS) { + switch_status_t status; + status = switch_core_session_read_frame(session, &read_frame, -1, 0); + + if (!SWITCH_READ_ACCEPTABLE(status)) { break; } } if ((write_frame.datalen = (uint32_t)switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) { - if (loops > 0) { + if (loops) { switch_buffer_t *tmp; /* Switcharoo*/ @@ -1719,11 +1722,12 @@ static JSBool teletone_generate(JSContext *cx, JSObject *obj, uintN argc, jsval tto->loop_buffer = tmp; loops--; /* try again */ - if ((write_frame.datalen = (uint32_t)switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) { + if ((write_frame.datalen = + (uint32_t)switch_buffer_read(tto->audio_buffer, fdata, write_frame.codec->implementation->bytes_per_frame)) <= 0) { break; } } else { - continue; + break; } }