View Single Post
Old 22nd February 2007, 07:56 PM
nicholash nicholash is offline
Join Date: Aug 2005
Posts: 2
Default Chasing weird bugs

One of the bugs reported in the new beta was that some games did not have sound/sound effects/music where they did in version 1.6. So some games might have music but no sound effects. The game this was first noticed in was doom64. It had sound in the intro sequence, but once you got in to the game it had no sound. I figured that since this worked in 1.6 but not in 1.7 then it should not be too hard to fix. Maybe 4 hour’s worth of work, boy was I wrong.
First off change all the normal setting, change to interpreter, use all the same plug-ins from 1.6. It should work but it doesn't. The game has still has sound in the intro, but once in game it does not. Ok make a save state in 1.6 and take it across, now have sound from save but no sound effects. Change the source code so I can log what is data is being to the RSP. After a day of tweaking I am able to get the same timings, it seems to generate the exact same data. It does not appear anything is different here, so I have no clue what is causing it. I try using Azimers audio plugin and set it to HLE the audio. This works, the audio is now playing, this suggests that what is sent to the RSP is correct.
I am totally confused at this point, I know it was working in 1.6 so I try one of the oldest version of 1.7 I had the source for ( This is still failing, so I decide to slowly de-evolve the source back to the 1.6 code. Make sure all the interpreter ops are the same. On to getting the memory code back to the original, after that timing. Then the code for plugins. Then timing code. Then settings, I am totally confused there is not much left and none of the code left should effect the game. Then change some on the initialization code and it is working. Only took me a week to get to this point.
Ok, now I am getting somewhere. 8 hours latter I have narrowed down exactly what allows 1.6 to play with audio and 1.7 does not. The difference was that in 1.6 I created a thread to load the game and then this spawned another thread to execute the emulated core. In 1.7 I reduced it down to not re-spawning because I did not think it was needed. Ok I have a solution, this works when I start the CPU I just do it in another thread.
I just do not like this solution it might work but it makes no sense. I start to move more code in to the CPU thread to find out if there was anything that could give me a better idea what is actually causing this to happen. I find what does not like to be in the same thread as the emulation, initialization of the graphics plug-in. WTF initialization of the gfx plugin in another thread fixes the audio in game! Ok time to try the other gfx plugins. All the Direct X ones have the same effect with doom64, although the opengl has sound working.
Now it is time to talk to Jabo, to see if he has any clue. He has none. He has tracked down the problem to initiating d3d, do this and no sound effect, skip this you got audio. Ok do some more research it suggests that the creating the d3d object should be done in the thread that controls the UI because it adds different hooks in to the message handling. I change this so after loading the rom it will send a message to the UI to initialize the plugins there. This works, not necessarily the nicest solution, and I do not know exactly how it caused the issues. But at least it is working now and better then just spawning a thread for the sake of it.
Reply With Quote