From b7fb24cdffe9eb08e58e6b5b8237c79120b71f01 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 2 Mar 2010 23:35:26 +0000 Subject: [PATCH] re-arrange location of events git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16871 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_core_media_bug.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/switch_core_media_bug.c b/src/switch_core_media_bug.c index c5a39ac6b8..0f6738fdd2 100644 --- a/src/switch_core_media_bug.c +++ b/src/switch_core_media_bug.c @@ -37,6 +37,8 @@ static void switch_core_media_bug_destroy(switch_media_bug_t *bug) { + switch_event_t *event = NULL; + if (bug->raw_read_buffer) { switch_buffer_destroy(&bug->raw_read_buffer); } @@ -44,6 +46,13 @@ static void switch_core_media_bug_destroy(switch_media_bug_t *bug) if (bug->raw_write_buffer) { switch_buffer_destroy(&bug->raw_write_buffer); } + + if (switch_event_create(&event, SWITCH_EVENT_MEDIA_BUG_STOP) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Media-Bug-Function", "%s", bug->function); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Media-Bug-Target", "%s", bug->target); + if (bug->session) switch_channel_event_set_data(bug->session->channel, event); + switch_event_fire(&event); + } } SWITCH_DECLARE(void) switch_core_media_bug_pause(switch_core_session_t *session) @@ -357,13 +366,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t *new_bug = bug; if (switch_event_create(&event, SWITCH_EVENT_MEDIA_BUG_START) == SWITCH_STATUS_SUCCESS) { - switch_channel_event_set_data(session->channel, event); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Media-Bug-Function", "%s", bug->function); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Media-Bug-Target", "%s", bug->target); + switch_channel_event_set_data(session->channel, event); switch_event_fire(&event); } - return SWITCH_STATUS_SUCCESS; } @@ -461,19 +469,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(switch_core_session } switch_thread_rwlock_unlock(session->bug_rwlock); if (bp) { - switch_event_t *event = NULL; - - if (switch_event_create(&event, SWITCH_EVENT_MEDIA_BUG_STOP) == SWITCH_STATUS_SUCCESS) { - switch_channel_event_set_data(session->channel, event); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Media-Bug-Function", "%s", bp->function); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Media-Bug-Target", "%s", bp->target); - } - - if ((status = switch_core_media_bug_close(&bp)) == SWITCH_STATUS_SUCCESS) { - switch_event_fire(&event); - } else { - switch_event_destroy(&event); - } + status = switch_core_media_bug_close(&bp); } }