Commit graph

6 commits

Author SHA1 Message Date
Seungha Yang
b7abd34285 wasapi2src: Add support for loopback recording
... and add various device error handling.

This loopback implementation is functionally identical to that of wasapisrc.
When it's enabled, wasapi2src will read data from render device instead of
capture device.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2311>
2021-06-09 22:15:06 +09:00
Seungha Yang
a8ec40c850 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-06-08 19:39:27 +09:00
Seungha Yang
8d1a79e520 wasapi2device: Make wasapi2 device distinguishable from wasapi device
Both wasapi2 and wasapi plugins use WASAPI API. So "device.api=wasapi"
would make sense for the wasapi2 plugin as well. But people would be
confused by the identical "device.api=wasapi" property if intended
plugin is wasapi, not wasapi2. This change will make them distinguishable
by using "device.api" device property.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2024>
2021-02-18 21:46:08 +09:00
Seungha Yang
ed14e0d5a6 wasapi2device: Allow empty caps for UWP use case
If the device has not been activated yet, caps might not be available.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1466>
2020-07-26 12:52:15 +00:00
Seungha Yang
b10afc574e wasapi2: Add a new property for ICoreDispatcher setting
... so that ensure device activation on UI thread.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1466>
2020-07-26 12:52:15 +00:00
Seungha Yang
a6a4267c7b wasapi2: Add device provider implementation
Similar to device provider implementation of wasapi plugin,
this implementation supports only static probing.
But we can implement runtime device add/remove/update
monitoring using DeviceWatcher interface later.

See https://docs.microsoft.com/en-us/uwp/api/windows.devices.enumeration.devicewatcher

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1264>
2020-06-08 03:10:05 +00:00