NAudio throws COMException when running stop - naudio

So I am using NAudio to run tests with a headset. I have been using this for a while with no issues but today I have been getting an exception. I start the audio, put the computer to sleep while the audio is playing then wake it up. Once it wakes up the audio device playing the audio has changed and of course the audio isn't playing anymore. After it has woke up NAudio tries to run DirectSoundOut.StopPlayback() on its own causing a System.Runtime.InteropServices.COMException. I see how this might happen since the audio is stopped and maybe NAudio still thinks it is playing or something but I am confused because I have never gotten this issue before. I'm trying to find a way around this or a better way to do it. The only thing that needs to happen is the audio has to be playing when the computer goes to sleep, it can't be stopped before that.

Related

Kinect Freezing After a Minute and a Half

I've been messing around with programming the old Kinect for a while, and something I've noticed is that whenever I start a program that uses the Kinect sensor, the Kinect will stop sending inputs after 1:30 minutes, no matter what program it is. For example, my game that I made will still have enemies moving around, but the player's rendered skeleton from the Kinect just freezes. I can't find anything about this anywhere online, so is it just mine? Is there a way to fix this?
This is a bug somewhere between the Microsoft SDK and using a Kinect for XBOX on Windows (didn't try the Kinect for Windows).
The Kinect stream freezes after 1 minute 28 seconds. In the Unity editor, you'll also notice once you reach this freeze, you need to quit and restart Unity to be able to play again. If not, you'll get messages like "Device not genuine", etc.
The only way to solve it that I found is to re-initialize whatever Kinect Manager you are using. For instance, Destroy()ing the gameObject holding the manager and re-Instantiate()ting it.
This will effectively halt your Kinect stream (and any gesture/joint reading) for about 4 seconds and then it will work again, so this is something the user will definitely notice.
Now, this may not work for most games, but if you're working on a casual game and you can keep it under 1:28 or you're able to show the user some sort of screen while you restart the Kinect manager every 1:20, you'll be safe.
If you never exceed the 1:28, you'll be able to stop and play in the Unity editor as many times as you want, and keep it running as many times as you want.
Now, this may not be an actual "answer", but may work for someone.
Let me know if you need any help to make this work. I hope this helps someone.
You can test the Kinect with built in programs in this link.programs to check and see if it works smoothly. If not may be something wrong with your program.
I have the same issue. At first I thought it was something related to Unity3d. But I tested with other programas and it's still happening.
Talking to the guy who developed the plugin he said: " two users complained that Kinect tracking stops after a while"
https://www.assetstore.unity3d.com/en/#!/content/7747
Also, I sent him an email and he told me that more and more people are getting this issue.

Gamemaker game freezing computer

My friend is currently making a game in gamemaker, but whenever I test it out for him my computer seems to just completely lock up. My PC that I am testing on is no way underpowered, it has a 2500k, Radeon 6950 and 8GB RAM. My RAM, GPU and CPU usage is barely touched during the freeze. If I am playing music at the time of the freeze the speakers just buzz. Whenever is occurs a full system reboot is always required, nothing at all responds. The image of the game stays on the screen, mouse, keyboard and restart button don't respond. This question may be better suited for the Gamemaker forums, but it could be an issue with my computer. I am unsure. I can play MW2 and Crysis for hours without it crashing, so it is either a software problem or something weird. All of my temps are normal. Others have suggested checking while loops, but wouldn't an infinite loop cause the CPU usage to rise?
In any of your loops that have a potential of running infinitely, put io_handle(); (I think thats the command) This command somehow keeps windows from thinking a program has frozen. If that isn't the case... then try to play the music through an extension like fMod or another one. Furthermore, try it on another computer is it just your computer? Your computer doesn't sound underpowered at all... but what about your operating system? If you're using xp it may not support the Directx that GM requires. I believe that its very easy to make gm games very directx intensive, so check that out. Good luck! I love Game Maker!
It's most likely an infinite loop in your code. Try stripping away your code, compile, and test if your computer freezes again. Then build back up to where you started from.
This kind of issue is probably due to something internally in game maker, OR it could be an issue with a listener or script you may have bound to a sprite or object. Begin removing things, one by one, until you find the culprit.
Try to strip out pieces of code part by part and isolate the function / code that is causing the freeze. Then come back here and tell us the status.
I've kind of seen this before on another Gamemaker game. Do you have any infinite loops or shaders in your game? The last game that had this problem was caused by a bad shader.

OSX Lion and Movist: playback freezes at specific instant

I'm a newbie developer who worked on Movist media player over the last months.
The project seems to be dead so I started to look at the code and try to understand how it behaves.
I have been able to add hardware decoding (with VDADecoder), fix all deprecated functions, plus other minor things and everything seems to work nicely on Snow Leopard.
When testing the app on OSX Lion, instead, I encounter a very annoying issue and I'm short of idea because I tried quite everything..
The video playback freezes for about 0.1 - 0.2 seconds always at the same instant during the playback. It seems to freeze just when the decoder reaches the end of file and when the remaining (already) decoded frames get displayed.
The issue appears with both hardware and software decoding and it's not related to the part of code that I have added.
Obviously, the same movie file plays smoothly on Snow Leopard (with both software and hardware decoding) and on Leopard (with software decoding) (hardware decoding isn't supported).
I tried to use Instruments to debug this issue but I don't know how to catch that instant. Sometimes Instruments records a lot of "sys enter trap" around that instant..is this a hint?
I tried to rebuild the project with Xcode 4 and SDK 10.7 and to fix all the warnings but the issue still persists.
Is there a way to debug this issue?
I don't know how to discover the bug...if there is any..
I hope you can help me.
Regards
Andrea
Just to let everyone know, I found what was causing the issue.
It was given by the Restorable feature of the movie window which was causing that periodical stuttering.

BSOD while playing a sound resource

I have a VB.NET application that crashes on a client's computer with a BSOD error... KERNEL_DATA_INPAGE_ERROR.
This error occurs at a point where my program does two things:
Locks the computer
Plays a sound in BackgroundLoop mode
For locking the work station, I am just using this:
<DllImport("user32")> _
Public Shared Sub LockWorkStation()
End Sub
For playing the sound, I am doing this:
My.Computer.Audio.Play(My.Resources.ResourceManager.GetStream("somesound"), AudioPlayMode.BackgroundLoop)
Now, this sound loops until the user logs back in. My software detects the session state switch and stops playing the sound. Sometimes when I log back in, the sound card plays garbage data for a split second, instead of the rest of the audio buffer. I get the impression that this has something to do with session switching.
Could my client be having an issue where there is memory corruption occurring at the point of locking the computer?
I apologize for the vagueness of this post... I am not sure where to begin as I cannot reproduce the problem myself.
Edit: If the sound is left to play on its own, even without locking the computer, eventually the computer will lock up and then bluescreen. Playing the sound while locking at the same causes it to happen sooner.
Edit #2: So I've seen it fail now. The sound loop starts playing correctly but quickly switches to looping of garbage data. It's as if it is just reading a random location in memory and looping that. Very strange behavior!
Solved!: It was hardware all along afterall. Apparently this particular model of laptop has a problem where the speaker is installed right on top of the hard drive. When playing sounds loudly, it creates all sorts of problems.
A blue screen is almost certainly related to defective hardware or drivers. Softwarewise, there's really not much you can do about this apart from putting together a workaround.
You can perform a memory dump and try to determine what specifically went wrong, or with some clever debugging see where it bombs out in order to try to avoid it.
Otherwise, you're probably talking about doing some maintenance work on the machine in question.

Using Cocoa to detect when a running application plays audio

I'm looking into writing an app that runs as a background process and detects when an app (say, Safari) is playing audio. I can use NSWorkspace to get the process ID's of the currently running applications but I'm at a loss when it comes to detecting what those processes are doing. I assume that there is a way to listen in on a process and detect what public messages the objects are sending. I apologize for my ignorance on the subject.
Has anyone attempted anything like this or are aware of any resources that can help?
I don't think that your "answer" is an answer at all...
and there IS an answer (which is not "42")
your best bet for doing this would be to write a pass-through audio output device. Much like soundflower, actually. so your audio output device would then load the actual (physical) audio output device and pass the audio data along to it directly (after first having a look at the audio stream, of course!). then you only need to convince your users to configure your audio device as the default audio output device so that the majority of applications which play sound will use it automatically. and voila...
your audio processing function will probably just do a quick RMS on the buffer before passing it along to the actual output device. and when the audio power crosses a certain threshold (probably something like -54dB with apple audio hardware), then you know that some app is making sound.
|K<
SoundFlower is an open-source project that allows Mac OS X applications to pass audio to each other. It almost certainly does something similar to what you describe.
I've been informed on another thread that while this is possible, it is an extremely advanced technique and not recommended. It would involve using Application Enhancer (APE) and is considered a not 'nice' thing to do. Looks like that app idea is destined for the big recycling bin in the sky :)