gstreamer/subprojects/gst-plugins-bad/sys/wasapi2/meson.build

150 lines
4.4 KiB
Meson
Raw Normal View History

wasapi2_sources = [
'gstwasapi2src.c',
'gstwasapi2sink.c',
'gstwasapi2util.c',
'gstwasapi2client.cpp',
'gstwasapi2device.c',
wasapi2: Rewrite plugin and implement audioringbuffer subclass ... based on MediaFoundation work queue API. By this commit, wasapi2 plugin will make use of pull mode scheduling with audioringbuffer subclass. There are several drawbacks of audiosrc/audiosink subclassing (not audiobasesrc/audiobasesink) for WASAPI API, which are: * audiosrc/audiosink classes try to set high priority to read/write thread via MMCSS (Multimedia Class Scheduler Service) but it's not allowed in case of UWP application. In order to use MMCSS in UWP, application should use MediaFoundation work queue indirectly. Since audiosrc/audiosink scheduling model is not compatible with MediaFoundation's work queue model, audioringbuffer subclassing is required. * WASAPI capture device might report larger packet size than expected (i.e., larger frames we can read than expected frame size per period). Meanwhile, in any case, application should drain all packets at that moment. In order to handle the case, wasapi/wasapi2 plugins were making use of GstAdapter which is obviously sub-optimal because it requires additional memory allocation and copy. By implementing audioringbuffer subclassing, we can avoid such inefficiency. In this commit, all the device read/write operations will be moved to newly implemented wasapi2ringbuffer class and existing wasapi2client class will take care of device enumeration and activation parts only. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2306>
2021-05-10 11:45:28 +00:00
'gstwasapi2ringbuffer.cpp',
'plugin.c',
]
mmdeviceapi_symbols = [
'ActivateAudioInterfaceAsync',
'DEVINTERFACE_AUDIO_RENDER',
'DEVINTERFACE_AUDIO_CAPTURE',
]
wasapi2_option = get_option('wasapi2')
if host_system != 'windows'
if wasapi2_option.disabled()
subdir_done()
elif wasapi2_option.enabled()
error('Cannot build wasapi2 plugin when not building for Windows')
endif
endif
ole32_dep = cc.find_library('ole32', required : get_option('wasapi2'))
ksuser_dep = cc.find_library('ksuser', required : get_option('wasapi2'))
runtimeobject_dep = cc.find_library('runtimeobject', required : get_option('wasapi2'))
mmdeviceapi_dep = cc.find_library('mmdevapi', required : get_option('wasapi2'))
wasapi2: Rewrite plugin and implement audioringbuffer subclass ... based on MediaFoundation work queue API. By this commit, wasapi2 plugin will make use of pull mode scheduling with audioringbuffer subclass. There are several drawbacks of audiosrc/audiosink subclassing (not audiobasesrc/audiobasesink) for WASAPI API, which are: * audiosrc/audiosink classes try to set high priority to read/write thread via MMCSS (Multimedia Class Scheduler Service) but it's not allowed in case of UWP application. In order to use MMCSS in UWP, application should use MediaFoundation work queue indirectly. Since audiosrc/audiosink scheduling model is not compatible with MediaFoundation's work queue model, audioringbuffer subclassing is required. * WASAPI capture device might report larger packet size than expected (i.e., larger frames we can read than expected frame size per period). Meanwhile, in any case, application should drain all packets at that moment. In order to handle the case, wasapi/wasapi2 plugins were making use of GstAdapter which is obviously sub-optimal because it requires additional memory allocation and copy. By implementing audioringbuffer subclassing, we can avoid such inefficiency. In this commit, all the device read/write operations will be moved to newly implemented wasapi2ringbuffer class and existing wasapi2client class will take care of device enumeration and activation parts only. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2306>
2021-05-10 11:45:28 +00:00
mfplat_dep = cc.find_library('mfplat', required : get_option('wasapi2'))
wasapi2_dep = [ole32_dep, ksuser_dep, runtimeobject_dep, mmdeviceapi_dep, mfplat_dep]
extra_args = ['-DGST_USE_UNSTABLE_API']
foreach dep: wasapi2_dep
if not dep.found()
if wasapi2_option.enabled()
error('wasapi2 plugin was enabled explicitly, but required dependencies were not found')
else
subdir_done()
endif
endif
endforeach
if not cxx.has_header_symbol ('audioclient.h', 'IAudioClient3', dependencies : wasapi2_dep)
if wasapi2_option.enabled()
error('wasapi2 plugin was enabled explicitly, but IAudioClient3 is unavailable')
else
subdir_done()
endif
endif
foreach symbol: mmdeviceapi_symbols
if not cxx.has_header_symbol ('mmdeviceapi.h', symbol, dependencies : wasapi2_dep)
if wasapi2_option.enabled()
error('wasapi2 plugin was enabled explicitly, but @1@ is unavailable'.format(symbol))
else
subdir_done()
endif
endif
endforeach
winapi_app = cxx.compiles('''#include <winapifamily.h>
#include <windows.applicationmodel.core.h>
#include <wrl.h>
#include <wrl/wrappers/corewrappers.h>
#include <audioclient.h>
#include <mmdeviceapi.h>
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
#error "not winrt"
#endif
int main (int argc, char ** argv) {
IAudioClient3 *client = NULL;
return 0;
} ''',
dependencies: wasapi2_dep,
name: 'building for WINAPI_PARTITION_APP')
if not winapi_app
if wasapi2_option.enabled()
error('wasapi2 plugin was enabled explicitly, but build target is not include WINAPI_PARTITION_APP')
else
subdir_done()
endif
endif
winapi_desktop = cxx.compiles('''#include <winapifamily.h>
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#error "not win32"
#endif''',
name: 'building for WINAPI_PARTITION_DESKTOP')
if winapi_app and not winapi_desktop
extra_args += ['-DGST_WASAPI2_WINAPI_ONLY_APP']
endif
win10_sdk = cxx.compiles('''#include <windows.h>
#ifndef WDK_NTDDI_VERSION
#error "unknown Windows SDK version"
#endif
#if (WDK_NTDDI_VERSION < 0x0A000000)
#error "Not a Windows 10 SDK"
#endif
''',
name: 'building with Windows 10 SDK')
if not win10_sdk
if wasapi2_option.enabled()
error('wasapi2 plugin was enabled explicitly, but Windows 10 SDK is unavailable')
else
subdir_done()
endif
endif
building_for_win10 = cxx.compiles('''#include <windows.h>
#ifndef WINVER
#error "unknown minimum supported OS version"
#endif
#if (WINVER < 0x0A00)
#error "Windows 10 API is not guaranteed"
#endif
''',
name: 'building for Windows 10')
if not building_for_win10
message('Bumping target Windows version to Windows 10 for building wasapi2 plugin')
extra_args += ['-DWINVER=0x0A00', '-D_WIN32_WINNT=0x0A00', '-DNTDDI_VERSION=WDK_NTDDI_VERSION']
endif
if not gstwinrt_dep.found()
if wasapi2_option.enabled()
error('wasapi2 plugin was enabled explicitly, but GstWinRt library is unavailable')
else
subdir_done()
endif
endif
# Work around for Windows SDK header issue
# https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-160#windows-header-issues
extra_cpp_args = cxx.get_supported_arguments(['/Zc:twoPhase-'])
gstwasapi2 = library('gstwasapi2',
wasapi2_sources,
c_args : gst_plugins_bad_args + ['-DCOBJMACROS'] + extra_args,
cpp_args : gst_plugins_bad_args + extra_args + extra_cpp_args,
include_directories : [configinc],
dependencies : [gstaudio_dep, gstwinrt_dep] + wasapi2_dep,
install : true,
install_dir : plugins_install_dir)
plugins += [gstwasapi2]