[MMIXER, WDMAUD_KERNEL]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Fri, 12 Feb 2010 06:18:31 +0000 (06:18 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Fri, 12 Feb 2010 06:18:31 +0000 (06:18 +0000)
- Implement retrieving device path

svn path=/trunk/; revision=45582

reactos/drivers/wdm/audio/legacy/wdmaud/mmixer.c
reactos/lib/drivers/sound/mmixer/mmixer.h
reactos/lib/drivers/sound/mmixer/wave.c

index 1d8a806..cf58846 100644 (file)
@@ -551,10 +551,12 @@ NTSTATUS
 WdmAudGetPnpNameByIndexAndType(
     IN ULONG DeviceIndex, 
     IN SOUND_DEVICE_TYPE DeviceType, 
-    OUT LPWSTR *Device)
+    OUT LPWSTR *DevicePath)
 {
-    UNIMPLEMENTED
-    return STATUS_NOT_IMPLEMENTED;
+    if (MMixerGetWaveDevicePath(&MixerContext, DeviceType == WAVE_IN_DEVICE_TYPE, DeviceIndex, DevicePath) == MM_STATUS_SUCCESS)
+        return STATUS_SUCCESS;
+    else
+        return STATUS_UNSUCCESSFUL;
 }
 
 NTSTATUS
index 7f117e3..e14d663 100644 (file)
@@ -191,4 +191,11 @@ MMixerSetWaveStatus(
     IN HANDLE PinHandle,
     IN KSSTATE State);
 
+MIXER_STATUS
+MMixerGetWaveDevicePath(
+    IN PMIXER_CONTEXT MixerContext,
+    IN ULONG bWaveIn,
+    IN ULONG DeviceId,
+    OUT LPWSTR * DevicePath);
+
 #endif
index c156378..a8b2675 100644 (file)
@@ -611,3 +611,61 @@ MMixerSetWaveStatus(
 
     return MixerContext->Control(PinHandle, IOCTL_KS_PROPERTY, &Property, sizeof(KSPROPERTY), &State, sizeof(KSSTATE), &Length);
 }
+
+MIXER_STATUS
+MMixerGetWaveDevicePath(
+    IN PMIXER_CONTEXT MixerContext,
+    IN ULONG bWaveIn,
+    IN ULONG DeviceId,
+    OUT LPWSTR * DevicePath)
+{
+    PMIXER_LIST MixerList;
+    LPMIXER_DATA MixerData;
+    LPWAVE_INFO WaveInfo;
+    ULONG Length;
+    MIXER_STATUS Status;
+
+    // verify mixer context
+    Status = MMixerVerifyContext(MixerContext);
+
+    if (Status != MM_STATUS_SUCCESS)
+    {
+        // invalid context passed
+        return Status;
+    }
+
+    // grab mixer list
+    MixerList = (PMIXER_LIST)MixerContext->MixerContext;
+
+    /* find destination wave */
+    Status = MMixerGetWaveInfoByIndexAndType(MixerList, DeviceId, bWaveIn, &WaveInfo);
+    if (Status != MM_STATUS_SUCCESS)
+    {
+        /* failed to find wave info */
+        return MM_STATUS_INVALID_PARAMETER;
+    }
+
+    /* get associated device id */
+    MixerData = MMixerGetDataByDeviceId(MixerList, WaveInfo->DeviceId);
+    if (!MixerData)
+        return MM_STATUS_INVALID_PARAMETER;
+
+    /* calculate length */
+    Length = wcslen(MixerData->DeviceName)+1;
+
+    /* allocate destination buffer */
+    *DevicePath = MixerContext->Alloc(Length * sizeof(WCHAR));
+
+    if (!*DevicePath)
+    {
+        /* no memory */
+        return MM_STATUS_NO_MEMORY;
+    }
+
+    /* copy device path */
+    MixerContext->Copy(*DevicePath, MixerData->DeviceName, Length * sizeof(WCHAR));
+
+    /* done */
+    return MM_STATUS_SUCCESS;
+}
+