decklinkaudiosink: Fix playback when video caps is configured before audio
authorSeungha Yang <seungha@centricular.com>
Fri, 7 Apr 2023 13:13:24 +0000 (22:13 +0900)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 7 Apr 2023 23:00:16 +0000 (00:00 +0100)
Scheduled playback starts on videosink's state change or on caps
but it's possible that audiosink is configure without caps yet.
Try start scheduled playback on audiosink's caps event as well

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4368>

subprojects/gst-plugins-bad/sys/decklink/gstdecklinkaudiosink.cpp

index b82f63d..67e3a9e 100644 (file)
@@ -332,9 +332,11 @@ gst_decklink_audio_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
     sample_depth = bmdAudioSampleType32bitInteger;
   }
 
+  g_mutex_lock (&self->output->lock);
   ret = self->output->output->EnableAudioOutput (bmdAudioSampleRate48kHz,
       sample_depth, info.channels, bmdAudioOutputStreamContinuous);
   if (ret != S_OK) {
+    g_mutex_unlock (&self->output->lock);
     GST_WARNING_OBJECT (self, "Failed to enable audio output 0x%08lx",
         (unsigned long) ret);
     return FALSE;
@@ -343,6 +345,10 @@ gst_decklink_audio_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
   self->output->audio_enabled = TRUE;
   self->info = info;
 
+  if (self->output->start_scheduled_playback && self->output->videosink)
+    self->output->start_scheduled_playback (self->output->videosink);
+  g_mutex_unlock (&self->output->lock);
+
   // Create a new resampler as needed
   if (self->resampler)
     gst_audio_resampler_free (self->resampler);