diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-01-09 01:50:38 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-01-09 01:50:38 +0000 |
| commit | 9af085242bda9ad4da78ef23e9d4ed180aa2c629 (patch) | |
| tree | c776a5dfefbe475936a461b54d469d244df9de75 /macosx/PluginList.m | |
| parent | c5b4bf6974fbfd05b6e75c494d11569756034e36 (diff) | |
| download | pcsxr-9af085242bda9ad4da78ef23e9d4ed180aa2c629.tar.gz | |
Use ARC in 64-bit mode on the Mac.
Register when we drag a disc image (or double click) to Pcsxr in the recent menu.
Comment out ReleasePlugins() in SysClose: it was causing a pointer to be released twice when you changed a plug-in (specifically, the GPU).
Cleaning up the Recent items code. One notable case is only releasing objects we have ownership of (this is pointless in ARC, but necessary in 32-bit code).
Had to rewrite -[PluginList setActivePlugin:forType:] because the previous version wasn't ARC-friendly.
If we select a disc while the emulator is running, load the disc into the current session.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@82136 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/PluginList.m')
| -rwxr-xr-x | macosx/PluginList.m | 111 |
1 files changed, 98 insertions, 13 deletions
diff --git a/macosx/PluginList.m b/macosx/PluginList.m index 72ec6aa0..09469322 100755 --- a/macosx/PluginList.m +++ b/macosx/PluginList.m @@ -11,6 +11,7 @@ #import "PcsxrPlugin.h" #include "psxcommon.h" #include "plugins.h" +#import "ARCBridge.h" //NSMutableArray *plugins; static PluginList *sPluginList = nil; @@ -132,18 +133,18 @@ const static int typeList[5] = {PSE_LT_GPU, PSE_LT_SPU, PSE_LT_CDR, PSE_LT_PAD, - (void)dealloc { - [activeGpuPlugin release]; - [activeSpuPlugin release]; - [activeCdrPlugin release]; - [activePadPlugin release]; - [activeNetPlugin release]; + RELEASEOBJ(activeGpuPlugin); + RELEASEOBJ(activeSpuPlugin); + RELEASEOBJ(activeCdrPlugin); + RELEASEOBJ(activePadPlugin); + RELEASEOBJ(activeNetPlugin); - [pluginList release]; + RELEASEOBJ(pluginList); if (sPluginList == self) sPluginList = nil; - [super dealloc]; + SUPERDEALLOC; } - (void)refreshPlugins @@ -174,7 +175,7 @@ const static int typeList[5] = {PSE_LT_GPU, PSE_LT_SPU, PSE_LT_CDR, PSE_LT_PAD, PcsxrPlugin *plugin = [[PcsxrPlugin alloc] initWithPath:pname]; if (plugin != nil) { [pluginList addObject:plugin]; - [plugin release]; + RELEASEOBJ(plugin); } } } @@ -259,7 +260,90 @@ const static int typeList[5] = {PSE_LT_GPU, PSE_LT_SPU, PSE_LT_CDR, PSE_LT_PAD, - (BOOL)setActivePlugin:(PcsxrPlugin *)plugin forType:(int)type { - PcsxrPlugin **pluginPtr; +#if 1 + + PcsxrPlugin *toCopy = plugin; + PcsxrPlugin *pluginPtr = nil; + + switch (type) { + case PSE_LT_GPU: pluginPtr = activeGpuPlugin; break; + case PSE_LT_CDR: pluginPtr = activeCdrPlugin; break; + case PSE_LT_SPU: pluginPtr = activeSpuPlugin; break; + case PSE_LT_PAD: pluginPtr = activePadPlugin; break; + case PSE_LT_NET: pluginPtr = activeNetPlugin; break; + default: return NO; + } + if (toCopy == pluginPtr) { + return YES; + } + + + BOOL active = pluginPtr && [EmuThread active]; + BOOL wasPaused = NO; + if (active) { + // TODO: temporary freeze? + wasPaused = [EmuThread pauseSafe]; + ClosePlugins(); + ReleasePlugins(); + } + + // stop the old plugin and start the new one + if (pluginPtr) { + [pluginPtr shutdownAs:type]; + RELEASEOBJ(pluginPtr); + } + + if ([toCopy runAs:type] != 0) { + toCopy = nil; + } + switch (type) { + case PSE_LT_GPU: + activeGpuPlugin = RETAINOBJ(toCopy); + break; + case PSE_LT_CDR: + activeCdrPlugin = RETAINOBJ(toCopy); + break; + case PSE_LT_SPU: + activeSpuPlugin = RETAINOBJ(toCopy); + break; + case PSE_LT_PAD: + activePadPlugin = RETAINOBJ(toCopy); + break; + case PSE_LT_NET: + activeNetPlugin = RETAINOBJ(toCopy); + break; + } + + + // write path to the correct config entry + const char *str; + if (toCopy != nil) { + str = [[plugin path] fileSystemRepresentation]; + if (str == nil) { + str = "Invalid Plugin"; + } + } else { + str = "Invalid Plugin"; + } + + char **dst = [PcsxrPlugin configEntriesForType:type]; + while (*dst) { + strncpy(*dst, str, MAXPATHLEN); + dst++; + } + + if (active) { + LoadPlugins(); + OpenPlugins(); + + if (!wasPaused) { + [EmuThread resume]; + } + } + + return toCopy != nil; +#else + PcsxrPlugin *__strong*pluginPtr; switch (type) { case PSE_LT_GPU: pluginPtr = &activeGpuPlugin; break; case PSE_LT_CDR: pluginPtr = &activeCdrPlugin; break; @@ -284,13 +368,12 @@ const static int typeList[5] = {PSE_LT_GPU, PSE_LT_SPU, PSE_LT_CDR, PSE_LT_PAD, // stop the old plugin and start the new one if (*pluginPtr) { [*pluginPtr shutdownAs:type]; - - [*pluginPtr release]; + RELEASEOBJ(*pluginPtr); } - *pluginPtr = [plugin retain]; + *pluginPtr = RETAINOBJ(plugin); if (*pluginPtr) { if ([*pluginPtr runAs:type] != 0) { - [*pluginPtr release]; + RELEASEOBJ(*pluginPtr); *pluginPtr = nil; } } @@ -322,6 +405,8 @@ const static int typeList[5] = {PSE_LT_GPU, PSE_LT_SPU, PSE_LT_CDR, PSE_LT_PAD, } return *pluginPtr != nil; + +#endif } @end |
