Hi,
in my previous message about audio buffer overflow i did not noticed
about possible reason.
IMHO one of reasons is too high priority of melted. That cause decklink
callback delayed if avformat producer has higher activity.
To avoid it i prepared patch (*0001-change-priority-on-demand.patch*)
that enable maximum priority if it required by argument from command
line, also that makes possible to setup priority higher then default.
After changing priority to default value no overrun happens.
So next step was to increase a decklink callback thread priority over
other threads in MLT -
*0005-rise-DriverNotificationThreadFunction-priority.patch* - that could
give additional benefits on decklink hardware control timings.
And finally one more hack to improve decklink's operation is increasing
priority of internal thread to RT:
--- blackmagic_lib.c.origin 2010-11-23 05:53:00.000000000 +0200
+++ blackmagic_lib.c 2011-07-19 14:31:25.430397998 +0300
@@ -45,6 +45,7 @@
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/time.h>
+#include <linux/sched.h>
#include <asm/page.h>
#include <asm/i387.h>
#include <asm/div64.h>
@@ -450,6 +451,8 @@
int dl_thread_wrapper(void *data)
{
struct dl_thread_wrapper_struct *tws = data;
+ struct sched_param param = { .sched_priority = MAX_RT_PRIO - 1};
+ sched_setscheduler(current, SCHED_FIFO, ¶m);
tws->func(tws->param, 0);
kfree(tws);
return 0;
but that require to change a module license:
--- blackmagic_core.c.origin 2011-05-11 06:59:11.000000000 +0300
+++ blackmagic_core.c 2011-07-19 14:16:02.644661012 +0300
@@ -429,7 +429,8 @@
MODULE_AUTHOR("Blackmagic Design Inc. <[email protected]>");
MODULE_DESCRIPTION("Blackmagic Design DesktopVideo driver");
MODULE_VERSION("8.0.1rc4");
-MODULE_LICENSE("Proprietary");
+//MODULE_LICENSE("Proprietary");
+MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(pci, blackmagic_ids);
module_init(pci_blackmagic_init);
that why this is a hack :-))
--
________________________________________
Maksym Veremeyenko
>From 1c800addcf8fac14b8d92af07622bc6a4bb15dd3 Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <[email protected]>
Date: Tue, 19 Jul 2011 15:58:09 +0300
Subject: [PATCH] change priority on demand
---
src/melted/melted.c | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/src/melted/melted.c b/src/melted/melted.c
index be019ec..217774f 100644
--- a/src/melted/melted.c
+++ b/src/melted/melted.c
@@ -71,7 +71,6 @@ int main( int argc, char **argv )
int index = 0;
int background = 1;
struct timespec tm = { 1, 0 };
- struct sched_param scp;
mvcp_status_t status;
struct {
int clip_index;
@@ -79,12 +78,22 @@ int main( int argc, char **argv )
} asrun[ MAX_UNITS ];
const char *config_file = "/etc/melted.conf";
- // Use realtime scheduling if possible
- memset( &scp, '\0', sizeof( scp ) );
- scp.sched_priority = sched_get_priority_max( SCHED_FIFO ) - 1;
+ for ( index = 1; index < argc; index ++ )
+ {
#ifndef __DARWIN__
- sched_setscheduler( 0, SCHED_FIFO, &scp );
-#endif
+ if ( !strcmp( argv[ index ], "-prio" ) )
+ {
+ struct sched_param scp;
+ int prio = atol(argv[ ++ index ]);
+ memset( &scp, 0, sizeof( struct sched_param ) );
+ if ( prio )
+ scp.sched_priority = prio;
+ else
+ scp.sched_priority = sched_get_priority_max( SCHED_FIFO ) - 1;
+ sched_setscheduler( 0, SCHED_FIFO, &scp );
+ }
+#endif /* __DARWIN__ */
+ }
mlt_factory_init( NULL );
@@ -100,6 +109,8 @@ int main( int argc, char **argv )
background = 0;
else if ( !strcmp( argv[ index ], "-c" ) )
config_file = argv[ ++ index ];
+ else if ( !strcmp( argv[ index ], "-prio" ) )
+ index++;
else
usage( argv[ 0 ] );
}
--
1.7.4.4
>From 3beca5c34a0d7d10d13ae53e9e9ce3ba6402090f Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <[email protected]>
Date: Tue, 19 Jul 2011 15:55:52 +0300
Subject: [PATCH 5/5] rise DriverNotificationThreadFunction priority
---
src/modules/decklink/consumer_decklink.cpp | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/src/modules/decklink/consumer_decklink.cpp b/src/modules/decklink/consumer_decklink.cpp
index f84802f..4604737 100644
--- a/src/modules/decklink/consumer_decklink.cpp
+++ b/src/modules/decklink/consumer_decklink.cpp
@@ -56,6 +56,7 @@ private:
bool m_terminate_on_pause;
uint32_t m_preroll;
uint32_t m_acnt;
+ bool m_reprio;
IDeckLinkDisplayMode* getDisplayMode()
{
@@ -236,6 +237,7 @@ public:
}
m_preroll = preroll;
+ m_reprio = false;
// preroll frames
for( i = 0; i < preroll; i++ )
@@ -438,6 +440,30 @@ public:
virtual HRESULT STDMETHODCALLTYPE ScheduledFrameCompleted( IDeckLinkVideoFrame* completedFrame, BMDOutputFrameCompletionResult completed )
{
+ if( !m_reprio )
+ {
+ int r;
+ pthread_t thread;
+ pthread_attr_t tattr;
+ struct sched_param param;
+
+ thread = pthread_self();
+
+ pthread_attr_init(&tattr);
+ pthread_attr_setschedpolicy(&tattr, SCHED_FIFO);
+ param.sched_priority = sched_get_priority_max(SCHED_FIFO) - 1;
+ pthread_attr_setschedparam(&tattr, ¶m);
+
+ r = pthread_setschedparam(thread, SCHED_FIFO, ¶m);
+ if( r )
+ {
+ mlt_log_verbose( getConsumer(),
+ "ScheduledFrameCompleted: pthread_setschedparam retured %d\n", r);
+ };
+
+ m_reprio = true;
+ };
+
uint32_t cnt;
m_deckLinkOutput->GetBufferedAudioSampleFrameCount(&cnt);
if(cnt != m_acnt)
--
1.7.4.4
------------------------------------------------------------------------------
Magic Quadrant for Content-Aware Data Loss Prevention
Research study explores the data loss prevention market. Includes in-depth
analysis on the changes within the DLP market, and the criteria used to
evaluate the strengths and weaknesses of these DLP solutions.
http://www.accelacomm.com/jaw/sfnl/114/51385063/
_______________________________________________
Mlt-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mlt-devel