ThbWaveIn and ThbWaveOut are using an exception mechanism to make the application
aware of occuring errors. If an error occurs when using a Windows wave
function, an EWaveError exception is raised. The ErrorCode property holds
the result code of the last executed wave function (MMResult) and then
Message property holds the correspondig text.
The playing and recording of waveform-audio data works in an asynchronous
mater. Asynchronous occuring errors are advised by triggering an ThbWaveIn.OnWaveError
resp. ThbWaveOut.OnWaveError
event.
Example
hbWaveOut1.Active := False;
hbWaveOut1.DeviceName := 'Wave Device #1';
hbWaveOut1.Playlist.Clear;
hbWaveOut1.Playlist.Add'('wavefile.wav');
try
hbWaveOut1.Active := True;
except
on E:EWaveError do
begin
if E.ErrorCode = MMSYSERR_ALLOCATED then
begin
MessageDlg('Specified resource
is already allocated.', mtInformation, [mbOk], 0);
end
else
raise E;
end;
end;
The ErrorCode member holds the numeric value of the error. This uses
one of the MMSYSERR_ constants:
Value
(Hex)
Constant
Description
0
MMSYSERR_NOERROR
no error
MMSYSERR_BASE + 1
MMSYSERR_ERROR
unspecified error
MMSYSERR_BASE + 2
MMSYSERR_BADDEVICEID
device ID out of range
MMSYSERR_BASE + 3
MMSYSERR_NOTENABLED
driver failed enable
MMSYSERR_BASE + 4
MMSYSERR_ALLOCATED
device already allocated
MMSYSERR_BASE + 5
MMSYSERR_INVALHANDLE
device handle is invalid
MMSYSERR_BASE + 6
MMSYSERR_NODRIVER
no device driver present
MMSYSERR_BASE + 7
MMSYSERR_NOMEM
memory allocation error
MMSYSERR_BASE + 8
MMSYSERR_NOTSUPPORTED
function isn't supported
MMSYSERR_BASE + 9
MMSYSERR_BADERRNUM
error value out of range
MMSYSERR_BASE + 10
MMSYSERR_INVALFLAG
invalid flag passed
MMSYSERR_BASE + 11
MMSYSERR_INVALPARAM
invalid parameter passed
MMSYSERR_BASE + 12
MMSYSERR_HANDLEBUSY
handle being used simultaneously on another thread (eg callback)
MMSYSERR_BASE + 13
MMSYSERR_INVALIDALIAS
specified alias not found
MMSYSERR_BASE + 14
MMSYSERR_BADDB
bad registry database
MMSYSERR_BASE + 15
MMSYSERR_KEYNOTFOUND
registry key not found
MMSYSERR_BASE + 16
MMSYSERR_READERROR
registry read error
MMSYSERR_BASE + 17
MMSYSERR_WRITEERROR
registry write error
MMSYSERR_BASE + 18
MMSYSERR_DELETEERROR
registry delete error
MMSYSERR_BASE + 19
MMSYSERR_VALNOTFOUND
registry value not found
MMSYSERR_BASE + 20
MMSYSERR_NODRIVERCB
driver does not call DriverCallback
Message (String)
The Message member holds a text with the description of the occured error.
This text can be used to displayed user information and is read from the
Windows Multimedia API.