SharpDX exception thrown by MediaFactory.GetService

When playing a song I get an exception (with code 0x80004002 which, according the SharpDX, means an Interface doesnt’ exist but I assume actually means the audio interface isn’t ready) in MediaPlayer.WMS.cs in the code

try
{
    MediaFactory.GetService(_session, MRPolicyVolumeService, SimpleAudioVolumeGuid, out volumeObj);
}
catch
{
    MediaFactory.GetService(_session, MRPolicyVolumeService, SimpleAudioVolumeGuid, out volumeObj);
} 

Confused at first why the try and catch would have the same code I come to the conclusion that the first call spun on the service and a failure is expected and the catch is hoping that some async task has completed in time. On Windows at least, this doesn’t work.

I’m just starting to dig into this issue and stumbled upon this older thread. with a hacked work around that will block the main thread but eventually gets the job done. I want to avoid something like this though.

Is this currently a known issue that is being worked on (and I should work on something else in the meantime) or is this worth digging into and solving?

Yea… as you suspect it seems this was someone’s attempt to deal with it occasionally failing on the first call.

Absolutely… if someone can come up with a better fix please submit it to us.

So i found away to fix this issue.
It seems like the MediaFactory.GetService call is being called too fast or too early.

The way i fixed it was by putting a thread.sleep(1000) call before it in the catch clause.
Yes. its a bad solution. before i submit a final fix, i will see if i can find a better way.