decklinksrc: Handle callback/delegate object the same way as in the sink

Potentially fixes crashes.
This commit is contained in:
Sebastian Dröge 2014-11-28 14:50:18 +01:00
parent 2a0123d79a
commit ee8766b342
3 changed files with 10 additions and 5 deletions

View file

@ -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);

View file

@ -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;

View file

@ -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;