AecKsBinder.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //-------------------------------------------------------------------------
  2. // File: AecKsBinder.h
  3. //
  4. // Desciption: Definition of audio devices binding functions
  5. //
  6. // Copyright (c) 2004-2006, Microsoft Corporation. All rights reserved.
  7. //---------------------------------------------------------------------------
  8. #ifndef _AEC_KSBINDER_H_
  9. #define _AEC_KSBINDER_H_
  10. #include <ATLComCli.h>
  11. #include <AudioEngineEndPoint.h>
  12. #include <DeviceTopology.h>
  13. #include <EndpointVolume.h>
  14. #include <MMDeviceApi.h>
  15. #include <atlbase.h>
  16. #include <audioclient.h>
  17. typedef struct
  18. {
  19. KSPROPERTY KsProperty;
  20. BOOLEAN bEndpointFlag;
  21. ULONG ulEntityId;
  22. union {
  23. ULONG ulEndpoint;
  24. ULONG ulInterface;
  25. };
  26. ULONG ulOffset;
  27. } USBAUDIO_MEMORY_PROPERTY, *PUSBAUDIO_MEMORY_PROPERTY;
  28. static const GUID USB_AUDIO_PROP_SET_GUID = {0xC3FA16D7,
  29. 0x274E,
  30. 0x4f2b,
  31. {0xA6, 0x3B, 0xD5, 0xE1, 0x09, 0x55, 0xFA, 0x27}};
  32. const DWORD USBAUDIO_PROPERTY_GETSET_MEM = 0;
  33. #define MAX_STR_LEN 512
  34. typedef struct
  35. {
  36. TCHAR szDeviceName[MAX_STR_LEN];
  37. TCHAR szDeviceID[MAX_STR_LEN];
  38. bool bIsMicArrayDevice;
  39. } AUDIO_DEVICE_INFO, *PAUDIO_DEVICE_INFO;
  40. HRESULT GetDeviceNum(EDataFlow eDataFlow, UINT &uDevCount);
  41. __inline HRESULT GetRenderDeviceNum(UINT &uDevCount)
  42. {
  43. return GetDeviceNum(eRender, uDevCount);
  44. }
  45. __inline HRESULT GetCaptureDeviceNum(UINT &uDevCount)
  46. {
  47. return GetDeviceNum(eCapture, uDevCount);
  48. }
  49. HRESULT EnumDevice(EDataFlow eDataFlow, UINT uNumElements, AUDIO_DEVICE_INFO *pDevicInfo);
  50. __inline HRESULT EnumRenderDevice(UINT uNumElements, AUDIO_DEVICE_INFO *pDevicInfo)
  51. {
  52. return EnumDevice(eRender, uNumElements, pDevicInfo);
  53. }
  54. __inline HRESULT EnumCaptureDevice(UINT uNumElements, AUDIO_DEVICE_INFO *pDevicInfo)
  55. {
  56. return EnumDevice(eCapture, uNumElements, pDevicInfo);
  57. }
  58. HRESULT DeviceBindTo(
  59. EDataFlow eDataFlow, // eCapture or eRender
  60. INT uDevIdx, // Device Index. USE_DEFAULT_DEVICE - use default device.
  61. IAudioClient **ppAudioClient, // pointer pointer to IAudioClient interface
  62. IAudioEndpointVolume **ppEndpointVolume,
  63. WCHAR **ppszEndpointDeviceId // Device ID. Need to be freed in caller with CoTaskMemoryFree
  64. );
  65. __inline HRESULT CaptureDeviceBindTo(
  66. INT uDevIdx,
  67. IAudioClient **ppAudioClient, // pointer pointer to IAudioClient interface
  68. IAudioEndpointVolume **ppEndpointVolume,
  69. WCHAR **ppszEndpointDeviceId)
  70. {
  71. return DeviceBindTo(eCapture, uDevIdx, ppAudioClient, ppEndpointVolume, ppszEndpointDeviceId);
  72. }
  73. __inline HRESULT RenderDeviceBindTo(
  74. INT uDevIdx,
  75. IAudioClient **ppAudioClient, // pointer pointer to IAudioClient interface
  76. IAudioEndpointVolume **ppEndpointVolume,
  77. WCHAR **ppszEndpointDeviceId)
  78. {
  79. return DeviceBindTo(eRender, uDevIdx, ppAudioClient, ppEndpointVolume, ppszEndpointDeviceId);
  80. }
  81. HRESULT DeviceIsMicArray(wchar_t szDeviceId[], bool &bIsMicArray);
  82. HRESULT EndpointIsMicArray(IMMDevice *pEndpoint, bool &isMicrophoneArray);
  83. HRESULT GetJackSubtypeForEndpoint(IMMDevice *pEndpoint, GUID *pgSubtype);
  84. __checkReturn HRESULT GetInputJack(IMMDevice *pDevice, CComPtr<IPart> &spPart);
  85. HRESULT GetMicArrayGeometry(wchar_t szDeviceId[],
  86. KSAUDIO_MIC_ARRAY_GEOMETRY **ppGeometry,
  87. ULONG &cbSize);
  88. #endif //_AEC_KSBINDER_H_