filesink: Fix for updating the index of memory to write in the next iteration
authorSeungha Yang <seungha@centricular.com>
Tue, 31 Mar 2020 10:05:30 +0000 (19:05 +0900)
committerSeungha Yang <seungha@centricular.com>
Tue, 31 Mar 2020 10:05:30 +0000 (19:05 +0900)
current_buf_mem_idx stands for the index of memory of the corresponding
buffer which is scheduled to be written in the next iteration.
If all memory objects were scheduled to be written in the current
iteration, reset the index to zero so that starting from the first
memory object of the next buffer.

plugins/elements/gstelements_private.c

index 5f3c5a8..75cdcfd 100644 (file)
@@ -535,9 +535,11 @@ gst_writev_buffer_list (GstObject * sink, gint fd, GstPoll * fdset,
         left += vecs[num_vecs].iov_len;
         num_vecs++;
       }
+      current_buf_mem_idx = j;
+      if (j == num_mem)
+        current_buf_mem_idx = 0;
     }
     current_buf_idx = i;
-    current_buf_mem_idx = j;
   }
 
   do {
@@ -622,9 +624,11 @@ gst_writev_buffer_list (GstObject * sink, gint fd, GstPoll * fdset,
           left += vecs[num_vecs].iov_len;
           num_vecs++;
         }
+        current_buf_mem_idx = j;
+        if (current_buf_mem_idx == num_mem)
+          current_buf_mem_idx = 0;
       }
       current_buf_idx = i;
-      current_buf_mem_idx = j;
     }
   } while (left > 0);