mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
winepulse-PulseAudio_Support: Rebase and re-enable.
This commit is contained in:
parent
8630febc5c
commit
c437a01e2f
@ -249,6 +249,7 @@ patch_enable_all ()
|
||||
enable_winemenubuilder_Desktop_Icon_Path="$1"
|
||||
enable_winemenubuilder_integration="$1"
|
||||
enable_wineps_drv_PostScript_Fixes="$1"
|
||||
enable_winepulse_PulseAudio_Support="$1"
|
||||
enable_winex11_CandidateWindowPos="$1"
|
||||
enable_winex11_MWM_Decorations="$1"
|
||||
enable_winex11_UpdateLayeredWindow="$1"
|
||||
@ -778,6 +779,9 @@ patch_enable ()
|
||||
wineps.drv-PostScript_Fixes)
|
||||
enable_wineps_drv_PostScript_Fixes="$2"
|
||||
;;
|
||||
winepulse-PulseAudio_Support)
|
||||
enable_winepulse_PulseAudio_Support="$2"
|
||||
;;
|
||||
winex11-CandidateWindowPos)
|
||||
enable_winex11_CandidateWindowPos="$2"
|
||||
;;
|
||||
@ -3771,6 +3775,22 @@ if test "$enable_wineps_drv_PostScript_Fixes" -eq 1; then
|
||||
patch_apply wineps.drv-PostScript_Fixes/0004-wineps.drv-Add-support-for-GETFACENAME-and-DOWNLOADF.patch
|
||||
fi
|
||||
|
||||
# Patchset winepulse-PulseAudio_Support
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
# | * [#37042] Implement exclusive mode in PulseAudio backend
|
||||
# |
|
||||
# | Modified files:
|
||||
# | * dlls/winepulse.drv/Makefile.in, dlls/winepulse.drv/mmdevdrv.c, dlls/winepulse.drv/pulse.c, dlls/winepulse.drv/unixlib.h
|
||||
# |
|
||||
if test "$enable_winepulse_PulseAudio_Support" -eq 1; then
|
||||
patch_apply winepulse-PulseAudio_Support/0001-winepulse.drv-Use-a-separate-mainloop-and-ctx-for-pu.patch
|
||||
patch_apply winepulse-PulseAudio_Support/0003-winepulse-expose-audio-devices-directly-to-programs.patch
|
||||
patch_apply winepulse-PulseAudio_Support/0005-winepulse-implement-GetPropValue.patch
|
||||
patch_apply winepulse-PulseAudio_Support/0006-winepulse-fetch-actual-program-name-if-possible.patch
|
||||
patch_apply winepulse-PulseAudio_Support/0007-winepulse-return-PKEY_AudioEndpoint_PhysicalSpeakers.patch
|
||||
fi
|
||||
|
||||
# Patchset winex11-CandidateWindowPos
|
||||
# |
|
||||
# | This patchset fixes the following Wine bugs:
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 4e795dd8fda937cc61bf393880eafd28e8dea98f Mon Sep 17 00:00:00 2001
|
||||
From 503c347c96daf6d1f7be91038898a8b192fe5f6b Mon Sep 17 00:00:00 2001
|
||||
From: Mark Harmstone <mark@harmstone.com>
|
||||
Date: Mon, 3 Nov 2014 02:06:40 +0000
|
||||
Subject: [PATCH] winepulse: expose audio devices directly to programs
|
||||
@ -15,189 +15,468 @@ Changes by Sebastian Lackner <sebastian@fds-team.de>:
|
||||
* Fixed compiler warnings with -Werror
|
||||
* Some style fixes and better error handling
|
||||
* Move initialization code to pulse_test_connect()
|
||||
|
||||
Changes by Gabriel Ivăncescu <gabrielopcode@gmail.com>:
|
||||
* Rebased with unixlib separation.
|
||||
* Pass KEY_WOW64_64KEY so they use the same keys.
|
||||
* Store the display name in the registry, and generate the GUID when enumerating.
|
||||
* Move the special default devices lookup to get_pulse_name_by_guid.
|
||||
---
|
||||
dlls/winepulse.drv/mmdevdrv.c | 252 ++++++++++++++++++++++++++++++----
|
||||
1 file changed, 224 insertions(+), 28 deletions(-)
|
||||
dlls/winepulse.drv/mmdevdrv.c | 183 ++++++++++++++++++++++++++++------
|
||||
dlls/winepulse.drv/pulse.c | 175 ++++++++++++++++++++++++++++++--
|
||||
dlls/winepulse.drv/unixlib.h | 1 +
|
||||
3 files changed, 318 insertions(+), 41 deletions(-)
|
||||
|
||||
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
|
||||
index 6d4ffecaca8..4d91aa60151 100644
|
||||
index 35a66e1..c8856ff 100644
|
||||
--- a/dlls/winepulse.drv/mmdevdrv.c
|
||||
+++ b/dlls/winepulse.drv/mmdevdrv.c
|
||||
@@ -79,12 +79,25 @@ static pthread_mutex_t pulse_lock;
|
||||
static pthread_cond_t pulse_cond = PTHREAD_COND_INITIALIZER;
|
||||
static struct list g_sessions = LIST_INIT(g_sessions);
|
||||
|
||||
+typedef struct _PhysDevice {
|
||||
+ struct list entry;
|
||||
+ GUID guid;
|
||||
+ WCHAR name[0];
|
||||
+} PhysDevice;
|
||||
+
|
||||
static UINT g_phys_speakers_mask = 0;
|
||||
+static struct list g_phys_speakers = LIST_INIT(g_phys_speakers);
|
||||
+static struct list g_phys_sources = LIST_INIT(g_phys_sources);
|
||||
|
||||
/* Mixer format + period times */
|
||||
static WAVEFORMATEXTENSIBLE pulse_fmt[2];
|
||||
static REFERENCE_TIME pulse_min_period[2], pulse_def_period[2];
|
||||
|
||||
+static const WCHAR drv_key_devicesW[] = {'S','o','f','t','w','a','r','e','\\',
|
||||
+ 'W','i','n','e','\\','D','r','i','v','e','r','s','\\',
|
||||
+ 'w','i','n','e','p','u','l','s','e','.','d','r','v','\\','d','e','v','i','c','e','s',0};
|
||||
+static const WCHAR guidW[] = {'g','u','i','d',0};
|
||||
+
|
||||
static GUID pulse_render_guid =
|
||||
{ 0xfd47d9cc, 0x4218, 0x4135, { 0x9c, 0xe2, 0x0c, 0x19, 0x5c, 0x87, 0x40, 0x5b } };
|
||||
static GUID pulse_capture_guid =
|
||||
@@ -106,6 +119,13 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved)
|
||||
if (pthread_mutex_init(&pulse_lock, &attr) != 0)
|
||||
pthread_mutex_init(&pulse_lock, NULL);
|
||||
} else if (reason == DLL_PROCESS_DETACH) {
|
||||
+ PhysDevice *dev, *dev_next;
|
||||
+
|
||||
+ LIST_FOR_EACH_ENTRY_SAFE(dev, dev_next, &g_phys_speakers, PhysDevice, entry)
|
||||
+ HeapFree(GetProcessHeap(), 0, dev);
|
||||
+ LIST_FOR_EACH_ENTRY_SAFE(dev, dev_next, &g_phys_sources, PhysDevice, entry)
|
||||
+ HeapFree(GetProcessHeap(), 0, dev);
|
||||
+
|
||||
if (pulse_thread)
|
||||
SetThreadPriority(pulse_thread, 0);
|
||||
if (pulse_ctx) {
|
||||
@@ -167,6 +187,7 @@ struct ACImpl {
|
||||
@@ -134,6 +134,7 @@ struct ACImpl {
|
||||
IUnknown *marshal;
|
||||
IMMDevice *parent;
|
||||
struct list entry;
|
||||
float vol[PA_CHANNELS_MAX];
|
||||
+ char device[256];
|
||||
float *vol;
|
||||
|
||||
LONG ref;
|
||||
EDataFlow dataflow;
|
||||
@@ -196,8 +217,6 @@ struct ACImpl {
|
||||
struct list packet_filled_head;
|
||||
@@ -147,8 +148,6 @@ struct ACImpl {
|
||||
AudioSessionWrapper *session_wrapper;
|
||||
};
|
||||
|
||||
-static const WCHAR defaultW[] = {'P','u','l','s','e','a','u','d','i','o',0};
|
||||
-static const WCHAR defaultW[] = L"PulseAudio";
|
||||
-
|
||||
static const IAudioClient3Vtbl AudioClient3_Vtbl;
|
||||
static const IAudioRenderClientVtbl AudioRenderClient_Vtbl;
|
||||
static const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl;
|
||||
@@ -605,12 +624,92 @@ fail:
|
||||
return E_FAIL;
|
||||
@@ -267,39 +266,96 @@ static void set_stream_volumes(ACImpl *This)
|
||||
pulse_call(set_volumes, ¶ms);
|
||||
}
|
||||
|
||||
-HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, const WCHAR ***ids, GUID **keys,
|
||||
+HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID **keys,
|
||||
UINT *num, UINT *def_index)
|
||||
{
|
||||
- WCHAR *id;
|
||||
+ WCHAR flow_char = (flow == eRender) ? '0' : '1';
|
||||
+ DWORD i, k = 0, count = 0, maxlen, size, type;
|
||||
+ WCHAR *id, *key_name = NULL;
|
||||
+ HKEY dev_key, key = NULL;
|
||||
+ LSTATUS status;
|
||||
+ GUID guid;
|
||||
|
||||
TRACE("%d %p %p %p\n", flow, ids, num, def_index);
|
||||
|
||||
- *num = 1;
|
||||
+ *num = 0;
|
||||
*def_index = 0;
|
||||
-
|
||||
- *ids = HeapAlloc(GetProcessHeap(), 0, sizeof(**ids));
|
||||
+ *ids = NULL;
|
||||
*keys = NULL;
|
||||
- if (!*ids)
|
||||
- return E_OUTOFMEMORY;
|
||||
|
||||
- (*ids)[0] = id = HeapAlloc(GetProcessHeap(), 0, sizeof(defaultW));
|
||||
- *keys = HeapAlloc(GetProcessHeap(), 0, sizeof(**keys));
|
||||
- if (!*keys || !id) {
|
||||
- HeapFree(GetProcessHeap(), 0, id);
|
||||
- HeapFree(GetProcessHeap(), 0, *keys);
|
||||
- HeapFree(GetProcessHeap(), 0, *ids);
|
||||
- *ids = NULL;
|
||||
- *keys = NULL;
|
||||
- return E_OUTOFMEMORY;
|
||||
+ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Wine\\Drivers\\winepulse.drv\\devices",
|
||||
+ 0, KEY_READ | KEY_WOW64_64KEY, &key) == ERROR_SUCCESS) {
|
||||
+ status = RegQueryInfoKeyW(key, NULL, NULL, NULL, &count, &maxlen, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
+ if (status != ERROR_SUCCESS || maxlen < 3)
|
||||
+ count = 0;
|
||||
}
|
||||
- memcpy(id, defaultW, sizeof(defaultW));
|
||||
|
||||
- if (flow == eRender)
|
||||
- (*keys)[0] = pulse_render_guid;
|
||||
- else
|
||||
- (*keys)[0] = pulse_capture_guid;
|
||||
+ if (count && !(key_name = malloc((maxlen + 1) * sizeof(WCHAR))))
|
||||
+ goto err;
|
||||
+
|
||||
+ *ids = HeapAlloc(GetProcessHeap(), 0, (count + 1) * sizeof(**ids));
|
||||
+ *keys = HeapAlloc(GetProcessHeap(), 0, (count + 1) * sizeof(**keys));
|
||||
+ if (!*ids || !*keys)
|
||||
+ goto err;
|
||||
+
|
||||
+ if (!(id = HeapAlloc(GetProcessHeap(), 0, sizeof(L"PulseAudio"))))
|
||||
+ goto err;
|
||||
+ wcscpy(id, L"PulseAudio");
|
||||
+ (*ids)[k] = id;
|
||||
+ (*keys)[k++] = (flow == eRender) ? pulse_render_guid : pulse_capture_guid;
|
||||
+
|
||||
+ for (i = 0; i < count; i++) {
|
||||
+ DWORD key_name_size = maxlen + 1;
|
||||
+
|
||||
+ if (RegEnumKeyExW(key, i, key_name, &key_name_size, NULL, NULL, NULL, NULL) != ERROR_SUCCESS ||
|
||||
+ key_name_size < 3 || key_name[0] != flow_char ||
|
||||
+ RegOpenKeyExW(key, key_name, 0, KEY_READ | KEY_WRITE | KEY_WOW64_64KEY, &dev_key) != ERROR_SUCCESS)
|
||||
+ continue;
|
||||
+
|
||||
+ status = RegQueryValueExW(dev_key, L"name", 0, &type, NULL, &size);
|
||||
+ if (status == ERROR_SUCCESS && type == REG_SZ && size >= sizeof(WCHAR)) {
|
||||
+ if (!(id = HeapAlloc(GetProcessHeap(), 0, size))) {
|
||||
+ RegCloseKey(dev_key);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ status = RegQueryValueExW(dev_key, L"name", 0, &type, (BYTE*)id, &size);
|
||||
+ if (status == ERROR_SUCCESS && type == REG_SZ && size >= sizeof(WCHAR)) {
|
||||
+ id[size / sizeof(WCHAR) - 1] = 0;
|
||||
+
|
||||
+ size = sizeof(guid);
|
||||
+ status = RegQueryValueExW(dev_key, L"guid", 0, &type, (BYTE*)&guid, &size);
|
||||
+
|
||||
+ if (status != ERROR_SUCCESS || type != REG_BINARY || size != sizeof(guid)) {
|
||||
+ CoCreateGuid(&guid);
|
||||
+ status = RegSetValueExW(dev_key, L"guid", 0, REG_BINARY, (BYTE*)&guid, sizeof(guid));
|
||||
+ if (status != ERROR_SUCCESS)
|
||||
+ ERR("Failed to store device GUID for %s to registry\n", debugstr_w(key_name + 2));
|
||||
+ }
|
||||
+ (*ids)[k] = id;
|
||||
+ (*keys)[k++] = guid;
|
||||
+ } else {
|
||||
+ HeapFree(GetProcessHeap(), 0, id);
|
||||
+ }
|
||||
+ }
|
||||
+ RegCloseKey(dev_key);
|
||||
+ }
|
||||
+ *num = k;
|
||||
+ *ids = HeapReAlloc(GetProcessHeap(), 0, *ids, k * sizeof(**ids));
|
||||
+ *keys = HeapReAlloc(GetProcessHeap(), 0, *keys, k * sizeof(**keys));
|
||||
|
||||
+ if (key) RegCloseKey(key);
|
||||
+ free(key_name);
|
||||
return S_OK;
|
||||
+
|
||||
+err:
|
||||
+ if (key) RegCloseKey(key);
|
||||
+ while (k--) HeapFree(GetProcessHeap(), 0, (*ids)[k]);
|
||||
+ HeapFree(GetProcessHeap(), 0, *keys);
|
||||
+ HeapFree(GetProcessHeap(), 0, *ids);
|
||||
+ free(key_name);
|
||||
+ *ids = NULL;
|
||||
+ *keys = NULL;
|
||||
+ return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
int WINAPI AUDDRV_GetPriority(void)
|
||||
@@ -314,26 +370,88 @@ int WINAPI AUDDRV_GetPriority(void)
|
||||
return SUCCEEDED(params.result) ? Priority_Preferred : Priority_Unavailable;
|
||||
}
|
||||
|
||||
+static BOOL get_pulse_name_by_guid(const GUID *guid, char *name, DWORD name_size, EDataFlow *flow)
|
||||
+{
|
||||
+ DWORD key_name_size;
|
||||
+ WCHAR key_name[258];
|
||||
+ DWORD index = 0;
|
||||
+ HKEY key;
|
||||
+
|
||||
+ name[0] = 0;
|
||||
+ if (IsEqualGUID(guid, &pulse_render_guid)) {
|
||||
+ *flow = eRender;
|
||||
+ return TRUE;
|
||||
+ } else if (IsEqualGUID(guid, &pulse_capture_guid)) {
|
||||
+ *flow = eCapture;
|
||||
+ return TRUE;
|
||||
+ }
|
||||
+
|
||||
+ if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Wine\\Drivers\\winepulse.drv\\devices",
|
||||
+ 0, KEY_READ | KEY_WOW64_64KEY, &key) != ERROR_SUCCESS) {
|
||||
+ ERR("No devices found in registry?\n");
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ for (;;) {
|
||||
+ DWORD size, type;
|
||||
+ LSTATUS status;
|
||||
+ GUID reg_guid;
|
||||
+ HKEY dev_key;
|
||||
+
|
||||
+ key_name_size = ARRAY_SIZE(key_name);
|
||||
+ if (RegEnumKeyExW(key, index++, key_name, &key_name_size, NULL,
|
||||
+ NULL, NULL, NULL) != ERROR_SUCCESS)
|
||||
+ break;
|
||||
+
|
||||
+ if (RegOpenKeyExW(key, key_name, 0, KEY_READ | KEY_WOW64_64KEY, &dev_key) != ERROR_SUCCESS) {
|
||||
+ ERR("Couldn't open key: %s\n", wine_dbgstr_w(key_name));
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ size = sizeof(reg_guid);
|
||||
+ status = RegQueryValueExW(dev_key, L"guid", 0, &type, (BYTE *)®_guid, &size);
|
||||
+ RegCloseKey(dev_key);
|
||||
+
|
||||
+ if (status == ERROR_SUCCESS && type == REG_BINARY && size == sizeof(reg_guid) && IsEqualGUID(®_guid, guid)) {
|
||||
+ RegCloseKey(key);
|
||||
+
|
||||
+ TRACE("Found matching device key: %s\n", wine_dbgstr_w(key_name));
|
||||
+
|
||||
+ if (key_name[0] == '0')
|
||||
+ *flow = eRender;
|
||||
+ else if (key_name[0] == '1')
|
||||
+ *flow = eCapture;
|
||||
+ else {
|
||||
+ ERR("Unknown device type: %c\n", key_name[0]);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ return WideCharToMultiByte(CP_UNIXCP, 0, key_name + 2, -1, name, name_size, NULL, NULL);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ RegCloseKey(key);
|
||||
+ WARN("No matching device in registry for GUID %s\n", debugstr_guid(guid));
|
||||
+ return FALSE;
|
||||
+}
|
||||
+
|
||||
HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient **out)
|
||||
{
|
||||
- ACImpl *This;
|
||||
+ ACImpl *This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
|
||||
EDataFlow dataflow;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("%s %p %p\n", debugstr_guid(guid), dev, out);
|
||||
- if (IsEqualGUID(guid, &pulse_render_guid))
|
||||
- dataflow = eRender;
|
||||
- else if (IsEqualGUID(guid, &pulse_capture_guid))
|
||||
- dataflow = eCapture;
|
||||
- else
|
||||
- return E_UNEXPECTED;
|
||||
|
||||
*out = NULL;
|
||||
-
|
||||
- This = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*This));
|
||||
if (!This)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
+ if (!get_pulse_name_by_guid(guid, This->device, sizeof(This->device), &dataflow)) {
|
||||
+ HeapFree(GetProcessHeap(), 0, This);
|
||||
+ return AUDCLNT_E_DEVICE_INVALIDATED;
|
||||
+ }
|
||||
+
|
||||
This->IAudioClient3_iface.lpVtbl = &AudioClient3_Vtbl;
|
||||
This->IAudioRenderClient_iface.lpVtbl = &AudioRenderClient_Vtbl;
|
||||
This->IAudioCaptureClient_iface.lpVtbl = &AudioCaptureClient_Vtbl;
|
||||
@@ -609,6 +727,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
|
||||
}
|
||||
|
||||
params.name = name = get_application_name();
|
||||
+ params.device = This->device[0] ? This->device : NULL;
|
||||
params.dataflow = This->dataflow;
|
||||
params.mode = mode;
|
||||
params.flags = flags;
|
||||
diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c
|
||||
index c8c3104..76e4935 100644
|
||||
--- a/dlls/winepulse.drv/pulse.c
|
||||
+++ b/dlls/winepulse.drv/pulse.c
|
||||
@@ -82,6 +82,11 @@ typedef struct _ACPacket
|
||||
UINT32 discont;
|
||||
} ACPacket;
|
||||
|
||||
+typedef struct _PhysDevice {
|
||||
+ struct list entry;
|
||||
+ char device[0];
|
||||
+} PhysDevice;
|
||||
+
|
||||
static pa_context *pulse_ctx;
|
||||
static pa_mainloop *pulse_ml;
|
||||
|
||||
@@ -90,6 +95,9 @@ static WAVEFORMATEXTENSIBLE pulse_fmt[2];
|
||||
static REFERENCE_TIME pulse_min_period[2], pulse_def_period[2];
|
||||
|
||||
static UINT g_phys_speakers_mask = 0;
|
||||
+static struct list g_phys_speakers = LIST_INIT(g_phys_speakers);
|
||||
+static struct list g_phys_sources = LIST_INIT(g_phys_sources);
|
||||
+static HKEY devices_key;
|
||||
|
||||
static const REFERENCE_TIME MinimumPeriod = 30000;
|
||||
static const REFERENCE_TIME DefaultPeriod = 100000;
|
||||
@@ -153,6 +161,61 @@ static int muldiv(int a, int b, int c)
|
||||
return ret;
|
||||
}
|
||||
|
||||
+/* wrapper for NtCreateKey that creates the key recursively if necessary */
|
||||
+static HKEY reg_create_key(HKEY root, const WCHAR *name, ULONG name_len)
|
||||
+{
|
||||
+ UNICODE_STRING nameW = { name_len, name_len, (WCHAR *)name };
|
||||
+ OBJECT_ATTRIBUTES attr;
|
||||
+ NTSTATUS status;
|
||||
+ HANDLE ret = 0;
|
||||
+
|
||||
+ attr.Length = sizeof(attr);
|
||||
+ attr.RootDirectory = root;
|
||||
+ attr.ObjectName = &nameW;
|
||||
+ attr.Attributes = 0;
|
||||
+ attr.SecurityDescriptor = NULL;
|
||||
+ attr.SecurityQualityOfService = NULL;
|
||||
+
|
||||
+ status = NtCreateKey(&ret, KEY_QUERY_VALUE | KEY_WRITE | KEY_WOW64_64KEY, &attr, 0, NULL, 0, NULL);
|
||||
+ if (status == STATUS_OBJECT_NAME_NOT_FOUND) {
|
||||
+ DWORD pos = 0, i = 0, len = name_len / sizeof(WCHAR);
|
||||
+
|
||||
+ /* don't try to create registry root */
|
||||
+ if (!root) i += 10;
|
||||
+
|
||||
+ while (i < len && name[i] != '\\') i++;
|
||||
+ if (i == len) return 0;
|
||||
+ for (;;) {
|
||||
+ nameW.Buffer = (WCHAR *)name + pos;
|
||||
+ nameW.Length = (i - pos) * sizeof(WCHAR);
|
||||
+ status = NtCreateKey(&ret, KEY_QUERY_VALUE | KEY_WRITE | KEY_WOW64_64KEY, &attr, 0, NULL, 0, NULL);
|
||||
+
|
||||
+ if (attr.RootDirectory != root) NtClose(attr.RootDirectory);
|
||||
+ if (!NT_SUCCESS(status)) return 0;
|
||||
+ if (i == len) break;
|
||||
+ attr.RootDirectory = ret;
|
||||
+ while (i < len && name[i] == '\\') i++;
|
||||
+ pos = i;
|
||||
+ while (i < len && name[i] != '\\') i++;
|
||||
+ }
|
||||
+ }
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static HKEY open_devices_key(void)
|
||||
+{
|
||||
+ static const WCHAR drv_key_devicesW[] = {
|
||||
+ '\\','R','e','g','i','s','t','r','y','\\','M','a','c','h','i','n','e','\\',
|
||||
+ 'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\','D','r','i','v','e','r','s','\\',
|
||||
+ 'w','i','n','e','p','u','l','s','e','.','d','r','v','\\','d','e','v','i','c','e','s'
|
||||
+ };
|
||||
+ HANDLE ret;
|
||||
+
|
||||
+ if (!(ret = reg_create_key(NULL, drv_key_devicesW, sizeof(drv_key_devicesW))))
|
||||
+ ERR("Failed to open devices registry key\n");
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
/* Following pulseaudio design here, mainloop has the lock taken whenever
|
||||
* it is handling something for pulse, and the lock is required whenever
|
||||
* doing any pa_* call that can affect the state in any way
|
||||
@@ -191,6 +254,13 @@ static NTSTATUS pulse_process_attach(void *args)
|
||||
|
||||
static NTSTATUS pulse_process_detach(void *args)
|
||||
{
|
||||
+ PhysDevice *dev, *dev_next;
|
||||
+
|
||||
+ LIST_FOR_EACH_ENTRY_SAFE(dev, dev_next, &g_phys_speakers, PhysDevice, entry)
|
||||
+ free(dev);
|
||||
+ LIST_FOR_EACH_ENTRY_SAFE(dev, dev_next, &g_phys_sources, PhysDevice, entry)
|
||||
+ free(dev);
|
||||
+
|
||||
if (pulse_ctx)
|
||||
{
|
||||
pa_context_disconnect(pulse_ctx);
|
||||
@@ -358,12 +428,73 @@ static DWORD pulse_channel_map_to_channel_mask(const pa_channel_map *map)
|
||||
return mask;
|
||||
}
|
||||
|
||||
-/* For default PulseAudio render device, OR together all of the
|
||||
- * PKEY_AudioEndpoint_PhysicalSpeakers values of the sinks. */
|
||||
+static BOOL get_device_guid(EDataFlow flow, const char *device, GUID *guid)
|
||||
+static void store_device_info(EDataFlow flow, const char *device, const char *name)
|
||||
+{
|
||||
+ HKEY key, dev_key;
|
||||
+ DWORD type, size = sizeof(*guid);
|
||||
+ WCHAR key_name[258];
|
||||
+ static const WCHAR nameW[] = { 'n','a','m','e' };
|
||||
+ UNICODE_STRING name_str = { sizeof(nameW), sizeof(nameW), (WCHAR*)nameW };
|
||||
+ UINT name_len = strlen(name);
|
||||
+ WCHAR key_name[258], *wname;
|
||||
+ DWORD len, key_len;
|
||||
+ HKEY key;
|
||||
+
|
||||
+ if (!devices_key || !(wname = malloc((name_len + 1) * sizeof(WCHAR))))
|
||||
+ return;
|
||||
+
|
||||
+ key_name[0] = (flow == eCapture) ? '1' : '0';
|
||||
+ key_name[1] = ',';
|
||||
+ if (!MultiByteToWideChar(CP_UTF8, 0, device, -1, key_name + 2,
|
||||
+ (sizeof(key_name) / sizeof(*key_name)) - 2))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ if (RegCreateKeyExW(HKEY_CURRENT_USER, drv_key_devicesW, 0, NULL, 0,
|
||||
+ KEY_WRITE|KEY_READ, NULL, &key, NULL) != ERROR_SUCCESS){
|
||||
+ ERR("Failed to open registry key %s\n", debugstr_w(drv_key_devicesW));
|
||||
+ return FALSE;
|
||||
+ key_len = ntdll_umbstowcs(device, strlen(device), key_name + 2, ARRAY_SIZE(key_name) - 2);
|
||||
+ if (!key_len || key_len >= ARRAY_SIZE(key_name) - 2)
|
||||
+ goto done;
|
||||
+ key_len += 2;
|
||||
+
|
||||
+ if (!(len = ntdll_umbstowcs(name, name_len, wname, name_len)))
|
||||
+ goto done;
|
||||
+ wname[len] = 0;
|
||||
+
|
||||
+ if (!(key = reg_create_key(devices_key, key_name, key_len * sizeof(WCHAR)))) {
|
||||
+ ERR("Failed to open registry key for device %s\n", device);
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
+ if (RegCreateKeyExW(key, key_name, 0, NULL, 0, KEY_WRITE|KEY_READ,
|
||||
+ NULL, &dev_key, NULL) != ERROR_SUCCESS){
|
||||
+ ERR("Failed to open registry key for device %s\n", debugstr_w(key_name));
|
||||
+ RegCloseKey(key);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+ if (NtSetValueKey(key, &name_str, 0, REG_SZ, wname, (len + 1) * sizeof(WCHAR)))
|
||||
+ ERR("Failed to store name for %s to registry\n", device);
|
||||
+ NtClose(key);
|
||||
+
|
||||
+ if (RegQueryValueExW(dev_key, guidW, 0, &type, (BYTE *)guid,
|
||||
+ &size) == ERROR_SUCCESS){
|
||||
+ if (type == REG_BINARY && size == sizeof(*guid)){
|
||||
+ RegCloseKey(dev_key);
|
||||
+ RegCloseKey(key);
|
||||
+ return TRUE;
|
||||
+ }
|
||||
+
|
||||
+ ERR("Invalid type for device %s GUID: %u; ignoring and overwriting\n",
|
||||
+ wine_dbgstr_w(key_name), type);
|
||||
+ }
|
||||
+
|
||||
+ /* generate new GUID for this device */
|
||||
+ CoCreateGuid(guid);
|
||||
+
|
||||
+ if (RegSetValueExW(dev_key, guidW, 0, REG_BINARY, (BYTE *)guid,
|
||||
+ sizeof(GUID)) != ERROR_SUCCESS)
|
||||
+ ERR("Failed to store device GUID for %s to registry\n", device);
|
||||
+
|
||||
+ RegCloseKey(dev_key);
|
||||
+ RegCloseKey(key);
|
||||
+ return TRUE;
|
||||
+done:
|
||||
+ free(wname);
|
||||
+}
|
||||
+
|
||||
+static void pulse_add_device(struct list *list, GUID *guid, const char *name)
|
||||
+static void pulse_add_device(struct list *list, const char *device)
|
||||
+{
|
||||
+ int len = MultiByteToWideChar(CP_UNIXCP, 0, name, -1, NULL, 0);
|
||||
+ if (len) {
|
||||
+ PhysDevice *dev = HeapAlloc(GetProcessHeap(), 0, offsetof(PhysDevice, name[len]));
|
||||
+ if (dev) {
|
||||
+ MultiByteToWideChar(CP_UNIXCP, 0, name, -1, dev->name, len);
|
||||
+ dev->guid = *guid;
|
||||
+ list_add_tail(list, &dev->entry);
|
||||
+ }
|
||||
+ }
|
||||
+ DWORD len = strlen(device);
|
||||
+ PhysDevice *dev = malloc(offsetof(PhysDevice, device[len + 1]));
|
||||
+
|
||||
+ if (!dev)
|
||||
+ return;
|
||||
+ memcpy(dev->device, device, len + 1);
|
||||
+
|
||||
+ list_add_tail(list, &dev->entry);
|
||||
+}
|
||||
+
|
||||
static void pulse_phys_speakers_cb(pa_context *c, const pa_sink_info *i, int eol, void *userdata)
|
||||
{
|
||||
- if (i)
|
||||
+ GUID guid;
|
||||
+
|
||||
+ if (i) {
|
||||
+ if (i && i->name && i->name[0]) {
|
||||
+ /* For default PulseAudio render device, OR together all of the
|
||||
+ * PKEY_AudioEndpoint_PhysicalSpeakers values of the sinks. */
|
||||
g_phys_speakers_mask |= pulse_channel_map_to_channel_mask(&i->channel_map);
|
||||
+
|
||||
+ if (!get_device_guid(eRender, i->name, &guid))
|
||||
+ CoCreateGuid(&guid);
|
||||
+ pulse_add_device(&g_phys_speakers, &guid, i->description);
|
||||
+ store_device_info(eRender, i->name, i->description);
|
||||
+ pulse_add_device(&g_phys_speakers, i->name);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void pulse_phys_sources_cb(pa_context *c, const pa_source_info *i, int eol, void *userdata)
|
||||
+{
|
||||
+ GUID guid;
|
||||
+
|
||||
+ if (i) {
|
||||
+ if (!get_device_guid(eCapture, i->name, &guid))
|
||||
+ CoCreateGuid(&guid);
|
||||
+ pulse_add_device(&g_phys_sources, &guid, i->description);
|
||||
+ if (i && i->name && i->name[0]) {
|
||||
+ store_device_info(eCapture, i->name, i->description);
|
||||
+ pulse_add_device(&g_phys_sources, i->name);
|
||||
+ }
|
||||
}
|
||||
|
||||
/* some poorly-behaved applications call audio functions during DllMain, so we
|
||||
@@ -626,6 +725,10 @@ static HRESULT pulse_test_connect(void)
|
||||
pa_mainloop *ml;
|
||||
/* For most hardware on Windows, users must choose a configuration with an even
|
||||
@@ -541,6 +672,11 @@ static NTSTATUS pulse_test_connect(void *args)
|
||||
pa_context *ctx;
|
||||
|
||||
+ /* Make sure we never run this function twice accidentially */
|
||||
pulse_lock();
|
||||
+
|
||||
+ /* Make sure we never run twice accidentally */
|
||||
+ if (!list_empty(&g_phys_speakers))
|
||||
+ return S_OK;
|
||||
+ goto success;
|
||||
+
|
||||
ml = pa_mainloop_new();
|
||||
|
||||
pa_mainloop_set_poll_func(ml, pulse_poll_func, NULL);
|
||||
@@ -676,6 +779,9 @@ static HRESULT pulse_test_connect(void)
|
||||
@@ -581,7 +717,12 @@ static NTSTATUS pulse_test_connect(void *args)
|
||||
pulse_probe_settings(ml, ctx, 1, &pulse_fmt[0]);
|
||||
pulse_probe_settings(ml, ctx, 0, &pulse_fmt[1]);
|
||||
|
||||
+ devices_key = open_devices_key();
|
||||
g_phys_speakers_mask = 0;
|
||||
+ pulse_add_device(&g_phys_speakers, &pulse_render_guid, "Pulseaudio");
|
||||
+ pulse_add_device(&g_phys_sources, &pulse_capture_guid, "Pulseaudio");
|
||||
+
|
||||
+ pulse_add_device(&g_phys_speakers, "");
|
||||
+ pulse_add_device(&g_phys_sources, "");
|
||||
+
|
||||
o = pa_context_get_sink_info_list(ctx, &pulse_phys_speakers_cb, NULL);
|
||||
if (o) {
|
||||
while (pa_mainloop_iterate(ml, 1, &ret) >= 0 &&
|
||||
@@ -684,6 +790,14 @@ static HRESULT pulse_test_connect(void)
|
||||
@@ -590,6 +731,15 @@ static NTSTATUS pulse_test_connect(void *args)
|
||||
pa_operation_unref(o);
|
||||
}
|
||||
|
||||
@ -208,203 +487,76 @@ index 6d4ffecaca8..4d91aa60151 100644
|
||||
+ {}
|
||||
+ pa_operation_unref(o);
|
||||
+ }
|
||||
+ NtClose(devices_key);
|
||||
+
|
||||
pa_context_unref(ctx);
|
||||
pa_mainloop_free(ml);
|
||||
|
||||
@@ -601,6 +751,7 @@ static NTSTATUS pulse_test_connect(void *args)
|
||||
config->modes[1].def_period = pulse_def_period[1];
|
||||
config->modes[1].min_period = pulse_min_period[1];
|
||||
|
||||
+success:
|
||||
pulse_unlock();
|
||||
|
||||
params->result = S_OK;
|
||||
@@ -769,12 +920,13 @@ static HRESULT pulse_spec_from_waveformat(struct pulse_stream *stream, const WAV
|
||||
return S_OK;
|
||||
@@ -1111,6 +1225,8 @@ static HRESULT pulse_stream_connect(ACImpl *This, UINT32 period_bytes) {
|
||||
}
|
||||
|
||||
-static HRESULT pulse_stream_connect(struct pulse_stream *stream, UINT32 period_bytes)
|
||||
+static HRESULT pulse_stream_connect(struct pulse_stream *stream, const char *device, UINT32 period_bytes)
|
||||
{
|
||||
int ret;
|
||||
char buffer[64];
|
||||
static LONG number;
|
||||
pa_buffer_attr attr;
|
||||
+ int moving = 0;
|
||||
+
|
||||
if (This->stream) {
|
||||
pa_stream_disconnect(This->stream);
|
||||
while (pa_stream_get_state(This->stream) == PA_STREAM_READY)
|
||||
@@ -1136,12 +1252,18 @@ static HRESULT pulse_stream_connect(ACImpl *This, UINT32 period_bytes) {
|
||||
attr.maxlength = This->bufsize_frames * pa_frame_size(&This->ss);
|
||||
attr.prebuf = pa_frame_size(&This->ss);
|
||||
|
||||
ret = InterlockedIncrement(&number);
|
||||
sprintf(buffer, "audio stream #%i", ret);
|
||||
@@ -795,12 +947,17 @@ static HRESULT pulse_stream_connect(struct pulse_stream *stream, UINT32 period_b
|
||||
attr.maxlength = stream->bufsize_frames * pa_frame_size(&stream->ss);
|
||||
attr.prebuf = pa_frame_size(&stream->ss);
|
||||
dump_attr(&attr);
|
||||
+
|
||||
+ /* If device name is given use exactly the specified device */
|
||||
+ if (This->device[0]){
|
||||
+ if (device)
|
||||
+ moving = PA_STREAM_DONT_MOVE;
|
||||
+ }
|
||||
+
|
||||
if (This->dataflow == eRender)
|
||||
ret = pa_stream_connect_playback(This->stream, NULL, &attr,
|
||||
if (stream->dataflow == eRender)
|
||||
- ret = pa_stream_connect_playback(stream->stream, NULL, &attr,
|
||||
- PA_STREAM_START_CORKED|PA_STREAM_START_UNMUTED|PA_STREAM_ADJUST_LATENCY, NULL, NULL);
|
||||
+ ret = pa_stream_connect_playback(stream->stream, device, &attr,
|
||||
+ PA_STREAM_START_CORKED|PA_STREAM_START_UNMUTED|PA_STREAM_ADJUST_LATENCY|moving, NULL, NULL);
|
||||
else
|
||||
ret = pa_stream_connect_record(This->stream, NULL, &attr,
|
||||
- ret = pa_stream_connect_record(stream->stream, NULL, &attr,
|
||||
- PA_STREAM_START_CORKED|PA_STREAM_START_UNMUTED|PA_STREAM_ADJUST_LATENCY);
|
||||
+ ret = pa_stream_connect_record(stream->stream, device, &attr,
|
||||
+ PA_STREAM_START_CORKED|PA_STREAM_START_UNMUTED|PA_STREAM_ADJUST_LATENCY|moving);
|
||||
if (ret < 0) {
|
||||
WARN("Returns %i\n", ret);
|
||||
return AUDCLNT_E_ENDPOINT_CREATE_FAILED;
|
||||
@@ -1158,39 +1280,53 @@ static HRESULT pulse_stream_connect(ACImpl *This, UINT32 period_bytes) {
|
||||
return S_OK;
|
||||
}
|
||||
@@ -862,7 +1019,7 @@ static NTSTATUS pulse_create_stream(void *args)
|
||||
|
||||
-HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, const WCHAR ***ids, GUID **keys,
|
||||
+HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID **keys,
|
||||
UINT *num, UINT *def_index)
|
||||
stream->share = params->mode;
|
||||
stream->flags = params->flags;
|
||||
- hr = pulse_stream_connect(stream, stream->period_bytes);
|
||||
+ hr = pulse_stream_connect(stream, params->device, stream->period_bytes);
|
||||
if (SUCCEEDED(hr)) {
|
||||
UINT32 unalign;
|
||||
const pa_buffer_attr *attr = pa_stream_get_buffer_attr(stream->stream);
|
||||
diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h
|
||||
index d28a73c..5445a0f 100644
|
||||
--- a/dlls/winepulse.drv/unixlib.h
|
||||
+++ b/dlls/winepulse.drv/unixlib.h
|
||||
@@ -40,6 +40,7 @@ struct main_loop_params
|
||||
struct create_stream_params
|
||||
{
|
||||
+ struct list *list = (flow == eRender) ? &g_phys_speakers : &g_phys_sources;
|
||||
+ PhysDevice *dev;
|
||||
+ DWORD count;
|
||||
WCHAR *id;
|
||||
|
||||
TRACE("%d %p %p %p\n", flow, ids, num, def_index);
|
||||
|
||||
- *num = 1;
|
||||
+ *num = count = list_count(list);
|
||||
*def_index = 0;
|
||||
|
||||
- *ids = HeapAlloc(GetProcessHeap(), 0, sizeof(**ids));
|
||||
- *keys = NULL;
|
||||
- if (!*ids)
|
||||
- return E_OUTOFMEMORY;
|
||||
-
|
||||
- (*ids)[0] = id = HeapAlloc(GetProcessHeap(), 0, sizeof(defaultW));
|
||||
- *keys = HeapAlloc(GetProcessHeap(), 0, sizeof(**keys));
|
||||
- if (!*keys || !id) {
|
||||
- HeapFree(GetProcessHeap(), 0, id);
|
||||
- HeapFree(GetProcessHeap(), 0, *keys);
|
||||
- HeapFree(GetProcessHeap(), 0, *ids);
|
||||
+ if (!count) {
|
||||
*ids = NULL;
|
||||
*keys = NULL;
|
||||
- return E_OUTOFMEMORY;
|
||||
+ return E_FAIL;
|
||||
}
|
||||
- memcpy(id, defaultW, sizeof(defaultW));
|
||||
|
||||
- if (flow == eRender)
|
||||
- (*keys)[0] = pulse_render_guid;
|
||||
- else
|
||||
- (*keys)[0] = pulse_capture_guid;
|
||||
+ *ids = HeapAlloc(GetProcessHeap(), 0, count * sizeof(**ids));
|
||||
+ *keys = HeapAlloc(GetProcessHeap(), 0, count * sizeof(**keys));
|
||||
+ if (!*ids || !*keys) {
|
||||
+ count = 0;
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
+ count = 0;
|
||||
+ LIST_FOR_EACH_ENTRY(dev, list, PhysDevice, entry) {
|
||||
+ id = HeapAlloc(GetProcessHeap(), 0, (strlenW(dev->name) + 1) * sizeof(WCHAR));
|
||||
+ if (!id)
|
||||
+ goto err;
|
||||
+ (*ids)[count] = id;
|
||||
+ (*keys)[count] = dev->guid;
|
||||
+ strcpyW(id, dev->name);
|
||||
+ count++;
|
||||
+ }
|
||||
|
||||
return S_OK;
|
||||
+
|
||||
+err:
|
||||
+ while (count)
|
||||
+ HeapFree(GetProcessHeap(), 0, (*ids)[--count]);
|
||||
+ HeapFree(GetProcessHeap(), 0, *keys);
|
||||
+ HeapFree(GetProcessHeap(), 0, *ids);
|
||||
+ *ids = NULL;
|
||||
+ *keys = NULL;
|
||||
+ return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
int WINAPI AUDDRV_GetPriority(void)
|
||||
@@ -1202,20 +1338,79 @@ int WINAPI AUDDRV_GetPriority(void)
|
||||
return SUCCEEDED(hr) ? Priority_Preferred : Priority_Unavailable;
|
||||
}
|
||||
|
||||
+static BOOL get_pulse_name_by_guid(const GUID *guid, char *name, DWORD name_size, EDataFlow *flow)
|
||||
+{
|
||||
+ HKEY key;
|
||||
+ DWORD index = 0;
|
||||
+ WCHAR key_name[258];
|
||||
+ DWORD key_name_size;
|
||||
+
|
||||
+ if (RegOpenKeyExW(HKEY_CURRENT_USER, drv_key_devicesW, 0, KEY_READ,
|
||||
+ &key) != ERROR_SUCCESS){
|
||||
+ ERR("No devices found in registry?\n");
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ while(1){
|
||||
+ HKEY dev_key;
|
||||
+ DWORD size, type;
|
||||
+ GUID reg_guid;
|
||||
+
|
||||
+ key_name_size = sizeof(key_name)/sizeof(WCHAR);
|
||||
+ if(RegEnumKeyExW(key, index++, key_name, &key_name_size, NULL,
|
||||
+ NULL, NULL, NULL) != ERROR_SUCCESS)
|
||||
+ break;
|
||||
+
|
||||
+ if (RegOpenKeyExW(key, key_name, 0, KEY_READ, &dev_key) != ERROR_SUCCESS){
|
||||
+ ERR("Couldn't open key: %s\n", wine_dbgstr_w(key_name));
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ size = sizeof(reg_guid);
|
||||
+ if (RegQueryValueExW(dev_key, guidW, 0, &type, (BYTE *)®_guid, &size) == ERROR_SUCCESS){
|
||||
+ if (type == REG_BINARY && size == sizeof(reg_guid) && IsEqualGUID(®_guid, guid)){
|
||||
+ RegCloseKey(dev_key);
|
||||
+ RegCloseKey(key);
|
||||
+
|
||||
+ TRACE("Found matching device key: %s\n", wine_dbgstr_w(key_name));
|
||||
+
|
||||
+ if (key_name[0] == '0')
|
||||
+ *flow = eRender;
|
||||
+ else if (key_name[0] == '1')
|
||||
+ *flow = eCapture;
|
||||
+ else{
|
||||
+ ERR("Unknown device type: %c\n", key_name[0]);
|
||||
+ return FALSE;
|
||||
+ }
|
||||
+
|
||||
+ return WideCharToMultiByte(CP_UNIXCP, 0, key_name + 2, -1, name, name_size, NULL, NULL);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ RegCloseKey(dev_key);
|
||||
+ }
|
||||
+
|
||||
+ RegCloseKey(key);
|
||||
+ WARN("No matching device in registry for GUID %s\n", debugstr_guid(guid));
|
||||
+ return FALSE;
|
||||
+}
|
||||
+
|
||||
HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient **out)
|
||||
{
|
||||
+ char pulse_name[256] = {0};
|
||||
ACImpl *This;
|
||||
int i;
|
||||
const char *name;
|
||||
+ const char *device;
|
||||
EDataFlow dataflow;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("%s %p %p\n", debugstr_guid(guid), dev, out);
|
||||
+
|
||||
if (IsEqualGUID(guid, &pulse_render_guid))
|
||||
dataflow = eRender;
|
||||
else if (IsEqualGUID(guid, &pulse_capture_guid))
|
||||
dataflow = eCapture;
|
||||
- else
|
||||
- return E_UNEXPECTED;
|
||||
+ else if(!get_pulse_name_by_guid(guid, pulse_name, sizeof(pulse_name), &dataflow))
|
||||
+ return AUDCLNT_E_DEVICE_INVALIDATED;
|
||||
|
||||
*out = NULL;
|
||||
|
||||
@@ -1233,6 +1428,7 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient
|
||||
This->parent = dev;
|
||||
for (i = 0; i < PA_CHANNELS_MAX; ++i)
|
||||
This->vol[i] = 1.f;
|
||||
+ strcpy(This->device, pulse_name);
|
||||
|
||||
hr = CoCreateFreeThreadedMarshaler((IUnknown*)&This->IAudioClient3_iface, &This->marshal);
|
||||
if (hr) {
|
||||
AUDCLNT_SHAREMODE mode;
|
||||
DWORD flags;
|
||||
--
|
||||
2.28.0
|
||||
|
||||
|
@ -1,199 +1,333 @@
|
||||
From 4f994a5499335f908debff6be84e49733c94144b Mon Sep 17 00:00:00 2001
|
||||
From d5ab784623b3ea451cf2ceca466662e320958ede Mon Sep 17 00:00:00 2001
|
||||
From: Mark Harmstone <mark@harmstone.com>
|
||||
Date: Thu, 4 Dec 2014 21:36:42 +0000
|
||||
Subject: [PATCH] winepulse: implement GetPropValue
|
||||
|
||||
Changes by Gabriel Ivăncescu <gabrielopcode@gmail.com>:
|
||||
* Rebased with unixlib separation.
|
||||
* Cache the pulse device names for a given GUID.
|
||||
---
|
||||
dlls/winepulse.drv/mmdevdrv.c | 116 ++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 109 insertions(+), 7 deletions(-)
|
||||
dlls/winepulse.drv/mmdevdrv.c | 92 ++++++++++++++++++++++++++++++++++-
|
||||
dlls/winepulse.drv/pulse.c | 69 ++++++++++++++++++++++++--
|
||||
dlls/winepulse.drv/unixlib.h | 18 +++++++
|
||||
3 files changed, 173 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
|
||||
index 5c471d3c13b..b7ae9aeaabf 100644
|
||||
index c8856ff..072d27e 100644
|
||||
--- a/dlls/winepulse.drv/mmdevdrv.c
|
||||
+++ b/dlls/winepulse.drv/mmdevdrv.c
|
||||
@@ -83,6 +83,8 @@ static struct list g_sessions = LIST_INIT(g_sessions);
|
||||
typedef struct _PhysDevice {
|
||||
struct list entry;
|
||||
GUID guid;
|
||||
+ EndpointFormFactor form;
|
||||
+ WCHAR device[128];
|
||||
WCHAR name[0];
|
||||
} PhysDevice;
|
||||
@@ -63,6 +63,14 @@ static struct pulse_config pulse_config;
|
||||
|
||||
@@ -674,14 +676,67 @@ static BOOL get_device_guid(EDataFlow flow, const char *device, GUID *guid)
|
||||
return TRUE;
|
||||
}
|
||||
static HANDLE pulse_thread;
|
||||
static struct list g_sessions = LIST_INIT(g_sessions);
|
||||
+static struct list g_devices_cache = LIST_INIT(g_devices_cache);
|
||||
+
|
||||
+struct device_cache {
|
||||
+ struct list entry;
|
||||
+ GUID guid;
|
||||
+ EDataFlow dataflow;
|
||||
+ char device[0];
|
||||
+};
|
||||
|
||||
-static void pulse_add_device(struct list *list, GUID *guid, const char *name)
|
||||
+static BOOL get_device_path(pa_proplist *p, int index, GUID *guid, WCHAR path[128])
|
||||
static GUID pulse_render_guid =
|
||||
{ 0xfd47d9cc, 0x4218, 0x4135, { 0x9c, 0xe2, 0x0c, 0x19, 0x5c, 0x87, 0x40, 0x5b } };
|
||||
@@ -88,6 +96,10 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved)
|
||||
if (__wine_unix_call(pulse_handle, process_attach, NULL))
|
||||
return FALSE;
|
||||
} else if (reason == DLL_PROCESS_DETACH) {
|
||||
+ struct device_cache *device, *device_next;
|
||||
+
|
||||
+ LIST_FOR_EACH_ENTRY_SAFE(device, device_next, &g_devices_cache, struct device_cache, entry)
|
||||
+ free(device);
|
||||
__wine_unix_call(pulse_handle, process_detach, NULL);
|
||||
if (pulse_thread) {
|
||||
WaitForSingleObject(pulse_thread, INFINITE);
|
||||
@@ -372,6 +384,7 @@ int WINAPI AUDDRV_GetPriority(void)
|
||||
|
||||
static BOOL get_pulse_name_by_guid(const GUID *guid, char *name, DWORD name_size, EDataFlow *flow)
|
||||
{
|
||||
+ static const WCHAR usbformatW[] = { '{','1','}','.','U','S','B','\\','V','I','D','_',
|
||||
+ '%','0','4','X','&','P','I','D','_','%','0','4','X','\\',
|
||||
+ '%','u','&','%','0','8','X',0 }; /* "{1}.USB\VID_%04X&PID_%04X\%u&%08X" */
|
||||
+ static const WCHAR pciformatW[] = { '{','1','}','.','H','D','A','U','D','I','O','\\','F','U','N','C','_','0','1','&',
|
||||
+ 'V','E','N','_','%','0','4','X','&','D','E','V','_',
|
||||
+ '%','0','4','X','\\','%','u','&','%','0','8','X',0 }; /* "{1}.HDAUDIO\FUNC_01&VEN_%04X&DEV_%04X\%u&%08X" */
|
||||
+ struct device_cache *device;
|
||||
DWORD key_name_size;
|
||||
WCHAR key_name[258];
|
||||
DWORD index = 0;
|
||||
@@ -386,6 +399,15 @@ static BOOL get_pulse_name_by_guid(const GUID *guid, char *name, DWORD name_size
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+ /* Check the cache first */
|
||||
+ LIST_FOR_EACH_ENTRY(device, &g_devices_cache, struct device_cache, entry) {
|
||||
+ if (!IsEqualGUID(guid, &device->guid))
|
||||
+ continue;
|
||||
+ *flow = device->dataflow;
|
||||
+ strcpy(name, device->device);
|
||||
+ return TRUE;
|
||||
+ }
|
||||
+
|
||||
+ USHORT vendor_id, product_id;
|
||||
+ const char *buffer;
|
||||
+ UINT serial_number;
|
||||
+ BOOL is_usb;
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Wine\\Drivers\\winepulse.drv\\devices",
|
||||
0, KEY_READ | KEY_WOW64_64KEY, &key) != ERROR_SUCCESS) {
|
||||
ERR("No devices found in registry?\n");
|
||||
@@ -397,6 +419,7 @@ static BOOL get_pulse_name_by_guid(const GUID *guid, char *name, DWORD name_size
|
||||
LSTATUS status;
|
||||
GUID reg_guid;
|
||||
HKEY dev_key;
|
||||
+ int len;
|
||||
|
||||
key_name_size = ARRAY_SIZE(key_name);
|
||||
if (RegEnumKeyExW(key, index++, key_name, &key_name_size, NULL,
|
||||
@@ -426,7 +449,17 @@ static BOOL get_pulse_name_by_guid(const GUID *guid, char *name, DWORD name_size
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
- return WideCharToMultiByte(CP_UNIXCP, 0, key_name + 2, -1, name, name_size, NULL, NULL);
|
||||
+ if (!(len = WideCharToMultiByte(CP_UNIXCP, 0, key_name + 2, -1, name, name_size, NULL, NULL)))
|
||||
+ return FALSE;
|
||||
+
|
||||
+ buffer = pa_proplist_gets(p, PA_PROP_DEVICE_BUS);
|
||||
+ if (!buffer)
|
||||
+ return FALSE;
|
||||
+
|
||||
+ if (!strcmp(buffer,"usb"))
|
||||
+ is_usb = TRUE;
|
||||
+ else if (!strcmp(buffer,"pci"))
|
||||
+ is_usb = FALSE;
|
||||
+ else
|
||||
+ return FALSE;
|
||||
+
|
||||
+ buffer = pa_proplist_gets(p, PA_PROP_DEVICE_VENDOR_ID);
|
||||
+ if (buffer)
|
||||
+ vendor_id = strtol(buffer, NULL, 16);
|
||||
+ else
|
||||
+ return FALSE;
|
||||
+
|
||||
+ buffer = pa_proplist_gets(p, PA_PROP_DEVICE_PRODUCT_ID);
|
||||
+ if (buffer)
|
||||
+ product_id = strtol(buffer, NULL, 16);
|
||||
+ else
|
||||
+ return FALSE;
|
||||
+
|
||||
+ /* As hardly any audio devices have serial numbers, Windows instead
|
||||
+ appears to use a persistent random number. We emulate this here
|
||||
+ by instead using the last 8 hex digits of the GUID. */
|
||||
+ serial_number = (guid->Data4[4] << 24) | (guid->Data4[5] << 16) | (guid->Data4[6] << 8) | guid->Data4[7];
|
||||
+
|
||||
+ if (is_usb)
|
||||
+ sprintfW( path, usbformatW, vendor_id, product_id, index, serial_number);
|
||||
+ else
|
||||
+ sprintfW( path, pciformatW, vendor_id, product_id, index, serial_number);
|
||||
+
|
||||
+ return TRUE;
|
||||
+}
|
||||
+
|
||||
+static void pulse_add_device(struct list *list, GUID *guid, EndpointFormFactor form, WCHAR device[128], const char *name)
|
||||
+{
|
||||
+ static const WCHAR emptyW[] = {0};
|
||||
int len = MultiByteToWideChar(CP_UNIXCP, 0, name, -1, NULL, 0);
|
||||
if (len) {
|
||||
PhysDevice *dev = HeapAlloc(GetProcessHeap(), 0, offsetof(PhysDevice, name[len]));
|
||||
if (dev) {
|
||||
- MultiByteToWideChar(CP_UNIXCP, 0, name, -1, dev->name, len);
|
||||
dev->guid = *guid;
|
||||
+ dev->form = form;
|
||||
+ strcpyW(dev->device, device ? device : emptyW);
|
||||
+ MultiByteToWideChar(CP_UNIXCP, 0, name, -1, dev->name, len);
|
||||
list_add_tail(list, &dev->entry);
|
||||
+ device = malloc(offsetof(struct device_cache, device[len]));
|
||||
+ if (device) {
|
||||
+ device->guid = reg_guid;
|
||||
+ device->dataflow = *flow;
|
||||
+ strcpy(device->device, name);
|
||||
+ list_add_tail(&g_devices_cache, &device->entry);
|
||||
+ }
|
||||
+ return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -689,6 +744,7 @@ static void pulse_add_device(struct list *list, GUID *guid, const char *name)
|
||||
|
||||
static void pulse_phys_speakers_cb(pa_context *c, const pa_sink_info *i, int eol, void *userdata)
|
||||
{
|
||||
+ WCHAR device[128];
|
||||
GUID guid;
|
||||
|
||||
if (i) {
|
||||
@@ -698,18 +754,25 @@ static void pulse_phys_speakers_cb(pa_context *c, const pa_sink_info *i, int eol
|
||||
|
||||
if (!get_device_guid(eRender, i->name, &guid))
|
||||
CoCreateGuid(&guid);
|
||||
- pulse_add_device(&g_phys_speakers, &guid, i->description);
|
||||
+ if (!get_device_path(i->proplist, i->index, &guid, device))
|
||||
+ device[0] = 0;
|
||||
+ pulse_add_device(&g_phys_speakers, &guid, Speakers, device, i->description);
|
||||
}
|
||||
}
|
||||
|
||||
static void pulse_phys_sources_cb(pa_context *c, const pa_source_info *i, int eol, void *userdata)
|
||||
{
|
||||
+ EndpointFormFactor form;
|
||||
+ WCHAR device[128];
|
||||
GUID guid;
|
||||
|
||||
if (i) {
|
||||
+ form = (i->monitor_of_sink == PA_INVALID_INDEX) ? Microphone : LineLevel;
|
||||
if (!get_device_guid(eCapture, i->name, &guid))
|
||||
CoCreateGuid(&guid);
|
||||
- pulse_add_device(&g_phys_sources, &guid, i->description);
|
||||
+ if (!get_device_path(i->proplist, i->index, &guid, device))
|
||||
+ device[0] = 0;
|
||||
+ pulse_add_device(&g_phys_sources, &guid, form, device, i->description);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -780,8 +843,8 @@ static HRESULT pulse_test_connect(void)
|
||||
pulse_probe_settings(ml, ctx, 0, &pulse_fmt[1]);
|
||||
|
||||
g_phys_speakers_mask = 0;
|
||||
- pulse_add_device(&g_phys_speakers, &pulse_render_guid, "Pulseaudio");
|
||||
- pulse_add_device(&g_phys_sources, &pulse_capture_guid, "Pulseaudio");
|
||||
+ pulse_add_device(&g_phys_speakers, &pulse_render_guid, Speakers, NULL, "Pulseaudio");
|
||||
+ pulse_add_device(&g_phys_sources, &pulse_capture_guid, Microphone, NULL, "Pulseaudio");
|
||||
|
||||
o = pa_context_get_sink_info_list(ctx, &pulse_phys_speakers_cb, NULL);
|
||||
if (o) {
|
||||
@@ -3889,8 +3952,36 @@ HRESULT WINAPI AUDDRV_GetAudioSessionManager(IMMDevice *device,
|
||||
@@ -2491,8 +2524,49 @@ HRESULT WINAPI AUDDRV_GetAudioSessionManager(IMMDevice *device,
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
+static const PROPERTYKEY devicepath_key = { /* undocumented? - {b3f8fa53-0004-438e-9003-51a46e139bfc},2 */
|
||||
+ {0xb3f8fa53, 0x0004, 0x438e, {0x90, 0x03, 0x51, 0xa4, 0x6e, 0x13, 0x9b, 0xfc}}, 2
|
||||
+};
|
||||
+
|
||||
+static HRESULT pulse_device_get_prop_value(PhysDevice *dev, const PROPERTYKEY *prop, PROPVARIANT *out)
|
||||
+static HRESULT get_device_path(struct get_device_info_params *params, GUID *guid, PROPVARIANT *out)
|
||||
+{
|
||||
+ if (IsEqualPropertyKey(*prop, devicepath_key)) {
|
||||
+ if (!dev->device[0])
|
||||
+ return E_FAIL;
|
||||
+ UINT serial_number;
|
||||
+ const WCHAR *fmt;
|
||||
+ WCHAR path[128];
|
||||
+ int len;
|
||||
+
|
||||
+ out->vt = VT_LPWSTR;
|
||||
+ out->pwszVal = CoTaskMemAlloc((strlenW(dev->device) + 1) * sizeof(WCHAR));
|
||||
+ if (!out->pwszVal)
|
||||
+ return E_OUTOFMEMORY;
|
||||
+
|
||||
+ strcpyW(out->pwszVal, dev->device);
|
||||
+ return S_OK;
|
||||
+ } else if (IsEqualPropertyKey(*prop, PKEY_AudioEndpoint_FormFactor)) {
|
||||
+ out->vt = VT_UI4;
|
||||
+ out->ulVal = dev->form;
|
||||
+ return S_OK;
|
||||
+ switch (params->bus_type) {
|
||||
+ case phys_device_bus_pci:
|
||||
+ fmt = L"{1}.HDAUDIO\\FUNC_01&VEN_%04X&DEV_%04X\\%u&%08X";
|
||||
+ break;
|
||||
+ case phys_device_bus_usb:
|
||||
+ fmt = L"{1}.USB\\VID_%04X&PID_%04X\\%u&%08X";
|
||||
+ break;
|
||||
+ default:
|
||||
+ return E_FAIL;
|
||||
+ }
|
||||
+
|
||||
+ return E_NOTIMPL;
|
||||
+ /* As hardly any audio devices have serial numbers, Windows instead
|
||||
+ appears to use a persistent random number. We emulate this here
|
||||
+ by instead using the last 8 hex digits of the GUID. */
|
||||
+ serial_number = (guid->Data4[4] << 24) | (guid->Data4[5] << 16) | (guid->Data4[6] << 8) | guid->Data4[7];
|
||||
+
|
||||
+ len = swprintf(path, ARRAY_SIZE(path), fmt, params->vendor_id, params->product_id, params->index, serial_number);
|
||||
+ if (len < 0)
|
||||
+ return E_FAIL;
|
||||
+
|
||||
+ out->vt = VT_LPWSTR;
|
||||
+ out->pwszVal = CoTaskMemAlloc((len + 1) * sizeof(WCHAR));
|
||||
+ if (!out->pwszVal)
|
||||
+ return E_OUTOFMEMORY;
|
||||
+
|
||||
+ wcscpy(out->pwszVal, path);
|
||||
+ return S_OK;
|
||||
+}
|
||||
+
|
||||
HRESULT WINAPI AUDDRV_GetPropValue(GUID *guid, const PROPERTYKEY *prop, PROPVARIANT *out)
|
||||
{
|
||||
+ PhysDevice *dev;
|
||||
+ static const PROPERTYKEY devicepath_key = { /* undocumented? - {b3f8fa53-0004-438e-9003-51a46e139bfc},2 */
|
||||
+ {0xb3f8fa53, 0x0004, 0x438e, {0x90, 0x03, 0x51, 0xa4, 0x6e, 0x13, 0x9b, 0xfc}}, 2
|
||||
+ };
|
||||
+ struct get_device_info_params params;
|
||||
+
|
||||
TRACE("%s, (%s,%u), %p\n", wine_dbgstr_guid(guid), wine_dbgstr_guid(&prop->fmtid), prop->pid, out);
|
||||
|
||||
if (IsEqualGUID(guid, &pulse_render_guid) && IsEqualPropertyKey(*prop, PKEY_AudioEndpoint_PhysicalSpeakers)) {
|
||||
@@ -3900,7 +3991,18 @@ HRESULT WINAPI AUDDRV_GetPropValue(GUID *guid, const PROPERTYKEY *prop, PROPVARI
|
||||
@@ -2502,5 +2576,21 @@ HRESULT WINAPI AUDDRV_GetPropValue(GUID *guid, const PROPERTYKEY *prop, PROPVARI
|
||||
return out->ulVal ? S_OK : E_FAIL;
|
||||
}
|
||||
|
||||
- return E_NOTIMPL;
|
||||
+ LIST_FOR_EACH_ENTRY(dev, &g_phys_speakers, PhysDevice, entry) {
|
||||
+ if (IsEqualGUID(guid, &dev->guid))
|
||||
+ return pulse_device_get_prop_value(dev, prop, out);
|
||||
+ if (!get_pulse_name_by_guid(guid, params.device, sizeof(params.device), ¶ms.dataflow))
|
||||
+ return E_FAIL;
|
||||
+
|
||||
+ pulse_call(get_device_info, ¶ms);
|
||||
+ if (params.result != S_OK)
|
||||
+ return params.result;
|
||||
+
|
||||
+ if (IsEqualPropertyKey(*prop, devicepath_key))
|
||||
+ return get_device_path(¶ms, guid, out);
|
||||
+
|
||||
+ if (IsEqualPropertyKey(*prop, PKEY_AudioEndpoint_FormFactor)) {
|
||||
+ out->vt = VT_UI4;
|
||||
+ out->ulVal = params.form;
|
||||
+ return S_OK;
|
||||
+ }
|
||||
+
|
||||
+ LIST_FOR_EACH_ENTRY(dev, &g_phys_sources, PhysDevice, entry) {
|
||||
+ if (IsEqualGUID(guid, &dev->guid))
|
||||
+ return pulse_device_get_prop_value(dev, prop, out);
|
||||
+ }
|
||||
+
|
||||
+ WARN("Unknown GUID %s\n", debugstr_guid(guid));
|
||||
+ return E_FAIL;
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c
|
||||
index 76e4935..951a7bf 100644
|
||||
--- a/dlls/winepulse.drv/pulse.c
|
||||
+++ b/dlls/winepulse.drv/pulse.c
|
||||
@@ -84,6 +84,10 @@ typedef struct _ACPacket
|
||||
|
||||
typedef struct _PhysDevice {
|
||||
struct list entry;
|
||||
+ enum phys_device_bus_type bus_type;
|
||||
+ USHORT vendor_id, product_id;
|
||||
+ EndpointFormFactor form;
|
||||
+ UINT index;
|
||||
char device[0];
|
||||
} PhysDevice;
|
||||
|
||||
@@ -465,7 +469,33 @@ done:
|
||||
free(wname);
|
||||
}
|
||||
|
||||
-static void pulse_add_device(struct list *list, const char *device)
|
||||
+static void fill_device_info(PhysDevice *dev, pa_proplist *p)
|
||||
+{
|
||||
+ const char *buffer;
|
||||
+
|
||||
+ dev->bus_type = phys_device_bus_invalid;
|
||||
+ dev->vendor_id = 0;
|
||||
+ dev->product_id = 0;
|
||||
+
|
||||
+ if (!p)
|
||||
+ return;
|
||||
+
|
||||
+ if ((buffer = pa_proplist_gets(p, PA_PROP_DEVICE_BUS))) {
|
||||
+ if (!strcmp(buffer, "usb"))
|
||||
+ dev->bus_type = phys_device_bus_usb;
|
||||
+ else if (!strcmp(buffer, "pci"))
|
||||
+ dev->bus_type = phys_device_bus_pci;
|
||||
+ }
|
||||
+
|
||||
+ if ((buffer = pa_proplist_gets(p, PA_PROP_DEVICE_VENDOR_ID)))
|
||||
+ dev->vendor_id = strtol(buffer, NULL, 16);
|
||||
+
|
||||
+ if ((buffer = pa_proplist_gets(p, PA_PROP_DEVICE_PRODUCT_ID)))
|
||||
+ dev->product_id = strtol(buffer, NULL, 16);
|
||||
+}
|
||||
+
|
||||
+static void pulse_add_device(struct list *list, pa_proplist *proplist, int index, EndpointFormFactor form,
|
||||
+ const char *device)
|
||||
{
|
||||
DWORD len = strlen(device);
|
||||
PhysDevice *dev = malloc(offsetof(PhysDevice, device[len + 1]));
|
||||
@@ -473,6 +503,9 @@ static void pulse_add_device(struct list *list, const char *device)
|
||||
if (!dev)
|
||||
return;
|
||||
memcpy(dev->device, device, len + 1);
|
||||
+ dev->form = form;
|
||||
+ dev->index = index;
|
||||
+ fill_device_info(dev, proplist);
|
||||
|
||||
list_add_tail(list, &dev->entry);
|
||||
}
|
||||
@@ -485,7 +518,7 @@ static void pulse_phys_speakers_cb(pa_context *c, const pa_sink_info *i, int eol
|
||||
g_phys_speakers_mask |= pulse_channel_map_to_channel_mask(&i->channel_map);
|
||||
|
||||
store_device_info(eRender, i->name, i->description);
|
||||
- pulse_add_device(&g_phys_speakers, i->name);
|
||||
+ pulse_add_device(&g_phys_speakers, i->proplist, i->index, Speakers, i->name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,7 +526,8 @@ static void pulse_phys_sources_cb(pa_context *c, const pa_source_info *i, int eo
|
||||
{
|
||||
if (i && i->name && i->name[0]) {
|
||||
store_device_info(eCapture, i->name, i->description);
|
||||
- pulse_add_device(&g_phys_sources, i->name);
|
||||
+ pulse_add_device(&g_phys_sources, i->proplist, i->index,
|
||||
+ (i->monitor_of_sink == PA_INVALID_INDEX) ? Microphone : LineLevel, i->name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -720,8 +754,8 @@ static NTSTATUS pulse_test_connect(void *args)
|
||||
devices_key = open_devices_key();
|
||||
g_phys_speakers_mask = 0;
|
||||
|
||||
- pulse_add_device(&g_phys_speakers, "");
|
||||
- pulse_add_device(&g_phys_sources, "");
|
||||
+ pulse_add_device(&g_phys_speakers, NULL, 0, Speakers, "");
|
||||
+ pulse_add_device(&g_phys_sources, NULL, 0, Microphone, "");
|
||||
|
||||
o = pa_context_get_sink_info_list(ctx, &pulse_phys_speakers_cb, NULL);
|
||||
if (o) {
|
||||
@@ -765,6 +799,30 @@ fail:
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
+static NTSTATUS pulse_get_device_info(void *args)
|
||||
+{
|
||||
+ struct get_device_info_params *params = args;
|
||||
+ const struct list *const list = (params->dataflow == eRender) ? &g_phys_speakers : &g_phys_sources;
|
||||
+ const char *device = params->device;
|
||||
+ PhysDevice *dev;
|
||||
+
|
||||
+ LIST_FOR_EACH_ENTRY(dev, list, PhysDevice, entry) {
|
||||
+ if (!strcmp(device, dev->device)) {
|
||||
+ params->bus_type = dev->bus_type;
|
||||
+ params->vendor_id = dev->vendor_id;
|
||||
+ params->product_id = dev->product_id;
|
||||
+ params->index = dev->index;
|
||||
+ params->form = dev->form;
|
||||
+ params->result = S_OK;
|
||||
+ return STATUS_SUCCESS;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ WARN("Unknown device %s\n", device);
|
||||
+ params->result = E_FAIL;
|
||||
+ return STATUS_SUCCESS;
|
||||
+}
|
||||
+
|
||||
static DWORD get_channel_mask(unsigned int channels)
|
||||
{
|
||||
switch(channels) {
|
||||
@@ -2139,5 +2197,6 @@ const unixlib_entry_t __wine_unix_call_funcs[] =
|
||||
pulse_set_volumes,
|
||||
pulse_set_event_handle,
|
||||
pulse_test_connect,
|
||||
+ pulse_get_device_info,
|
||||
pulse_is_started,
|
||||
};
|
||||
diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h
|
||||
index 5445a0f..7383110 100644
|
||||
--- a/dlls/winepulse.drv/unixlib.h
|
||||
+++ b/dlls/winepulse.drv/unixlib.h
|
||||
@@ -181,6 +181,23 @@ struct test_connect_params
|
||||
struct pulse_config *config;
|
||||
};
|
||||
|
||||
+enum phys_device_bus_type {
|
||||
+ phys_device_bus_invalid = -1,
|
||||
+ phys_device_bus_pci,
|
||||
+ phys_device_bus_usb
|
||||
+};
|
||||
+
|
||||
+struct get_device_info_params
|
||||
+{
|
||||
+ char device[256];
|
||||
+ EDataFlow dataflow;
|
||||
+ enum phys_device_bus_type bus_type;
|
||||
+ USHORT vendor_id, product_id;
|
||||
+ EndpointFormFactor form;
|
||||
+ UINT index;
|
||||
+ HRESULT result;
|
||||
+};
|
||||
+
|
||||
struct is_started_params
|
||||
{
|
||||
struct pulse_stream *stream;
|
||||
@@ -211,5 +228,6 @@ enum unix_funcs
|
||||
set_volumes,
|
||||
set_event_handle,
|
||||
test_connect,
|
||||
+ get_device_info,
|
||||
is_started,
|
||||
};
|
||||
--
|
||||
2.30.2
|
||||
|
||||
|
@ -1,34 +1,44 @@
|
||||
From 8cfb9cdbf9448fbd2234a52ff69ac2921702996c Mon Sep 17 00:00:00 2001
|
||||
From 5b1db5456a018cc39938effae3c1bf05bd7618f9 Mon Sep 17 00:00:00 2001
|
||||
From: Mark Harmstone <mark@harmstone.com>
|
||||
Date: Sun, 21 Dec 2014 23:49:41 +0000
|
||||
Subject: [PATCH] winepulse: fetch actual program name if possible
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Changes by Sebastian Lackner <sebastian@fds-team.de>:
|
||||
* Improved error handling, fix memory leak
|
||||
* Remove check for UTF16, there are several examples where this doesn't work
|
||||
(for example with VLC media player)
|
||||
* Simplify algorithm to choose best translation.
|
||||
|
||||
Changes by Gabriel Ivăncescu <gabrielopcode@gmail.com>:
|
||||
* Move the bulk of it into get_application_name, since it needs the path.
|
||||
* Pass an argument to query the program name or not, to avoid querying it
|
||||
during test_connect, so it matches the previous behavior.
|
||||
---
|
||||
dlls/winepulse.drv/Makefile.in | 2 +-
|
||||
dlls/winepulse.drv/mmdevdrv.c | 124 ++++++++++++++++++++++++++++++---
|
||||
2 files changed, 117 insertions(+), 9 deletions(-)
|
||||
dlls/winepulse.drv/mmdevdrv.c | 107 +++++++++++++++++++++++++++++++--
|
||||
2 files changed, 104 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/dlls/winepulse.drv/Makefile.in b/dlls/winepulse.drv/Makefile.in
|
||||
index d6600632360..2448789dedf 100644
|
||||
index c71b2833d13..d4b40e66644 100644
|
||||
--- a/dlls/winepulse.drv/Makefile.in
|
||||
+++ b/dlls/winepulse.drv/Makefile.in
|
||||
@@ -1,5 +1,5 @@
|
||||
@@ -1,7 +1,7 @@
|
||||
EXTRADEFS = -DWINE_NO_LONG_TYPES
|
||||
MODULE = winepulse.drv
|
||||
UNIXLIB = winepulse.so
|
||||
-IMPORTS = dxguid uuid winmm user32 advapi32 ole32
|
||||
+IMPORTS = dxguid uuid winmm user32 advapi32 ole32 version
|
||||
EXTRALIBS = $(PULSE_LIBS) $(PTHREAD_LIBS)
|
||||
EXTRALIBS = $(PULSE_LIBS) $(PTHREAD_LIBS) -lm
|
||||
EXTRAINCL = $(PULSE_CFLAGS)
|
||||
|
||||
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
|
||||
index 510797a2edc..46f20ce419d 100644
|
||||
index 072d27e16ac..3559baf7a80 100644
|
||||
--- a/dlls/winepulse.drv/mmdevdrv.c
|
||||
+++ b/dlls/winepulse.drv/mmdevdrv.c
|
||||
@@ -43,6 +43,7 @@
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "wine/list.h"
|
||||
|
||||
#include "ole2.h"
|
||||
@ -36,143 +46,138 @@ index 510797a2edc..46f20ce419d 100644
|
||||
#include "dshow.h"
|
||||
#include "dsound.h"
|
||||
#include "propsys.h"
|
||||
@@ -559,6 +560,109 @@ static void pulse_probe_settings(pa_mainloop *ml, pa_context *ctx, int render, W
|
||||
fmt->SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
|
||||
@@ -240,13 +241,111 @@ static DWORD CALLBACK pulse_mainloop_thread(void *event)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static char *get_application_name(void)
|
||||
+typedef struct tagLANGANDCODEPAGE
|
||||
+{
|
||||
+ WORD wLanguage;
|
||||
+ WORD wCodePage;
|
||||
+ WORD wLanguage;
|
||||
+ WORD wCodePage;
|
||||
+} LANGANDCODEPAGE;
|
||||
+
|
||||
+static BOOL query_productname(void *data, LANGANDCODEPAGE *lang, LPVOID *buffer, DWORD *len)
|
||||
+{
|
||||
+ static const WCHAR productnameW[] = {'\\','S','t','r','i','n','g','F','i','l','e','I','n','f','o',
|
||||
+ '\\','%','0','4','x','%','0','4','x',
|
||||
+ '\\','P','r','o','d','u','c','t','N','a','m','e',0};
|
||||
+ WCHAR pn[37];
|
||||
+ sprintfW(pn, productnameW, lang->wLanguage, lang->wCodePage);
|
||||
+ swprintf(pn, ARRAY_SIZE(pn), L"\\StringFileInfo\\%04x%04x\\ProductName", lang->wLanguage, lang->wCodePage);
|
||||
+ return VerQueryValueW(data, pn, buffer, len) && *len;
|
||||
+}
|
||||
+
|
||||
+static char* get_programname(WCHAR *path)
|
||||
+{
|
||||
+ static const WCHAR translationW[] = {'\\','V','a','r','F','i','l','e','I','n','f','o',
|
||||
+ '\\','T','r','a','n','s','l','a','t','i','o','n',0};
|
||||
+ UINT translate_size, productname_size;
|
||||
+ LANGANDCODEPAGE *translate;
|
||||
+ LPVOID productname;
|
||||
+ BOOL found = FALSE;
|
||||
+ void *data = NULL;
|
||||
+ char *ret = NULL;
|
||||
+ unsigned int i;
|
||||
+ LCID locale;
|
||||
+ DWORD size;
|
||||
+
|
||||
+ size = GetFileVersionInfoSizeW(path, NULL);
|
||||
+ if (!size)
|
||||
+ goto out;
|
||||
+
|
||||
+ data = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
+ if (!data)
|
||||
+ goto out;
|
||||
+
|
||||
+ if (!GetFileVersionInfoW(path, 0, size, data))
|
||||
+ goto out;
|
||||
+
|
||||
+ if (!VerQueryValueW(data, translationW, (LPVOID *)&translate, &translate_size))
|
||||
+ goto out;
|
||||
+
|
||||
+ /* no translations found */
|
||||
+ if (translate_size < sizeof(LANGANDCODEPAGE))
|
||||
+ goto out;
|
||||
+
|
||||
+ /* The following code will try to find the best translation. We first search for an
|
||||
+ * exact match of the language, then a match of the language PRIMARYLANGID, then we
|
||||
+ * search for a LANG_NEUTRAL match, and if that still doesn't work we pick the
|
||||
+ * first entry which contains a proper productname. */
|
||||
+
|
||||
+ locale = GetThreadLocale();
|
||||
+
|
||||
+ for (i = 0; i < translate_size / sizeof(LANGANDCODEPAGE); i++) {
|
||||
+ if (translate[i].wLanguage == locale &&
|
||||
+ query_productname(data, &translate[i], &productname, &productname_size)) {
|
||||
+ found = TRUE;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!found) {
|
||||
+ for (i = 0; i < translate_size / sizeof(LANGANDCODEPAGE); i++) {
|
||||
+ if (PRIMARYLANGID(translate[i].wLanguage) == PRIMARYLANGID(locale) &&
|
||||
+ query_productname(data, &translate[i], &productname, &productname_size)) {
|
||||
+ found = TRUE;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!found) {
|
||||
+ for (i = 0; i < translate_size / sizeof(LANGANDCODEPAGE); i++) {
|
||||
+ if (PRIMARYLANGID(translate[i].wLanguage) == LANG_NEUTRAL &&
|
||||
+ query_productname(data, &translate[i], &productname, &productname_size)) {
|
||||
+ found = TRUE;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!found) {
|
||||
+ for (i = 0; i < translate_size / sizeof(LANGANDCODEPAGE); i++) {
|
||||
+ if (query_productname(data, &translate[i], &productname, &productname_size)) {
|
||||
+ found = TRUE;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (found) {
|
||||
+ int len = WideCharToMultiByte(CP_UTF8, 0, productname, -1, NULL, 0, NULL, NULL);
|
||||
+ ret = pa_xmalloc(len);
|
||||
+ if (ret) WideCharToMultiByte(CP_UTF8, 0, productname, -1, ret, len, NULL, NULL);
|
||||
+ }
|
||||
+
|
||||
+out:
|
||||
+ HeapFree(GetProcessHeap(), 0, data);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
static HRESULT pulse_connect(void)
|
||||
+static char *get_application_name(BOOL query_program_name)
|
||||
{
|
||||
int len;
|
||||
@@ -582,14 +686,18 @@ static HRESULT pulse_connect(void)
|
||||
pa_context_unref(pulse_ctx);
|
||||
WCHAR path[MAX_PATH], *name;
|
||||
+ char *str = NULL;
|
||||
size_t len;
|
||||
- char *str;
|
||||
|
||||
GetModuleFileNameW(NULL, path, ARRAY_SIZE(path));
|
||||
- name = strrchrW(path, '\\');
|
||||
- if (!name)
|
||||
- name = path;
|
||||
- else
|
||||
- name++;
|
||||
- len = WideCharToMultiByte(CP_UNIXCP, 0, name, -1, NULL, 0, NULL, NULL);
|
||||
- str = pa_xmalloc(len);
|
||||
- WideCharToMultiByte(CP_UNIXCP, 0, name, -1, str, len, NULL, NULL);
|
||||
+ str = get_programname(path);
|
||||
+ if (!str) {
|
||||
+ name = strrchrW(path, '\\');
|
||||
+ if (!name)
|
||||
+ name = path;
|
||||
+ else
|
||||
+ name++;
|
||||
+ len = WideCharToMultiByte(CP_UNIXCP, 0, name, -1, NULL, 0, NULL, NULL);
|
||||
+ str = pa_xmalloc(len);
|
||||
+ WideCharToMultiByte(CP_UNIXCP, 0, name, -1, str, len, NULL, NULL);
|
||||
+
|
||||
+ if (query_program_name)
|
||||
+ {
|
||||
+ UINT translate_size, productname_size;
|
||||
+ LANGANDCODEPAGE *translate;
|
||||
+ LPVOID productname;
|
||||
+ BOOL found = FALSE;
|
||||
+ void *data = NULL;
|
||||
+ unsigned int i;
|
||||
+ LCID locale;
|
||||
+ DWORD size;
|
||||
+
|
||||
+ size = GetFileVersionInfoSizeW(path, NULL);
|
||||
+ if (!size)
|
||||
+ goto skip;
|
||||
+
|
||||
+ data = malloc(size);
|
||||
+ if (!data)
|
||||
+ goto skip;
|
||||
+
|
||||
+ if (!GetFileVersionInfoW(path, 0, size, data))
|
||||
+ goto skip;
|
||||
+
|
||||
+ if (!VerQueryValueW(data, L"\\VarFileInfo\\Translation", (LPVOID *)&translate, &translate_size))
|
||||
+ goto skip;
|
||||
+
|
||||
+ /* no translations found */
|
||||
+ if (translate_size < sizeof(LANGANDCODEPAGE))
|
||||
+ goto skip;
|
||||
+
|
||||
+ /* The following code will try to find the best translation. We first search for an
|
||||
+ * exact match of the language, then a match of the language PRIMARYLANGID, then we
|
||||
+ * search for a LANG_NEUTRAL match, and if that still doesn't work we pick the
|
||||
+ * first entry which contains a proper productname. */
|
||||
+
|
||||
+ locale = GetThreadLocale();
|
||||
+
|
||||
+ for (i = 0; i < translate_size / sizeof(LANGANDCODEPAGE); i++) {
|
||||
+ if (translate[i].wLanguage == locale &&
|
||||
+ query_productname(data, &translate[i], &productname, &productname_size)) {
|
||||
+ found = TRUE;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!found) {
|
||||
+ for (i = 0; i < translate_size / sizeof(LANGANDCODEPAGE); i++) {
|
||||
+ if (PRIMARYLANGID(translate[i].wLanguage) == PRIMARYLANGID(locale) &&
|
||||
+ query_productname(data, &translate[i], &productname, &productname_size)) {
|
||||
+ found = TRUE;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!found) {
|
||||
+ for (i = 0; i < translate_size / sizeof(LANGANDCODEPAGE); i++) {
|
||||
+ if (PRIMARYLANGID(translate[i].wLanguage) == LANG_NEUTRAL &&
|
||||
+ query_productname(data, &translate[i], &productname, &productname_size)) {
|
||||
+ found = TRUE;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!found) {
|
||||
+ for (i = 0; i < translate_size / sizeof(LANGANDCODEPAGE); i++) {
|
||||
+ if (query_productname(data, &translate[i], &productname, &productname_size)) {
|
||||
+ found = TRUE;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (found) {
|
||||
+ len = WideCharToMultiByte(CP_UTF8, 0, productname, -1, NULL, 0, NULL, NULL);
|
||||
+ str = malloc(len);
|
||||
+ if (str) WideCharToMultiByte(CP_UTF8, 0, productname, -1, str, len, NULL, NULL);
|
||||
+ }
|
||||
+
|
||||
+ skip:
|
||||
+ free(data);
|
||||
+ if (str) return str;
|
||||
+ }
|
||||
+
|
||||
TRACE("Name: %s\n", str);
|
||||
pulse_ctx = pa_context_new(pa_mainloop_get_api(pulse_ml), str);
|
||||
pa_xfree(str);
|
||||
name = wcsrchr(path, '\\');
|
||||
if (!name)
|
||||
name = path;
|
||||
@@ -375,7 +474,7 @@ int WINAPI AUDDRV_GetPriority(void)
|
||||
struct test_connect_params params;
|
||||
char *name;
|
||||
|
||||
- params.name = name = get_application_name();
|
||||
+ params.name = name = get_application_name(FALSE);
|
||||
params.config = &pulse_config;
|
||||
pulse_call(test_connect, ¶ms);
|
||||
free(name);
|
||||
@@ -759,7 +858,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
|
||||
CloseHandle(event);
|
||||
}
|
||||
|
||||
- params.name = name = get_application_name();
|
||||
+ params.name = name = get_application_name(TRUE);
|
||||
params.device = This->device[0] ? This->device : NULL;
|
||||
params.dataflow = This->dataflow;
|
||||
params.mode = mode;
|
||||
--
|
||||
2.17.1
|
||||
2.34.1
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 64fdf14331c7a50c94c1c7cbd2807fed870b7202 Mon Sep 17 00:00:00 2001
|
||||
From 5eea4a95306f510d6056cdb79faaed73a84e53dd Mon Sep 17 00:00:00 2001
|
||||
From: Mark Harmstone <mark@harmstone.com>
|
||||
Date: Wed, 10 Dec 2014 18:08:41 +0000
|
||||
Subject: [PATCH] winepulse: return PKEY_AudioEndpoint_PhysicalSpeakers device
|
||||
@ -6,56 +6,90 @@ Subject: [PATCH] winepulse: return PKEY_AudioEndpoint_PhysicalSpeakers device
|
||||
|
||||
Changes by Sebastian Lackner <sebastian@fds-team.de>:
|
||||
* Rework logic to get all channel masks in pulse_test_connect.
|
||||
|
||||
Changes by Gabriel Ivăncescu <gabrielopcode@gmail.com>:
|
||||
* Rebased with unixlib separation.
|
||||
---
|
||||
dlls/winepulse.drv/mmdevdrv.c | 34 +++++++++++++++++++---------------
|
||||
1 file changed, 19 insertions(+), 15 deletions(-)
|
||||
dlls/winepulse.drv/mmdevdrv.c | 13 ++++++-------
|
||||
dlls/winepulse.drv/pulse.c | 24 +++++++++++++++---------
|
||||
dlls/winepulse.drv/unixlib.h | 2 +-
|
||||
3 files changed, 22 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
|
||||
index a1379fd97a2..5673a6a678d 100644
|
||||
index 3559baf..a29450e 100644
|
||||
--- a/dlls/winepulse.drv/mmdevdrv.c
|
||||
+++ b/dlls/winepulse.drv/mmdevdrv.c
|
||||
@@ -85,11 +85,11 @@ typedef struct _PhysDevice {
|
||||
struct list entry;
|
||||
GUID guid;
|
||||
@@ -2668,13 +2668,6 @@ HRESULT WINAPI AUDDRV_GetPropValue(GUID *guid, const PROPERTYKEY *prop, PROPVARI
|
||||
|
||||
TRACE("%s, (%s,%u), %p\n", wine_dbgstr_guid(guid), wine_dbgstr_guid(&prop->fmtid), prop->pid, out);
|
||||
|
||||
- if (IsEqualGUID(guid, &pulse_render_guid) && IsEqualPropertyKey(*prop, PKEY_AudioEndpoint_PhysicalSpeakers)) {
|
||||
- out->vt = VT_UI4;
|
||||
- out->ulVal = pulse_config.speakers_mask;
|
||||
-
|
||||
- return out->ulVal ? S_OK : E_FAIL;
|
||||
- }
|
||||
-
|
||||
if (!get_pulse_name_by_guid(guid, params.device, sizeof(params.device), ¶ms.dataflow))
|
||||
return E_FAIL;
|
||||
|
||||
@@ -2691,5 +2684,11 @@ HRESULT WINAPI AUDDRV_GetPropValue(GUID *guid, const PROPERTYKEY *prop, PROPVARI
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
+ if (IsEqualPropertyKey(*prop, PKEY_AudioEndpoint_PhysicalSpeakers)) {
|
||||
+ out->vt = VT_UI4;
|
||||
+ out->ulVal = params.channel_mask;
|
||||
+ return out->ulVal ? S_OK : E_FAIL;
|
||||
+ }
|
||||
+
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c
|
||||
index 951a7bf..79c676f 100644
|
||||
--- a/dlls/winepulse.drv/pulse.c
|
||||
+++ b/dlls/winepulse.drv/pulse.c
|
||||
@@ -87,6 +87,7 @@ typedef struct _PhysDevice {
|
||||
enum phys_device_bus_type bus_type;
|
||||
USHORT vendor_id, product_id;
|
||||
EndpointFormFactor form;
|
||||
+ DWORD channel_mask;
|
||||
WCHAR device[128];
|
||||
WCHAR name[0];
|
||||
UINT index;
|
||||
char device[0];
|
||||
} PhysDevice;
|
||||
@@ -98,7 +99,6 @@ static pa_mainloop *pulse_ml;
|
||||
static WAVEFORMATEXTENSIBLE pulse_fmt[2];
|
||||
static REFERENCE_TIME pulse_min_period[2], pulse_def_period[2];
|
||||
|
||||
-static UINT g_phys_speakers_mask = 0;
|
||||
static struct list g_phys_speakers = LIST_INIT(g_phys_speakers);
|
||||
static struct list g_phys_sources = LIST_INIT(g_phys_sources);
|
||||
|
||||
@@ -834,7 +834,8 @@ static BOOL get_device_path(pa_proplist *p, int index, GUID *guid, WCHAR path[12
|
||||
return TRUE;
|
||||
static HKEY devices_key;
|
||||
@@ -495,7 +495,7 @@ static void fill_device_info(PhysDevice *dev, pa_proplist *p)
|
||||
}
|
||||
|
||||
-static void pulse_add_device(struct list *list, GUID *guid, EndpointFormFactor form, WCHAR device[128], const char *name)
|
||||
+static void pulse_add_device(struct list *list, GUID *guid, EndpointFormFactor form, DWORD channel_mask,
|
||||
+ WCHAR device[128], const char *name)
|
||||
static void pulse_add_device(struct list *list, pa_proplist *proplist, int index, EndpointFormFactor form,
|
||||
- const char *device)
|
||||
+ DWORD channel_mask, const char *device)
|
||||
{
|
||||
static const WCHAR emptyW[] = {0};
|
||||
int len = MultiByteToWideChar(CP_UNIXCP, 0, name, -1, NULL, 0);
|
||||
@@ -843,6 +844,7 @@ static void pulse_add_device(struct list *list, GUID *guid, EndpointFormFactor f
|
||||
if (dev) {
|
||||
dev->guid = *guid;
|
||||
dev->form = form;
|
||||
+ dev->channel_mask = channel_mask;
|
||||
strcpyW(dev->device, device ? device : emptyW);
|
||||
MultiByteToWideChar(CP_UNIXCP, 0, name, -1, dev->name, len);
|
||||
list_add_tail(list, &dev->entry);
|
||||
@@ -852,19 +854,25 @@ static void pulse_add_device(struct list *list, GUID *guid, EndpointFormFactor f
|
||||
DWORD len = strlen(device);
|
||||
PhysDevice *dev = malloc(offsetof(PhysDevice, device[len + 1]));
|
||||
@@ -505,6 +505,7 @@ static void pulse_add_device(struct list *list, pa_proplist *proplist, int index
|
||||
memcpy(dev->device, device, len + 1);
|
||||
dev->form = form;
|
||||
dev->index = index;
|
||||
+ dev->channel_mask = channel_mask;
|
||||
fill_device_info(dev, proplist);
|
||||
|
||||
list_add_tail(list, &dev->entry);
|
||||
@@ -512,13 +513,19 @@ static void pulse_add_device(struct list *list, pa_proplist *proplist, int index
|
||||
|
||||
static void pulse_phys_speakers_cb(pa_context *c, const pa_sink_info *i, int eol, void *userdata)
|
||||
{
|
||||
+ struct list *speaker;
|
||||
+ DWORD channel_mask;
|
||||
WCHAR device[128];
|
||||
GUID guid;
|
||||
|
||||
if (i) {
|
||||
+ channel_mask = pulse_channel_map_to_channel_mask(&i->channel_map);
|
||||
+
|
||||
if (i && i->name && i->name[0]) {
|
||||
+ DWORD channel_mask = pulse_channel_map_to_channel_mask(&i->channel_map);
|
||||
+
|
||||
/* For default PulseAudio render device, OR together all of the
|
||||
* PKEY_AudioEndpoint_PhysicalSpeakers values of the sinks. */
|
||||
@ -64,61 +98,70 @@ index a1379fd97a2..5673a6a678d 100644
|
||||
+ if (speaker)
|
||||
+ LIST_ENTRY(speaker, PhysDevice, entry)->channel_mask |= channel_mask;
|
||||
|
||||
if (!get_device_guid(eRender, i->name, &guid))
|
||||
CoCreateGuid(&guid);
|
||||
if (!get_device_path(i->proplist, i->index, &guid, device))
|
||||
device[0] = 0;
|
||||
- pulse_add_device(&g_phys_speakers, &guid, Speakers, device, i->description);
|
||||
+ pulse_add_device(&g_phys_speakers, &guid, Speakers, channel_mask, device, i->description);
|
||||
store_device_info(eRender, i->name, i->description);
|
||||
- pulse_add_device(&g_phys_speakers, i->proplist, i->index, Speakers, i->name);
|
||||
+ pulse_add_device(&g_phys_speakers, i->proplist, i->index, Speakers, channel_mask, i->name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -880,7 +888,7 @@ static void pulse_phys_sources_cb(pa_context *c, const pa_source_info *i, int eo
|
||||
CoCreateGuid(&guid);
|
||||
if (!get_device_path(i->proplist, i->index, &guid, device))
|
||||
device[0] = 0;
|
||||
- pulse_add_device(&g_phys_sources, &guid, form, device, i->description);
|
||||
+ pulse_add_device(&g_phys_sources, &guid, form, 0, device, i->description);
|
||||
@@ -527,7 +534,7 @@ static void pulse_phys_sources_cb(pa_context *c, const pa_source_info *i, int eo
|
||||
if (i && i->name && i->name[0]) {
|
||||
store_device_info(eCapture, i->name, i->description);
|
||||
pulse_add_device(&g_phys_sources, i->proplist, i->index,
|
||||
- (i->monitor_of_sink == PA_INVALID_INDEX) ? Microphone : LineLevel, i->name);
|
||||
+ (i->monitor_of_sink == PA_INVALID_INDEX) ? Microphone : LineLevel, 0, i->name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -950,9 +958,8 @@ static HRESULT pulse_test_connect(void)
|
||||
pulse_probe_settings(ml, ctx, 1, &pulse_fmt[0]);
|
||||
@@ -752,10 +759,9 @@ static NTSTATUS pulse_test_connect(void *args)
|
||||
pulse_probe_settings(ml, ctx, 0, &pulse_fmt[1]);
|
||||
|
||||
devices_key = open_devices_key();
|
||||
- g_phys_speakers_mask = 0;
|
||||
- pulse_add_device(&g_phys_speakers, &pulse_render_guid, Speakers, NULL, "Pulseaudio");
|
||||
- pulse_add_device(&g_phys_sources, &pulse_capture_guid, Microphone, NULL, "Pulseaudio");
|
||||
+ pulse_add_device(&g_phys_speakers, &pulse_render_guid, Speakers, 0, NULL, "Pulseaudio");
|
||||
+ pulse_add_device(&g_phys_sources, &pulse_capture_guid, Microphone, 0, NULL, "Pulseaudio");
|
||||
|
||||
- pulse_add_device(&g_phys_speakers, NULL, 0, Speakers, "");
|
||||
- pulse_add_device(&g_phys_sources, NULL, 0, Microphone, "");
|
||||
+ pulse_add_device(&g_phys_speakers, NULL, 0, Speakers, 0, "");
|
||||
+ pulse_add_device(&g_phys_sources, NULL, 0, Microphone, 0, "");
|
||||
|
||||
o = pa_context_get_sink_info_list(ctx, &pulse_phys_speakers_cb, NULL);
|
||||
if (o) {
|
||||
@@ -4081,6 +4088,10 @@ static HRESULT pulse_device_get_prop_value(PhysDevice *dev, const PROPERTYKEY *p
|
||||
out->vt = VT_UI4;
|
||||
out->ulVal = dev->form;
|
||||
return S_OK;
|
||||
+ } else if (IsEqualPropertyKey(*prop, PKEY_AudioEndpoint_PhysicalSpeakers)) {
|
||||
+ out->vt = VT_UI4;
|
||||
+ out->ulVal = dev->channel_mask;
|
||||
+ return out->ulVal ? S_OK : E_FAIL;
|
||||
}
|
||||
@@ -777,7 +783,6 @@ static NTSTATUS pulse_test_connect(void *args)
|
||||
pa_context_unref(ctx);
|
||||
pa_mainloop_free(ml);
|
||||
|
||||
return E_NOTIMPL;
|
||||
@@ -4092,13 +4103,6 @@ HRESULT WINAPI AUDDRV_GetPropValue(GUID *guid, const PROPERTYKEY *prop, PROPVARI
|
||||
- config->speakers_mask = g_phys_speakers_mask;
|
||||
config->modes[0].format = pulse_fmt[0];
|
||||
config->modes[0].def_period = pulse_def_period[0];
|
||||
config->modes[0].min_period = pulse_min_period[0];
|
||||
@@ -813,6 +818,7 @@ static NTSTATUS pulse_get_device_info(void *args)
|
||||
params->product_id = dev->product_id;
|
||||
params->index = dev->index;
|
||||
params->form = dev->form;
|
||||
+ params->channel_mask = dev->channel_mask;
|
||||
params->result = S_OK;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h
|
||||
index 7383110..9cd73a8 100644
|
||||
--- a/dlls/winepulse.drv/unixlib.h
|
||||
+++ b/dlls/winepulse.drv/unixlib.h
|
||||
@@ -29,7 +29,6 @@ struct pulse_config
|
||||
REFERENCE_TIME def_period;
|
||||
REFERENCE_TIME min_period;
|
||||
} modes[2];
|
||||
- unsigned int speakers_mask;
|
||||
};
|
||||
|
||||
TRACE("%s, (%s,%u), %p\n", wine_dbgstr_guid(guid), wine_dbgstr_guid(&prop->fmtid), prop->pid, out);
|
||||
|
||||
- if (IsEqualGUID(guid, &pulse_render_guid) && IsEqualPropertyKey(*prop, PKEY_AudioEndpoint_PhysicalSpeakers)) {
|
||||
- out->vt = VT_UI4;
|
||||
- out->ulVal = g_phys_speakers_mask;
|
||||
-
|
||||
- return out->ulVal ? S_OK : E_FAIL;
|
||||
- }
|
||||
-
|
||||
LIST_FOR_EACH_ENTRY(dev, &g_phys_speakers, PhysDevice, entry) {
|
||||
if (IsEqualGUID(guid, &dev->guid))
|
||||
return pulse_device_get_prop_value(dev, prop, out);
|
||||
struct main_loop_params
|
||||
@@ -194,6 +193,7 @@ struct get_device_info_params
|
||||
enum phys_device_bus_type bus_type;
|
||||
USHORT vendor_id, product_id;
|
||||
EndpointFormFactor form;
|
||||
+ DWORD channel_mask;
|
||||
UINT index;
|
||||
HRESULT result;
|
||||
};
|
||||
--
|
||||
2.30.2
|
||||
|
||||
|
@ -3,6 +3,3 @@ Fixes: [37042] Implement exclusive mode in PulseAudio backend
|
||||
Fixes: Add support for GetPropValue to PulseAudio backend
|
||||
Fixes: Use actual program name if available to describe PulseAudio streams
|
||||
Fixes: Expose PKEY_AudioEndpoint_PhysicalSpeakers device property in PulseAudio driver
|
||||
Disabled: True
|
||||
|
||||
# Non-Trival to rebase
|
||||
|
Loading…
Reference in New Issue
Block a user