2015-08-30, 13:42
(2015-08-30, 13:18)garbear Wrote: Each peripheral bus gets its own thread, and all scanning happens within that thread, regardless of where the scan was triggered
Are you sure about that? Anyone can call CPeripherals::TriggerDeviceScan() which in turn calls CPeripheralBus::TriggerDeviceScan() which then either triggers an asynchronous device scan through CPeripheralBus:rocess() or directly calls CPeripheralBus::ScanForDevices() in which case the scan isn't performed in the CPeripheralBus thread.
(2015-08-30, 13:18)garbear Wrote: The mistake here is that the add-on bus shouldn't hold a lock when passing control to the add-on. I'll get this fixed
The locks being held in below stack trace make sense with the current lock structure (apart from the fact that often the locks are protecting a container but then return a raw pointer to an item from the container which might disappear anytime). Moving to RWLocks wouldn't help in the situation either.
I took a quick look at the code and looks like the CPeripherals::GetAddon() is new to RetroPlayer and its call to CPeripherals::GetBusType() which already exists in master is causing the deadlock. The add-on peripheral bus implementation doesn't hold any specific locks that are causing this issue. They are all in CPeripherals and CPeripheralBus.
I've also done some more runtime testing on the emulators and every now and then when I stop an emulator (doesn't matter which one) it crashes when calling Destroy() on game.libretro. Couldn't figure out yet how to reliably reproduce this. I just start and stop the emulator a lot until it happens. Need to setup game.libretro for debugging.
Furthermore I'm getting the feeling that input delay gets worse the longer I'm playing in an emulator. When starting Super Mario Bros. in level 1 input is perfectly fine but when reaching level 4 there's a huge lag and some button presses aren't detected at all anymore (especially when I'm pressing multiple buttons at once like running and jumping etc. I'm not really sure if it has anything to do with how long the emulator is running but I've never noticed any problems after starting fresh.