Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8414559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:12:01+00:00 2026-06-10T01:12:01+00:00

I’ve created a class, which derives from System.Windows.Media.AudioSink to provide recording capabilities. To check

  • 0

I’ve created a class, which derives from System.Windows.Media.AudioSink to provide recording capabilities. To check the state of my concrete sink I do the following:

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;
        }
    }
}

Sometimes when I query against the proprety IsRecording, I get the following exception:

{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()

Sometimes when I do this._myAudioSink.Stop(), I get the following (similar) exception:

{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()

So … what’s the reason for that? How can I prevent this exception (except introducing my own field and set it in the overrides of OnCaptureStarted and OnCaptureStopped)?

The only topic on this problem I’ve found on the net is here …

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T01:12:02+00:00Added an answer on June 10, 2026 at 1:12 am

    I ended up with overriding the specific commands (OnCaptureStopped, OnCaptureStarted, ..) to encapsulate the state in my model AND encapsulated the captureSource inside my concrete audio-sink in a separate field.

    Obviously this does the trick, and I never had any problems again.

    PS: I somewhere read that the encapsulation of the captureSource should be sufficient – atm I cannot provide the link … it’s somewhere out there, sry!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.