Commit b77487ae authored by robiwan's avatar robiwan

Committing Lelands patch for WDM-KS, should take care of some of the problems...

Committing Lelands patch for WDM-KS, should take care of some of the problems referenced here http://music.columbia.edu/pipermail/portaudio/2014-August/016246.html

git-svn-id: https://subversion.assembla.com/svn/portaudio/portaudio/trunk@1932 0f58301d-fd10-0410-b4af-bbb618454e57
parent cf397b6d
......@@ -1012,7 +1012,7 @@ static ULONG GetNumberOfConnectionsTo(const KSTOPOLOGY_CONNECTION* pTo, PaWinWdm
ULONG retval = 0;
unsigned i;
const KSTOPOLOGY_CONNECTION* connections = (const KSTOPOLOGY_CONNECTION*)(filter->connections + 1);
PA_DEBUG(("GetNumberOfConnectionsTo: Checking %u connections...", filter->connections->Count));
PA_DEBUG(("GetNumberOfConnectionsTo: Checking %u connections...\n", filter->connections->Count));
for (i = 0; i < filter->connections->Count; ++i)
{
const KSTOPOLOGY_CONNECTION* pConn = connections + i;
......@@ -1022,6 +1022,7 @@ static ULONG GetNumberOfConnectionsTo(const KSTOPOLOGY_CONNECTION* pTo, PaWinWdm
++retval;
}
}
PA_DEBUG(("GetNumberOfConnectionsTo: Returning %d\n", retval));
return retval;
}
......@@ -1031,16 +1032,18 @@ static const KSTOPOLOGY_CONNECTION* FindStartConnectionFrom(ULONG startPin, PaWi
{
unsigned i;
const KSTOPOLOGY_CONNECTION* connections = (const KSTOPOLOGY_CONNECTION*)(filter->connections + 1);
PA_DEBUG(("FindStartConnectionFrom: Checking %u connections...", filter->connections->Count));
PA_DEBUG(("FindStartConnectionFrom: Checking %u connections...\n", filter->connections->Count));
for (i = 0; i < filter->connections->Count; ++i)
{
const KSTOPOLOGY_CONNECTION* pConn = connections + i;
if (pConn->ToNode == KSFILTER_NODE && pConn->ToNodePin == startPin)
{
PA_DEBUG(("FindStartConnectionFrom: returning %p\n", pConn));
return pConn;
}
}
PA_DEBUG(("FindStartConnectionFrom: returning NULL\n"));
assert(FALSE);
return 0;
}
......@@ -1049,26 +1052,36 @@ static const KSTOPOLOGY_CONNECTION* FindStartConnectionTo(ULONG startPin, PaWinW
{
unsigned i;
const KSTOPOLOGY_CONNECTION* connections = (const KSTOPOLOGY_CONNECTION*)(filter->connections + 1);
PA_DEBUG(("FindStartConnectionTo: Checking %u connections...", filter->connections->Count));
PA_DEBUG(("FindStartConnectionTo: Checking %u connections...\n", filter->connections->Count));
for (i = 0; i < filter->connections->Count; ++i)
{
const KSTOPOLOGY_CONNECTION* pConn = connections + i;
if (pConn->FromNode == KSFILTER_NODE && pConn->FromNodePin == startPin)
{
PA_DEBUG(("FindStartConnectionTo: returning %p\n", pConn));
return pConn;
}
}
PA_DEBUG(("FindStartConnectionTo: returning NULL\n"));
assert(FALSE);
return 0;
}
static ULONG GetConnectedPin(ULONG startPin, BOOL forward, PaWinWdmFilter* filter, int muxPosition, ULONG *muxInputPinId, ULONG *muxNodeId)
{
int limit=1000;
const KSTOPOLOGY_CONNECTION *conn = NULL;
TFnGetConnection fnGetConnection = forward ? GetConnectionTo : GetConnectionFrom ;
PA_LOGE_;
while (1)
{
limit--;
if (limit == 0) {
PA_DEBUG(("GetConnectedPin: LOOP LIMIT REACHED\n"));
break;
}
if (conn == NULL)
{
conn = forward ? FindStartConnectionTo(startPin, filter) : FindStartConnectionFrom(startPin, filter);
......@@ -1114,6 +1127,7 @@ static ULONG GetConnectedPin(ULONG startPin, BOOL forward, PaWinWdmFilter* filte
}
}
}
PA_LOGL_;
return KSFILTER_NODE;
}
......@@ -1123,6 +1137,7 @@ static void DumpConnectionsAndNodes(PaWinWdmFilter* filter)
const KSTOPOLOGY_CONNECTION* connections = (const KSTOPOLOGY_CONNECTION*)(filter->connections + 1);
const GUID* nodes = (const GUID*)(filter->nodes + 1);
PA_LOGE_;
PA_DEBUG(("DumpConnectionsAndNodes: connections=%d, nodes=%d\n", filter->connections->Count, filter->nodes->Count));
for (i=0; i < filter->connections->Count; ++i)
......@@ -1147,6 +1162,7 @@ static void DumpConnectionsAndNodes(PaWinWdmFilter* filter)
pConn->Data4[6], pConn->Data4[7]
));
}
PA_LOGL_;
}
......@@ -1196,6 +1212,7 @@ static PaError GetNameFromCategory(const GUID* pGUID, BOOL input, wchar_t* name,
PaError result = paUnanticipatedHostError;
USHORT usbTerminalGUID = (USHORT)(pGUID->Data1 - 0xDFF219E0);
PA_LOGE_;
if (input && usbTerminalGUID >= 0x301 && usbTerminalGUID < 0x400)
{
/* Output terminal name for an input !? Set it to Line! */
......@@ -1235,6 +1252,7 @@ static PaError GetNameFromCategory(const GUID* pGUID, BOOL input, wchar_t* name,
{
PaWinWDM_SetLastErrorInfo(result, "GetNameFromCategory: usbTerminalGUID = %04X ", usbTerminalGUID);
}
PA_LOGL_;
return result;
}
......@@ -1633,6 +1651,8 @@ static PaWinWdmPin* PinNew(PaWinWdmFilter* parentFilter, unsigned long pinId, Pa
else
{
KSPIN_PHYSICALCONNECTION* pc = (KSPIN_PHYSICALCONNECTION*)PaUtil_AllocateMemory(cbBytes + 2);
ULONG pcPin;
wchar_t symbLinkName[MAX_PATH];
PA_DEBUG(("PinNew: Physical connection found!\n"));
if (pc == NULL)
{
......@@ -1647,10 +1667,18 @@ static PaWinWdmPin* PinNew(PaWinWdmFilter* parentFilter, unsigned long pinId, Pa
cbBytes,
NULL
);
if (result == paNoError)
{
wchar_t symbLinkName[MAX_PATH];
pcPin = pc->Pin;
wcsncpy(symbLinkName, pc->SymbolicLinkName, MAX_PATH);
PaUtil_FreeMemory( pc );
if (result != paNoError)
{
/* Shouldn't happen, but fail if it does */
PA_DEBUG(("PinNew: failed to retrieve physical connection!\n"));
goto error;
}
if (symbLinkName[1] == TEXT('?'))
{
symbLinkName[1] = TEXT('\\');
......@@ -1692,7 +1720,7 @@ static PaWinWdmPin* PinNew(PaWinWdmFilter* parentFilter, unsigned long pinId, Pa
PA_DEBUG(("PinNew: Checking for output endpoint pin id...\n"));
endpointPinId = GetConnectedPin(pc->Pin, TRUE, pin->parentFilter->topologyFilter, -1, NULL, NULL);
endpointPinId = GetConnectedPin(pcPin, TRUE, pin->parentFilter->topologyFilter, -1, NULL, NULL);
if (endpointPinId == KSFILTER_NODE)
{
......@@ -1737,23 +1765,24 @@ static PaWinWdmPin* PinNew(PaWinWdmFilter* parentFilter, unsigned long pinId, Pa
{
result = GetNameFromCategory(&category, (pin->dataFlow == KSPIN_DATAFLOW_OUT), pin->friendlyName, MAX_PATH);
}
}
/* Make sure we get a name for the pin */
if (wcslen(pin->friendlyName) == 0)
{
wcscpy(pin->friendlyName, L"Output");
wcscpy(pin->friendlyName, kOutputName);
}
#ifdef UNICODE
PA_DEBUG(("PinNew: Pin name '%s'\n", pin->friendlyName));
#else
PA_DEBUG(("PinNew: Pin name '%S'\n", pin->friendlyName));
#endif
}
/* Set endpoint pin ID (this is the topology INPUT pin, since portmixer will always traverse the
filter in audio streaming direction, see http://msdn.microsoft.com/en-us/library/windows/hardware/ff536331(v=vs.85).aspx
for more information)
*/
pin->endpointPinId = pc->Pin;
pin->endpointPinId = pcPin;
}
else
{
......@@ -1765,14 +1794,13 @@ static PaWinWdmPin* PinNew(PaWinWdmFilter* parentFilter, unsigned long pinId, Pa
ULONG muxNodeIdTest = (unsigned)-1;
PA_DEBUG(("PinNew: Checking for input endpoint pin id (%d)...\n", i));
endpointPinId = GetConnectedPin(pc->Pin,
endpointPinId = GetConnectedPin(pcPin,
FALSE,
pin->parentFilter->topologyFilter,
(int)i,
NULL,
&muxNodeIdTest);
if (endpointPinId == KSFILTER_NODE)
{
/* We're done */
......@@ -1874,7 +1902,7 @@ static PaWinWdmPin* PinNew(PaWinWdmFilter* parentFilter, unsigned long pinId, Pa
}
}
endpointPinId = GetConnectedPin(pc->Pin,
endpointPinId = GetConnectedPin(pcPin,
FALSE,
pin->parentFilter->topologyFilter,
muxPos,
......@@ -1936,8 +1964,6 @@ static PaWinWdmPin* PinNew(PaWinWdmFilter* parentFilter, unsigned long pinId, Pa
}
}
}
PaUtil_FreeMemory(pc);
}
}
else
{
......@@ -1966,18 +1992,14 @@ error:
Error cleanup
*/
PaUtil_FreeMemory( item );
if( pin )
{
if (pin->parentFilter->topologyFilter && pin->parentFilter->topologyFilter->handle != NULL)
{
FilterRelease(pin->parentFilter->topologyFilter);
}
PaUtil_FreeMemory( pin->pinConnect );
PaUtil_FreeMemory( pin->dataRangesItem );
PaUtil_FreeMemory( pin );
}
PaUtil_FreeMemory( item );
PinFree(pin);
*error = result;
PA_LOGL_;
return NULL;
......@@ -2264,6 +2286,8 @@ static PaError PinQueryNotificationSupport(PaWinWdmPin* pPin, BOOL* pbResult)
PaError result = paNoError;
KSPROPERTY propIn;
PA_LOGE_;
propIn.Set = KSPROPSETID_RtAudio;
propIn.Id = 8; /* = KSPROPERTY_RTAUDIO_QUERY_NOTIFICATION_SUPPORT */
propIn.Flags = KSPROPERTY_TYPE_GET;
......@@ -2280,8 +2304,8 @@ static PaError PinQueryNotificationSupport(PaWinWdmPin* pPin, BOOL* pbResult)
PA_DEBUG(("Failed PinQueryNotificationSupport\n"));
}
PA_LOGL_;
return result;
}
static PaError PinGetBufferWithNotification(PaWinWdmPin* pPin, void** pBuffer, DWORD* pRequestedBufSize, BOOL* pbCallMemBarrier)
......@@ -2290,6 +2314,8 @@ static PaError PinGetBufferWithNotification(PaWinWdmPin* pPin, void** pBuffer, D
KSRTAUDIO_BUFFER_PROPERTY_WITH_NOTIFICATION propIn;
KSRTAUDIO_BUFFER propOut;
PA_LOGE_;
propIn.BaseAddress = 0;
propIn.NotificationCount = 2;
propIn.RequestedBufferSize = *pRequestedBufSize;
......@@ -2315,6 +2341,7 @@ static PaError PinGetBufferWithNotification(PaWinWdmPin* pPin, void** pBuffer, D
PA_DEBUG(("Failed to get buffer with notification\n"));
}
PA_LOGL_;
return result;
}
......@@ -2324,6 +2351,8 @@ static PaError PinGetBufferWithoutNotification(PaWinWdmPin* pPin, void** pBuffer
KSRTAUDIO_BUFFER_PROPERTY propIn;
KSRTAUDIO_BUFFER propOut;
PA_LOGE_;
propIn.BaseAddress = NULL;
propIn.RequestedBufferSize = *pRequestedBufSize;
propIn.Property.Set = KSPROPSETID_RtAudio;
......@@ -2348,6 +2377,7 @@ static PaError PinGetBufferWithoutNotification(PaWinWdmPin* pPin, void** pBuffer
PA_DEBUG(("Failed to get buffer without notification\n"));
}
PA_LOGL_;
return result;
}
......@@ -2365,9 +2395,17 @@ requested buffer size on multiples of 128 bytes:
static PaError PinGetBuffer(PaWinWdmPin* pPin, void** pBuffer, DWORD* pRequestedBufSize, BOOL* pbCallMemBarrier)
{
PaError result = paNoError;
int limit = 1000;
PA_LOGE_;
while (1)
{
limit--;
if (limit == 0) {
PA_DEBUG(("PinGetBuffer: LOOP LIMIT REACHED\n"));
break;
}
if (pPin->pinKsSubType != SubType_kPolled)
{
/* In case of unknown (or notification), we try both modes */
......@@ -2410,6 +2448,8 @@ static PaError PinGetBuffer(PaWinWdmPin* pPin, void** pBuffer, DWORD* pRequested
}
}
PA_LOGL_;
return result;
}
......@@ -2424,7 +2464,7 @@ static PaError PinRegisterPositionRegister(PaWinWdmPin* pPin)
propIn.BaseAddress = NULL;
propIn.Property.Set = KSPROPSETID_RtAudio;
propIn.Property.Id = KSPROPERTY_RTAUDIO_POSITIONREGISTER;
propIn.Property.Flags = KSPROPERTY_TYPE_GET;
propIn.Property.Flags = KSPROPERTY_TYPE_SET;
result = WdmSyncIoctl(pPin->handle, IOCTL_KS_PROPERTY,
&propIn,
......@@ -2808,7 +2848,7 @@ error:
{
if (filter->pins[pinId])
{
PaUtil_FreeMemory(filter->pins[pinId]);
PinFree(filter->pins[pinId]);
filter->pins[pinId] = 0;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment