]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
MODAPP-201
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 20 Jan 2009 13:55:00 +0000 (13:55 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 20 Jan 2009 13:55:00 +0000 (13:55 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11307 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_core_media_bug.c

index a939de9bb3f7bfa2b2b9d77454d5d5ba469f98a8..cf7dfc8b5573827e02a2b4554062cd2076f0b946 100644 (file)
@@ -235,7 +235,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
        bug->flags = flags;
 
        bug->stop_time = stop_time;
-       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Attaching BUG to %s\n", switch_channel_get_name(session->channel));
        bytes = session->read_codec->implementation->decoded_bytes_per_packet;
 
        if (!bug->flags) {
@@ -258,6 +257,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
                bug->thread_id = switch_thread_self();
        }
 
+       if (bug->callback) {
+               switch_bool_t result = bug->callback(bug, bug->user_data, SWITCH_ABC_TYPE_INIT);
+               if (result == SWITCH_FALSE) {
+                       switch_core_media_bug_remove(session, new_bug);
+                       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;
+               }
+       }
+
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Attaching BUG to %s\n", switch_channel_get_name(session->channel));
        bug->ready = 1;
        switch_thread_rwlock_wrlock(session->bug_rwlock);
        bug->next = session->bugs;
@@ -265,13 +274,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_add(switch_core_session_t
        switch_thread_rwlock_unlock(session->bug_rwlock);
        *new_bug = bug;
 
-       if (bug->callback) {
-               switch_bool_t result = bug->callback(bug, bug->user_data, SWITCH_ABC_TYPE_INIT);
-               if (result == SWITCH_FALSE) {
-                       return switch_core_media_bug_remove(session, new_bug);
-               }
-       }
-
        return SWITCH_STATUS_SUCCESS;
 }