/* * delete_fluid_midishare_midi_driver */ int delete_fluid_midishare_midi_driver(fluid_midi_driver_t* p) { fluid_midishare_midi_driver_t* dev; dev = (fluid_midishare_midi_driver_t*) p; if (dev == NULL) { return FLUID_OK; } if (dev->filter) MidiFreeFilter(dev->filter); #if defined(MIDISHARE_DRIVER) fluid_midishare_close_driver(dev); #else fluid_midishare_close_appl(dev); #endif #if defined(MACINTOSH) && defined(MACOS9) DisposeRoutineDescriptor(dev->upp_alarm_ptr); DisposeRoutineDescriptor(dev->upp_wakeup_ptr); DisposeRoutineDescriptor(dev->upp_sleep_ptr); DisposeRoutineDescriptor(dev->upp_task_ptr); #endif dev->status = FLUID_MIDI_DONE; FLUID_FREE(dev); return FLUID_OK; }
/* * delete_fluid_sndmgr_audio_driver */ int delete_fluid_sndmgr_audio_driver(fluid_audio_driver_t* p) { fluid_sndmgr_audio_driver_t* dev = (fluid_sndmgr_audio_driver_t*) p; if (dev != NULL) { if (dev->channel != NULL) { SndDisposeChannel(dev->channel, 1); } if (dev->doubleCallbackProc != NULL) { DisposeRoutineDescriptor(dev->doubleCallbackProc); } if (dev->doubleHeader != NULL) { if(dev->doubleHeader->dbhBufferPtr[0] != NULL) { FLUID_FREE(dev->doubleHeader->dbhBufferPtr[0]); } if (dev->doubleHeader->dbhBufferPtr[1] != NULL) { FLUID_FREE(dev->doubleHeader->dbhBufferPtr[1]); } FLUID_FREE(dev->doubleHeader); } if (dev->convbuffers[0] != NULL) { FLUID_FREE(dev->convbuffers[0]); } if (dev->convbuffers[1] != NULL) { FLUID_FREE(dev->convbuffers[1]); } FLUID_FREE(dev); } return 0; }
OSErr RVRequestVideoSetting (VideoRequestRecPtr requestRecPtr) { Boolean displayMgrPresent; short iCount = 0; // just a counter of GDevices we have seen DMDisplayModeListIteratorUPP myModeIteratorProc = nil; // for DM2.0 searches SpBlock spBlock; Boolean suppliedGDevice; DisplayIDType theDisplayID; // for DM2.0 searches DMListIndexType theDisplayModeCount; // for DM2.0 searches DMListType theDisplayModeList; // for DM2.0 searches long value = 0; GDHandle walkDevice = nil; // for everybody Gestalt(gestaltDisplayMgrAttr,&value); displayMgrPresent=value&(1<<gestaltDisplayMgrPresent); displayMgrPresent=displayMgrPresent && (SVersion(&spBlock)==noErr); // need slot manager if (displayMgrPresent) { // init the needed data before we start if (requestRecPtr->screenDevice) // user wants a specifc device? { walkDevice = requestRecPtr->screenDevice; suppliedGDevice = true; } else { walkDevice = DMGetFirstScreenDevice (dmOnlyActiveDisplays); // for everybody suppliedGDevice = false; } myModeIteratorProc = NewDMDisplayModeListIteratorProc(ModeListIterator); // for DM2.0 searches // Note that we are hosed if somebody changes the gdevice list behind our backs while we are iterating.... // ...now do the loop if we can start if( walkDevice && myModeIteratorProc) do // start the search { iCount++; // GDevice we are looking at (just a counter) if( noErr == DMGetDisplayIDByGDevice( walkDevice, &theDisplayID, false ) ) // DM1.0 does not need this, but it fits in the loop { theDisplayModeCount = 0; // for DM2.0 searches if (noErr == DMNewDisplayModeList(theDisplayID, 0, 0, &theDisplayModeCount, &theDisplayModeList) ) { // search NuBus & PCI the new kool way through Display Manager 2.0 GetRequestTheDM2Way (requestRecPtr, walkDevice, myModeIteratorProc, theDisplayModeCount, &theDisplayModeList); DMDisposeList(theDisplayModeList); // now toss the lists for this gdevice and go on to the next one } else { // search NuBus only the old disgusting way through the slot manager GetRequestTheDM1Way (requestRecPtr, walkDevice); } } } while ( !suppliedGDevice && nil != (walkDevice = DMGetNextScreenDevice ( walkDevice, dmOnlyActiveDisplays )) ); // go until no more gdevices if( myModeIteratorProc ) DisposeRoutineDescriptor(myModeIteratorProc); return (noErr); // we were able to get the look for a match } return (-1); // return a generic error }
int audio_close(snd_node *n) { buffer_state *data = (buffer_state *)n->u.audio.descriptor; OSErr err; if (data->recording) { SPBStopRecording(data->refnum); SPBCloseDevice(data->refnum); if (data->starved) { data->starved = 0; } #ifndef TARGET_CARBON DisposeRoutineDescriptor(data->params.interruptRoutine); #endif free((void *)data->recBuffer); } else { data->finished = 1; SndCallBackUPP callBack = data->chan->callBack; err = SndDisposeChannel(data->chan, true // quiets the channel now ); #ifndef TARGET_CARBON DisposeRoutineDescriptor(callBack); #endif free((void *)data->buffer); free((void *)data->nextBuffer); } free((void *)data); return SND_SUCCESS; }
GDHandle display_device_dialog( GDSpecPtr device_spec) { GDHandle device= BestDevice(device_spec); if (device) { DialogPtr dialog= myGetNewDialog(dlogDEVICE, NULL, (WindowPtr) -1, 0); ModalFilterUPP device_dialog_filter_upp= NewModalFilterProc(device_dialog_filter_proc); short item_hit; assert(dialog); assert(device_dialog_filter_upp); /* setup globals */ device_dialog_globals.device_spec= *device_spec; device_dialog_globals.device= device; /* setup and show dialog */ device_dialog_instantiate_proc(dialog); ShowWindow(dialog); do { boolean reinstantiate= FALSE; ModalDialog(device_dialog_filter_upp, &item_hit); switch(item_hit) { case iCOLORS: device_dialog_globals.device_spec.flags|= deviceIsColor; reinstantiate= TRUE; break; case iGRAYS: device_dialog_globals.device_spec.flags&= ~deviceIsColor; reinstantiate= TRUE; break; case iDEVICE_AREA: reinstantiate= TRUE; break; case iOK: *device_spec= device_dialog_globals.device_spec; device= device_dialog_globals.device; break; } if (reinstantiate) device_dialog_instantiate_proc(dialog); } while (item_hit!=iOK && item_hit!=iCANCEL); DisposeDialog(dialog); DisposeRoutineDescriptor(device_dialog_filter_upp); } return device; }
CMacAsyncFile::~CMacAsyncFile() { if (m_DeferredTaskStruct.dtAddr != NULL) { #ifdef _CARBON DisposeDeferredTaskUPP(m_DeferredTaskStruct.dtAddr); #else DisposeRoutineDescriptor(m_DeferredTaskStruct.dtAddr); #endif m_DeferredTaskStruct.dtAddr = NULL; } Close(); HX_DELETE(mAsyncQueue); HX_DELETE(m_pPendingCallbackList); HX_DELETE(m_pTimedPQList); HX_DELETE(m_pLocationPQList); HX_DELETE(mReadQueue); #if defined(_DEBUG) && defined(LOG_MULTIPLE_DEFERRED_TASKS) HXBOOL bWaitedForDeferred = FALSE; if ( m_bDeferredTaskPending ) { bWaitedForDeferred = TRUE; DebugStr("\pCMacAsyncFile dtor -- a deferred task is pending!;g"); } #endif UINT32 timeout = TickCount() + 300L; m_bIsQuitting = TRUE; while ( m_bDeferredTaskPending && timeout - TickCount() > 0 ) { // sit-n-spin, awaiting completion of callbacks. } #if defined(_DEBUG) && defined(LOG_MULTIPLE_DEFERRED_TASKS) if ( bWaitedForDeferred ) { if ( m_bDeferredTaskPending ) { DebugStr("\pdeferred task STILL pending! This is gonna hurt;g"); } else { DebugStr( "\pDeferred tasks were successfully purged;g" ); } }
int DoEnterNewAddressDialog(StringPtr name, StringPtr description) { short itemHit,okay=FALSE,keepGoing=TRUE; DialogPtr dlog=NIL; GrafPtr oldPort; ModalFilterUPP MyFilterUPP; GetPort(&oldPort); /* On PowerPC, need a RoutineDescriptor from heap; on 68K, no allocation */ MyFilterUPP = NewModalFilterProc(MyFilter); if (MyFilterUPP == NIL) goto cleanUp; /* Build dialog window and install its item values */ dlog = OpenThisDialog(name, description); if (dlog == NIL) goto cleanUp; /* Entertain filtered user events until dialog is dismissed */ while (keepGoing) { ModalDialog(MyFilterUPP,&itemHit); keepGoing = DoDialogItem(dlog,itemHit); } /* * Do final processing of item values, such as exporting them to caller. * DoDialogItem() has already called AnyBadValues(). */ okay = (itemHit == OK_ITEM); if (okay) { GetDlgString(dlog, EDIT5, name); GetDlgString(dlog, EDIT6, description); } /* That's all, folks! */ cleanUp: if (dlog) CloseThisDialog(dlog); if (MyFilterUPP) DisposeRoutineDescriptor(MyFilterUPP); SetPort(oldPort); return(okay); }
OSErr RVConfirmVideoRequest (VideoRequestRecPtr requestRecPtr) { short alertReturn; // Alert() return value ModalFilterUPP confirmFilterUPP; // got to have us one of them new fangled UPP thingies if (requestRecPtr->availFlags & 1<<kModeValidNotSafeBit) { // new mode is valid but not safe, so ask user to confirm SetCursor(&qd.arrow); // have to show the arrow confirmFilterUPP = NewModalFilterProc (ConfirmAlertFilter); // create a new modal filter proc UPP alertReturn = Alert(rConfirmSwtchAlrt, confirmFilterUPP); // alert the user DisposeRoutineDescriptor (confirmFilterUPP); // of course there is no DisposeModalFilterProc... if (alertReturn != iConfirmItem) return (-1); // tell the caller to switch back to a known setting else return (noErr); // all is well with the new setting, just leave it } return (noErr); // the mode was safe, so do nothing }
pascal OSErr IndexedSearch(CSParamPtr pb, long dirID) { static LevelRecHandle searchStack = NULL; /* static handle to LevelRec stack */ static Size searchStackSize = 0; /* size of static handle */ SearchPositionRecPtr catPosition; long modDate; short index; ExtendedTMTask timerTask; OSErr result; short realVRefNum; Str63 itemName; CInfoPBRec cPB; long tempLong; Boolean includeFiles; Boolean includeDirs; Boolean includeNames; Str63 upperName; timerTask.stopSearch = false; /* do NOT stop yet! */ /* If request has a timeout, install a Time Manager task. */ if ( pb->ioSearchTime != 0 ) { /* Start timer */ timerTask.theTask.tmAddr = NewTimerProc(TimeOutTask); InsTime((QElemPtr)&(timerTask.theTask)); PrimeTime((QElemPtr)&(timerTask.theTask), pb->ioSearchTime); } /* Check the parameter block passed for things that we do NOT want to assume */ /* are OK later in the code. For example, make sure pointers to data structures */ /* and buffers are not NULL. And while we are in there, see if the request */ /* specified searching for files, directories, or both, and see if the search */ /* was by full or partial name. */ result = VerifyUserPB(pb, &includeFiles, &includeDirs, &includeNames); if ( result == noErr ) { pb->ioActMatchCount = 0; /* no matches yet */ if ( includeNames ) { /* The search includes seach by full or partial name. */ /* Make an upper case copy of the match string to pass to */ /* CheckForMatches. */ BlockMoveData(pb->ioSearchInfo1->hFileInfo.ioNamePtr, upperName, pb->ioSearchInfo1->hFileInfo.ioNamePtr[0] + 1); /* Use the same non-international call the File Manager uses */ UpperString(upperName, true); } /* Prevent casting to my type throughout code */ catPosition = (SearchPositionRecPtr)&pb->ioCatPosition; /* Create searchStack first time called */ if ( searchStack == NULL ) { searchStack = (LevelRecHandle)NewHandle(kAdditionalLevelRecs * sizeof(LevelRec)); } /* Make sure searchStack really exists */ if ( searchStack != NULL ) { searchStackSize = InlineGetHandleSize((Handle)searchStack); /* See if the search is a new search or a resumed search. */ if ( catPosition->initialize == 0 ) { /* New search. */ /* Get the real vRefNum and fill in catPosition->initialize. */ result = CheckVol(pb->ioNamePtr, pb->ioVRefNum, &realVRefNum, &catPosition->initialize); if ( result == noErr ) { /* clear searchStack */ catPosition->stackDepth = 0; /* use dirID parameter passed and... */ index = -1; /* start with the passed directory itself! */ } } else { /* We are resuming a search. */ /* Get the real vRefNum and make sure catPosition->initialize is valid. */ result = CheckVol(pb->ioNamePtr, pb->ioVRefNum, &realVRefNum, &tempLong); if ( result == noErr ) { /* Make sure the resumed search is to the same volume! */ if ( catPosition->initialize == tempLong ) { /* For resume, catPosition->stackDepth > 0 */ if ( catPosition->stackDepth > 0 ) { /* Position catPosition->stackDepth to access last saved level */ --(catPosition->stackDepth); /* Get the dirID and index for the next item */ dirID = (*searchStack)[catPosition->stackDepth].dirID; index = (*searchStack)[catPosition->stackDepth].index; /* Check the dir's mod date against the saved mode date on our "stack" */ modDate = GetDirModDate(realVRefNum, dirID); if ( modDate != (*searchStack)[catPosition->stackDepth].dirModDate ) { result = catChangedErr; } } else { /* Invalid catPosition record was passed */ result = paramErr; } } else { /* The volume is not the same */ result = catChangedErr; } } } if ( result == noErr ) { /* ioNamePtr and ioVRefNum only need to be set up once. */ cPB.hFileInfo.ioNamePtr = itemName; cPB.hFileInfo.ioVRefNum = realVRefNum; /* ** Here is the loop that: ** Finds the next item on the volume. ** If noErr, calls the code to check for matches and add matches ** to the match buffer. ** Sets up dirID and index for to find the next item on the volume. ** ** The looping ends when: ** (a) an unexpected error is returned by PBGetCatInfo. All that ** is expected is noErr and fnfErr (after the last item in a ** directory is found). ** (b) the caller specified a timeout and our Time Manager task ** has fired. ** (c) the number of matches requested by the caller has been found. ** (d) the last item on the volume was found. */ do { /* get the next item */ cPB.hFileInfo.ioFDirIndex = index; cPB.hFileInfo.ioDirID = dirID; result = PBGetCatInfoSync(&cPB); if ( index != -1 ) { if ( result == noErr ) { /* We found something */ CheckForMatches(&cPB, pb, upperName, includeFiles, includeDirs); ++index; if ( (cPB.dirInfo.ioFlAttrib & ioDirMask) != 0 ) { /* It is/was a directory */ result = CheckStack(catPosition->stackDepth, searchStack, &searchStackSize); if ( result == noErr ) { /* Save the current state on the searchStack */ /* when we come back, this is where we will start */ (*searchStack)[catPosition->stackDepth].dirID = dirID; (*searchStack)[catPosition->stackDepth].index = index; (*searchStack)[catPosition->stackDepth].dirModDate = GetDirModDate(realVRefNum, dirID); /* position catPosition->stackDepth for next saved level */ ++(catPosition->stackDepth); /* The next item to get is the 1st item in the child directory */ dirID = cPB.dirInfo.ioDrDirID; index = 1; } } /* else do nothing for files */ } else { /* End of directory found (or we had some error and that */ /* means we have to drop out of this directory). */ /* Restore last thing put on stack and */ /* see if we need to continue or quit. */ if ( catPosition->stackDepth > 0 ) { /* position catPosition->stackDepth to access last saved level */ --(catPosition->stackDepth); dirID = (*searchStack)[catPosition->stackDepth].dirID; index = (*searchStack)[catPosition->stackDepth].index; /* Check the dir's mod date against the saved mode date on our "stack" */ modDate = GetDirModDate(realVRefNum, dirID); if ( modDate != (*searchStack)[catPosition->stackDepth].dirModDate ) { result = catChangedErr; } else { /* Going back to ancestor directory. */ /* Clear error so we can continue. */ result = noErr; } } else { /* We hit the bottom of the stack, so we will let the */ /* the eofErr drop us out of the loop. */ result = eofErr; } } } else { /* Special case for index == -1; that means that we are/were starting */ /* a new search and so the first item to check is the directory */ /* passed to us. */ if ( result == noErr ) { /* We found something */ CheckForMatches(&cPB, pb, upperName, includeFiles, includeDirs); /* Now, set the index to 1 and then we are ready to look inside */ /* the passed directory. */ index = 1; } } } while ( (!timerTask.stopSearch) && /* timer has NOT fired */ (result == noErr) && /* no unexpected errors */ (pb->ioReqMatchCount > pb->ioActMatchCount) ); /* we have NOT found our limit */ /* Did we drop out of the loop because of timeout or */ /* ioReqMatchCount was found? */ if ( result == noErr ) { result = CheckStack(catPosition->stackDepth, searchStack, &searchStackSize); if ( result == noErr ) { /* Either there was a timeout or ioReqMatchCount was reached. */ /* Save the dirID and index for the next time we are called. */ (*searchStack)[catPosition->stackDepth].dirID = dirID; (*searchStack)[catPosition->stackDepth].index = index; (*searchStack)[catPosition->stackDepth].dirModDate = GetDirModDate(realVRefNum, dirID); /* position catPosition->stackDepth for next saved level */ ++(catPosition->stackDepth); } } } } else { /* searchStack Handle could not be allocated */ result = memFullErr; } } if ( pb->ioSearchTime != 0 ) { /* Stop Time Manager task here if it was installed */ RmvTime((QElemPtr)&(timerTask.theTask)); DisposeRoutineDescriptor(timerTask.theTask.tmAddr); } return ( result ); }