[gtk-v4l] Remove glib source on a device unplug, this avoids errors when the fd
Hans de Goede
jwrdegoede at fedoraproject.org
Wed May 9 11:07:05 UTC 2012
commit 4c0a56ce403312c306fda5718b560fa2ef4c93ae
Author: Hans de Goede <hdegoede at redhat.com>
Date: Wed May 9 13:07:06 2012 +0200
Remove glib source on a device unplug, this avoids errors when the fd
gets reused later
...-gtk-v4l-device-remove-source-on-finalize.patch | 53 ++++++++++++++++++++
gtk-v4l.spec | 21 ++++----
2 files changed, 64 insertions(+), 10 deletions(-)
---
diff --git a/0001-gtk-v4l-device-remove-source-on-finalize.patch b/0001-gtk-v4l-device-remove-source-on-finalize.patch
new file mode 100644
index 0000000..301c6b1
--- /dev/null
+++ b/0001-gtk-v4l-device-remove-source-on-finalize.patch
@@ -0,0 +1,53 @@
+From e7730e2eb0e148e94f6bba13a70ddf61ae94b313 Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Wed, 9 May 2012 13:00:07 +0200
+Subject: [PATCH] gtk-v4l-device: remove source on finalize
+
+This fixes us from getting events from it, with a user_data argument
+pointing to the finalized object, when the fd gets re-used if another device
+gets plugged in later, and that device then generates ctrl events.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ lib/gtk-v4l-device.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/lib/gtk-v4l-device.c b/lib/gtk-v4l-device.c
+index c4ce1e5..67e8ccc 100644
+--- a/lib/gtk-v4l-device.c
++++ b/lib/gtk-v4l-device.c
+@@ -43,6 +43,7 @@ enum
+ struct _Gtkv4lDevicePrivate {
+ GList *controls;
+ GIOChannel *channel;
++ guint channel_source_id;
+ };
+
+ /* will create gtk_v4l_device_get_type and set gtk_v4l_device_parent_class */
+@@ -166,8 +167,10 @@ gtk_v4l_device_finalize (GObject *object)
+ g_list_foreach (self->priv->controls, gtk_v4l_device_free_control, NULL);
+ g_list_free (self->priv->controls);
+
+- if (self->priv->channel)
++ if (self->priv->channel) {
++ g_source_remove (self->priv->channel_source_id);
+ g_io_channel_unref (self->priv->channel);
++ }
+
+ if (self->fd != -1)
+ close (self->fd);
+@@ -303,8 +306,9 @@ gtk_v4l_device_new_control (Gtkv4lDevice *self, struct v4l2_queryctrl *query)
+ r = v4l2_ioctl(self->fd, VIDIOC_SUBSCRIBE_EVENT, &sub);
+ if (r >= 0 && !self->priv->channel) {
+ self->priv->channel = g_io_channel_unix_new (self->fd);
+- g_io_add_watch (self->priv->channel, G_IO_PRI, gtk_v4l_device_ctrl_event,
+- self);
++ self->priv->channel_source_id =
++ g_io_add_watch (self->priv->channel, G_IO_PRI, gtk_v4l_device_ctrl_event,
++ self);
+ }
+ }
+
+--
+1.7.10
+
diff --git a/gtk-v4l.spec b/gtk-v4l.spec
index 1004e60..967baa7 100644
--- a/gtk-v4l.spec
+++ b/gtk-v4l.spec
@@ -1,12 +1,12 @@
Name: gtk-v4l
Version: 0.4
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Video4Linux Device Preferences
Group: Applications/Multimedia
-License: GPLv2
+License: GPLv2+
URL: http://fedorahosted.org/gtk-v4l
Source0: https://fedorahosted.org/releases/g/t/%{name}/%{name}-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+Patch0: 0001-gtk-v4l-device-remove-source-on-finalize.patch
BuildRequires: scrollkeeper
BuildRequires: libv4l-devel >= 0.6
BuildRequires: gtk3-devel >= 3.0
@@ -24,8 +24,10 @@ Requires: %{name} = %{version}-%{release}
%description devel
Contains library and header files for gtk-v4l
+
%prep
%setup -q
+%patch0 -p1
%build
@@ -34,19 +36,15 @@ make CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags}
%install
-rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
-%clean
-rm -rf $RPM_BUILD_ROOT
-
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
+
%files
-%defattr(-,root,root,-)
%doc COPYING AUTHORS ChangeLog README
%{_bindir}/gtk-v4l
%{_datadir}/applications/gtk-v4l.desktop
@@ -54,7 +52,6 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/libgtkv4l.so.0
%files devel
-%defattr(-,root,root,-)
%doc COPYING
%{_includedir}/gtk-v4l-widget.h
%{_includedir}/gtk-v4l-device-list.h
@@ -62,7 +59,11 @@ rm -rf $RPM_BUILD_ROOT
%changelog
-* Fri Jan 20 2012 Huzaifa Sidhpurwala <huzaifas at redhat.com> - 0.4
+* Wed May 9 2012 Hans de Goede <hdegoede at redhat.com> - 0.4-2
+- Remove glib source on a device unplug, this avoids errors when the fd
+ gets reused later
+
+* Fri Jan 20 2012 Huzaifa Sidhpurwala <huzaifas at redhat.com> - 0.4-1
- New upstream release
* Fri Jan 13 2012 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.3-6
More information about the scm-commits
mailing list