Config.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef NULLSOFT_OUT_DS_CONFIG_H
  2. #define NULLSOFT_OUT_DS_CONFIG_H
  3. #include <windows.h>
  4. #include "ds_main.h"
  5. class DS2config //config struct to pass to DS2::create(); if create messes up, this struct also returns error message
  6. {
  7. public:
  8. enum
  9. {
  10. DEFAULT_BUFFER = 1500,
  11. DEFAULT_PREBUFFER = 500,
  12. };
  13. private:
  14. size_t sr, bps, nch;
  15. HWND wnd;
  16. bool create_primary;
  17. DWORD chan_mask;
  18. UINT ms;
  19. UINT preb;
  20. bool use_cpu_management;
  21. int volmode;
  22. int logvol_min;
  23. bool logfades;
  24. GUID guid;
  25. bool delayed_shutdown, prim_override;
  26. UINT _p_bps, _p_nch, _p_sr;
  27. float sil_db;
  28. UINT mixing;
  29. UINT refresh;
  30. UINT coop;
  31. #ifdef DS2_HAVE_PITCH
  32. bool have_pitch;
  33. #endif
  34. TCHAR error[256];
  35. void SetError(LPCTSTR n_error);
  36. void SetErrorCodeMsgA(const TCHAR *msg, DWORD code);
  37. public:
  38. enum {
  39. MIXING_DEFAULT = 0,
  40. MIXING_FORCE_HARDWARE = 1,
  41. MIXING_FORCE_SOFTWARE = 2
  42. };
  43. DS2config();
  44. inline const TCHAR *GetError() { return error[0] ? error : 0;}
  45. void _inline SetPCM(UINT _sr, UINT _bps, UINT _nch) {sr = _sr;bps = _bps;nch = _nch;}
  46. void _inline SetWindow(HWND w) {wnd = w;}
  47. void _inline SetCreatePrimary(bool b) {create_primary = b;}
  48. void _inline SetChanMask(DWORD c) {chan_mask = c;}
  49. void _inline SetDeviceGUID(const GUID& g) {guid = g;}
  50. void _inline ResetDevice() {memset(&guid, 0, sizeof(guid));}
  51. void _inline SetBuffer(UINT _ms = DEFAULT_BUFFER, UINT _preb = DEFAULT_PREBUFFER) {ms = _ms;preb = _preb;}
  52. void _inline SetSilence(float s) {sil_db = s;} // s is in negative dB
  53. void _inline SetDelayedShutdown(bool d) {delayed_shutdown = d;} //disable for AC97 shit, NOTE: this is global, not per-DS2 instance
  54. void _inline SetImmediateShutdown(bool d) {delayed_shutdown = !d;}
  55. void _inline SetPrimaryOverride(bool b) {prim_override = b;}
  56. void _inline SetPrimaryOverrideFormat(UINT _sr, UINT _bps, UINT _nch) {_p_bps = _bps;_p_nch = _nch;_p_sr = _sr;}
  57. void _inline SetVolMode(int mode, int logmin = 100, bool _logfades = 0) {volmode = mode;logvol_min = logmin;logfades = _logfades;}
  58. void _inline SetMixing(UINT m) {mixing = m;}
  59. void _inline SetCpuManagement(bool b) {use_cpu_management = b;}
  60. void _inline SetRefresh(UINT n) {refresh = n;}
  61. void _inline SetCoop(UINT n) {coop = n;}
  62. #ifdef DS2_HAVE_PITCH
  63. void _inline SetHavePitch(bool b) {have_pitch = b;}
  64. #endif
  65. friend class DS2;
  66. };
  67. #endif