]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7501: add mutex to vid buf and fix regression from last regression fix
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 27 Mar 2015 20:04:54 +0000 (15:04 -0500)
committerMichael Jerris <mike@jerris.com>
Thu, 28 May 2015 17:47:14 +0000 (12:47 -0500)
src/switch_core_media.c
src/switch_vidderbuffer.c

index a80472a81bff0dd869654b1a01c8180eb16b12d8..cda875ef772e90ced66d3bd0f14d61c47a015176 100644 (file)
@@ -4772,7 +4772,7 @@ static void *SWITCH_THREAD_FUNC video_helper_thread(switch_thread_t *thread, voi
                
                vloops++;
 
-               if (!buf && switch_channel_test_flag(channel, CF_VIDEO_DECODED_READ)) {
+               if (!buf) {
                        int buflen = SWITCH_RECOMMENDED_BUFFER_SIZE * 4;
                        buf = switch_core_session_alloc(session, buflen);
                        fr.packet = buf;
index 6377b46c534ec539f6e6f2d97e1480f26558eacb..1cce952e4e53095b8350ac91c33ad389abc6b9ad 100644 (file)
@@ -346,7 +346,9 @@ SWITCH_DECLARE(void) switch_vb_reset(switch_vb_t *vb)
        vb->next_seq = 0;
        vb->complete_frames = 0;
 
+       switch_mutex_lock(vb->mutex);
        hide_nodes(vb);
+       switch_mutex_unlock(vb->mutex);
 }
 
 SWITCH_DECLARE(switch_status_t) switch_vb_create(switch_vb_t **vbp, uint32_t min_frame_len, uint32_t max_frame_len, switch_memory_pool_t *pool)
@@ -520,11 +522,12 @@ SWITCH_DECLARE(switch_status_t) switch_vb_get_packet(switch_vb_t *vb, switch_rtp
        switch_vb_node_t *node = NULL;
        switch_status_t status;
        
+       switch_mutex_lock(vb->mutex);
        vb_debug(vb, 2, "GET PACKET %u/%u n:%d\n", vb->complete_frames , vb->frame_len, vb->visible_nodes);
 
        if (vb->complete_frames < vb->frame_len) {
                vb_debug(vb, 2, "BUFFERING %u/%u\n", vb->complete_frames , vb->frame_len);
-               return SWITCH_STATUS_MORE_DATA;
+               switch_goto_status(SWITCH_STATUS_MORE_DATA, end);
        }
 
        if ((status = vb_next_packet(vb, &node)) == SWITCH_STATUS_SUCCESS) {
@@ -552,11 +555,11 @@ SWITCH_DECLARE(switch_status_t) switch_vb_get_packet(switch_vb_t *vb, switch_rtp
                switch(status) {
                case SWITCH_STATUS_RESTART:
                        vb_debug(vb, 2, "%s", "Error encountered ask for new keyframe\n");
-                       return SWITCH_STATUS_RESTART;
+                       switch_goto_status(SWITCH_STATUS_RESTART, end);
                case SWITCH_STATUS_NOTFOUND:
                default:
                        vb_debug(vb, 2, "%s", "No frames found wait for more\n");
-                       return SWITCH_STATUS_MORE_DATA;
+                       switch_goto_status(SWITCH_STATUS_MORE_DATA, end);
                }
        }
        
@@ -570,10 +573,15 @@ SWITCH_DECLARE(switch_status_t) switch_vb_get_packet(switch_vb_t *vb, switch_rtp
 
                vb_debug(vb, 1, "GET packet ts:%u seq:%u %s\n", ntohl(packet->header.ts), ntohs(packet->header.seq), packet->header.m ? " <MARK>" : "");
 
-               return status;
+       } else {
+               status = SWITCH_STATUS_MORE_DATA;
        }
 
-       return SWITCH_STATUS_MORE_DATA;
+ end:
+
+       switch_mutex_unlock(vb->mutex);
+
+       return status;
 
 }