mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 05:01:23 +00:00
osxaudio: Avoid dangling pointer on shutdown
When tearing down the elements we were still referring to the ringbuffer unique_id as our property while it was already freed, leading to potential segfaults when accessing the property. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7451>
This commit is contained in:
parent
01ab04a0b4
commit
f7faf5e8e5
2 changed files with 16 additions and 0 deletions
|
@ -239,6 +239,11 @@ gst_osx_audio_sink_change_state (GstElement * element,
|
|||
GstStateChangeReturn ret;
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||
GST_OBJECT_LOCK (osxsink);
|
||||
osxsink->device_id = kAudioDeviceUnknown;
|
||||
GST_OBJECT_UNLOCK (osxsink);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -256,7 +261,9 @@ gst_osx_audio_sink_change_state (GstElement * element,
|
|||
ringbuffer =
|
||||
GST_OSX_AUDIO_RING_BUFFER (GST_AUDIO_BASE_SINK (osxsink)->ringbuffer);
|
||||
if (ringbuffer->core_audio->device_id != osxsink->device_id) {
|
||||
GST_OBJECT_LOCK (osxsink);
|
||||
osxsink->device_id = ringbuffer->core_audio->device_id;
|
||||
GST_OBJECT_UNLOCK (osxsink);
|
||||
g_object_notify (G_OBJECT (osxsink), "device");
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -210,6 +210,12 @@ gst_osx_audio_src_change_state (GstElement * element, GstStateChange transition)
|
|||
GstStateChangeReturn ret;
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_READY_TO_NULL:{
|
||||
GST_OBJECT_LOCK (osxsrc);
|
||||
osxsrc->device_id = kAudioDeviceUnknown;
|
||||
GST_OBJECT_UNLOCK (osxsrc);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -224,7 +230,10 @@ gst_osx_audio_src_change_state (GstElement * element, GstStateChange transition)
|
|||
ringbuffer =
|
||||
GST_OSX_AUDIO_RING_BUFFER (GST_AUDIO_BASE_SRC (osxsrc)->ringbuffer);
|
||||
if (ringbuffer->core_audio->device_id != osxsrc->device_id) {
|
||||
GST_OBJECT_LOCK (osxsrc);
|
||||
osxsrc->device_id = ringbuffer->core_audio->device_id;
|
||||
GST_OBJECT_UNLOCK (osxsrc);
|
||||
|
||||
g_object_notify (G_OBJECT (osxsrc), "device");
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue