summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2014-11-28 14:50:18 +0100
committerSebastian Dröge <sebastian@centricular.com>2014-11-28 14:51:53 +0100
commitee8766b342a9feb68f1e1ed4947db1f3ca5660b3 (patch)
tree710d156da5845e43357e0f764c1c0e90f4817732
parent2a0123d79a86b4d22a147cebf5cdb9c80158ef87 (diff)
decklinksrc: Handle callback/delegate object the same way as in the sink
Potentially fixes crashes.
-rw-r--r--sys/decklink/capture.h2
-rw-r--r--sys/decklink/gstdecklinksrc.cpp11
-rw-r--r--sys/decklink/gstdecklinksrc.h2
3 files changed, 10 insertions, 5 deletions
diff --git a/sys/decklink/capture.h b/sys/decklink/capture.h
index 029500f2c..e6c584648 100644
--- a/sys/decklink/capture.h
+++ b/sys/decklink/capture.h
@@ -7,7 +7,7 @@ class DeckLinkCaptureDelegate : public IDeckLinkInputCallback
{
public:
DeckLinkCaptureDelegate();
- ~DeckLinkCaptureDelegate();
+ virtual ~DeckLinkCaptureDelegate();
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *ppv) { return E_NOINTERFACE; }
virtual ULONG STDMETHODCALLTYPE AddRef(void);
diff --git a/sys/decklink/gstdecklinksrc.cpp b/sys/decklink/gstdecklinksrc.cpp
index 5769c174a..939fb8b8e 100644
--- a/sys/decklink/gstdecklinksrc.cpp
+++ b/sys/decklink/gstdecklinksrc.cpp
@@ -408,7 +408,6 @@ static gboolean
gst_decklink_src_start (GstElement * element)
{
GstDecklinkSrc *decklinksrc = GST_DECKLINK_SRC (element);
- DeckLinkCaptureDelegate *delegate;
BMDAudioSampleType sample_depth;
int channels;
HRESULT ret;
@@ -431,9 +430,9 @@ gst_decklink_src_start (GstElement * element)
return FALSE;
}
- delegate = new DeckLinkCaptureDelegate ();
- delegate->priv = decklinksrc;
- ret = decklinksrc->input->SetCallback (delegate);
+ decklinksrc->delegate = new DeckLinkCaptureDelegate ();
+ decklinksrc->delegate->priv = decklinksrc;
+ ret = decklinksrc->input->SetCallback (decklinksrc->delegate);
if (ret != S_OK) {
GST_ERROR ("set callback failed (input source)");
return FALSE;
@@ -559,6 +558,10 @@ gst_decklink_src_stop (GstElement * element)
decklinksrc->input->DisableVideoInput ();
decklinksrc->input->DisableAudioInput ();
+ decklinksrc->input->SetCallback (NULL);
+ delete decklinksrc->delegate;
+ decklinksrc->delegate = NULL;
+
g_list_free_full (decklinksrc->pending_events,
(GDestroyNotify) gst_mini_object_unref);
decklinksrc->pending_events = NULL;
diff --git a/sys/decklink/gstdecklinksrc.h b/sys/decklink/gstdecklinksrc.h
index f071b662b..eb7a252c2 100644
--- a/sys/decklink/gstdecklinksrc.h
+++ b/sys/decklink/gstdecklinksrc.h
@@ -22,6 +22,7 @@
#include <gst/gst.h>
#include "gstdecklink.h"
+#include "capture.h"
G_BEGIN_DECLS
@@ -52,6 +53,7 @@ struct _GstDecklinkSrc
IDeckLink *decklink;
IDeckLinkInput *input;
IDeckLinkConfiguration *config;
+ DeckLinkCaptureDelegate *delegate;
GMutex mutex;
GCond cond;