decklink: Fix format specifier warnings in logging v2
authorNirbheek Chauhan <nirbheek@centricular.com>
Tue, 18 Jul 2017 22:49:34 +0000 (04:19 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Tue, 18 Jul 2017 22:49:34 +0000 (04:19 +0530)
HRESULT is unsigned long on Windows, but the Decklink headers define
it to 'int' on Linux. Confusingly, the defines that talk about the
possible return values for it use long constants. The easy fix would
be to change the linux/LinuxCOM.h header, but that's copied from the
decklink SDK.

Change the logging to always upcast to unsigned long while printing
HRESULT for consistency across platforms.

sys/decklink/gstdecklink.cpp
sys/decklink/gstdecklinkaudiosink.cpp
sys/decklink/gstdecklinkaudiosrc.cpp
sys/decklink/gstdecklinkvideosink.cpp
sys/decklink/gstdecklinkvideosrc.cpp

index 49f3143..66f07f2 100644 (file)
@@ -815,7 +815,7 @@ public:
           video_frame->GetStreamTime (&stream_time, &stream_duration,
           GST_SECOND);
       if (res != S_OK) {
-        GST_ERROR ("Failed to get stream time: 0x%08x", res);
+        GST_ERROR ("Failed to get stream time: 0x%08lx", (unsigned long) res);
         stream_time = GST_CLOCK_TIME_NONE;
         stream_duration = GST_CLOCK_TIME_NONE;
       }
@@ -829,7 +829,8 @@ public:
             &dtc);
 
         if (res != S_OK) {
-          GST_DEBUG_OBJECT (videosrc, "Failed to get timecode: 0x%08x", res);
+          GST_DEBUG_OBJECT (videosrc, "Failed to get timecode: 0x%08lx",
+              (unsigned long) res);
           dtc = NULL;
         }
       }
@@ -1093,8 +1094,8 @@ init_devices (gpointer data)
     ret = decklink->QueryInterface (IID_IDeckLinkInput,
         (void **) &devices[i].input.input);
     if (ret != S_OK) {
-      GST_WARNING ("selected device does not have input interface: 0x%08x",
-          ret);
+      GST_WARNING ("selected device does not have input interface: 0x%08lx",
+          (unsigned long) ret);
     } else {
       IDeckLinkDisplayModeIterator *mode_iter;
 
@@ -1130,8 +1131,8 @@ init_devices (gpointer data)
     ret = decklink->QueryInterface (IID_IDeckLinkOutput,
         (void **) &devices[i].output.output);
     if (ret != S_OK) {
-      GST_WARNING ("selected device does not have output interface: 0x%08x",
-          ret);
+      GST_WARNING ("selected device does not have output interface: 0x%08lx",
+          (unsigned long) ret);
     } else {
       IDeckLinkDisplayModeIterator *mode_iter;
 
@@ -1168,16 +1169,16 @@ init_devices (gpointer data)
     ret = decklink->QueryInterface (IID_IDeckLinkConfiguration,
         (void **) &devices[i].input.config);
     if (ret != S_OK) {
-      GST_WARNING ("selected device does not have config interface: 0x%08x",
-          ret);
+      GST_WARNING ("selected device does not have config interface: 0x%08lx",
+          (unsigned long) ret);
     }
 
     ret = decklink->QueryInterface (IID_IDeckLinkAttributes,
         (void **) &devices[i].input.attributes);
     devices[i].output.attributes = devices[i].input.attributes;
     if (ret != S_OK) {
-      GST_WARNING ("selected device does not have attributes interface: 0x%08x",
-          ret);
+      GST_WARNING ("selected device does not have attributes interface: "
+          "0x%08lx", (unsigned long) ret);
     }
 
     ret = iterator->Next (&decklink);
@@ -1419,9 +1420,9 @@ gst_decklink_clock_get_internal_time (GstClock * clock)
   GST_LOG_OBJECT (clock,
       "result %" GST_TIME_FORMAT " time %" GST_TIME_FORMAT " last time %"
       GST_TIME_FORMAT " offset %" GST_TIME_FORMAT " start time %"
-      GST_TIME_FORMAT " (ret: 0x%08x)", GST_TIME_ARGS (result),
+      GST_TIME_FORMAT " (ret: 0x%08lx)", GST_TIME_ARGS (result),
       GST_TIME_ARGS (time), GST_TIME_ARGS (last_time), GST_TIME_ARGS (offset),
-      GST_TIME_ARGS (start_time), ret);
+      GST_TIME_ARGS (start_time), (unsigned long) ret);
 
   return result;
 }
index 68aa10d..d3641f8 100644 (file)
@@ -276,7 +276,7 @@ public:
     } while (len > 0 && res == S_OK);
 
     GST_LOG_OBJECT (m_ringbuffer->sink, "Wrote %u samples: 0x%08lx", written_sum,
-        res);
+        (unsigned long) res);
 
     gst_audio_ring_buffer_clear (GST_AUDIO_RING_BUFFER_CAST (m_ringbuffer),
         seg);
