blob: f2528e4826204e9b10fd93886e4f7fd7c9a8ca3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
using Whisper.Internal;
namespace Whisper
{
/// <summary>Implement this abstract class to provide callbacks for audio capture method</summary>
public abstract class CaptureCallbacks
{
/// <summary>Override this method to support cancellation</summary>
protected virtual bool shouldCancel( Context sender ) { return false; }
/// <summary>Override this method to get notified about status changes</summary>
protected virtual void captureStatusChanged( Context sender, eCaptureStatus status ) { }
internal pfnShouldCancel cancel( Context sender )
{
const int S_OK = 0;
const int S_FALSE = 1;
return delegate ( IntPtr pv )
{
try
{
return shouldCancel( sender ) ? S_FALSE : S_OK;
}
catch( Exception ex )
{
NativeLogger.captureException( ex );
return ex.HResult;
}
};
}
internal pfnCaptureStatus status( Context sender )
{
return delegate ( IntPtr pv, eCaptureStatus status )
{
try
{
captureStatusChanged( sender, status );
return 0;
}
catch( Exception ex )
{
NativeLogger.captureException( ex );
return ex.HResult;
}
};
}
}
}
|