static pascal ComponentResult myDataHScheduleData64( DataHandler dh, Ptr PlaceToPutDataPtr, const wide * FileOffset, long DataSize, long RefCon, DataHSchedulePtr scheduleRec, DataHCompletionUPP CompletionRtn) { Handle storage = GetComponentInstanceStorage(dh); DHData *data = (DHData*)*storage; HRESULT hr; SInt64 fileOffset64 = WideToSInt64(*FileOffset); LONGLONG offset = fileOffset64; BYTE* buffer = (BYTE*)PlaceToPutDataPtr; TRACE("%p %p %s %li %li %p %p\n",dh, PlaceToPutDataPtr, wine_dbgstr_longlong(offset), DataSize, RefCon, scheduleRec, CompletionRtn); hr = IAsyncReader_SyncRead(data->dataRef.pReader, offset, DataSize, buffer); TRACE("result %x\n",hr); if (CompletionRtn) { if (data->AsyncCompletionRtn) InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn); data->AsyncPtr = PlaceToPutDataPtr; data->AsyncRefCon = RefCon; data->AsyncCompletionRtn = CompletionRtn; } return noErr; }
static pascal ComponentResult myDataHGetFileSizeAsync ( DataHandler dh, wide *fileSize, DataHCompletionUPP CompletionRtn, long RefCon ) { Handle storage = GetComponentInstanceStorage(dh); DHData *data = (DHData*)*storage; LONGLONG total; LONGLONG available; SInt64 total64; TRACE("%p\n",dh); IAsyncReader_Length(data->dataRef.pReader,&total,&available); total64 = total; *fileSize = SInt64ToWide(total64); if (CompletionRtn) { if (data->AsyncCompletionRtn) InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn); data->AsyncPtr = (Ptr)fileSize; data->AsyncRefCon = RefCon; data->AsyncCompletionRtn = CompletionRtn; } return noErr; }
static pascal ComponentResult myDataHGetFileName ( DataHandler dh, Str255 str) { Handle storage = GetComponentInstanceStorage(dh); DHData *data = (DHData*)*storage; TRACE("%p %s\n",str,debugstr_guid(&data->dataRef.streamSubtype)); /* Todo Expand this list */ if (IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_MPEG1Video) || IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_MPEG1System)) CFStringGetPascalString(CFSTR("video.mpg"),str,256,kCFStringEncodingMacRoman); else if(IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_Asf)) CFStringGetPascalString(CFSTR("video.asf"),str,256,kCFStringEncodingMacRoman); else if(IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_Avi)) CFStringGetPascalString(CFSTR("video.avi"),str,256,kCFStringEncodingMacRoman); else if(IsEqualIID(&data->dataRef.streamSubtype, &MEDIASUBTYPE_QTMovie)) CFStringGetPascalString(CFSTR("video.mov"),str,256,kCFStringEncodingMacRoman); else { BYTE header[10] = {0,0,0,0,0,0,0,0,0,0}; int i; IAsyncReader_SyncRead(data->dataRef.pReader, 0, 8, header); for (i=0; i < sizeof(stream_sigs)/sizeof(signature); i++) if (memcmp(header, stream_sigs[i].sig, stream_sigs[i].sig_length)==0) { str[0] = strlen(stream_sigs[i].fname); memcpy(str + 1, stream_sigs[i].fname, str[0]); return noErr; } return badComponentSelector; } return noErr; }
// get the fast dispatch pointers void Init() { UInt32 size = sizeof(AudioUnitRenderProc); if (AudioUnitGetProperty(mUnit, kAudioUnitProperty_FastDispatch, kAudioUnitScope_Global, kAudioUnitRenderSelect, &mRenderProc, &size) != noErr) mRenderProc = NULL; if (AudioUnitGetProperty(mUnit, kAudioUnitProperty_FastDispatch, kAudioUnitScope_Global, kAudioUnitGetParameterSelect, &mGetParamProc, &size) != noErr) mGetParamProc = NULL; if (AudioUnitGetProperty(mUnit, kAudioUnitProperty_FastDispatch, kAudioUnitScope_Global, kAudioUnitSetParameterSelect, &mSetParamProc, &size) != noErr) mSetParamProc = NULL; if (AudioUnitGetProperty(mUnit, kAudioUnitProperty_FastDispatch, kAudioUnitScope_Global, kMusicDeviceMIDIEventSelect, &mMIDIEventProc, &size) != noErr) mMIDIEventProc = NULL; if (mRenderProc || mGetParamProc || mSetParamProc || mMIDIEventProc) mConnInstanceStorage = GetComponentInstanceStorage(mUnit); else mConnInstanceStorage = NULL; }
static pascal ComponentResult myDataHGetDataRef ( DataHandler dh, Handle *dataRef) { Handle storage = GetComponentInstanceStorage(dh); TRACE("\n"); *dataRef = storage; HandToHand(dataRef); return noErr; }
static pascal ComponentResult myDataHSetDataRef ( DataHandler dh, Handle dataRef) { Handle storage = GetComponentInstanceStorage(dh); DHData *data = (DHData*)*storage; WineDataRefRecord* newRef = (WineDataRefRecord*)(*dataRef); TRACE("\n"); if (newRef->pReader != data->dataRef.pReader) IAsyncReader_AddRef(newRef->pReader); data->dataRef = *newRef; return noErr; }
static pascal ComponentResult myDataHCompareDataRef ( DataHandler dh, Handle dataRef, Boolean *equal) { WineDataRefRecord *ptr1; Handle storage = GetComponentInstanceStorage(dh); DHData *data = (DHData*)*storage; TRACE("\n"); ptr1 = (WineDataRefRecord*)dataRef; *equal = (ptr1->pReader == data->dataRef.pReader); return noErr; }
static pascal ComponentResult myDataHGetFileSize ( DataHandler dh, long *fileSize) { Handle storage = GetComponentInstanceStorage(dh); DHData *data = (DHData*)*storage; LONGLONG total; LONGLONG available; TRACE("%p\n",dh); IAsyncReader_Length(data->dataRef.pReader,&total,&available); *fileSize = total; return noErr; }
static pascal ComponentResult myComponentClose(ComponentInstance ci, ComponentInstance self) { Handle storage = GetComponentInstanceStorage(self); DHData *data; if (storage) { data = (DHData*)*storage; if (data && data->dataRef.pReader != NULL) IAsyncReader_Release(data->dataRef.pReader); DisposeHandle(storage); SetComponentInstanceStorage(self,NULL); } return noErr; }
static PyObject *CmpInstObj_GetComponentInstanceStorage(ComponentInstanceObject *_self, PyObject *_args) { PyObject *_res = NULL; Handle _rv; #ifndef GetComponentInstanceStorage PyMac_PRECHECK(GetComponentInstanceStorage); #endif if (!PyArg_ParseTuple(_args, "")) return NULL; _rv = GetComponentInstanceStorage(_self->ob_itself); _res = Py_BuildValue("O&", ResObj_New, _rv); return _res; }
static pascal ComponentResult myDataHGetAvailableFileSize64(DataHandler dh, wide * fileSize) { Handle storage = GetComponentInstanceStorage(dh); DHData *data = (DHData*)*storage; LONGLONG total; LONGLONG available; SInt64 total64; TRACE("%p\n",dh); IAsyncReader_Length(data->dataRef.pReader,&total,&available); total64 = available; *fileSize = SInt64ToWide(total64); return noErr; }
static pascal ComponentResult myDataHTask(DataHandler dh) { Handle storage = GetComponentInstanceStorage(dh); DHData *data = (DHData*)*storage; if (data->AsyncCompletionRtn) { TRACE("Sending Completion\n"); InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn); data->AsyncPtr = NULL; data->AsyncRefCon = 0; data->AsyncCompletionRtn = NULL; } return noErr; }
static pascal ComponentResult myDataHFinishData (DataHandler dh, Ptr PlaceToPutDataPtr, Boolean Cancel) { Handle storage = GetComponentInstanceStorage(dh); DHData *data = (DHData*)*storage; if (!data->AsyncCompletionRtn) return noErr; if (!PlaceToPutDataPtr || PlaceToPutDataPtr == data->AsyncPtr) { if (!Cancel) InvokeDataHCompletionUPP(data->AsyncPtr, data->AsyncRefCon, noErr, data->AsyncCompletionRtn); data->AsyncPtr = NULL; data->AsyncRefCon = 0; data->AsyncCompletionRtn = NULL; } return noErr; }
static pascal ComponentResult myDataHGetData ( DataHandler dh, Handle h, long hOffset, long offset, long size) { Handle storage = GetComponentInstanceStorage(dh); DHData *data = (DHData*)*storage; BYTE *target = (BYTE*)*h; LONGLONG off = offset; HRESULT hr; TRACE("%p %p %li %li %li\n",dh, h, hOffset, offset, size); hr = IAsyncReader_SyncRead(data->dataRef.pReader, off, size, target+hOffset); TRACE("result %x\n",hr); return noErr; }
pascal ComponentResult BIMOpenComponent( ComponentInstance inComponentInstance ) { ComponentResult result; Handle sessionHandle; result = noErr; sessionHandle = nil; // If this is the first instance of our component, initalize our global state. Normally, // this means that we load our text service menu, install event handlers for the menu, // and initialize any global variables that persist across sessions. if( gInstanceRefCount == 0 ) result = BIMInitialize( inComponentInstance, &gTextServiceMenu ); gInstanceRefCount++; // Now initialize a new session context. We store our per-session data in a session // handle that is stored with the component instance. if( result == noErr ) { // Get our component instance storage. sessionHandle = GetComponentInstanceStorage( inComponentInstance ); // Initialize the new session. result = BIMSessionOpen( inComponentInstance, (BIMSessionHandle *) &sessionHandle ); // Save the returned handle as our component instance storage. if( result == noErr ) SetComponentInstanceStorage( inComponentInstance, sessionHandle ); } return result; }