MMDEVICE.INT 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. {========================================================================}
  2. {= (c) 1995-98 SwiftSoft Ronald Dittrich =}
  3. {========================================================================}
  4. {= All Rights Reserved =}
  5. {========================================================================}
  6. {= D 01099 Dresden = Tel.: +0351-8012255 =}
  7. {= Loewenstr.7a = info@swiftsoft.de =}
  8. {========================================================================}
  9. {= Actual versions on http://www.swiftsoft.de/mmtools.html =}
  10. {========================================================================}
  11. {= This code is for reference purposes only and may not be copied or =}
  12. {= distributed in any format electronic or otherwise except one copy =}
  13. {= for backup purposes. =}
  14. {= =}
  15. {= No Delphi Component Kit or Component individually or in a collection=}
  16. {= subclassed or otherwise from the code in this unit, or associated =}
  17. {= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
  18. {= without express permission from SwiftSoft. =}
  19. {= =}
  20. {= For more licence informations please refer to the associated =}
  21. {= HelpFile. =}
  22. {========================================================================}
  23. {= $Date: 20.01.1998 - 18:00:00 $ =}
  24. {========================================================================}
  25. unit MMDevice;
  26. {$I COMPILER.INC}
  27. interface
  28. uses
  29. {$IFDEF WIN32}
  30. Windows,
  31. {$ELSE}
  32. WinTypes,
  33. WinProcs,
  34. {$ENDIF}
  35. Classes,
  36. SysUtils,
  37. MMSystem,
  38. MMObj,
  39. MMObsrv,
  40. MMUtils;
  41. type
  42. { D3: This lines rely on current Win32 API}
  43. TMMAudioDeviceType = (dtMidiIn,dtMidiOut,dtWaveIn,dtWaveOut,dtAux,dtMixer);
  44. {$IFDEF WIN32}
  45. TMMDeviceId = type UINT;
  46. TMMManufacturerId = WORD;
  47. TMMProductId = WORD;
  48. TMMVersion = Byte;
  49. {$ENDIF}
  50. const
  51. defAudioDeviceType = dtWaveOut;
  52. defDeviceId = 0;
  53. badDeviceId = -2;
  54. MapperId = -1;
  55. { D3: This lines rely on current Win32 API}
  56. type
  57. {-- TMMDeviceCaps ---------------------------------------------------}
  58. TMMDeviceCaps = class(TPersistent)
  59. public
  60. procedure Clear;
  61. published
  62. property ManufacturerId: TMMManufacturerId read FManufacturerId write FWDummy stored False;
  63. property ProductId : TMMProductId read FProductId write FWDummy stored False;
  64. property VerMajor : TMMVersion read FVerMajor write FVDummy stored False;
  65. property VerMinor : TMMVersion read FVerMinor write FVDummy stored False;
  66. property ProductName : string read FProductName write SetDummyStr stored False;
  67. end;
  68. {-- TMMCustomAudioDevice ------------------------------------------------}
  69. TMMCustomAudioDevice = class(TMMComponent)
  70. protected
  71. procedure Open; virtual;
  72. procedure Close; virtual;
  73. procedure UpdateDevice; virtual;
  74. procedure RetrieveDeviceCaps;
  75. procedure SetActive(Value: Boolean);
  76. function GetActive: Boolean;
  77. procedure Changed; virtual;
  78. procedure DoChange; dynamic;
  79. procedure Loaded; override;
  80. { If descendant needs to immediately update device id w/o reopening }
  81. procedure SetDeviceIdDirect(Value: TMMDeviceId);
  82. function GetMapper: Boolean;
  83. public
  84. constructor Create(AOwner: TComponent); override;
  85. destructor Destroy; override;
  86. procedure AddObserver(O: TMMObserver);
  87. procedure RemoveObserver(O: TMMObserver);
  88. function ValidDevice: Boolean;
  89. procedure GetDeviceList(List: TStrings; IncludeMapper: Boolean);
  90. function GetDeviceType: TMMAudioDeviceType;
  91. { badDeviceId if no mixer for device }
  92. property MixerId: TMMDeviceId read GetMixerId;
  93. protected
  94. property DeviceType: TMMAudioDeviceType read FDeviceType write SetDeviceType default defAudioDeviceType;
  95. published
  96. property DeviceCount : Integer read GetDeviceCount write FDummyInt stored False;
  97. property DeviceCaps : TMMDeviceCaps read FDeviceCaps write SetDeviceCaps stored False;
  98. property Mapper : Boolean read GetMapper write FDummyBool stored False;
  99. property Active : Boolean read GetActive write SetActive default False;
  100. property DeviceId : TMMDeviceId read FDeviceId write SetDeviceId default defDeviceId;
  101. property OnChange : TNotifyEvent read FOnChange write FOnChange;
  102. end;
  103. {-- TMMDeviceChange -------------------------------------------------}
  104. TMMDeviceChange = class(TObject)
  105. end;
  106. {-- TMMAudioDevice --------------------------------------------------}
  107. TMMAudioDevice = class(TMMCustomAudioDevice)
  108. published
  109. property DeviceType;
  110. end;
  111. {-- EMMMCIError ---------------------------------------------------------}
  112. EMMMCIError = class(Exception)
  113. private
  114. FResult : MMResult;
  115. public
  116. constructor CreateRes(Res: MMResult);
  117. property Result: MMResult read FResult;
  118. end;
  119. {-- EMMDeviceError ------------------------------------------------------}
  120. EMMDeviceError = class(Exception)
  121. end;
  122. function Check(MMRes: MMResult): MMResult;
  123. function CheckExcl(MMRes: MMResult; const Excl: array of MMResult): MMResult;
  124. function DeviceIdToIdent(Id: LongInt; var S: string): Boolean;
  125. function IdentToDeviceId(const S: string; var Id: LongInt): Boolean;
  126. {========================================================================}
  127. implementation
  128. {========================================================================}