void LoadAudioUnits() { ComponentDescription desc; Component component; desc.componentType = kAudioUnitType_Effect; //'aufx' desc.componentSubType = 0; desc.componentManufacturer = 0; desc.componentFlags = 0; desc.componentFlagsMask = 0; component = FindNextComponent(NULL, &desc); while (component != NULL) { ComponentDescription found; Handle nameHandle = NewHandle(0); GetComponentInfo(component, &found, nameHandle, 0, 0); HLock(nameHandle); int len = ((const char *)(*nameHandle))[0]; wxString name((const char *)(*nameHandle)+1, len); HUnlock(nameHandle); DisposeHandle(nameHandle); Effect::RegisterEffect(new AudioUnitEffect(name, component)); component = FindNextComponent (component, &desc); } }
// Component Open Request - Required pascal ComponentResult DelegateOnly_ImageCodecOpen(DelegateOnly_Globals glob, ComponentInstance self) { ComponentDescription cd = { decompressorComponentType, k422YpCbCr8CodecType, FOUR_CHAR_CODE('app3'), 0, 0 }; Component c = 0; ComponentResult rc; // Allocate memory for our globals, set them up and inform the component manager that we've done so glob = (DelegateOnly_Globals)NewPtrClear(sizeof(DelegateOnly_GlobalsRecord)); if (rc = MemError()) goto bail; SetComponentInstanceStorage(self, (Handle)glob); glob->self = self; glob->target = self; if (c = FindNextComponent(c, &cd)) { rc = OpenAComponent(c, &glob->delegateComponent); if (rc) goto bail; ComponentSetTarget(glob->delegateComponent, self); } bail: return rc; }
OSStatus openOutput (AudioUnit *outputUnit) { OSStatus status = noErr; ComponentDescription description; Component component; description.componentType = kAudioUnitType_Output; description.componentSubType = kAudioUnitSubType_DefaultOutput; description.componentManufacturer = kAudioUnitManufacturer_Apple; description.componentFlags = 0; description.componentFlagsMask = 0; component = FindNextComponent(NULL, &description); if (component == NULL) { fprintf(stderr, "Could not find audio output device.\n"); exit(EXIT_FAILURE); } status = OpenAComponent(component, outputUnit); if (status != noErr) { fprintf(stderr, "Could not open audio output device.\n"); exit(EXIT_FAILURE); } status = AudioUnitInitialize(*outputUnit); if (status != noErr) { fprintf(stderr, "Could not initialize audio output device.\n"); exit(EXIT_FAILURE); } return status; }
void AUEditWindow::SetUnitToDisplay (AudioUnit editUnit, ComponentDescription& inDesc) { CloseView(); mEditUnit = editUnit; Component editComp = FindNextComponent(NULL, &inDesc); verify_noerr(OpenAComponent(editComp, &mEditView)); ControlRef rootControl; verify_noerr(GetRootControl(mWindow, &rootControl)); Rect r; ControlRef viewPane; GetControlBounds(rootControl, &r); Float32Point location = { kOffsetForAUView_X, kOffsetForAUView_Y }; Float32Point size = { Float32(r.right), Float32(r.bottom) }; verify_noerr(AudioUnitCarbonViewCreate(mEditView, mEditUnit, mWindow, rootControl, &location, &size, &viewPane)); AudioUnitCarbonViewSetEventListener(mEditView, EventListener, this); GetControlBounds(viewPane, &r); size.x = r.right-r.left + kOffsetForAUView_X; size.y = r.bottom-r.top + kOffsetForAUView_Y; Rect r2; GetControlBounds (mResizeableControl->MacControl(), &r2); if ((r.bottom - r.top) < (r2.bottom - r2.top + 20)) size.y = r2.bottom + 20; SetSize(size); }
CAComponent::CAComponent (OSType inType, OSType inSubtype, OSType inManu) : mDesc (inType, inSubtype, inManu), mManuName(0), mAUName(0), mCompName(0), mCompInfo (0) { mComp = FindNextComponent (NULL, &mDesc); GetComponentInfo (Comp(), &mDesc, NULL, NULL, NULL); }
void findGraphicsExporterComponents(_List& compList, _SimpleList& compIndex) { ComponentDescription cd, cd2; Component c = 0; cd.componentType = GraphicsExporterComponentType; cd.componentSubType = 0; cd.componentManufacturer = 0; cd.componentFlags = 0; cd.componentFlagsMask = graphicsExporterIsBaseExporter; _String fileFormat; while( ( c = FindNextComponent( c, &cd ) ) != 0 ) { Handle cInfo = NewHandle(256); GetComponentInfo (c,&cd2,cInfo,nil,nil); (*cInfo)[**cInfo+1] = 0; fileFormat = (char*)(*cInfo+1); if (fileFormat.sLength) { compList&& &fileFormat; compIndex << (long)c; } DisposeHandle(cInfo); } }
void showConfigurations(encodingParameters *params) { ComponentDescription cd; cd.componentType = 'aenc'; cd.componentSubType = 'aac '; cd.componentManufacturer = kAppleManufacturer; cd.componentFlags = 0; cd.componentFlagsMask = 0; long qtversion = 0; Gestalt(gestaltQuickTime,&qtversion); int lcversion = CallComponentVersion((ComponentInstance)FindNextComponent(NULL, &cd)); cd.componentSubType = 'aach'; int heversion = CallComponentVersion((ComponentInstance)FindNextComponent(NULL, &cd)); if(heversion != badComponentInstance) fprintf(stderr,"Using QuickTime %d.%d.%d (LC-AAC encoder %d.%d.%d, HE-AAC encoder %d.%d.%d)\n",(qtversion>>24)&0xff,(qtversion>>20)&0xf,(qtversion>>16)&0xf,(lcversion>>16)&0xffff,(lcversion>>8)&0xff,lcversion&0xff,(heversion>>16)&0xffff,(heversion>>8)&0xff,heversion&0xff); else
AudioDestinationMac::AudioDestinationMac(AudioSourceProvider& provider, float sampleRate) : m_outputUnit(0) , m_provider(provider) , m_renderBus(2, kBufferSize, false) , m_sampleRate(sampleRate) , m_isPlaying(false) { // Open and initialize DefaultOutputUnit Component comp; ComponentDescription desc; desc.componentType = kAudioUnitType_Output; desc.componentSubType = kAudioUnitSubType_DefaultOutput; desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; comp = FindNextComponent(0, &desc); ASSERT(comp); OSStatus result = OpenAComponent(comp, &m_outputUnit); ASSERT(!result); result = AudioUnitInitialize(m_outputUnit); ASSERT(!result); configure(); }
bool auLoader::loadPlugin() { Component comp = FindNextComponent(NULL, &m_desc); if(comp == NULL) { debug(LOG_ERROR, "AU '%s' '%s' '%s' was not found", m_type, m_subtype, m_manuf); return false; } else { debug(LOG_INFO, "AU '%s' '%s' '%s' found", m_type, m_subtype, m_manuf); } OSErr result = OpenAComponent(comp, &m_plugin); if(result) { debug(LOG_ERROR, "Could not open AU"); return false; } else { debug(LOG_INFO, "AU opened"); } return true; }
AUEditWindow::AUEditWindow(XController *owner, IBNibRef nibRef, CFStringRef name, AudioUnit editUnit, ComponentDescription inCompDesc ) : XWindow(owner, nibRef, name), mEditUnit(editUnit) { Component editComp = FindNextComponent(NULL, &inCompDesc); verify_noerr(OpenAComponent(editComp, &mEditView)); ControlRef rootControl; verify_noerr(GetRootControl(mWindow, &rootControl)); ControlRef customControl = 0; ControlID controlID; controlID.signature = 'cust'; controlID.id = 1000; GetControlByID( mWindow, &controlID, &customControl ); ControlRef ourControl = customControl ? customControl : rootControl; Rect r = {0,0,400,400}; ControlRef viewPane; if(customControl) GetControlBounds(ourControl, &r); Float32Point location = { r.left, r.top }; Float32Point size = { Float32(r.right - r.left ), Float32(r.bottom - r.top ) }; verify_noerr(AudioUnitCarbonViewCreate(mEditView, mEditUnit, mWindow, ourControl, &location, &size, &viewPane)); GetControlBounds(viewPane, &r); size.x = r.right-r.left; size.y = r.bottom-r.top; if(!customControl) SetSize(size); Show(); }
bool macsgCamera::findCamera() { int num_components = 0; Component c = 0; ComponentDescription cd; cd.componentType = SeqGrabComponentType; cd.componentSubType = 0; cd.componentManufacturer = 0; cd.componentFlags = 0; cd.componentFlagsMask = 0; while((c = FindNextComponent(c, &cd)) != 0) { // add component c to the list num_components++; } //fprintf(stdout, "number of SGcomponents: %d\n",num_components); if(num_components==0) { fprintf(stderr, "no quicktime camera found\n"); return false; } else { cameraID = 0; return true; } }
// 2. // Create the Video Digitizer (using GWorld Pixmap as target mamory) void QuicktimeLiveImageStream::createVideoDigitizer() { // #define videoDigitizerComponentType = 'vdig' ComponentDescription video_component_description; video_component_description.componentType = 'vdig'; /* A unique 4-byte code indentifying the command set */ video_component_description.componentSubType = 0; /* Particular flavor of this instance */ video_component_description.componentManufacturer = 0; /* Vendor indentification */ video_component_description.componentFlags = 0; /* 8 each for Component,Type,SubType,Manuf/revision */ video_component_description.componentFlagsMask = 0; /* Mask for specifying which flags to consider in search, zero during registration */ long num_video_components = CountComponents (&video_component_description); OSG_DEBUG << " available Video DigitizerComponents : " << num_video_components << std::endl; if (num_video_components) { Component aComponent = 0; short aDeviceID = 0; do { ComponentDescription full_video_component_description = video_component_description; aComponent = FindNextComponent(aComponent, &full_video_component_description); if (aComponent && (aDeviceID == m_videoDeviceID)) { OSG_DEBUG << "Component" << std::endl; OSErr err; Handle compName = NewHandle(256); Handle compInfo = NewHandle(256); err = GetComponentInfo( aComponent, &full_video_component_description, compName,compInfo,0); OSG_DEBUG << " Name: " << pstr_printable((StringPtr)*compName) << std::endl; OSG_DEBUG << " Desc: " << pstr_printable((StringPtr)*compInfo) << std::endl; //Capabilities VideoDigitizerComponent component_instance = OpenComponent(aComponent); m_vdig = component_instance; //Setup // Onscreen // Check capability and setting of Sequence Grabber GDHandle origDevice; CGrafPtr origPort; GetGWorld (&origPort, &origDevice); VideoDigitizerError error; Rect destinationBounds; destinationBounds.left = 0; destinationBounds.top = 0; destinationBounds.right = m_videoRectWidth; destinationBounds.bottom = m_videoRectHeight; error = VDSetPlayThruDestination(m_vdig, m_pixmap, &destinationBounds, 0, 0); //error = VDSetPlayThruGlobalRect(m_vdig, (GrafPtr)origPort, &destinationBounds); if (error != noErr) { OSG_FATAL << "VDSetPlayThruDestination : error" << std::endl; } print_video_component_capability(component_instance); break; } ++aDeviceID; } while (0 != aComponent); } }
CAComponent::CAComponent (const ComponentDescription& inDesc, CAComponent* next) : mManuName(0), mAUName(0), mCompName(0), mCompInfo (0) { mComp = FindNextComponent ((next ? next->Comp() : NULL), const_cast<ComponentDescription*>(&inDesc)); if (mComp) GetComponentInfo (Comp(), &mDesc, NULL, NULL, NULL); else memcpy (&mDesc, &inDesc, sizeof(ComponentDescription)); }
AUEditWindow::AUEditWindow(XController *owner, IBNibRef nibRef, CFStringRef name, AudioUnit editUnit, bool forceGeneric) : XWindow(owner, nibRef, name), mEditUnit(editUnit) { OSStatus err; ComponentDescription editorComponentDesc; // set up to use generic UI component editorComponentDesc.componentType = kAudioUnitCarbonViewComponentType; editorComponentDesc.componentSubType = 'gnrc'; editorComponentDesc.componentManufacturer = 'appl'; editorComponentDesc.componentFlags = 0; editorComponentDesc.componentFlagsMask = 0; if (!forceGeneric) { // ask the AU for its first editor component UInt32 propertySize; err = AudioUnitGetPropertyInfo(editUnit, kAudioUnitProperty_GetUIComponentList, kAudioUnitScope_Global, 0, &propertySize, NULL); if (!err) { int nEditors = propertySize / sizeof(ComponentDescription); ComponentDescription *editors = new ComponentDescription[nEditors]; err = AudioUnitGetProperty(editUnit, kAudioUnitProperty_GetUIComponentList, kAudioUnitScope_Global, 0, editors, &propertySize); if (!err) // just pick the first one for now editorComponentDesc = editors[0]; delete[] editors; } } Component editComp = FindNextComponent(NULL, &editorComponentDesc); verify_noerr(OpenAComponent(editComp, &mEditView)); ControlRef rootControl; verify_noerr(GetRootControl(mWindow, &rootControl)); Rect r; ControlRef viewPane; GetControlBounds(rootControl, &r); Float32Point location = { 0., 0. }; Float32Point size = { Float32(r.right), Float32(r.bottom) }; verify_noerr(AudioUnitCarbonViewCreate(mEditView, mEditUnit, mWindow, rootControl, &location, &size, &viewPane)); AudioUnitCarbonViewSetEventListener(mEditView, EventListener, this); GetControlBounds(viewPane, &r); size.x = r.right-r.left; size.y = r.bottom-r.top; SetSize(size); Show(); /* EventLoopTimerRef timer; RequireNoErr( InstallEventLoopTimer( GetMainEventLoop(), 5., 0., TimerProc, this, &timer));*/ }
Component SMACIMAsdec::FindIMAAudioDecoderComponent(const AudioStreamBasicDescription& inFormat) { Component theDecoderComponent = NULL; ComponentDescription theDecoderDescription = { kAudioDecoderComponentType, inFormat.mFormatID, 0, 0, 0 }; // If a component has sub types, ala MPEG-4, you'll need to loop here and look at the sub-type theDecoderComponent = FindNextComponent(NULL, &theDecoderDescription); return theDecoderComponent; }
static ALCenum ca_open_playback(ALCdevice *device, const ALCchar *deviceName) { ComponentDescription desc; Component comp; ca_data *data; OSStatus err; if(!deviceName) deviceName = ca_device; else if(strcmp(deviceName, ca_device) != 0) return ALC_INVALID_VALUE; /* open the default output unit */ desc.componentType = kAudioUnitType_Output; #if TARGET_OS_IPHONE desc.componentSubType = kAudioUnitSubType_RemoteIO; #else desc.componentSubType = kAudioUnitSubType_DefaultOutput; #endif // TARGET_OS_IPHONE desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; comp = FindNextComponent(NULL, &desc); if(comp == NULL) { ERR("FindNextComponent failed\n"); return ALC_INVALID_VALUE; } data = calloc(1, sizeof(*data)); err = OpenAComponent(comp, &data->audioUnit); if(err != noErr) { ERR("OpenAComponent failed\n"); free(data); return ALC_INVALID_VALUE; } /* init and start the default audio unit... */ err = AudioUnitInitialize(data->audioUnit); if(err != noErr) { ERR("AudioUnitInitialize failed\n"); CloseComponent(data->audioUnit); free(data); return ALC_INVALID_VALUE; } device->DeviceName = strdup(deviceName); device->ExtraData = data; return ALC_NO_ERROR; }
OSStatus CAComponent::Restore (CFPropertyListRef &inData) { if (mDesc.Restore (inData)) return -1; Clear(); mComp = FindNextComponent (NULL, &mDesc); // this will restore the current flags... if (mComp) GetComponentInfo (Comp(), &mDesc, NULL, NULL, NULL); return noErr; }
int initoutput(){ ComponentDescription desc; Component comp; OSStatus err; UInt32 size; Boolean canwrite; AudioStreamBasicDescription inputdesc,outputdesc; desc.componentType=kAudioUnitType_Output; desc.componentSubType=kAudioUnitSubType_DefaultOutput; desc.componentManufacturer=kAudioUnitManufacturer_Apple; desc.componentFlags=0; desc.componentFlagsMask=0; comp=FindNextComponent(NULL,&desc);if (comp==NULL) return -1; err=OpenAComponent(comp,&out);if (err) return err; err=AudioUnitInitialize(out);if (err) return err; err=AudioUnitGetPropertyInfo(out,kAudioUnitProperty_StreamFormat,kAudioUnitScope_Output,0,&size,&canwrite); if (err) return err; err=AudioUnitGetProperty(out,kAudioUnitProperty_StreamFormat,kAudioUnitScope_Input,0,&outputdesc,&size); if (err) return err; // dumpdesc(&outputdesc); inputdesc.mSampleRate=44100.0; inputdesc.mFormatID='lpcm'; #if __BIG_ENDIAN__ inputdesc.mFormatFlags=0x0e; #else inputdesc.mFormatFlags=0x0c; #endif inputdesc.mBytesPerPacket=4; inputdesc.mFramesPerPacket=1; inputdesc.mBytesPerFrame=4; inputdesc.mChannelsPerFrame=2; inputdesc.mBitsPerChannel=16; inputdesc.mReserved=0; // dumpdesc(&inputdesc); err=AudioConverterNew(&inputdesc,&outputdesc,&conv); if (err) { // printf("AudioConvertNew failed %.*s\n",4,(char*)&err); return err; } return err; }
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; }
// SGSettingsDialog with the "Compression" panel removed static OSErr MinimalSGSettingsDialog(SeqGrabComponent seqGrab, SGChannel sgchanVideo, WindowPtr gMonitor) { OSErr err; Component *panelListPtr = NULL; UInt8 numberOfPanels = 0; ComponentDescription cd = { SeqGrabPanelType, VideoMediaType, 0, 0, 0 }; Component c = 0; Component *cPtr = NULL; numberOfPanels = CountComponents(&cd); panelListPtr = (Component *) NewPtr(sizeof(Component) * (numberOfPanels + 1)); cPtr = panelListPtr; numberOfPanels = 0; CFStringRef compressionCFSTR = CFSTR("Compression"); do { ComponentDescription compInfo; c = FindNextComponent(c, &cd); if (c) { Handle hName = NewHandle(0); GetComponentInfo(c, &compInfo, hName, NULL, NULL); CFStringRef nameCFSTR = CFStringCreateWithPascalString(kCFAllocatorDefault, (unsigned char *)(*hName), kCFStringEncodingASCII); if (CFStringCompare (nameCFSTR, compressionCFSTR, kCFCompareCaseInsensitive) != kCFCompareEqualTo) { *cPtr++ = c; numberOfPanels++; } DisposeHandle(hName); } } while (c); if ((err = SGSettingsDialog(seqGrab, sgchanVideo, numberOfPanels, panelListPtr, seqGrabSettingsPreviewOnly, (SGModalFilterUPP) NewSGModalFilterUPP(SeqGrabberModalFilterProc), (long)gMonitor))) { return err; } return 0; }
OSStatus CAPlayThrough::SetupAUHAL(AudioDeviceID in) { OSStatus err = noErr; Component comp; ComponentDescription desc; //There are several different types of Audio Units. //Some audio units serve as Outputs, Mixers, or DSP //units. See AUComponent.h for listing desc.componentType = kAudioUnitType_Output; //Every Component has a subType, which will give a clearer picture //of what this components function will be. desc.componentSubType = kAudioUnitSubType_HALOutput; //all Audio Units in AUComponent.h must use //"kAudioUnitManufacturer_Apple" as the Manufacturer desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; //Finds a component that meets the desc spec's comp = FindNextComponent(NULL, &desc); if (comp == NULL) exit (-1); //gains access to the services provided by the component OpenAComponent(comp, &mInputUnit); //AUHAL needs to be initialized before anything is done to it err = AudioUnitInitialize(mInputUnit); checkErr(err); err = EnableIO(); checkErr(err); err= SetInputDeviceAsCurrent(in); checkErr(err); err = CallbackSetup(); checkErr(err); //Don't setup buffers until you know what the //input and output device audio streams look like. err = AudioUnitInitialize(mInputUnit); return err; }
Boolean QTMissing_IsComponentOfTypeAvailable (OSType theType, OSType theSubType) { ComponentDescription myCompDesc; Component myComponent = NULL; // look for the specified component myCompDesc.componentType = theType; myCompDesc.componentSubType = theSubType; myCompDesc.componentManufacturer = 0; myCompDesc.componentFlags = 0; myCompDesc.componentFlagsMask = cmpIsMissing; myComponent = FindNextComponent(NULL, &myCompDesc); return(myComponent != NULL); }
static int coreaudio_init (void) { trace ("coreaudio_init\n"); //selecting the default output unit ComponentDescription desc; desc.componentType = kAudioUnitType_Output; desc.componentSubType = kAudioUnitSubType_DefaultOutput; desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; OSStatus err = noErr; Component comp = FindNextComponent(NULL, &desc); if (comp == NULL) { trace ("FindNextComponent= failed to find the default output component.\n"); return -1; } err = OpenAComponent(comp, &output_unit); if (comp == NULL) { trace ("OpenAComponent= %s\n", GetMacOSStatusErrorString(err)); return -1; } // filling out the description for linear PCM data (can only be called after opening audio component) if (coreaudio_set_data_format(&plugin.fmt) < 0) return -1; // callback AURenderCallbackStruct input_cb; input_cb.inputProc = coreaudio_callback; input_cb.inputProcRefCon = NULL; err = AudioUnitSetProperty(output_unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &input_cb, sizeof(input_cb)); if (err) { trace ("AudioUnitSetProperty-CB= %s\n", GetMacOSStatusErrorString(err)); return -1; } // Initialize unit err = AudioUnitInitialize(output_unit); if (err) { trace ("AudioUnitInitialize= %s\n", GetMacOSStatusErrorString(err)); return -1; } au_state = 1; // audio unit initialised state = OUTPUT_STATE_STOPPED; return 0; }
// 1. // Create the Sequence Grabber (using GWorld as target memory) void QuicktimeLiveImageStream::createSequenceGrabber() { ComponentDescription sg_component_description; sg_component_description.componentType = SeqGrabComponentType; /* A unique 4-byte code indentifying the command set */ sg_component_description.componentSubType = 0L; /* Particular flavor of this instance */ sg_component_description.componentManufacturer = 'appl'; /* Vendor indentification */ sg_component_description.componentFlags = 0L; /* 8 each for Component,Type,SubType,Manuf/revision */ sg_component_description.componentFlagsMask = 0L; /* Mask for specifying which flags to consider in search, zero during registration */ long num_sg_components = CountComponents (&sg_component_description); if (num_sg_components) { Component aComponent = 0; ComponentDescription full_sg_component_description = sg_component_description; aComponent = FindNextComponent(aComponent, &full_sg_component_description); if (aComponent) { m_gSeqGrabber = OpenComponent(aComponent); // If we got a sequence grabber, set it up if (m_gSeqGrabber != 0L) { // Check capability and setting of Sequence Grabber GDHandle origDevice; CGrafPtr origPort; // Create GWorld GetGWorld (&origPort, &origDevice); SetGWorld (m_gw, NULL); // set current graphics port to offscreen // Initialize the sequence grabber ComponentResult result = noErr; result = SGInitialize (m_gSeqGrabber); if (result == noErr) { // Set GWorld result = SGSetGWorld(m_gSeqGrabber, (CGrafPtr)m_gw, 0); if (result != noErr) { OSG_FATAL << "Could not set GWorld on SG" << std::endl; } } // Set GWorld back SetGWorld(origPort, origDevice); } } } }
static void init_audio_unit(AudioUnit *au) { OSStatus err = noErr; ComponentDescription desc; desc.componentType = kAudioUnitType_Output; desc.componentSubType = kAudioUnitSubType_HALOutput; desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; Component comp = FindNextComponent(NULL, &desc); if (comp == NULL) { DBG_DYNA_AUDIO_DRV("!!CoreAudio: can't audio component\n"); } err = OpenAComponent(comp, au); if (err != noErr) { DBG_DYNA_AUDIO_DRV("!!CoreAudio: can't open audio component\n"); } }
static PyObject *Cm_FindNextComponent(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; Component _rv; Component aComponent; ComponentDescription looking; #ifndef FindNextComponent PyMac_PRECHECK(FindNextComponent); #endif if (!PyArg_ParseTuple(_args, "O&O&", CmpObj_Convert, &aComponent, CmpDesc_Convert, &looking)) return NULL; _rv = FindNextComponent(aComponent, &looking); _res = Py_BuildValue("O&", CmpObj_New, _rv); return _res; }
static au_instance_t *audiounits_create_player(SEXP source, float rate, int flags) { ComponentDescription desc = { kAudioUnitType_Output, kAudioUnitSubType_DefaultOutput, kAudioUnitManufacturer_Apple, 0, 0 }; Component comp; OSStatus err; au_instance_t *ap = (au_instance_t*) calloc(sizeof(au_instance_t), 1); ap->source = source; ap->sample_rate = rate; ap->done = NO; ap->position = 0; ap->length = LENGTH(source); ap->stereo = NO; { /* if the source is a matrix with 2 rows then we'll use stereo */ SEXP dim = Rf_getAttrib(source, R_DimSymbol); if (TYPEOF(dim) == INTSXP && LENGTH(dim) > 0 && INTEGER(dim)[0] == 2) ap->stereo = YES; } ap->loop = (flags & APFLAG_LOOP) ? YES : NO; memset(&ap->fmtOut, 0, sizeof(ap->fmtOut)); ap->fmtOut.mSampleRate = ap->sample_rate; ap->fmtOut.mFormatID = kAudioFormatLinearPCM; ap->fmtOut.mChannelsPerFrame = ap->stereo ? 2 : 1; ap->fmtOut.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; #if __ppc__ || __ppc64__ || __BIG_ENDIAN__ ap->fmtOut.mFormatFlags |= kAudioFormatFlagIsBigEndian; #endif ap->fmtOut.mFramesPerPacket = 1; ap->fmtOut.mBytesPerPacket = ap->fmtOut.mBytesPerFrame = ap->fmtOut.mFramesPerPacket * ap->fmtOut.mChannelsPerFrame * 2; ap->fmtOut.mBitsPerChannel = 16; if (ap->stereo) ap->length /= 2; comp = FindNextComponent(NULL, &desc); if (!comp) Rf_error("unable to find default audio output"); err = OpenAComponent(comp, &ap->outUnit); if (err) Rf_error("unable to open default audio (%08x)", err); err = AudioUnitInitialize(ap->outUnit); if (err) { CloseComponent(ap->outUnit); Rf_error("unable to initialize default audio (%08x)", err); } R_PreserveObject(ap->source); return ap; }
static OSStatus CheckInit () { if (playBackWasInit) return 0; OSStatus result = noErr; callbackSem = SDL_CreateSemaphore(0); SDL_CreateThread(RunCallBackThread, NULL); { ComponentDescription desc; desc.componentType = kAudioUnitType_Output; desc.componentSubType = kAudioUnitSubType_DefaultOutput; desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; Component comp = FindNextComponent (NULL, &desc); if (comp == NULL) { SDL_SetError ("CheckInit: FindNextComponent returned NULL"); if (result) return -1; } result = OpenAComponent (comp, &theUnit); if (result) return -1; result = AudioUnitInitialize (theUnit); if (result) return -1; playBackWasInit = true; } return 0; }
static ALCenum ca_open_playback(ALCdevice *device, const ALCchar *deviceName) { ComponentDescription desc; Component comp; ca_data *data; OSStatus err; if(!deviceName) deviceName = ca_device; else if(strcmp(deviceName, ca_device) != 0) return ALC_INVALID_VALUE; /* open the default output unit */ desc.componentType = kAudioUnitType_Output; desc.componentSubType = kAudioUnitSubType_DefaultOutput; desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; comp = FindNextComponent(NULL, &desc); if(comp == NULL) { ERR("FindNextComponent failed\n"); return ALC_INVALID_VALUE; } data = calloc(1, sizeof(*data)); device->ExtraData = data; err = OpenAComponent(comp, &data->audioUnit); if(err != noErr) { ERR("OpenAComponent failed\n"); free(data); device->ExtraData = NULL; return ALC_INVALID_VALUE; } return ALC_NO_ERROR; }
bool CCoreAudioUnit::Open(ComponentDescription desc) { if (m_Component) Close(); // Find the required Component Component outputComp = FindNextComponent(NULL, &desc); if (outputComp == NULL) // Unable to find the AudioUnit we requested { CLog::Log(LOGERROR, "CCoreAudioUnit::Open: Unable to locate AudioUnit Component."); return false; } // Create an instance of the AudioUnit Component OSStatus ret = OpenAComponent(outputComp, &m_Component); if (ret) // Unable to open AudioUnit { CLog::Log(LOGERROR, "CCoreAudioUnit::Open: Unable to open AudioUnit Component. Error = 0x%08x (%4.4s)", ret, CONVERT_OSSTATUS(ret)); return false; } return true; }