DevEnum.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef NULLSOFT_OUT_DS_DEVENUM_H
  2. #define NULLSOFT_OUT_DS_DEVENUM_H
  3. #include <windows.h>
  4. #include <mmsystem.h>
  5. #include <dsound.h>
  6. #include "res_wa2/resource.h"
  7. #include "api.h"
  8. #include "../Winamp/out.h"
  9. class DsDevEnum
  10. {
  11. private:
  12. struct DS_DEV
  13. {
  14. DS_DEV *next;
  15. TCHAR *name;
  16. GUID guid;
  17. } ;
  18. DS_DEV *pDev;
  19. DS_DEV *ds_devs;
  20. static BOOL WINAPI DSEnumCallback(LPGUID guid, LPCTSTR desc, LPCTSTR, DS_DEV *** var);
  21. public:
  22. const GUID GetGuid();
  23. inline const TCHAR *GetName(const TCHAR *def = TEXT("device not found")) {
  24. static wchar_t defStr[64];
  25. return pDev ? pDev->name : WASABI_API_LNGSTRINGW_BUF(IDS_DEVICE_NOT_FOUND,defStr,64);
  26. }
  27. inline bool operator++(int) {if (pDev) pDev = pDev->next; return pDev ? true : false;}
  28. inline operator bool() {return pDev ? true : false;}
  29. bool FindGuid(const GUID & g);
  30. bool FindDefault();
  31. bool FindName(LPCTSTR n);
  32. DsDevEnum();
  33. ~DsDevEnum();
  34. inline void Reset() {pDev = ds_devs;}
  35. static bool GetCapsFromGuid(const GUID *dev, LPDSCAPS pCaps, DWORD * speakercfg = 0);
  36. inline bool GetCaps(LPDSCAPS pCaps, DWORD * speakercfg = 0) { return GetCapsFromGuid(&pDev->guid, pCaps, speakercfg);}
  37. };
  38. //helpers
  39. class DsDevEnumGuid : public DsDevEnum
  40. {
  41. public:
  42. DsDevEnumGuid(const GUID & g) {FindGuid(g);}
  43. };
  44. class DsDevEnumName : public DsDevEnum
  45. {
  46. public:
  47. DsDevEnumName(LPCTSTR n) {FindName(n);}
  48. };
  49. class DsDevEnumDefault : public DsDevEnum
  50. {
  51. public:
  52. DsDevEnumDefault() {FindDefault();}
  53. };
  54. #endif