]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix regression in spandsp_tone_detect caused by some revent core changes
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 17 Jul 2012 22:19:28 +0000 (17:19 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 17 Jul 2012 22:19:28 +0000 (17:19 -0500)
src/mod/applications/mod_spandsp/mod_spandsp_dsp.c

index b3616c7892646d2faff85b159c87ef9e26945dd2..c74069aac1da608129a3088af313b47c3c5eb1a5 100644 (file)
@@ -742,7 +742,7 @@ switch_status_t callprogress_detector_start(switch_core_session_t *session, cons
        /* start listening for tones */
        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Starting tone detection for '%s'\n", switch_channel_get_name(channel), name);
        switch_core_media_bug_add(session, "spandsp_tone_detect", NULL,
-                              callprogress_detector_process_buffer, detector, 0 /* stop time */, SMBF_READ_STREAM, &bug);
+                              callprogress_detector_process_buffer, detector, 0 /* stop time */, SMBF_READ_REPLACE, &bug);
        if (!bug) {
                return SWITCH_STATUS_FALSE;
        }
@@ -761,28 +761,26 @@ switch_status_t callprogress_detector_start(switch_core_session_t *session, cons
  */
 static switch_bool_t callprogress_detector_process_buffer(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
 {
-       uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
-       switch_frame_t frame = { 0 };
        tone_detector_t *detector = (tone_detector_t *)user_data;
        switch_core_session_t *session = switch_core_media_bug_get_session(bug);
        switch_channel_t *channel = switch_core_session_get_channel(session);
 
-       frame.data = data;
-       frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
-
        switch(type) {
        case SWITCH_ABC_TYPE_INIT:
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) initializing tone detector\n", switch_channel_get_name(channel));
                tone_detector_init(detector);
                break;
-       case SWITCH_ABC_TYPE_READ:
+       case SWITCH_ABC_TYPE_READ_REPLACE:
        {
+        switch_frame_t *frame;
+
+
                const char *detected_tone = NULL;
                if (!detector->spandsp_detector) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) detector is destroyed\n", switch_channel_get_name(channel));
                        return SWITCH_FALSE;
                }
-               if (switch_core_media_bug_read(bug, &frame, SWITCH_TRUE) != SWITCH_STATUS_SUCCESS) {
+               if (!(frame = switch_core_media_bug_get_read_replace_frame(bug))) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) error reading frame\n", switch_channel_get_name(channel));
                        return SWITCH_FALSE;
                }