私は、記録機能を提供するためにSystem.Windows.Media.AudioSink
から派生したクラスを作成しました。私の具体的なシンクの状態を確認するために、私は次のようにします。私はproprety IsRecording
に対して照会するときCaptureSource.StateをチェックするとInvalidOperationExceptionが発生する
public class MyViewModel
{
private readonly MyAudioSink _myAudioSink; // this field is ensured in the ctor
public bool IsRecording
{
get
{
if (this._myAudioSink == null)
{
return false; // I know that `false` is wrong ...
}
return this._myAudioSink.CaptureSource.State == CaptureState.Started;
}
}
}
は時々、私は次の例外を取得:
{System.InvalidOperationException: Capture source is not stopped
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
at System.Windows.DependencyObject.SetValue(DependencyProperty property, DependencyObject doh)
at System.Windows.Media.CaptureSource..ctor()
at MS.Internal.CoreTypes.GetCoreWrapper(UInt32 typeId)
at MS.Internal.ManagedPeerTable.EnsureManagedPeer(IntPtr unmanagedPointer, Int32 typeIndex, Type type, Boolean preserveManagedObjectReference)
at MS.Internal.XcpImports.ConvertDO(IntPtr doPointer, Int32 typeIndex, Boolean releaseObjectReference)
at MS.Internal.XcpImports.ConvertType(CValue outVal, Int32 typeIndex, Boolean releaseObjectReference, Boolean deleteBuffer, IManagedPeerBase fromObject)
at MS.Internal.XcpImports.AudioSink_GetSource(AudioSink Sink)
at System.Windows.Media.AudioSink.get_CaptureSource()
at MyViewModel.get_IsRecording()
私はthis._myAudioSink.Stop()
を行うときに時々、私を得ます次の(同様の)例外:
{System.InvalidOperationException: Capture source is not stopped
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh)
at System.Windows.DependencyObject.SetValue(DependencyProperty property, DependencyObject doh)
at System.Windows.Media.CaptureSource..ctor()
at MS.Internal.CoreTypes.GetCoreWrapper(UInt32 typeId)
at MS.Internal.ManagedPeerTable.EnsureManagedPeer(IntPtr unmanagedPointer, Int32 typeIndex, Type type, Boolean preserveManagedObjectReference)
at MS.Internal.XcpImports.ConvertDO(IntPtr doPointer, Int32 typeIndex, Boolean releaseObjectReference)
at MS.Internal.XcpImports.ConvertType(CValue outVal, Int32 typeIndex, Boolean releaseObjectReference, Boolean deleteBuffer, IManagedPeerBase fromObject)
at MS.Internal.XcpImports.AudioSink_GetSource(AudioSink Sink)
at System.Windows.Media.AudioSink.get_CaptureSource()
これはどういう意味ですか?この例外を防止するにはどうすればよいですか(自分のフィールドを導入し、それを上書きしてOnCaptureStarted
とOnCaptureStopped
に設定します)。
私はネット上で見つけたこの問題の唯一のトピックがhereです...