]> git.sesse.net Git - vlc/blobdiff - modules/access/decklink.cpp
ps_psm_fill: fix logic bug spotted by clang
[vlc] / modules / access / decklink.cpp
index d9f5551f9c0fd679ebb814b773e632a286109afb..6dde9faa5bf64d587d00ed750837185c578b3d5e 100644 (file)
@@ -51,11 +51,6 @@ static void Close( vlc_object_t * );
     "This value should be a FOURCC code in textual " \
     "form, e.g. \"ntsc\"." )
 
-#define CACHING_TEXT N_("Caching value in ms")
-#define CACHING_LONGTEXT N_( \
-    "Caching value for DeckLink captures. This " \
-    "value should be set in milliseconds." )
-
 #define AUDIO_CONNECTION_TEXT N_("Audio connection")
 #define AUDIO_CONNECTION_LONGTEXT N_( \
     "Audio connection to use for DeckLink captures. " \
@@ -86,6 +81,13 @@ static const char *const ppsz_videoconns_text[] = {
     N_("SDI"), N_("HDMI"), N_("Optical SDI"), N_("Component"), N_("Composite"), N_("S-video")
 };
 
+static const char *const ppsz_audioconns[] = {
+    "embedded", "aesebu", "analog"
+};
+static const char *const ppsz_audioconns_text[] = {
+    N_("Embedded"), N_("AES/EBU"), N_("Analog")
+};
+
 #define ASPECT_RATIO_TEXT N_("Aspect ratio")
 #define ASPECT_RATIO_LONGTEXT N_( \
     "Aspect ratio (4:3, 16:9). Default assumes square pixels." )
@@ -96,22 +98,21 @@ vlc_module_begin ()
     set_category( CAT_INPUT )
     set_subcategory( SUBCAT_INPUT_ACCESS )
 
-    add_integer( "decklink-card-index", 0, NULL,
+    add_integer( "decklink-card-index", 0,
                  CARD_INDEX_TEXT, CARD_INDEX_LONGTEXT, true )
-    add_string( "decklink-mode", "pal ", NULL,
+    add_string( "decklink-mode", "pal ",
                  MODE_TEXT, MODE_LONGTEXT, true )
-    add_integer( "decklink-caching", DEFAULT_PTS_DELAY / 1000, NULL,
-                 CACHING_TEXT, CACHING_LONGTEXT, true )
-    add_string( "decklink-audio-connection", 0, NULL,
+    add_string( "decklink-audio-connection", 0,
                  AUDIO_CONNECTION_TEXT, AUDIO_CONNECTION_LONGTEXT, true )
-    add_integer( "decklink-audio-rate", 48000, NULL,
+        change_string_list( ppsz_audioconns, ppsz_audioconns_text, 0 )
+    add_integer( "decklink-audio-rate", 48000,
                  RATE_TEXT, RATE_LONGTEXT, true )
-    add_integer( "decklink-audio-channels", 2, NULL,
+    add_integer( "decklink-audio-channels", 2,
                  CHANNELS_TEXT, CHANNELS_LONGTEXT, true )
-    add_string( "decklink-video-connection", 0, NULL,
+    add_string( "decklink-video-connection", 0,
                  VIDEO_CONNECTION_TEXT, VIDEO_CONNECTION_LONGTEXT, true )
         change_string_list( ppsz_videoconns, ppsz_videoconns_text, 0 )
-    add_string( "decklink-aspect-ratio", NULL, NULL,
+    add_string( "decklink-aspect-ratio", NULL,
                 ASPECT_RATIO_TEXT, ASPECT_RATIO_LONGTEXT, true )
 
     add_shortcut( "decklink" )
@@ -129,6 +130,10 @@ struct demux_sys_t
     IDeckLinkInput *p_input;
     DeckLinkCaptureDelegate *p_delegate;
 
+    /* We need to hold onto the IDeckLinkConfiguration object, or our settings will not apply.
+       See section 2.4.15 of the Blackmagic Decklink SDK documentation. */
+    IDeckLinkConfiguration *p_config;
+
     es_out_id_t *p_video_es;
     es_out_id_t *p_audio_es;
 
@@ -289,6 +294,8 @@ static int Open( vlc_object_t *p_this )
 
     vlc_mutex_init( &p_sys->pts_lock );
 
+    IDeckLinkDisplayModeIterator *p_display_iterator = NULL;
+
     IDeckLinkIterator *decklink_iterator = CreateDeckLinkIteratorInstance();
     if( !decklink_iterator )
     {
@@ -338,8 +345,7 @@ static int Open( vlc_object_t *p_this )
     }
 
     /* Set up the video and audio sources. */
-    IDeckLinkConfiguration *p_config;
-    if( p_sys->p_card->QueryInterface( IID_IDeckLinkConfiguration, (void**)&p_config) != S_OK )
+    if( p_sys->p_card->QueryInterface( IID_IDeckLinkConfiguration, (void**)&p_sys->p_config) != S_OK )
     {
         msg_Err( p_demux, "Failed to get configuration interface" );
         goto finish;
@@ -368,8 +374,8 @@ static int Open( vlc_object_t *p_this )
             goto finish;
         }
 
-        msg_Dbg( p_demux, "Setting video input format to 0x%x", conn);
-        result = p_config->SetVideoInputFormat( conn );
+        msg_Dbg( p_demux, "Setting video input connection to 0x%x", conn);
+        result = p_sys->p_config->SetInt( bmdDeckLinkConfigVideoInputConnection, conn );
         if( result != S_OK )
         {
             msg_Err( p_demux, "Failed to set video input connection" );
@@ -395,7 +401,7 @@ static int Open( vlc_object_t *p_this )
         }
 
         msg_Dbg( p_demux, "Setting audio input format to 0x%x", conn);
-        result = p_config->SetAudioInputFormat( conn );
+        result = p_sys->p_config->SetInt( bmdDeckLinkConfigAudioInputConnection, conn );
         if( result != S_OK )
         {
             msg_Err( p_demux, "Failed to set audio input connection" );
@@ -404,7 +410,6 @@ static int Open( vlc_object_t *p_this )
     }
 
     /* Get the list of display modes. */
-    IDeckLinkDisplayModeIterator *p_display_iterator;
     result = p_sys->p_input->GetDisplayModeIterator( &p_display_iterator );
     if( result != S_OK )
     {
@@ -581,9 +586,6 @@ finish:
     if( decklink_iterator )
         decklink_iterator->Release();
 
-    if( p_config )
-        p_config->Release();
-
     free( psz_video_connection );
     free( psz_audio_connection );
     free( psz_display_mode );
@@ -602,6 +604,9 @@ static void Close( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t *)p_this;
     demux_sys_t *p_sys   = p_demux->p_sys;
 
+    if( p_sys->p_config )
+        p_sys->p_config->Release();
+
     if( p_sys->p_input )
     {
         p_sys->p_input->StopStreams();
@@ -614,6 +619,7 @@ static void Close( vlc_object_t *p_this )
     if( p_sys->p_delegate )
         p_sys->p_delegate->Release();
 
+    vlc_mutex_destroy( &p_sys->pts_lock );
     free( p_sys );
 }
 
@@ -635,7 +641,8 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
 
         case DEMUX_GET_PTS_DELAY:
             pi64 = (int64_t*)va_arg( args, int64_t * );
-            *pi64 = var_InheritInteger( p_demux, "decklink-caching" ) * 1000;
+            *pi64 =
+                INT64_C(1000) * var_InheritInteger( p_demux, "live-caching" );
             return VLC_SUCCESS;
 
         case DEMUX_GET_TIME: