mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 14:08:56 +00:00
asio: Add support for MinGW build
Drop MSVC specific bits and remove unused dependency Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6404>
This commit is contained in:
parent
f0761a7358
commit
17f92ab400
7 changed files with 43 additions and 59 deletions
|
@ -24,7 +24,6 @@
|
|||
#include "gstasiodeviceprovider.h"
|
||||
#include "gstasioutils.h"
|
||||
#include "gstasioobject.h"
|
||||
#include <atlconv.h>
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -165,8 +164,6 @@ gst_asio_device_provider_probe_internal (GstAsioDeviceProvider * self,
|
|||
const gchar *device_class, *factory_name;
|
||||
GList *iter;
|
||||
|
||||
USES_CONVERSION;
|
||||
|
||||
if (is_src) {
|
||||
device_class = "Audio/Source";
|
||||
factory_name = "asiosrc";
|
||||
|
@ -189,6 +186,7 @@ gst_asio_device_provider_probe_internal (GstAsioDeviceProvider * self,
|
|||
glong max_buf_size = 0;
|
||||
glong preferred_buf_size = 0;
|
||||
glong buf_size_granularity = 0;
|
||||
gchar *clsid_str_utf8;
|
||||
|
||||
obj = gst_asio_object_new (info, FALSE);
|
||||
if (!obj)
|
||||
|
@ -220,9 +218,12 @@ gst_asio_device_provider_probe_internal (GstAsioDeviceProvider * self,
|
|||
&preferred_buf_size, &buf_size_granularity))
|
||||
goto done;
|
||||
|
||||
clsid_str_utf8 = g_utf16_to_utf8 ((const gunichar2 *) clsid_str, -1,
|
||||
nullptr, nullptr, nullptr);
|
||||
|
||||
props = gst_structure_new ("asio-proplist",
|
||||
"device.api", G_TYPE_STRING, "asio",
|
||||
"device.clsid", G_TYPE_STRING, OLE2A (clsid_str),
|
||||
"device.clsid", G_TYPE_STRING, clsid_str_utf8,
|
||||
"asio.device.description", G_TYPE_STRING, info->driver_desc,
|
||||
"asio.device.min-buf-size", G_TYPE_LONG, min_buf_size,
|
||||
"asio.device.max-buf-size", G_TYPE_LONG, max_buf_size,
|
||||
|
@ -231,14 +232,18 @@ gst_asio_device_provider_probe_internal (GstAsioDeviceProvider * self,
|
|||
nullptr);
|
||||
|
||||
device = (GstDevice *) g_object_new (GST_TYPE_ASIO_DEVICE,
|
||||
"device-clsid", OLE2A (clsid_str),
|
||||
"device-clsid", clsid_str_utf8,
|
||||
"display-name", info->driver_desc, "caps", caps,
|
||||
"device-class", device_class, "properties", props, nullptr);
|
||||
GST_ASIO_DEVICE (device)->factory_name = factory_name;
|
||||
|
||||
g_free (clsid_str_utf8);
|
||||
|
||||
*devices = g_list_append (*devices, device);
|
||||
|
||||
done:
|
||||
if (clsid_str)
|
||||
CoTaskMemFree (clsid_str);
|
||||
gst_clear_caps (&caps);
|
||||
gst_clear_object (&obj);
|
||||
if (props)
|
||||
|
|
|
@ -959,7 +959,7 @@ gst_asio_object_get_caps (GstAsioObject * obj, GstAsioDeviceClassType type,
|
|||
|
||||
/* max_num_channels == 0 means [1, max-allowed-channles] */
|
||||
if (max_num_channels > 0) {
|
||||
if (max_num_channels > obj->max_num_input_channels) {
|
||||
if (max_num_channels > (guint) obj->max_num_input_channels) {
|
||||
GST_WARNING_OBJECT (obj, "Too many max channels");
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -968,7 +968,7 @@ gst_asio_object_get_caps (GstAsioObject * obj, GstAsioDeviceClassType type,
|
|||
}
|
||||
|
||||
if (min_num_channels > 0) {
|
||||
if (min_num_channels > obj->max_num_input_channels) {
|
||||
if (min_num_channels > (guint) obj->max_num_input_channels) {
|
||||
GST_WARNING_OBJECT (obj, "Too many min channels");
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -985,7 +985,7 @@ gst_asio_object_get_caps (GstAsioObject * obj, GstAsioDeviceClassType type,
|
|||
|
||||
/* max_num_channels == 0 means [1, max-allowed-channles] */
|
||||
if (max_num_channels > 0) {
|
||||
if (max_num_channels > obj->max_num_output_channels) {
|
||||
if (max_num_channels > (guint) obj->max_num_output_channels) {
|
||||
GST_WARNING_OBJECT (obj, "Too many max channels");
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -994,7 +994,7 @@ gst_asio_object_get_caps (GstAsioObject * obj, GstAsioDeviceClassType type,
|
|||
}
|
||||
|
||||
if (min_num_channels > 0) {
|
||||
if (min_num_channels > obj->max_num_output_channels) {
|
||||
if (min_num_channels > (guint) obj->max_num_output_channels) {
|
||||
GST_WARNING_OBJECT (obj, "Too many min channels");
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1094,7 +1094,7 @@ gst_asio_object_validate_channels (GstAsioObject * self, gboolean is_input,
|
|||
guint * channel_indices, guint num_channels)
|
||||
{
|
||||
if (is_input) {
|
||||
if (self->max_num_input_channels < num_channels) {
|
||||
if ((guint) self->max_num_input_channels < num_channels) {
|
||||
GST_WARNING_OBJECT (self, "%d exceeds max input channels %ld",
|
||||
num_channels, self->max_num_input_channels);
|
||||
return FALSE;
|
||||
|
@ -1102,7 +1102,7 @@ gst_asio_object_validate_channels (GstAsioObject * self, gboolean is_input,
|
|||
|
||||
for (guint i = 0; i < num_channels; i++) {
|
||||
guint ch = channel_indices[i];
|
||||
if (self->max_num_input_channels <= ch) {
|
||||
if ((guint) self->max_num_input_channels <= ch) {
|
||||
GST_WARNING_OBJECT (self, "%d exceeds max input channels %ld",
|
||||
ch, self->max_num_input_channels);
|
||||
|
||||
|
@ -1110,7 +1110,7 @@ gst_asio_object_validate_channels (GstAsioObject * self, gboolean is_input,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (self->max_num_output_channels < num_channels) {
|
||||
if ((guint) self->max_num_output_channels < num_channels) {
|
||||
GST_WARNING_OBJECT (self, "%d exceeds max output channels %ld",
|
||||
num_channels, self->max_num_output_channels);
|
||||
|
||||
|
@ -1119,7 +1119,7 @@ gst_asio_object_validate_channels (GstAsioObject * self, gboolean is_input,
|
|||
|
||||
for (guint i = 0; i < num_channels; i++) {
|
||||
guint ch = channel_indices[i];
|
||||
if (self->max_num_output_channels <= ch) {
|
||||
if ((guint) self->max_num_output_channels <= ch) {
|
||||
GST_WARNING_OBJECT (self, "%d exceeds max output channels %ld",
|
||||
ch, self->max_num_output_channels);
|
||||
|
||||
|
@ -1147,7 +1147,7 @@ gst_asio_object_check_buffer_reuse (GstAsioObject * self, ASIOBool is_input,
|
|||
continue;
|
||||
|
||||
for (guint j = 0; j < num_channels; j++) {
|
||||
if (info->channelNum == channel_indices[j]) {
|
||||
if ((guint) info->channelNum == channel_indices[j]) {
|
||||
num_found++;
|
||||
|
||||
break;
|
||||
|
@ -1347,7 +1347,7 @@ gst_asio_object_create_buffers (GstAsioObject * obj,
|
|||
}
|
||||
|
||||
obj->num_requested_input_channels = 0;
|
||||
for (guint i = 0; i < obj->max_num_input_channels; i++) {
|
||||
for (guint i = 0; i < (guint) obj->max_num_input_channels; i++) {
|
||||
if (obj->input_channel_requested[i])
|
||||
obj->num_requested_input_channels++;
|
||||
}
|
||||
|
@ -1359,7 +1359,7 @@ gst_asio_object_create_buffers (GstAsioObject * obj,
|
|||
}
|
||||
|
||||
obj->num_requested_output_channels = 0;
|
||||
for (guint i = 0; i < obj->max_num_output_channels; i++) {
|
||||
for (guint i = 0; i < (guint) obj->max_num_output_channels; i++) {
|
||||
if (obj->output_channel_requested[i])
|
||||
obj->num_requested_output_channels++;
|
||||
}
|
||||
|
@ -1370,7 +1370,7 @@ gst_asio_object_create_buffers (GstAsioObject * obj,
|
|||
obj->num_requested_output_channels;
|
||||
|
||||
obj->buffer_infos = g_new0 (ASIOBufferInfo, obj->num_allocated_buffers);
|
||||
for (i = 0, j = 0; i < obj->num_requested_input_channels; i++) {
|
||||
for (i = 0, j = 0; i < (guint) obj->num_requested_input_channels; i++) {
|
||||
ASIOBufferInfo *info = &obj->buffer_infos[i];
|
||||
|
||||
info->isInput = TRUE;
|
||||
|
@ -1382,7 +1382,7 @@ gst_asio_object_create_buffers (GstAsioObject * obj,
|
|||
}
|
||||
|
||||
for (i = obj->num_requested_input_channels, j = 0;
|
||||
i <
|
||||
i < (guint)
|
||||
obj->num_requested_input_channels + obj->num_requested_output_channels;
|
||||
i++) {
|
||||
ASIOBufferInfo *info = &obj->buffer_infos[i];
|
||||
|
|
|
@ -70,12 +70,6 @@ static gboolean gst_asio_ring_buffer_start (GstAudioRingBuffer * buf);
|
|||
static gboolean gst_asio_ring_buffer_stop (GstAudioRingBuffer * buf);
|
||||
static guint gst_asio_ring_buffer_delay (GstAudioRingBuffer * buf);
|
||||
|
||||
static gboolean gst_asio_buffer_switch_cb (GstAsioObject * obj,
|
||||
glong index, ASIOBufferInfo * infos, guint num_infos,
|
||||
ASIOChannelInfo * input_channel_infos,
|
||||
ASIOChannelInfo * output_channel_infos,
|
||||
ASIOSampleRate sample_rate, glong buffer_size, gpointer user_data);
|
||||
|
||||
#define gst_asio_ring_buffer_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstAsioRingBuffer, gst_asio_ring_buffer,
|
||||
GST_TYPE_AUDIO_RING_BUFFER);
|
||||
|
@ -196,7 +190,8 @@ gst_asio_buffer_switch_cb (GstAsioObject * obj, glong index,
|
|||
guint64 gap_frames = sample_position - self->expected_sample_position;
|
||||
gint gap_size = gap_frames * bps;
|
||||
|
||||
GST_WARNING_OBJECT (self, "%" G_GUINT64_FORMAT " frames are missing");
|
||||
GST_WARNING_OBJECT (self, "%" G_GUINT64_FORMAT " frames are missing",
|
||||
gap_frames);
|
||||
|
||||
while (gap_size >= len) {
|
||||
gst_audio_format_info_fill_silence (ringbuffer->spec.info.finfo,
|
||||
|
@ -232,7 +227,7 @@ gst_asio_buffer_switch_cb (GstAsioObject * obj, glong index,
|
|||
}
|
||||
|
||||
for (j = 0; j < self->num_channels; j++) {
|
||||
if (self->channel_indices[j] != info->channelNum)
|
||||
if (self->channel_indices[j] != (guint) info->channelNum)
|
||||
continue;
|
||||
|
||||
g_assert (num_channels < self->num_channels);
|
||||
|
@ -253,7 +248,7 @@ gst_asio_buffer_switch_cb (GstAsioObject * obj, glong index,
|
|||
guint gst_offset = 0, asio_offset = 0;
|
||||
|
||||
/* Interleaves audio */
|
||||
while (gst_offset < len) {
|
||||
while (gst_offset < (guint) len) {
|
||||
for (i = 0; i < num_channels; i++) {
|
||||
ASIOBufferInfo *info = self->infos[i];
|
||||
|
||||
|
@ -272,7 +267,7 @@ gst_asio_buffer_switch_cb (GstAsioObject * obj, glong index,
|
|||
guint gst_offset = 0, asio_offset = 0;
|
||||
|
||||
/* Interleaves audio */
|
||||
while (gst_offset < len) {
|
||||
while (gst_offset < (guint) len) {
|
||||
for (i = 0; i < num_channels; i++) {
|
||||
ASIOBufferInfo *info = self->infos[i];
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "gstasiosink.h"
|
||||
#include "gstasioobject.h"
|
||||
#include "gstasioringbuffer.h"
|
||||
#include <atlconv.h>
|
||||
#include <string.h>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
@ -240,8 +239,6 @@ gst_asio_sink_create_ringbuffer (GstAudioBaseSink * sink)
|
|||
guint i;
|
||||
gchar *ringbuffer_name;
|
||||
|
||||
USES_CONVERSION;
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Create ringbuffer");
|
||||
|
||||
if (gst_asio_enum (&device_infos) == 0) {
|
||||
|
@ -250,7 +247,10 @@ gst_asio_sink_create_ringbuffer (GstAudioBaseSink * sink)
|
|||
}
|
||||
|
||||
if (self->device_clsid) {
|
||||
hr = CLSIDFromString (A2COLE (self->device_clsid), &clsid);
|
||||
auto clsid_utf16 = g_utf8_to_utf16 (self->device_clsid,
|
||||
-1, nullptr, nullptr, nullptr);
|
||||
hr = CLSIDFromString ((const wchar_t *) clsid_utf16, &clsid);
|
||||
g_free (clsid_utf16);
|
||||
if (FAILED (hr)) {
|
||||
GST_WARNING_OBJECT (self, "Failed to convert %s to CLSID",
|
||||
self->device_clsid);
|
||||
|
@ -298,7 +298,7 @@ gst_asio_sink_create_ringbuffer (GstAudioBaseSink * sink)
|
|||
ch = g_strsplit (self->output_channels, ",", 0);
|
||||
|
||||
auto num_channels = g_strv_length (ch);
|
||||
if (num_channels > max_output_ch) {
|
||||
if (num_channels > (guint) max_output_ch) {
|
||||
GST_WARNING_OBJECT (self, "To many channels %d were requested",
|
||||
num_channels);
|
||||
} else {
|
||||
|
@ -318,7 +318,7 @@ gst_asio_sink_create_ringbuffer (GstAudioBaseSink * sink)
|
|||
}
|
||||
|
||||
if (channel_list.size () == 0) {
|
||||
for (i = 0; i < max_output_ch; i++)
|
||||
for (i = 0; i < (guint) max_output_ch; i++)
|
||||
channel_indices.push_back (i);
|
||||
} else {
|
||||
for (auto iter : channel_list)
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "gstasiosrc.h"
|
||||
#include "gstasioobject.h"
|
||||
#include "gstasioringbuffer.h"
|
||||
#include <atlconv.h>
|
||||
#include <string.h>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
@ -253,7 +252,6 @@ gst_asio_src_create_ringbuffer (GstAudioBaseSrc * src)
|
|||
guint i;
|
||||
gchar *ringbuffer_name;
|
||||
|
||||
USES_CONVERSION;
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Create ringbuffer");
|
||||
|
||||
|
@ -263,7 +261,11 @@ gst_asio_src_create_ringbuffer (GstAudioBaseSrc * src)
|
|||
}
|
||||
|
||||
if (self->device_clsid) {
|
||||
hr = CLSIDFromString (A2COLE (self->device_clsid), &clsid);
|
||||
auto clsid_utf16 = g_utf8_to_utf16 (self->device_clsid,
|
||||
-1, nullptr, nullptr, nullptr);
|
||||
hr = CLSIDFromString ((const wchar_t *) clsid_utf16, &clsid);
|
||||
g_free (clsid_utf16);
|
||||
|
||||
if (FAILED (hr)) {
|
||||
GST_WARNING_OBJECT (self, "Failed to convert %s to CLSID",
|
||||
self->device_clsid);
|
||||
|
@ -311,7 +313,7 @@ gst_asio_src_create_ringbuffer (GstAudioBaseSrc * src)
|
|||
ch = g_strsplit (self->capture_channles, ",", 0);
|
||||
|
||||
auto num_channels = g_strv_length (ch);
|
||||
if (num_channels > max_input_ch) {
|
||||
if (num_channels > (guint) max_input_ch) {
|
||||
GST_WARNING_OBJECT (self, "To many channels %d were requested",
|
||||
num_channels);
|
||||
} else {
|
||||
|
@ -331,7 +333,7 @@ gst_asio_src_create_ringbuffer (GstAudioBaseSrc * src)
|
|||
}
|
||||
|
||||
if (channel_list.size () == 0) {
|
||||
for (i = 0; i < max_input_ch; i++)
|
||||
for (i = 0; i < (guint) max_input_ch; i++)
|
||||
channel_indices.push_back (i);
|
||||
} else {
|
||||
for (auto iter : channel_list)
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "gstasioutils.h"
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
#include <atlconv.h>
|
||||
|
||||
static gboolean
|
||||
gst_asio_enum_check_class_root (GstAsioDeviceInfo * info, LPCWSTR clsid)
|
||||
|
@ -93,8 +92,6 @@ gst_asio_enum_new_device_info_from_reg (HKEY reg_key, LPWSTR key_name)
|
|||
CLSID id;
|
||||
HRESULT hr;
|
||||
|
||||
USES_CONVERSION;
|
||||
|
||||
status = RegOpenKeyExW (reg_key, key_name, 0, KEY_READ, &sub_key);
|
||||
if (status != ERROR_SUCCESS)
|
||||
return nullptr;
|
||||
|
@ -105,7 +102,7 @@ gst_asio_enum_new_device_info_from_reg (HKEY reg_key, LPWSTR key_name)
|
|||
if (status != ERROR_SUCCESS)
|
||||
goto done;
|
||||
|
||||
hr = CLSIDFromString (W2COLE (clsid_data), &id);
|
||||
hr = CLSIDFromString (clsid_data, &id);
|
||||
if (FAILED (hr))
|
||||
goto done;
|
||||
|
||||
|
|
|
@ -13,16 +13,6 @@ if asio_option.disabled() or host_system != 'windows'
|
|||
subdir_done()
|
||||
endif
|
||||
|
||||
# FIXME: non-msvc is not tested, and unlikely supported yet because of
|
||||
# tool-chain issue
|
||||
if cxx.get_id() != 'msvc'
|
||||
if asio_option.enabled()
|
||||
error('asio plugin can only be built with MSVC')
|
||||
else
|
||||
subdir_done ()
|
||||
endif
|
||||
endif
|
||||
|
||||
winapi_desktop = cxx.compiles('''#include <winapifamily.h>
|
||||
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
#error "not win32"
|
||||
|
@ -42,15 +32,10 @@ if not avrt_lib.found()
|
|||
subdir_done ()
|
||||
endif
|
||||
|
||||
winmm_lib = cc.find_library('winmm', required: asio_option)
|
||||
if not winmm_lib.found()
|
||||
subdir_done ()
|
||||
endif
|
||||
|
||||
gstasio = library('gstasio',
|
||||
asio_sources,
|
||||
include_directories : [configinc],
|
||||
dependencies : [gstaudio_dep, avrt_lib, winmm_lib],
|
||||
dependencies : [gstaudio_dep, avrt_lib],
|
||||
c_args : gst_plugins_bad_args,
|
||||
cpp_args : gst_plugins_bad_args,
|
||||
install : true,
|
||||
|
|
Loading…
Reference in a new issue