From 92671067f04d838adff3f70587d76ea21205553c Mon Sep 17 00:00:00 2001 From: Marc Olivier Chouinard Date: Sun, 27 Mar 2011 00:34:07 -0400 Subject: [PATCH] media_bug: Fix for rare race condition. More work required to make media bug safe. --- src/switch_core_io.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/switch_core_io.c b/src/switch_core_io.c index 14cec65808..31c8d5fb25 100644 --- a/src/switch_core_io.c +++ b/src/switch_core_io.c @@ -346,13 +346,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi memset(session->raw_read_frame.data, 255, session->raw_read_frame.datalen); status = SWITCH_STATUS_SUCCESS; } else { - status = switch_core_codec_decode(use_codec, + switch_thread_rwlock_rdlock(session->bug_rwlock); + status = switch_core_codec_decode(use_codec->implementation?use_codec:read_frame->codec, session->read_codec, read_frame->data, read_frame->datalen, session->read_impl.actual_samples_per_second, session->raw_read_frame.data, &session->raw_read_frame.datalen, &session->raw_read_frame.rate, &read_frame->flags); + switch_thread_rwlock_unlock(session->bug_rwlock); + } if (status == SWITCH_STATUS_SUCCESS) {