@@ -319,7 +319,8 @@ gst_decklink_audio_sink_ringbuffer_delay (GstAudioRingBuffer * rb)
       ret = 0;
   }
 
-  GST_DEBUG_OBJECT (self->sink, "Delay: %u (0x%08lx)", ret, res);
+  GST_DEBUG_OBJECT (self->sink, "Delay: %u (0x%08lx)", ret,
+      (unsigned long) res);
 
   return ret;
 }
@@ -415,7 +416,7 @@ gst_decklink_audio_sink_ringbuffer_acquire (GstAudioRingBuffer * rb,
       sample_depth, spec->info.channels, bmdAudioOutputStreamContinuous);
   if (ret != S_OK) {
     GST_WARNING_OBJECT (self->sink, "Failed to enable audio output 0x%08lx",
-        ret);
+        (unsigned long) ret);
     return FALSE;
   }
 
@@ -424,7 +425,7 @@ gst_decklink_audio_sink_ringbuffer_acquire (GstAudioRingBuffer * rb,
       output->SetAudioCallback (new GStreamerAudioOutputCallback (self));
   if (ret != S_OK) {
     GST_WARNING_OBJECT (self->sink,
-        "Failed to set audio output callback 0x%08lx", ret);
+        "Failed to set audio output callback 0x%08lx", (unsigned long) ret);
     return FALSE;
   }
 
index 97583b7..7aa642f 100644 (file)
@@ -406,7 +406,8 @@ gst_decklink_audio_src_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
         self->input->config->SetInt (bmdDeckLinkConfigAudioInputConnection,
         conn);
     if (ret != S_OK) {
-      GST_ERROR ("set configuration (audio input connection): 0x%08x", ret);
+      GST_ERROR ("set configuration (audio input connection): 0x%08lx",
+          (unsigned long) ret);
       return FALSE;
     }
   }
@@ -414,7 +415,8 @@ gst_decklink_audio_src_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
   ret = self->input->input->EnableAudioInput (bmdAudioSampleRate48kHz,
       sample_depth, self->info.channels);
   if (ret != S_OK) {
-    GST_WARNING_OBJECT (self, "Failed to enable audio input: 0x%08x", ret);
+    GST_WARNING_OBJECT (self, "Failed to enable audio input: 0x%08lx",
+        (unsigned long) ret);
     return FALSE;
   }
 
index 0c2b304..0a4f886 100644 (file)
@@ -404,7 +404,8 @@ gst_decklink_video_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
 
   ret = self->output->output->EnableVideoOutput (mode->mode, flags);
   if (ret != S_OK) {
-    GST_WARNING_OBJECT (self, "Failed to enable video output: 0x%08x", ret);
+    GST_WARNING_OBJECT (self, "Failed to enable video output: 0x%08lx",
+        (unsigned long) ret);
     return FALSE;
   }
 
@@ -611,7 +612,7 @@ gst_decklink_video_sink_prepare (GstBaseSink * bsink, GstBuffer * buffer)
       &frame);
   if (ret != S_OK) {
     GST_ELEMENT_ERROR (self, STREAM, FAILED,
-        (NULL), ("Failed to create video frame: 0x%08x", ret));
+        (NULL), ("Failed to create video frame: 0x%08lx", (unsigned long) ret));
     return GST_FLOW_ERROR;
   }
 
@@ -651,7 +652,8 @@ gst_decklink_video_sink_prepare (GstBaseSink * bsink, GstBuffer * buffer)
         (uint8_t) tc_meta->tc.seconds, (uint8_t) tc_meta->tc.frames, bflags);
     if (ret != S_OK) {
       GST_ERROR_OBJECT (self,
-          "Failed to set timecode %s to video frame: 0x%08x", tc_str, ret);
+          "Failed to set timecode %s to video frame: 0x%08lx", tc_str,
+          (unsigned long) ret);
       flow_ret = GST_FLOW_ERROR;
       g_free (tc_str);
       goto out;
@@ -667,7 +669,8 @@ gst_decklink_video_sink_prepare (GstBaseSink * bsink, GstBuffer * buffer)
     ret = self->output->output->DisplayVideoFrameSync (frame);
     if (ret != S_OK) {
       GST_ELEMENT_WARNING (self, STREAM, FAILED,
-          (NULL), ("Failed to show video frame synchronously: 0x%08x", ret));
+          (NULL), ("Failed to show video frame synchronously: 0x%08lx",
+            (unsigned long) ret));
       ret = S_OK;
     }
   }
@@ -680,7 +683,7 @@ gst_decklink_video_sink_prepare (GstBaseSink * bsink, GstBuffer * buffer)
       running_time, running_time_duration, GST_SECOND);
   if (ret != S_OK) {
     GST_ELEMENT_ERROR (self, STREAM, FAILED,
-        (NULL), ("Failed to schedule frame: 0x%08x", ret));
+        (NULL), ("Failed to schedule frame: 0x%08lx", (unsigned long) ret));
     flow_ret = GST_FLOW_ERROR;
     goto out;
   }
