/* protect against cached_caps going away */
GST_OBJECT_LOCK (buf);
- if (osxbuf->core_audio->cached_caps) {
+ if (osxbuf->core_audio->cached_caps_valid) {
GST_LOG_OBJECT (sink, "Returning cached caps");
caps = gst_caps_ref (osxbuf->core_audio->cached_caps);
} else if (buf->open) {
/* protect against cached_caps going away */
GST_OBJECT_LOCK (buf);
- if (osxbuf->core_audio->cached_caps) {
+ if (osxbuf->core_audio->cached_caps_valid) {
GST_LOG_OBJECT (src, "Returning cached caps");
caps = gst_caps_ref (osxbuf->core_audio->cached_caps);
} else if (buf->open) {
core_audio->is_src = FALSE;
core_audio->audiounit = NULL;
core_audio->cached_caps = NULL;
+ core_audio->cached_caps_valid = FALSE;
#ifndef HAVE_IOS
core_audio->hog_pid = -1;
core_audio->disabled_mixing = FALSE;
* as needed.
* This merely "refreshes" our PREFERRED caps. */
- /* protect against cached_caps going away */
- GST_OBJECT_LOCK (core_audio->osxbuf);
- gst_caps_replace (&core_audio->cached_caps, NULL);
- GST_OBJECT_UNLOCK (core_audio->osxbuf);
+ /* This function is called either from a Core Audio thread
+ * or as a result of a Core Audio API (e.g. AudioUnitInitialize)
+ * from our own thread. In the latter case, osxbuf can be
+ * already locked (GStreamer's mutex is not recursive).
+ * For this reason we use a boolean flag instead of nullifying
+ * cached_caps. */
+ core_audio->cached_caps_valid = FALSE;
}
break;
}
core_audio);
/* core_audio->osxbuf is already locked at this point */
+ core_audio->cached_caps_valid = FALSE;
gst_caps_replace (&core_audio->cached_caps, NULL);
AudioComponentInstanceDispose (core_audio->audiounit);
{
OSStatus status;
+ /* core_audio->osxbuf is already locked at this point */
+ core_audio->cached_caps_valid = FALSE;
+ gst_caps_replace (&core_audio->cached_caps, NULL);
+
if (!gst_core_audio_open_impl (core_audio))
return FALSE;