]> git.sesse.net Git - mlt/blobdiff - src/modules/decklink/consumer_decklink.cpp
Fix compiler warnings due to non-virtual destructors.
[mlt] / src / modules / decklink / consumer_decklink.cpp
index ee9ce7a8396b721517ce4acdc47e66178c336037..e6d20e09998373ac179cb0251c4a345aacf30f4c 100644 (file)
@@ -75,7 +75,7 @@ private:
                                mlt_log_verbose( getConsumer(), "BMD mode %dx%d %.3f fps prog %d\n", m_width, m_height, m_fps, p );
 
                                if ( m_width == profile->width && p == profile->progressive
-                                        && m_fps == mlt_profile_fps( profile )
+                                        && (int) m_fps == (int) mlt_profile_fps( profile )
                                         && ( m_height == profile->height || ( m_height == 486 && profile->height == 480 ) ) )
                                        result = mode;
                                else
@@ -100,7 +100,7 @@ public:
                m_decklinkFrame = NULL;
        }
 
-       ~DeckLinkConsumer()
+       virtual ~DeckLinkConsumer()
        {
                SAFE_RELEASE( m_displayMode );
                SAFE_RELEASE( m_deckLinkKeyer );
@@ -189,12 +189,15 @@ public:
 
        void* preroll_thread()
        {
+               mlt_properties properties = MLT_CONSUMER_PROPERTIES( getConsumer() );
+
                // preroll frames
-               for ( unsigned i = 0; i < m_preroll; i++ )
+               for ( unsigned i = 0; i < m_preroll && mlt_properties_get_int( properties, "running" ); i++ )
                        ScheduleNextFrame( true );
 
                // start scheduled playback
-               m_deckLinkOutput->StartScheduledPlayback( 0, m_timescale, 1.0 );
+               if ( mlt_properties_get_int( properties, "running" ) )
+                       m_deckLinkOutput->StartScheduledPlayback( 0, m_timescale, 1.0 );
 
                return 0;
        }
@@ -266,12 +269,12 @@ public:
                m_preroll = preroll;
                m_reprio = false;
 
-               // Do preroll in thread to ensure asynchronicity of mlt_consumer_start().
-               pthread_create( &m_prerollThread, NULL, preroll_thread_proxy, this );
-
                // Set the running state
                mlt_properties_set_int( properties, "running", 1 );
 
+               // Do preroll in thread to ensure asynchronicity of mlt_consumer_start().
+               pthread_create( &m_prerollThread, NULL, preroll_thread_proxy, this );
+
                return true;
        }
 
@@ -282,7 +285,9 @@ public:
 
                // set running state is 0
                mlt_properties_set_int( properties, "running", 0 );
-               mlt_consumer_stopped( getConsumer() );
+
+               if ( wasRunning )
+                       pthread_join( m_prerollThread, NULL );
 
                // Stop the audio and video output streams immediately
                if ( m_deckLinkOutput )
@@ -295,8 +300,7 @@ public:
                // release decklink frame
                SAFE_RELEASE( m_decklinkFrame );
 
-               if ( wasRunning )
-                       pthread_join( m_prerollThread, NULL );
+               mlt_consumer_stopped( getConsumer() );
 
                return true;
        }
@@ -311,15 +315,17 @@ public:
                if ( !mlt_frame_get_audio( frame, (void**) &pcm, &format, &frequency, &m_channels, &samples ) )
                {
 #ifdef WIN32
+#define DECKLINK_UNSIGNED_FORMAT "%lu"
                        unsigned long written = 0;
 #else
+#define DECKLINK_UNSIGNED_FORMAT "%u"
                        uint32_t written = 0;
 #endif
                        BMDTimeValue streamTime = m_count * frequency * m_duration / m_timescale;
                        m_deckLinkOutput->GetBufferedAudioSampleFrameCount( &written );
                        if ( written > (m_preroll + 1) * samples )
                        {
-                               mlt_log_verbose( getConsumer(), "renderAudio: will flush %lu audiosamples\n", written );
+                               mlt_log_verbose( getConsumer(), "renderAudio: will flush " DECKLINK_UNSIGNED_FORMAT " audiosamples\n", written );
                                m_deckLinkOutput->FlushBufferedAudioSamples();
                        };
 #ifdef WIN32
@@ -329,7 +335,7 @@ public:
 #endif
 
                        if ( written != (uint32_t) samples )
-                               mlt_log_verbose( getConsumer(), "renderAudio: samples=%d, written=%lu\n", samples, written );
+                               mlt_log_verbose( getConsumer(), "renderAudio: samples=%d, written=" DECKLINK_UNSIGNED_FORMAT "\n", samples, written );
                }
        }
 
@@ -410,9 +416,9 @@ public:
                                        // Normal non-keyer playout - needs byte swapping
                                        if ( !progressive && m_displayMode->GetFieldDominance() == bmdUpperFieldFirst )
                                                // convert lower field first to top field first
-                                               swab( (char*) image, (char*) buffer + stride, stride * ( height - 1 ) );
+                                               swab2( (char*) image, (char*) buffer + stride, stride * ( height - 1 ) );
                                        else
-                                               swab( (char*) image, (char*) buffer, stride * height );
+                                               swab2( (char*) image, (char*) buffer, stride * height );
                                }
                                else if ( !mlt_properties_get_int( MLT_FRAME_PROPERTIES( frame ), "test_image" ) )
                                {
@@ -530,8 +536,8 @@ public:
                if ( cnt != m_acnt )
                {
                        mlt_log_debug( getConsumer(),
-                               "ScheduledFrameCompleted: GetBufferedAudioSampleFrameCount %u -> %lu, m_count=%"PRIu64"\n",
-                               m_acnt, cnt, m_count );
+                               "ScheduledFrameCompleted: GetBufferedAudioSampleFrameCount %u -> " DECKLINK_UNSIGNED_FORMAT
+                               ", m_count=%"PRIu64"\n", m_acnt, cnt, m_count );
                        m_acnt = cnt;
                }