void QTDR_CloseDownHandlers (void) { if (gDataReader != NULL) { DataHCloseForRead(gDataReader); CloseComponent(gDataReader); gDataReader = NULL; } if (gDataWriter != NULL) { DataHCloseForWrite(gDataWriter); CloseComponent(gDataWriter); gDataWriter = NULL; } // dispose of the data buffer if (gDataBuffer != NULL) DisposePtr(gDataBuffer); // dispose of the routine descriptors if (gReadDataHCompletionUPP != NULL) DisposeDataHCompletionUPP(gReadDataHCompletionUPP); if (gWriteDataHCompletionUPP != NULL) DisposeDataHCompletionUPP(gWriteDataHCompletionUPP); gDoneTransferring = false; #if TARGET_OS_WIN32 // kill the timer that tasks the data handlers KillTimer(NULL, gTimerID); #endif }
CoreAudioOutput::~CoreAudioOutput() { OSSpinLockLock(_spinlockAU); if(_au != NULL) { AudioOutputUnitStop(_au); AudioUnitUninitialize(_au); #if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 if (IsOSXVersionSupported(10, 6, 0)) { AudioComponentInstanceDispose(_au); } else { CloseComponent(_au); } #else CloseComponent(_au); #endif _au = NULL; } OSSpinLockUnlock(_spinlockAU); delete _buffer; _buffer = NULL; free(_spinlockAU); _spinlockAU = NULL; }
void openMovSettingsPopup(TPropertyGroup *props, bool macBringToFront) { #ifdef _WIN32 if (InitializeQTML(0) != noErr) return; #endif ComponentInstance ci = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType); QTAtomContainer atoms; QTNewAtomContainer(&atoms); fromPropertiesToAtoms(*props, atoms); ComponentResult err; if ((err = SCSetSettingsFromAtomContainer(ci, atoms)) != noErr) { CloseComponent(ci); ci = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType); assert(false); } QTDisposeAtomContainer(atoms); #ifdef MACOSX // Install an external procedure to use a callback filter on the request // settings dialog // On MACOSX we need to change the dialog appearance in order to pop-up in front // of the // toonz main window. /* gProcStruct.filterProc = NewSCModalFilterUPP(QTCmpr_FilterProc); // I don't install any hook gProcStruct.hookProc = NULL; gProcStruct.customName[0] = 0; // I don't use refcon gProcStruct.refcon = 0; // set the current extended procs SCSetInfo(ci, scExtendedProcsType, &gProcStruct); */ #endif err = SCRequestSequenceSettings(ci); // assert(err==noErr); QTAtomContainer atomsOut; if (SCGetSettingsAsAtomContainer(ci, &atomsOut) != noErr) assert(false); fromAtomsToProperties(atomsOut, *props); QTDisposeAtomContainer(atomsOut); CloseComponent(ci); // int dataSize=0, numChildren = 0, numLevels=0; // retrieveData(settings, kParentAtomIsContainer, dataSize, numChildren, // numLevels); }
static bool osx_output_enable(struct audio_output *ao, GError **error_r) { struct osx_output *oo = (struct osx_output *)ao; ComponentDescription desc; desc.componentType = kAudioUnitType_Output; desc.componentSubType = oo->component_subtype; desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; Component comp = FindNextComponent(NULL, &desc); if (comp == 0) { g_set_error(error_r, osx_output_quark(), 0, "Error finding OS X component"); return false; } OSStatus status = OpenAComponent(comp, &oo->au); if (status != noErr) { g_set_error(error_r, osx_output_quark(), status, "Unable to open OS X component: %s", GetMacOSStatusCommentString(status)); return false; } if (!osx_output_set_device(oo, error_r)) { CloseComponent(oo->au); return false; } AURenderCallbackStruct callback; callback.inputProc = osx_render; callback.inputProcRefCon = oo; ComponentResult result = AudioUnitSetProperty(oo->au, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &callback, sizeof(callback)); if (result != noErr) { CloseComponent(oo->au); g_set_error(error_r, osx_output_quark(), result, "unable to set callback for OS X audio unit"); return false; } return true; }
static int close_coreaudio(audio_output_t *ao) { mpg123_coreaudio_t* ca = (mpg123_coreaudio_t*)ao->userptr; if (ca) { ca->decode_done = 1; while(!ca->play_done && ca->play) usleep(10000); /* No matter the error code, we want to close it (by brute force if necessary) */ AudioConverterDispose(ca->converter); AudioOutputUnitStop(ca->outputUnit); AudioUnitUninitialize(ca->outputUnit); CloseComponent(ca->outputUnit); /* Free the ring buffer */ sfifo_close( &ca->fifo ); /* Free the conversion buffer */ if (ca->buffer) { free( ca->buffer ); ca->buffer = NULL; } } return 0; }
void CoreAudioDrv_PCM_Shutdown(void) { OSStatus result; struct AudioUnitInputCallback callback; if (!Initialised) { return; } // stop processing the audio unit CoreAudioDrv_PCM_StopPlayback(); // Remove the input callback callback.inputProc = 0; callback.inputProcRefCon = 0; result = AudioUnitSetProperty(output_audio_unit, kAudioUnitProperty_SetInputCallback, kAudioUnitScope_Input, 0, &callback, sizeof(callback)); result = CloseComponent(output_audio_unit); pthread_mutex_destroy(&mutex); Initialised = 0; }
//------------------------------------------------------------------------ bool pixel_map::save_as_qt(const char *filename) const { FSSpec fss; OSErr err; // get file specification to application directory err = HGetVol(nil, &fss.vRefNum, &fss.parID); if (err == noErr) { GraphicsExportComponent ge; CopyCStringToPascal(filename, fss.name); // I decided to use PNG as output image file type. // There are a number of other available formats. // Should I check the file suffix to choose the image file format? err = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypePNG, &ge); if (err == noErr) { err = GraphicsExportSetInputGWorld(ge, m_pmap); if (err == noErr) { err = GraphicsExportSetOutputFile (ge, &fss); if (err == noErr) { GraphicsExportDoExport(ge, nil); } } CloseComponent(ge); } } return err == noErr; }
/*---------------------------------------------------------------------- | OsxAudioUnitsOutput_Destroy +---------------------------------------------------------------------*/ static BLT_Result OsxAudioUnitsOutput_Destroy(OsxAudioUnitsOutput* self) { /* drain the queue */ OsxAudioUnitsOutput_Drain(&ATX_BASE(self, BLT_OutputNode)); /* stop the audio pump */ OsxAudioUnitsOutput_Stop(&ATX_BASE_EX(self, BLT_BaseMediaNode, BLT_MediaNode)); /* close the audio unit */ if (self->audio_unit) { ComponentResult result; result = CloseComponent(self->audio_unit); if (result != noErr) { ATX_LOG_WARNING_1("CloseComponent failed (%d)", (int)result); } } /* destroy the queue */ ATX_List_Destroy(self->packet_queue); /* destroy the lock */ pthread_mutex_destroy(&self->lock); /* destruct the inherited object */ BLT_BaseMediaNode_Destruct(&ATX_BASE(self, BLT_BaseMediaNode)); /* free the object memory */ ATX_FreeMemory(self); return BLT_SUCCESS; }
SMACsdec::~SMACsdec() { if(mDecoder != NULL) { #if USE_DIRECT_ADEC DirectAudioCodecClose(mDecoder); #else CloseComponent(mDecoder); #endif } delete[] mOutputBuffer; delete[] mFloatBuffer; #if TARGET_API_MAC_OSX delete mThreadStateMutex; mThreadStateMutex = NULL; #endif #if CaptureDataToFile if(mOutputFileRefNum != -1) { FSCloseFork(mOutputFileRefNum); } #endif }
QList<QByteArray> QMacPasteboardMimePict::convertFromMime(const QString &mime, QVariant variant, QString flav) { QList<QByteArray> ret; if (!resolveMimeQuickTimeSymbols()) return ret; if (!canConvert(mime, flav)) return ret; QCFType<CGImageRef> cgimage = qt_mac_createCGImageFromQImage(qvariant_cast<QImage>(variant)); Handle pic = NewHandle(0); GraphicsExportComponent graphicsExporter; ComponentResult result = OpenADefaultComponent(GraphicsExporterComponentType, kQTFileTypePicture, &graphicsExporter); if (!result) { unsigned long sizeWritten; result = ptrGraphicsExportSetInputCGImage(graphicsExporter, cgimage); if (!result) result = ptrGraphicsExportSetOutputHandle(graphicsExporter, pic); if (!result) result = ptrGraphicsExportDoExport(graphicsExporter, &sizeWritten); CloseComponent(graphicsExporter); } int size = GetHandleSize((Handle)pic); // Skip the Picture File header (512 bytes) and feed the raw data QByteArray ar(reinterpret_cast<char *>(*pic + 512), size - 512); ret.append(ar); DisposeHandle(pic); return ret; }
static void coreaudio_free(void *data) { coreaudio_t *dev = (coreaudio_t*)data; if (!dev) return; if (dev->dev_alive) { AudioOutputUnitStop(dev->dev); #ifdef OSX_PPC CloseComponent(dev->dev); #else AudioComponentInstanceDispose(dev->dev); #endif } if (dev->buffer) fifo_free(dev->buffer); slock_free(dev->lock); scond_free(dev->cond); free(dev); }
static void coreaudio_free(void *data) { coreaudio_t *dev = (coreaudio_t*)data; if (!dev) return; if (dev->dev_alive) { AudioOutputUnitStop(dev->dev); #if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) CloseComponent(dev->dev); #else AudioComponentInstanceDispose(dev->dev); #endif } if (dev->buffer) fifo_free(dev->buffer); slock_free(dev->lock); scond_free(dev->cond); free(dev); }
static void osx_output_disable(struct audio_output *ao) { struct osx_output *oo = (struct osx_output *)ao; CloseComponent(oo->au); }
QVariant QMacPasteboardMimePict::convertToMime(const QString &mime, QList<QByteArray> data, QString flav) { if(data.count() > 1) qWarning("QMacPasteboardMimePict: Cannot handle multiple member data"); QVariant ret; if (!resolveMimeQuickTimeSymbols()) return ret; if(!canConvert(mime, flav)) return ret; const QByteArray &a = data.first(); // This function expects the 512 header (just to skip it, so create the extra space for it). Handle pic = NewHandle(a.size() + 512); memcpy(*pic + 512, a.constData(), a.size()); GraphicsImportComponent graphicsImporter; ComponentResult result = OpenADefaultComponent(GraphicsImporterComponentType, kQTFileTypePicture, &graphicsImporter); QCFType<CGImageRef> cgImage; if (!result) result = ptrGraphicsImportSetDataHandle(graphicsImporter, pic); if (!result) result = ptrGraphicsImportCreateCGImage(graphicsImporter, &cgImage, kGraphicsImportCreateCGImageUsingCurrentSettings); if (!result) ret = QVariant(QPixmap::fromMacCGImageRef(cgImage).toImage()); CloseComponent(graphicsImporter); DisposeHandle(pic); return ret; }
void AUEditWindow::CloseView () { if (mEditView) { verify_noerr(CloseComponent(mEditView)); mEditView = 0; } }
int __stdcall QuickTimeComponentVersion(char *type, char *subtype) { OSType real_type, real_subtype; ComponentInstance ci; long version; // If we don't have QuickTime, we can't have any components, either. if (QuickTimeVersion() == 0) return 0; // If our type or subtype is invalid, return 0. if (strlen(type) != 4 || strlen(subtype) != 4) return 0; // Convert our type strings to Macintosh OSType codes. real_type = (type[0] << 24 | type[1] << 16 | type[2] << 8 | type[3]); real_subtype = (subtype[0] << 24 | subtype[1] << 16 | subtype[2] << 8 | subtype[3]); // Open up an instance of our component. ci = OpenDefaultComponent(real_type, real_subtype); if (!ci) return 0; // Get the version of our component. version = GetComponentVersion(ci); if (GetComponentInstanceError(ci) != noErr) return 0; // Close our component instance. if (CloseComponent(ci) != noErr) return 0; return version; }
static void COREAUDIO_CloseDevice(_THIS) { if (this->hidden != NULL) { if (this->hidden->audioUnitOpened) { OSStatus result = noErr; AURenderCallbackStruct callback; const AudioUnitElement output_bus = 0; const AudioUnitElement input_bus = 1; const int iscapture = this->iscapture; const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus); const AudioUnitScope scope = ((iscapture) ? kAudioUnitScope_Output : kAudioUnitScope_Input); /* stop processing the audio unit */ result = AudioOutputUnitStop(this->hidden->audioUnit); /* Remove the input callback */ SDL_memset(&callback, '\0', sizeof(AURenderCallbackStruct)); result = AudioUnitSetProperty(this->hidden->audioUnit, kAudioUnitProperty_SetRenderCallback, scope, bus, &callback, sizeof(callback)); CloseComponent(this->hidden->audioUnit); this->hidden->audioUnitOpened = 0; } SDL_free(this->hidden->buffer); SDL_free(this->hidden); this->hidden = NULL; } }
void Core_CloseAudio(_THIS) { OSStatus result; struct AURenderCallbackStruct callback; /* stop processing the audio unit */ result = AudioOutputUnitStop (outputAudioUnit); if (result != noErr) { SDL_SetError("Core_CloseAudio: AudioOutputUnitStop"); return; } /* Remove the input callback */ callback.inputProc = 0; callback.inputProcRefCon = 0; result = AudioUnitSetProperty (outputAudioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &callback, sizeof(callback)); if (result != noErr) { SDL_SetError("Core_CloseAudio: AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback)"); return; } result = CloseComponent(outputAudioUnit); if (result != noErr) { SDL_SetError("Core_CloseAudio: CloseComponent"); return; } SDL_free(buffer); }
void _HYPlatformGraphicPane::_SavePicture (_String prompt) { InitializeQTExporters (); if (graphicsFormats.lLength) { _String filePath; long menuChoice = SaveFileWithPopUp (filePath, savePicPrompt,prompt,savePicAs,graphicsFormats); if (menuChoice>=0) { ComponentInstance grexc = OpenComponent ((Component)qtGrexComponents(menuChoice)); GraphicsExportSetInputGWorld (grexc,thePane); FSSpec fs; Str255 buff; StringToStr255 (filePath,buff); FSMakeFSSpec(0,0,buff,&fs); GraphicsExportSetOutputFile (grexc,&fs); GraphicsExportRequestSettings (grexc,nil,nil); unsigned long dummy; OSType t,c; GraphicsExportGetDefaultFileTypeAndCreator (grexc,&t,&c); GraphicsExportSetOutputFileTypeAndCreator (grexc,t,c); GraphicsExportDoExport (grexc,&dummy); CloseComponent (grexc); } } }
static void close_output(void) { if(dmp.fd == -1) return; if(gNoteAllocator != NULL) CloseComponent(gNoteAllocator); dmp.fd = -1; //disabled }
static gboolean gst_osx_video_src_stop (GstBaseSrc * src) { GstOSXVideoSrc *self; ComponentResult err; self = GST_OSX_VIDEO_SRC (src); GST_DEBUG_OBJECT (src, "stopping"); self->video_chan = NULL; err = CloseComponent (self->seq_grab); if (err != noErr) GST_WARNING_OBJECT (self, "CloseComponent returned %d", (int) err); self->seq_grab = NULL; DisposeGWorld (self->world); self->world = NULL; if (self->buffer != NULL) { gst_buffer_unref (self->buffer); self->buffer = NULL; } return TRUE; }
void CoreAudioDriver::disconnect() { OSStatus err = noErr; err = AudioOutputUnitStop( m_outputUnit ); err = AudioUnitUninitialize( m_outputUnit ); err = CloseComponent( m_outputUnit ); }
void free_qtcomponentdata(void) { if(qtdata) { if(qtdata->theComponent) CloseComponent(qtdata->theComponent); MEM_freeN(qtdata); qtdata = NULL; } }
static void MacQTCloseVideoComponent(ComponentInstance ci) { OSStatus err; err = CloseComponent(ci); CheckError(err, 11); }
/* MDIWndProc */ LRESULT CALLBACK MDIWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { HANDLE hInfo; PINFO pInfo; MSG msg; EventRecord macEvent; LONG thePoints = GetMessagePos(); PAINTSTRUCT ps; msg.hwnd = hwnd; msg.message = message; msg.wParam = wParam; msg.lParam = lParam; msg.time = GetMessageTime(); msg.pt.x = LOWORD(thePoints); msg.pt.y = HIWORD(thePoints); WinEventToMacEvent(&msg, &macEvent); switch (message) { case WM_CREATE: case WM_MDICREATE: break; case WM_DESTROY: hInfo = (HANDLE)GetWindowLong(hwnd, GWL_USERDATA); if (hInfo) { if ((pInfo = (PINFO)LocalLock(hInfo)) != NULL){ if (pInfo->gi) // close the graphic import component CloseComponent(pInfo->gi); // Destroy our port association DestroyPortAssociation((CGrafPort *)GetHWNDPort(pInfo->hwndChildWindow)); } LocalUnlock(hInfo); } break; // Draw our graphic case WM_PAINT: BeginPaint(hwnd, &ps); hInfo = (HANDLE)GetWindowLong(hwnd, GWL_USERDATA); if (hInfo) { if ((pInfo = (PINFO)LocalLock(hInfo)) != NULL) GraphicsImportDraw(pInfo->gi); LocalUnlock(hInfo); } EndPaint(hwnd, &ps); break; default: return DefMDIChildProc(hwnd, message, wParam, lParam); } return DefMDIChildProc(hwnd, message, wParam, lParam); }
void MovieMaker::EndCapture() { OSStatus error = noErr; if (movie && movieResRef) { if (media && track) { // Errors adding the frame aren't too important here. (void)addFrame(); error = EndMediaEdits(media); if (error == noErr) { error = SCCompressSequenceEnd(ci); } if (error == noErr) { error = InsertMediaIntoTrack(track, 0, 0, GetMediaDuration(media), fixed1); } media = NULL; track = NULL; } short resId = movieInDataForkResID; error = AddMovieResource(movie, movieResRef, &resId, "\pSecond Life"); CloseMovieFile(movieResRef); movieResRef = 0; movie = NULL; } // NOTE: idh is disposed by SCCompressSequenceEnd. idh = NULL; if(ci) { CloseComponent(ci); ci = NULL; } if(gworld) { DisposeGWorld(gworld); gworld = NULL; } if(buffer) { free(buffer); buffer = NULL; } if(invertedBuffer) { free(invertedBuffer); invertedBuffer = NULL; } }
/** free all memory allocated by a driver instance */ static void coreaudio_driver_delete(coreaudio_driver_t * driver) { AudioDeviceRemovePropertyListener(driver->device_id, 0, true, kAudioDeviceProcessorOverload, notification); free(driver->input_list); AudioUnitUninitialize(driver->au_hal); CloseComponent(driver->au_hal); free(driver); }
void CCoreAudioUnit::Close() { if (m_Initialized) AudioUnitUninitialize(m_Component); if (m_Component) CloseComponent(m_Component); m_Initialized = false; m_Component = 0; }
void qDestroyEncoderAPI(QEncoder* encoder) { // push out any remaining frames before releasing the compression session. ICMCompressionSessionCompleteFrames(encoder->session, 1, 0, 0); ICMCompressionSessionRelease(encoder->session); CloseComponent(encoder->compressor); free(encoder); }
void SMACscom::SetInfo(SoundSource inSourceID, OSType inSelector, void* inData) { switch(inSelector) { case siCompressionParams: { // process the the new params and produce an initialized // AudioCodec instance ComponentInstance theEncoder = SetCompressionParams(inData); ThrowIf(theEncoder == NULL, badFormat, "SMACscom::SetInfo: siCompressionParams didn't generate an encoder"); // get rid of the input data mSourceData = NULL; mOutputData.desc.sampleCount = 0; mOutputData.bufferSize = 0; mOutputData.frameCount = 0; mOutputData.commonFrameSize = 0; // close the old encoder if necessary if((mEncoder != NULL) && (theEncoder != mEncoder)) { CloseComponent(mEncoder); } // use the new one mEncoder = theEncoder; // get the number of frames in 1 packet of data UInt32 theSize = sizeof(UInt32); ComponentResult theError = AudioCodecGetProperty(mEncoder, kAudioCodecPropertyPacketFrameSize, &theSize, &mPacketFrameSize); ThrowIfError(theError, (CAException)theError, "SMACscom::SetInfo: siCompressionParams got an error from AudioCodecGetProperty while getting the packet frame size"); // get the maximum number of bytes in 1 packet of data theSize = sizeof(UInt32); theError = AudioCodecGetProperty(mEncoder, kAudioCodecPropertyMaximumPacketByteSize, &theSize, &mMaxPacketByteSize); ThrowIfError(theError, (CAException)theError, "SMACscom::SetInfo: siCompressionParams got an error from AudioCodecGetProperty while getting the maximum packet byte size"); // toss the old output buffer delete[] mOutputBuffer; // allocate enough space for 1 packet of data, since that's // that's all this component will produce per call to GetSourceData mOutputBuffer = new Byte[mMaxPacketByteSize]; } break; case siSourceIsExhausted: // in this case it seems to be passed by value -- ugh! mSourceIsExhausted = (Boolean)((UInt32)inData); // Now pass this on, so no break! default: ThrowIf(mSourceComponent == NULL, siUnknownInfoType, "SMACscom::SetInfo: no source to pass request to") ComponentResult theError = SoundComponentSetInfo(mSourceComponent, inSourceID, inSelector, inData); ThrowIfError(theError, (CAException)theError, "SMACscom::SetInfo: got an error from SoundComponentSetInfo"); break; }; }