From e22c7fb3e4a88359e9e92b3c5a03314ebef9e6cb Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Wed, 26 Jul 2023 00:21:24 +1000 Subject: [PATCH] osxaudio: Share debug category in the internal coreaudio object Make the internal coreaudio object output debug to the same debug category by making it shared between code units. Part-of: --- .../sys/osxaudio/gstosxcoreaudio.c | 6 +-- .../sys/osxaudio/gstosxcoreaudiocommon.c | 3 ++ .../sys/osxaudio/gstosxcoreaudiohal.c | 48 +++++++++---------- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudio.c b/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudio.c index 036245c7cf..6c5115d693 100644 --- a/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudio.c +++ b/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudio.c @@ -24,8 +24,8 @@ #include "gstosxcoreaudio.h" #include "gstosxcoreaudiocommon.h" -GST_DEBUG_CATEGORY_STATIC (osx_audio_debug); -#define GST_CAT_DEFAULT osx_audio_debug +GST_DEBUG_CATEGORY (osx_coreaudio_debug); +#define GST_CAT_DEFAULT osx_coreaudio_debug G_DEFINE_TYPE (GstCoreAudio, gst_core_audio, G_TYPE_OBJECT); @@ -260,7 +260,7 @@ gst_core_audio_select_device (GstCoreAudio * core_audio) void gst_core_audio_init_debug (void) { - GST_DEBUG_CATEGORY_INIT (osx_audio_debug, "osxaudio", 0, + GST_DEBUG_CATEGORY_INIT (osx_coreaudio_debug, "osxaudio", 0, "OSX Audio Elements"); } diff --git a/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiocommon.c b/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiocommon.c index 39d03ac5b4..deb6747dd2 100644 --- a/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiocommon.c +++ b/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiocommon.c @@ -23,6 +23,9 @@ #include "gstosxcoreaudiocommon.h" +GST_DEBUG_CATEGORY_EXTERN (osx_coreaudio_debug); +#define GST_CAT_DEFAULT osx_coreaudio_debug + void gst_core_audio_remove_render_callback (GstCoreAudio * core_audio) { diff --git a/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiohal.c b/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiohal.c index 31ebe60709..2eb27e2b49 100644 --- a/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiohal.c +++ b/subprojects/gst-plugins-good/sys/osxaudio/gstosxcoreaudiohal.c @@ -1162,7 +1162,7 @@ gst_core_audio_initialize_impl (GstCoreAudio * core_audio, _monitorize_spdif (core_audio); } else { OSStatus status; - UInt32 propertySize; + UInt32 propertySize = sizeof (*frame_size); core_audio->stream_idx = 0; if (!gst_core_audio_set_format (core_audio, format)) @@ -1172,34 +1172,30 @@ gst_core_audio_initialize_impl (GstCoreAudio * core_audio, format.mChannelsPerFrame, caps)) goto done; - if (core_audio->is_src) { - propertySize = sizeof (*frame_size); - - // Attempt to configure the requested frame size if smaller than the device's - // This will apparently modify the size for all audio devices in the current process so should - // be done conservatively - if (frame_size != 0) { - guint32 cur_frame_size; - status = AudioUnitGetProperty (core_audio->audiounit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0, /* N/A for global */ - &cur_frame_size, &propertySize); - if (!status && *frame_size < cur_frame_size) { - status = AudioUnitSetProperty (core_audio->audiounit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0, /* N/A for global */ - frame_size, propertySize); - if (status) { - GST_WARNING_OBJECT (core_audio->osxbuf, - "Failed to set desired frame size of %u: %d", *frame_size, - (int) status); - } + // Attempt to configure the requested frame size if smaller than the device's + // This will apparently modify the size for all audio devices in the current process so should + // be done conservatively + if (frame_size != 0) { + guint32 cur_frame_size; + status = AudioUnitGetProperty (core_audio->audiounit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0, /* N/A for global */ + &cur_frame_size, &propertySize); + if (!status && *frame_size < cur_frame_size) { + status = AudioUnitSetProperty (core_audio->audiounit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0, /* N/A for global */ + frame_size, propertySize); + if (status) { + GST_WARNING_OBJECT (core_audio->osxbuf, + "Failed to set desired frame size of %u: %d", *frame_size, + (int) status); } } - status = AudioUnitGetProperty (core_audio->audiounit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0, /* N/A for global */ - frame_size, &propertySize); + } + status = AudioUnitGetProperty (core_audio->audiounit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0, /* N/A for global */ + frame_size, &propertySize); - if (status) { - GST_WARNING_OBJECT (core_audio->osxbuf, "Failed to get frame size: %d", - (int) status); - goto done; - } + if (status) { + GST_WARNING_OBJECT (core_audio->osxbuf, "Failed to get frame size: %d", + (int) status); + goto done; } }