MODAPP-201

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11330 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-01-21 18:41:53 +00:00
parent 74d8880950
commit 4b51419e3a
1 changed files with 15 additions and 9 deletions

View File

@ -37,8 +37,13 @@
static void switch_core_media_bug_destroy(switch_media_bug_t *bug) static void switch_core_media_bug_destroy(switch_media_bug_t *bug)
{ {
if (bug->raw_read_buffer) {
switch_buffer_destroy(&bug->raw_read_buffer); switch_buffer_destroy(&bug->raw_read_buffer);
}
if (bug->raw_write_buffer) {
switch_buffer_destroy(&bug->raw_write_buffer); switch_buffer_destroy(&bug->raw_write_buffer);
}
} }
SWITCH_DECLARE(uint32_t) switch_core_media_bug_test_flag(switch_media_bug_t *bug, uint32_t flag) SWITCH_DECLARE(uint32_t) switch_core_media_bug_test_flag(switch_media_bug_t *bug, uint32_t flag)
@ -197,8 +202,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
switch_media_bug_t *bug; //, *bp; switch_media_bug_t *bug; //, *bp;
switch_size_t bytes; switch_size_t bytes;
if (flags & SMBF_WRITE_REPLACE) { *new_bug = NULL;
#if 0 #if 0
if (flags & SMBF_WRITE_REPLACE) {
switch_thread_rwlock_wrlock(session->bug_rwlock); switch_thread_rwlock_wrlock(session->bug_rwlock);
for (bp = session->bugs; bp; bp = bp->next) { for (bp = session->bugs; bp; bp = bp->next) {
if (switch_test_flag(bp, SMBF_WRITE_REPLACE)) { if (switch_test_flag(bp, SMBF_WRITE_REPLACE)) {
@ -208,11 +215,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
} }
} }
switch_thread_rwlock_unlock(session->bug_rwlock); switch_thread_rwlock_unlock(session->bug_rwlock);
#endif
} }
if (flags & SMBF_READ_REPLACE) { if (flags & SMBF_READ_REPLACE) {
#if 0
switch_thread_rwlock_wrlock(session->bug_rwlock); switch_thread_rwlock_wrlock(session->bug_rwlock);
for (bp = session->bugs; bp; bp = bp->next) { for (bp = session->bugs; bp; bp = bp->next) {
if (switch_test_flag(bp, SMBF_READ_REPLACE)) { if (switch_test_flag(bp, SMBF_READ_REPLACE)) {
@ -222,8 +227,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
} }
} }
switch_thread_rwlock_unlock(session->bug_rwlock); switch_thread_rwlock_unlock(session->bug_rwlock);
#endif
} }
#endif
if (!(bug = switch_core_session_alloc(session, sizeof(*bug)))) { if (!(bug = switch_core_session_alloc(session, sizeof(*bug)))) {
return SWITCH_STATUS_MEMERR; return SWITCH_STATUS_MEMERR;
@ -260,8 +265,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
if (bug->callback) { if (bug->callback) {
switch_bool_t result = bug->callback(bug, bug->user_data, SWITCH_ABC_TYPE_INIT); switch_bool_t result = bug->callback(bug, bug->user_data, SWITCH_ABC_TYPE_INIT);
if (result == SWITCH_FALSE) { if (result == SWITCH_FALSE) {
switch_core_media_bug_remove(session, &bug); switch_core_media_bug_destroy(bug);
*new_bug = NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error attaching BUG to %s\n", switch_channel_get_name(session->channel)); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error attaching BUG to %s\n", switch_channel_get_name(session->channel));
return SWITCH_STATUS_GENERR; return SWITCH_STATUS_GENERR;
} }
@ -377,8 +381,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(switch_core_session
last = bp; last = bp;
} }
switch_thread_rwlock_unlock(session->bug_rwlock); switch_thread_rwlock_unlock(session->bug_rwlock);
if (bp) {
status = switch_core_media_bug_close(&bp); status = switch_core_media_bug_close(&bp);
} }
}
if (!session->bugs && session->bug_codec.implementation) { if (!session->bugs && session->bug_codec.implementation) {
switch_core_codec_destroy(&session->bug_codec); switch_core_codec_destroy(&session->bug_codec);