2020-05-25 20:17:41 +00:00
|
|
|
wasapi2_sources = [
|
|
|
|
'gstwasapi2src.c',
|
|
|
|
'gstwasapi2sink.c',
|
|
|
|
'gstwasapi2util.c',
|
|
|
|
'gstwasapi2client.cpp',
|
2020-05-27 20:09:47 +00:00
|
|
|
'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',
|
2020-05-25 20:17:41 +00:00
|
|
|
'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]
|
2021-08-26 13:38:37 +00:00
|
|
|
extra_args = ['-DGST_USE_UNSTABLE_API']
|
2020-05-25 20:17:41 +00:00
|
|
|
|
|
|
|
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,
|
2021-01-12 15:27:40 +00:00
|
|
|
name: 'building for WINAPI_PARTITION_APP')
|
2020-05-25 20:17:41 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2022-01-19 20:59:36 +00:00
|
|
|
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
|
|
|
|
|
2021-01-12 15:27:40 +00:00
|
|
|
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')
|
2024-10-12 22:10:46 +00:00
|
|
|
extra_args += ['-U_WIN32_WINNT', '-UWINVER', '-DWINVER=0x0A00', '-D_WIN32_WINNT=0x0A00', '-DNTDDI_VERSION=WDK_NTDDI_VERSION']
|
2021-01-12 15:27:40 +00:00
|
|
|
endif
|
|
|
|
|
2021-08-26 13:38:37 +00:00
|
|
|
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
|
|
|
|
|
2021-10-16 13:43:32 +00:00
|
|
|
# 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-'])
|
|
|
|
|
2020-05-25 20:17:41 +00:00
|
|
|
gstwasapi2 = library('gstwasapi2',
|
|
|
|
wasapi2_sources,
|
2021-01-12 15:27:40 +00:00
|
|
|
c_args : gst_plugins_bad_args + ['-DCOBJMACROS'] + extra_args,
|
2021-10-16 13:43:32 +00:00
|
|
|
cpp_args : gst_plugins_bad_args + extra_args + extra_cpp_args,
|
2020-05-25 20:17:41 +00:00
|
|
|
include_directories : [configinc],
|
2021-08-26 13:38:37 +00:00
|
|
|
dependencies : [gstaudio_dep, gstwinrt_dep] + wasapi2_dep,
|
2020-05-25 20:17:41 +00:00
|
|
|
install : true,
|
|
|
|
install_dir : plugins_install_dir)
|
|
|
|
plugins += [gstwasapi2]
|