Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Strange problems with microphone and webcam

Discussion in 'Windows' started by Lexustio, Aug 7, 2013.

  1. Lexustio

    Lexustio

    Joined:
    Jun 26, 2013
    Posts:
    18
    Heyah. Like the title says, I'm having problems with using my tablet's microphone and webcam functionalities.

    In my app, it's possible to record voice take pictures, then attach them as AudioClips and Texture2Ds into a 3D-scene (think of a level of a game, actually an imported CAD model). Everything works fine inside the unity editor (no exceptions, no strange behaviour etc.) but when I build the project and deploy it to my tablet (Samsung Smart PC Pro 700T), neither of the devices work without problems.

    Before you say anything, permissions for both of the devices have been cleared (I've set up microphone webcam as app capabilities in Visual Studio manually granted permissions from the Win 8 side menu. Do I still have to ask permission from the user?)

    Anyways, when I launch the app and start the camera for the first time, I get this debug error message:

    Code (csharp):
    1. realGfxDevice == 0 || Thread::CurrentThreadIsMainThread()
    2. Thread::CurrentThreadIsMainThread()
    3. Thread::CurrentThreadIsMainThread()
    Another error I've been getting:

    Code (csharp):
    1. realGfxDevice == 0 || Thread::CurrentThreadIsMainThread()
    2. Thread::CurrentThreadIsMainThread()
    3. Thread::CurrentThreadIsMainThread()
    4. Error: Operation has failed with error 0x8000ffff: Catastrophic failure
    5.  
    6. (C:/BuildAgent/work/xxx/PlatformDependent/MetroPlayer/VideoTexture.cpp:WebCamTexture::Play::<lambda_xxx>::
    With this error message, the camera doesn't even start.

    A few times I've also gotten this spam:

    Code (csharp):
    1.  
    2. [...]
    3. Gfx command not handled: 255 (Last command: 255)
    4. Gfx command not handled: 255 (Last command: 255)
    5. Gfx command not handled: 255 (Last command: 255)
    6. Gfx command not handled: 255 (Last command: 255)
    7. [...]
    The camera still launches like it's supposed to and works flawlessly, so this problem is mainly a cosmetic one. What's puzzling about it is the word "realGfxDevice" though, as even google returns 0 results for it. If I close the camera and start it again (without closing the main app), I don't get the error message again. Code piece that causes the error message to pop up:

    Code (csharp):
    1. if (cameraOutput == null) {
    2.     cameraOutput = new WebCamTexture(WebCamTexture.devices[1].name, 640, 480, 30); // devices[1] = back camera
    3.     GetComponent<UITexture>().mainTexture = cameraOutput;
    4. }  
    5. cameraOutput.Play(); // error message pops up on this line
    [HR][/HR]
    With the microphone, I'm trying to record a clip when the user presses a button. In the deployed build, I get no error message at all, and the app just crashes to the desktop (or start menu, for that matter). Visual Studio's debugger then displays this as output:

    Code (csharp):
    1. The program '[1768] Template.exe: Managed (v4.0.30319)' has exited with code -1073740791 (0xc0000409).
    0xc0000409 = unknown software exception, so I'm kinda clueless here.

    Code piece that causes this to happen:


    Code (csharp):
    1. if (!Microphone.IsRecording(mic)  !audio.isPlaying) {
    2.     sound = Microphone.Start(mic, false, length, 44100); // app crashes on this line, shortly after execution
    3.     audio.clip = sound;
    4.     StartBars();
    5. }
    So like I said before, everything works flawlessly inside the the editor, but in the deployed build, the problems above appear, rendering the app completely broken. Both work when I build deploy to an iPad, no error messages or anything. Anybody have any clue about what's going on? Anybody even used Microphone/WebCamTextures in their Windows Store apps yet? Somebody throw me a bone as I'm totally clueless here.

    Edit: Forgot to mention that I'm indeed developing for a Win 8 Pro device, not RT. So x86 architecture instead of ARM.

    Edit Edit: so apparently the Microphone isn't yet officially supported by Unity. No wonder it doesnt' work then, my bad. The "problem" with the webcam still exists though
     
    Last edited: Aug 9, 2013