AecKsBinder.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 <atlbase.h>
  11. #include <ATLComCli.h>
  12. #include <audioclient.h>
  13. #include <MMDeviceApi.h>
  14. #include <AudioEngineEndPoint.h>
  15. #include <DeviceTopology.h>
  16. #include <EndpointVolume.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 =
  29. {0xC3FA16D7, 0x274E, 0x4f2b,
  30. {0xA6, 0x3B, 0xD5, 0xE1, 0x09, 0x55, 0xFA, 0x27}};
  31. const DWORD USBAUDIO_PROPERTY_GETSET_MEM = 0;
  32. #define MAX_STR_LEN 512
  33. typedef struct
  34. {
  35. TCHAR szDeviceName[MAX_STR_LEN];
  36. TCHAR szDeviceID[MAX_STR_LEN];
  37. bool bIsMicArrayDevice;
  38. } AUDIO_DEVICE_INFO, *PAUDIO_DEVICE_INFO;
  39. HRESULT GetDeviceNum(EDataFlow eDataFlow, UINT &uDevCount);
  40. __inline HRESULT GetRenderDeviceNum(UINT &uDevCount)
  41. { return GetDeviceNum(eRender, uDevCount); }
  42. __inline HRESULT GetCaptureDeviceNum(UINT &uDevCount)
  43. { return GetDeviceNum(eCapture, uDevCount); }
  44. HRESULT EnumDevice(
  45. EDataFlow eDataFlow,
  46. UINT uNumElements,
  47. AUDIO_DEVICE_INFO *pDevicInfo);
  48. __inline HRESULT EnumRenderDevice(UINT uNumElements, AUDIO_DEVICE_INFO *pDevicInfo)
  49. { return EnumDevice(eRender, uNumElements, pDevicInfo); }
  50. __inline HRESULT EnumCaptureDevice(UINT uNumElements, AUDIO_DEVICE_INFO *pDevicInfo)
  51. { return EnumDevice(eCapture, uNumElements, pDevicInfo); }
  52. HRESULT DeviceBindTo(
  53. EDataFlow eDataFlow, // eCapture or eRender
  54. INT uDevIdx, // Device Index. USE_DEFAULT_DEVICE - use default device.
  55. IAudioClient **ppAudioClient, // pointer pointer to IAudioClient interface
  56. IAudioEndpointVolume **ppEndpointVolume,
  57. WCHAR** ppszEndpointDeviceId // Device ID. Need to be freed in caller with CoTaskMemoryFree
  58. );
  59. __inline HRESULT CaptureDeviceBindTo(
  60. INT uDevIdx,
  61. IAudioClient **ppAudioClient, // pointer pointer to IAudioClient interface
  62. IAudioEndpointVolume **ppEndpointVolume,
  63. WCHAR** ppszEndpointDeviceId)
  64. {
  65. return DeviceBindTo(eCapture, uDevIdx, ppAudioClient, ppEndpointVolume, ppszEndpointDeviceId);
  66. }
  67. __inline HRESULT RenderDeviceBindTo(
  68. INT uDevIdx,
  69. IAudioClient **ppAudioClient, // pointer pointer to IAudioClient interface
  70. IAudioEndpointVolume **ppEndpointVolume,
  71. WCHAR** ppszEndpointDeviceId)
  72. {
  73. return DeviceBindTo(eRender, uDevIdx, ppAudioClient, ppEndpointVolume, ppszEndpointDeviceId);
  74. }
  75. HRESULT DeviceIsMicArray(wchar_t szDeviceId[], bool& bIsMicArray);
  76. HRESULT EndpointIsMicArray(IMMDevice* pEndpoint, bool& isMicrophoneArray);
  77. HRESULT GetJackSubtypeForEndpoint(IMMDevice* pEndpoint, GUID* pgSubtype);
  78. __checkReturn HRESULT GetInputJack(IMMDevice* pDevice, CComPtr<IPart>& spPart);
  79. HRESULT GetMicArrayGeometry(wchar_t szDeviceId[], KSAUDIO_MIC_ARRAY_GEOMETRY** ppGeometry, ULONG& cbSize);
  80. #endif //_AEC_KSBINDER_H_