@@ -829,7 +832,8 @@ gst_decklink_video_sink_start_scheduled_playback (GstElement * element)
       res = self->output->output->StopScheduledPlayback (0, 0, 0);
       if (res != S_OK) {
         GST_ELEMENT_ERROR (self, STREAM, FAILED,
-            (NULL), ("Failed to stop scheduled playback: 0x%08x", res));
+            (NULL), ("Failed to stop scheduled playback: 0x%08lx",
+              (unsigned long) res));
         gst_object_unref (clock);
         return;
       }
@@ -844,7 +848,8 @@ gst_decklink_video_sink_start_scheduled_playback (GstElement * element)
         GST_SECOND, 1.0);
     if (res != S_OK) {
       GST_ELEMENT_ERROR (self, STREAM, FAILED,
-          (NULL), ("Failed to start scheduled playback: 0x%08x", res));
+          (NULL), ("Failed to start scheduled playback: 0x%08lx",
+            (unsigned long) res));
       gst_object_unref (clock);
       return;
     }
@@ -912,7 +917,8 @@ gst_decklink_video_sink_stop_scheduled_playback (GstDecklinkVideoSink * self)
   res = self->output->output->StopScheduledPlayback (start_time, 0, GST_SECOND);
   if (res != S_OK) {
     GST_ELEMENT_ERROR (self, STREAM, FAILED,
-        (NULL), ("Failed to stop scheduled playback: 0x%08x", res));
+        (NULL), ("Failed to stop scheduled playback: 0x%08lx", (unsigned long)
+          res));
     ret = GST_STATE_CHANGE_FAILURE;
   }
   self->internal_base_time = GST_CLOCK_TIME_NONE;
index 542fd44..8978143 100644 (file)
@@ -423,7 +423,8 @@ gst_decklink_video_src_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
         gst_decklink_get_connection (self->connection));
     if (ret != S_OK) {
       GST_ERROR_OBJECT (self,
-          "Failed to set configuration (input source): 0x%08lx", ret);
+          "Failed to set configuration (input source): 0x%08lx",
+          (unsigned long) ret);
       return FALSE;
     }
 
@@ -432,7 +433,8 @@ gst_decklink_video_src_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
           bmdAnalogVideoFlagCompositeSetup75);
       if (ret != S_OK) {
         GST_ERROR_OBJECT (self,
-            "Failed to set configuration (composite setup): 0x%08lx", ret);
+            "Failed to set configuration (composite setup): 0x%08lx",
+            (unsigned long) ret);
         return FALSE;
       }
     }
@@ -449,7 +451,8 @@ gst_decklink_video_src_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
           &autoDetection);
       if (ret != S_OK) {
         GST_ERROR_OBJECT (self,
-            "Failed to get attribute (autodetection): 0x%08lx", ret);
+            "Failed to get attribute (autodetection): 0x%08lx",
+            (unsigned long) ret);
         return FALSE;
       }
       if (autoDetection)
@@ -467,7 +470,8 @@ gst_decklink_video_src_set_caps (GstBaseSrc * bsrc, GstCaps * caps)
   format = self->caps_format;
   ret = self->input->input->EnableVideoInput (mode->mode, format, flags);
   if (ret != S_OK) {
-    GST_WARNING_OBJECT (self, "Failed to enable video input: 0x%08lx", ret);
+    GST_WARNING_OBJECT (self, "Failed to enable video input: 0x%08lx",
+        (unsigned long) ret);
     return FALSE;
   }
 
@@ -699,7 +703,7 @@ gst_decklink_video_src_got_frame (GstElement * element,
       res = dtc->GetComponents (&hours, &minutes, &seconds, &frames);
       if (res != S_OK) {
         GST_ERROR ("Could not get components for timecode %p: 0x%08lx", dtc,
-            res);
+            (unsigned long) res);
         f.tc = NULL;
       } else {
         bflags = dtc->GetFlags ();
@@ -1031,7 +1035,7 @@ gst_decklink_video_src_start_streams (GstElement * element)
     res = self->input->input->StartStreams ();
     if (res != S_OK) {
       GST_ELEMENT_ERROR (self, STREAM, FAILED,
-          (NULL), ("Failed to start streams: 0x%08lx", res));
+          (NULL), ("Failed to start streams: 0x%08lx", (unsigned long) res));
       return;
     }
   } else {
@@ -1085,7 +1089,7 @@ gst_decklink_video_src_change_state (GstElement * element,
       res = self->input->input->StopStreams ();
       if (res != S_OK) {
         GST_ELEMENT_ERROR (self, STREAM, FAILED,
-            (NULL), ("Failed to stop streams: 0x%08lx", res));
+            (NULL), ("Failed to stop streams: 0x%08lx", (unsigned long) res));
         ret = GST_STATE_CHANGE_FAILURE;
       }
       break;