@@ -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;
}
@@ -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);
@@ -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);
@@ -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);
}
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@collabora.com> --- 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(-)