]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5011 add sync up flags so neither file writes data until audio is moving both...
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 28 Mar 2013 15:41:28 +0000 (10:41 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 28 Mar 2013 15:41:28 +0000 (10:41 -0500)
src/switch_ivr_async.c

index 40852b97680887cb505b954a62176616c7ba69d3..b545748cb2b59082ada9971adbd2325b2868a9eb 100644 (file)
@@ -1090,6 +1090,8 @@ struct record_helper {
        switch_file_handle_t in_fh;
        switch_file_handle_t out_fh;
        int native;
+       int rready;
+       int wready;
        uint32_t packet_len;
        int min_sec;
        switch_bool_t hangup_on_error;
@@ -1115,16 +1117,24 @@ static switch_bool_t record_callback(switch_media_bug_t *bug, void *user_data, s
                break;
        case SWITCH_ABC_TYPE_TAP_NATIVE_READ:
                {
-                       nframe = switch_core_media_bug_get_native_read_frame(bug);
-                       len = nframe->datalen;
-                       switch_core_file_write(&rh->in_fh, nframe->data, &len);
+                       rh->rready = 1;
+
+                       if (rh->rready && rh->wready) {
+                               nframe = switch_core_media_bug_get_native_read_frame(bug);
+                               len = nframe->datalen;
+                               switch_core_file_write(&rh->in_fh, nframe->data, &len);
+                       }
                }
                break;
        case SWITCH_ABC_TYPE_TAP_NATIVE_WRITE:
                {
-                       nframe = switch_core_media_bug_get_native_write_frame(bug);
-                       len = nframe->datalen;
-                       switch_core_file_write(&rh->out_fh, nframe->data, &len);
+                       rh->wready = 1;
+
+                       if (rh->rready && rh->wready) {                 
+                               nframe = switch_core_media_bug_get_native_write_frame(bug);
+                               len = nframe->datalen;
+                               switch_core_file_write(&rh->out_fh, nframe->data, &len);
+                       }
                }
                break;
        case SWITCH_ABC_TYPE_CLOSE: