GNOME Bugzilla – Bug 727306
decklink: fails to initialize on cards that only have input or only output interfaces
Last modified: 2014-06-19 20:04:54 UTC
When initializing devices in decklink.cpp, for some reason the code would return immediately if it can't get an input or output interface on the card. While this isn't a problem for most Blackmagic cards, two models only have an input or an output interface, causing certain interfaces not to be grabbed. This fixes bug #725175 as well. diff --git a/sys/decklink/gstdecklink.cpp b/sys/decklink/gstdecklink.cpp index 848ff28..067665e 100644 --- a/sys/decklink/gstdecklink.cpp +++ b/sys/decklink/gstdecklink.cpp @@ -228,21 +228,18 @@ init_devices (void) (void **) &devices[i].input); if (ret != S_OK) { GST_WARNING ("selected device does not have input interface"); - return; } ret = decklink->QueryInterface (IID_IDeckLinkOutput, (void **) &devices[i].output); if (ret != S_OK) { GST_WARNING ("selected device does not have output interface"); - return; } ret = decklink->QueryInterface (IID_IDeckLinkConfiguration, (void **) &devices[i].config); if (ret != S_OK) { GST_WARNING ("selected device does not have config interface"); - return; } ret = iterator->Next (&decklink);
That's seems fair, but incomplete. decklinksrc seems to care about input and config, decklinksink only cares about output (seems twisted, but I'm not surprised after having worked with V4L2). The reason it's incomplete, is that both sink and src assume these will be present, calling a function on the returned structure, leading to crash. To make it worst, this structure is not initialized from what I see (though this is C++, I might be wrong). So I would say, unless C++ make this safe, memset to 0 the array of Devices, and add required NULL check / failure in src and sink element. This way it can cleanly fail is the element is setup wrongly. Also, when done, commit your changes with your real name and email address into you local git repo (git master), and use git format-patch -1 to create a file we can merge using git am. We can deal with the backporting to 1.2, this element havent changed much. Thanks for your time and contribution.
Oh, when using git format-patch -1, it will create a file, that you should attach to this bug, not paste in a comment (which cause line wrapping). Thanks again, I'm sure many owner of these card will appreciate your effort, though i don't own one myself, so make sure you test all combination you can think of, as I only have my eyes to detect errors here.
I'm not a C/C++ programmer, so figuring out how to properly restructure the program is beyond me. I'd be happy to test any changes, however, just let me know. I've tested the changes with my two Decklink cards, but neither of them support outputting (or sinking in GST terms) video, only inputting/sourcing. I'll try and figure out git format-patch too, I'm pretty new to git and version control in general.
Created attachment 273251 [details] [review] Patch
Created attachment 273257 [details] [review] Fix support for HW without output Please test this patch. In order to test this, I may suggest these quick tests: /* Should fail, not crash */ gst-launch-1.0 videotestsrc ! decklinksink device-number=0 gst-launch-1.0 videotestsrc ! decklinksink device-number=0 /* Should work ? */ gst-launch-1.0 decklinksrc device-number=0 ! videoconvert ! xvimagesink gst-launch-1.0 decklinksrc device-number=1 ! videoconvert ! xvimagesink /* Should fail, not crash */ gst-launch-1.0 decklinksrc device-number=2 ! videoconvert ! xvimagesink
Btw, to apply, remove your patch (git reset --hard <commit hash before>) and apply, git am patch.
commit 1c1cc73a3b230454663971656515297f9ee8bd9f Author: Nicolas Dufresne <nicolas.dufresne@collabora.com> Date: Sat Mar 29 18:34:26 2014 -0400 decklink: Fix support for HW without output Devices suitable for decklinksrc may not have any output, hence querying the input returns NULL. Add support for all cases where input/output/config may be missing. https://bugzilla.gnome.org/show_bug.cgi?id=727306
I have a deckink minirecorder card and an decklink I/O card. The recorder card (with input only) still segfaults sometimes with version 1.3.2. The I/O card behaves normally. Has this patch been applied to 1.3.2? If so, it seems not to do the trick.
Yes, it should be in 1.3.2. Could you please file a new bug (or clone this bug) and get a stack trace of the crash?