locked
Source Resolver CreateObjectFromUrl hangs when called from ByteStreamHandler RRS feed

  • Question

  • Hi

    I have a  MediaFoundation Bytestreamhandler for a specific extension and for a specific case  I have to create a mediasource from a modified URL within the Bytestreamhandler.  I am trying to do this by calling pSourceResolver->CreateObjectFromUrl. The problem is this function hangs when called within BytestreamHandler. It also hangs for pSourceResolver->CreateObjectFromByteStream. (no error returned, just hangs).

    I was doubtful whether I am making a mistake with the options but when I try pSourceResolver->CreateObjectFromUrl from my own SchemeHandler, it gives me a valid mediasource which works.

    I didn’t see any documentation about this but is it that we can’t call SourceResolver from BytestreamHandler? I get that this would be like a recursive call but there should be someway to work around this Or is this a bug? Or Should I be using some other function to be getting a valid mediasource for a Valid URL when I need this to be called from ByteStreamHandler?

    Thanks,

    Kaks


    Friday, April 29, 2011 12:00 AM

Answers

  • The synchronous call to CreateObjectFromUrl/ByteStream blocks the current thread until the source resolution operation completes.  The current thread is a workqueue thread that has called into your byte stream handler, and since your byte stream handler was called by the source resolver it is also likely the workqueue thread that services the source resolver.  Since the thread that will do the work is being blocked, this will lead to a hang.  As a general rule, never make blocking calls on MF workqueue threads.

    One way to fix this is to call the source resolver asynchronously -- for example, BeginCreateObjectFromUrl rather than CreateObjectFromUrl.  Then in your async completion function in your bytestream handler you would do any final work on the generated source and issue the byte stream handler callback.

    • Marked as answer by kakskulkarni Tuesday, May 24, 2011 11:24 PM
    Tuesday, May 24, 2011 10:59 PM

All replies

  • The synchronous call to CreateObjectFromUrl/ByteStream blocks the current thread until the source resolution operation completes.  The current thread is a workqueue thread that has called into your byte stream handler, and since your byte stream handler was called by the source resolver it is also likely the workqueue thread that services the source resolver.  Since the thread that will do the work is being blocked, this will lead to a hang.  As a general rule, never make blocking calls on MF workqueue threads.

    One way to fix this is to call the source resolver asynchronously -- for example, BeginCreateObjectFromUrl rather than CreateObjectFromUrl.  Then in your async completion function in your bytestream handler you would do any final work on the generated source and issue the byte stream handler callback.

    • Marked as answer by kakskulkarni Tuesday, May 24, 2011 11:24 PM
    Tuesday, May 24, 2011 10:59 PM
  • Thanks for your Response

    Regards

    Karthik


    Tuesday, May 24, 2011 11:24 PM
  • I have seen that one said that he met the same problem when call the source resolver asynchronously.

    And I think maybe there are threads blocked or even dead locked, but if this happens, this can also happen in the "asynchronously" way.    Call the source resolver synchronously or asynchronously is not the point of solving the hanging. 

    Friday, August 22, 2014 7:34 AM
  • I noticed that CreateObjectFromUrl and CreateObjectFromByteStream actually hang when you forget to call MFStartup before.
    Wednesday, May 27, 2015 10:32 AM