[PATCH 3/8] v4l2-tracer: remove buffers by type and index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently duplicate buffers are identified for removal by file descriptor,
but if the buffers were added by QUERYBUF then they will all have the same
file descriptor and the wrong buffer might be removed. So, instead,
identify duplicate buffers for removal by type and index.

Signed-off-by: Deborah Brouwer <deborah.brouwer@xxxxxxxxxxxxx>
---
 utils/v4l2-tracer/retrace-helper.cpp | 4 ++--
 utils/v4l2-tracer/retrace.cpp        | 2 +-
 utils/v4l2-tracer/retrace.h          | 2 +-
 utils/v4l2-tracer/trace-helper.cpp   | 6 +++---
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/utils/v4l2-tracer/retrace-helper.cpp b/utils/v4l2-tracer/retrace-helper.cpp
index 3c68986f..db24c667 100644
--- a/utils/v4l2-tracer/retrace-helper.cpp
+++ b/utils/v4l2-tracer/retrace-helper.cpp
@@ -41,10 +41,10 @@ void add_buffer_retrace(int fd, __u32 type, __u32 index, __u32 offset)
 	ctx_retrace.buffers.push_front(buf);
 }
 
-void remove_buffer_retrace(int fd)
+void remove_buffer_retrace(__u32 type, __u32 index)
 {
 	for (auto it = ctx_retrace.buffers.begin(); it != ctx_retrace.buffers.end(); ++it) {
-		if (it->fd == fd) {
+		if ((it->type == type) && (it->index == index)) {
 			ctx_retrace.buffers.erase(it);
 			break;
 		}
diff --git a/utils/v4l2-tracer/retrace.cpp b/utils/v4l2-tracer/retrace.cpp
index 1bec635d..b2b4afbf 100644
--- a/utils/v4l2-tracer/retrace.cpp
+++ b/utils/v4l2-tracer/retrace.cpp
@@ -460,7 +460,7 @@ void retrace_vidioc_expbuf(int fd_retrace, json_object *ioctl_args_user, json_ob
 	 */
 	int fd_found_in_retrace_context = get_buffer_fd_retrace(ptr->type, ptr->index);
 	if (fd_found_in_retrace_context != -1)
-		remove_buffer_retrace(fd_found_in_retrace_context);
+		remove_buffer_retrace(ptr->type, ptr->index);
 
 	add_buffer_retrace(buf_fd_retrace, ptr->type, ptr->index);
 
diff --git a/utils/v4l2-tracer/retrace.h b/utils/v4l2-tracer/retrace.h
index 01157336..87a0417e 100644
--- a/utils/v4l2-tracer/retrace.h
+++ b/utils/v4l2-tracer/retrace.h
@@ -30,7 +30,7 @@ int retrace(std::string trace_filename);
 bool buffer_in_retrace_context(int fd, __u32 offset = 0);
 int get_buffer_fd_retrace(__u32 type, __u32 index);
 void add_buffer_retrace(int fd, __u32 type, __u32 index, __u32 offset = 0);
-void remove_buffer_retrace(int fd);
+void remove_buffer_retrace(__u32 type, __u32 index);
 void set_buffer_address_retrace(int fd, __u32 offset, long address_trace, long address_retrace);
 long get_retrace_address_from_trace_address(long address_trace);
 void add_fd(int fd_trace, int fd_retrace);
diff --git a/utils/v4l2-tracer/trace-helper.cpp b/utils/v4l2-tracer/trace-helper.cpp
index a1e83a44..b6336313 100644
--- a/utils/v4l2-tracer/trace-helper.cpp
+++ b/utils/v4l2-tracer/trace-helper.cpp
@@ -85,10 +85,10 @@ void add_buffer_trace(int fd, __u32 type, __u32 index, __u32 offset = 0)
 	ctx_trace.buffers.push_front(buf);
 }
 
-void remove_buffer_trace(int fd)
+void remove_buffer_trace(__u32 type, __u32 index)
 {
 	for (auto it = ctx_trace.buffers.begin(); it != ctx_trace.buffers.end(); ++it) {
-		if (it->fd == fd) {
+		if ((it->type == type) && (it->index == index)) {
 			ctx_trace.buffers.erase(it);
 			break;
 		}
@@ -420,7 +420,7 @@ void expbuf_setup(struct v4l2_exportbuffer *export_buffer)
 	 * file descriptor, replace the video fd with the more specific buffer fd from EXPBUF.
 	 */
 	if (fd_found_in_trace_context != 0)
-		remove_buffer_trace(fd_found_in_trace_context);
+		remove_buffer_trace(type, index);
 
 	add_buffer_trace(export_buffer->fd, type, index);
 }
-- 
2.41.0





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux