Hi,
after recent patch for decklink producer and consumer i found a strange
behavior when first decklink working in play mode (process X) and second
decklink works in play-record-play mode (process Y).
Either some race condition or kind of deadlock happens on a driver
level. For some reason code line:
126 if ( m_deckLink-QueryInterface(
IID_IDeckLinkOutput, (void**) m_deckLinkOutput ) == S_OK )
start thread:
(gdb) bt
#0 0x003ec22e8217 in ioctl () from /lib64/libc.so.6
#1 0x7f1946d0743c in WaitForNotificationEvents () from
/usr/lib64/libDeckLinkAPI.so
#2 0x7f1946ca2633 in CDeckLinkOutput::DriverNotificationThread() ()
from /usr/lib64/libDeckLinkAPI.so
#3 0x7f1946ca2709 in
CDeckLinkOutput::DriverNotificationThreadFunction(void*) ()
from /usr/lib64/libDeckLinkAPI.so
#4 0x003ec2607d90 in start_thread () from /lib64/libpthread.so.0
#5 0x003ec22ef48d in clone () from /lib64/libc.so.6
that stall next line that release m_deckLinkOutput:
#0 0x003ec2609080 in pthread_join () from /lib64/libpthread.so.0
#1 0x7f8346a37b04 in CDeckLinkOutput::~CDeckLinkOutput() () from
/usr/lib64/libDeckLinkAPI.so
#2 0x7f8346a20cca in CDeckLink::~CDeckLink() () from
/usr/lib64/libDeckLinkAPI.so
#3 0x7f8346a2072f in CDeckLink::Release() () from
/usr/lib64/libDeckLinkAPI.so
#4 0x7f8346a48c01 in CDeckLink_v8_0::~CDeckLink_v8_0() () from
/usr/lib64/libDeckLinkAPI.so
#5 0x7f8346a48ea7 in CDeckLink_v8_0::Release() () from
/usr/lib64/libDeckLinkAPI.so
#6 0x7f834e1ee5cb in listDevices (properties=0x7f82ec016768,
this=0x7f82ec016760)
at consumer_decklink.cpp:142
First i revised all decklink pointers for any leak:
0001-care-about-NULL-pointers.patch
but that do not helps, so i checked mode iteration loop:
0002-make-sure-all-is-release-in-mode-iteration-loop.patch
but the cure was to disable device listing:
0003-make-device-listing-only-if-list_devices-property-se.patch
i dont know if it driver bug or some arch specific behaviour, but that
patches is an only way for me to provide stable decklink operation...
--
Maksym Veremeyenko
From 5ec0801c361a58628038c0ed9b334ae5086c36fc Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko ve...@m1stereo.tv
Date: Sat, 17 Mar 2012 15:53:40 +0100
Subject: [PATCH 1/3] care about NULL pointers
---
src/modules/decklink/consumer_decklink.cpp | 74 ++-
src/modules/decklink/producer_decklink.cpp | 49 +++
2 files changed, 67 insertions(+), 56 deletions(-)
diff --git a/src/modules/decklink/consumer_decklink.cpp b/src/modules/decklink/consumer_decklink.cpp
index 8645506..dceccdc 100644
--- a/src/modules/decklink/consumer_decklink.cpp
+++ b/src/modules/decklink/consumer_decklink.cpp
@@ -33,6 +33,8 @@
#include DeckLinkAPI.h
#endif
+#define SAFE_RELEASE(V) if (V) { V-Release(); V = NULL; }
+
static const unsigned PREROLL_MINIMUM = 3;
class DeckLinkConsumer
@@ -92,15 +94,19 @@ private:
public:
mlt_consumer getConsumer()
{ return m_consumer; }
-
+
+ DeckLinkConsumer()
+ {
+ m_deckLinkKeyer = NULL;
+ m_deckLinkOutput = NULL;
+ m_deckLink = NULL;
+ }
+
~DeckLinkConsumer()
{
- if ( m_deckLinkKeyer )
- m_deckLinkKeyer-Release();
- if ( m_deckLinkOutput )
- m_deckLinkOutput-Release();
- if ( m_deckLink )
- m_deckLink-Release();
+ SAFE_RELEASE( m_deckLinkKeyer );
+ SAFE_RELEASE( m_deckLinkOutput );
+ SAFE_RELEASE( m_deckLink );
}
bool listDevices( mlt_properties properties )
@@ -137,11 +143,11 @@ public:
free( key );
free( name );
}
- m_deckLinkOutput-Release();
+ SAFE_RELEASE( m_deckLinkOutput );
}
-m_deckLink-Release();
+SAFE_RELEASE( m_deckLink );
}
- decklinkIterator-Release();
+ SAFE_RELEASE( decklinkIterator );
mlt_properties_set_int( properties, devices, i );
mlt_log_verbose( NULL, [consumer decklink] devices = %d\n, i );
@@ -149,8 +155,7 @@ public:
}
catch ( const char *error )
{
- if ( decklinkIterator )
-decklinkIterator-Release();
+ SAFE_RELEASE( decklinkIterator );
mlt_log_error( getConsumer(), %s\n, error );
return false;
}
@@ -182,30 +187,32 @@ public:
return false;
}
#endif
-
+
// Connect to the Nth DeckLink instance
- do {
- if ( deckLinkIterator-Next( m_deckLink ) != S_OK )
- {
-mlt_log_error( getConsumer(), DeckLink card not found\n );
-deckLinkIterator-Release();
-return false;
- }
- } while ( ++i = card );
- deckLinkIterator-Release();
-
+ for ( i = 0; deckLinkIterator-Next( m_deckLink ) == S_OK ; i++)
+ {
+ if(i == card)
+break;
+ else
+SAFE_RELEASE( m_deckLink );
+ }
+ SAFE_RELEASE( deckLinkIterator );
+ if( !m_deckLink )
+ {
+ mlt_log_error( getConsumer(), DeckLink card not found\n );
+ return false;
+ }
+
// Obtain the audio/video output interface (IDeckLinkOutput)
if (