Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.4 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Module: vsd.cpp
  4. //
  5. // Description:
  6. //
  7. // Virtual Source Data Class
  8. //
  9. //@@BEGIN_MSINTERNAL
  10. // Development Team:
  11. // Mike McLaughlin
  12. //
  13. // History: Date Author Comment
  14. //
  15. // To Do: Date Author Comment
  16. //
  17. //@@END_MSINTERNAL
  18. //
  19. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  20. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  21. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  22. // PURPOSE.
  23. //
  24. // Copyright (c) 1996-1999 Microsoft Corporation. All Rights Reserved.
  25. //
  26. //---------------------------------------------------------------------------
  27. #include "common.h"
  28. //---------------------------------------------------------------------------
  29. //---------------------------------------------------------------------------
  30. CVirtualSourceData::CVirtualSourceData(
  31. PDEVICE_NODE pDeviceNode
  32. )
  33. {
  34. LONG lLevel, i;
  35. cChannels = 2;
  36. MinimumValue = (-96 * 65536);
  37. MaximumValue = 0;
  38. Steps = (65536/2);
  39. GetVirtualSourceDefault(pDeviceNode, &lLevel);
  40. for(i = 0; i < MAX_NUM_CHANNELS; i++) {
  41. this->lLevel[i] = lLevel;
  42. }
  43. }
  44. NTSTATUS
  45. GetVirtualSourceDefault(
  46. IN PDEVICE_NODE pDeviceNode,
  47. IN PLONG plLevel
  48. )
  49. {
  50. PKEY_VALUE_FULL_INFORMATION pkvfi = NULL;
  51. NTSTATUS Status = STATUS_SUCCESS;
  52. UNICODE_STRING ustrName;
  53. HANDLE hkey = NULL;
  54. // Set the default volume level on virtualized pins. (0 dB attenuation)
  55. *plLevel = (0 * 65536);
  56. // Need to convert the filtername (symbolic link name) to a unicode string
  57. RtlInitUnicodeString(&ustrName, pDeviceNode->GetDeviceInterface());
  58. Status = IoOpenDeviceInterfaceRegistryKey(&ustrName, KEY_READ, &hkey);
  59. if(!NT_SUCCESS(Status)) {
  60. goto exit;
  61. }
  62. // Now we can go get the FriendlyName value
  63. Status = QueryRegistryValue(hkey, L"VirtualSourceDefault", &pkvfi);
  64. if(!NT_SUCCESS(Status)) {
  65. goto exit;
  66. }
  67. if(pkvfi->Type != REG_DWORD && pkvfi->Type != REG_BINARY) {
  68. Trap();
  69. Status = STATUS_INVALID_PARAMETER;
  70. goto exit;
  71. }
  72. if(pkvfi->Type == REG_BINARY && pkvfi->DataLength < sizeof(LONG)) {
  73. Trap();
  74. Status = STATUS_INVALID_PARAMETER;
  75. goto exit;
  76. }
  77. *plLevel = *((PLONG)(((PUCHAR)pkvfi) + pkvfi->DataOffset));
  78. exit:
  79. if(hkey != NULL) {
  80. ZwClose(hkey);
  81. }
  82. delete pkvfi;
  83. return(Status);
  84. }