void PanoramaViewDataList::DeleteItemFromIndex( size_t nIndex )
{
	DBElementCollection<PanoramaViewData>::DeleteItemFromIndex(nIndex);
	if( m_nSelectItem < (int) GetElementCount() )
	{

	}
	else
	{
		m_nSelectItem = (int)GetElementCount()-1;
	}
}
Exemple #2
0
JBoolean
JXMenuData::ShortcutToIndex
	(
	const JCharacter	c,
	JIndex*				index
	)
	const
{
	*index = 0;
	const JCharacter s[2] = { tolower(c), '\0' };

	const JIndex count = GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		const BaseItemData itemData = itsBaseItemData->GetElement(i);
		if (itemData.enabled && itemData.shortcuts != NULL &&
			(itemData.shortcuts)->Contains(s))
			{
			*index = i;
			return kJTrue;
			}
		}

	return kJFalse;
}
JBoolean
SCCircuitVarList::AddFunction
	(
	const JCharacter*	name,
	const JFunction&	f,
	const JBoolean		visible
	)
{
	JIndex index;
	if (!JNameValid(name))
		{
		return kJFalse;
		}
	else if (ParseVariableName(name, strlen(name), &index))
		{
		(JGetUserNotification())->ReportError("This variable name is already used.");
		return kJFalse;
		}
	else
		{
		VarInfo info;

		info.name = new JString(name);
		assert( info.name != NULL );

		info.f       = f.Copy();
		info.visible = visible;

		itsVars->AppendElement(info);
		Broadcast(VarInserted(GetElementCount()));
		return kJTrue;
		}
}
Exemple #4
0
void
JXMenuData::PrepareToOpenMenu
	(
	const JXMenu::UpdateAction updateAction
	)
{
	const JSize itemCount = GetElementCount();
	for (JIndex i=1; i<=itemCount; i++)
		{
		BaseItemData itemData = itsBaseItemData->GetElement(i);

		JBoolean changed = kJFalse;
		if (itemData.enabled &&
			(updateAction == JXMenu::kDisableAll ||
			 (itemData.submenu == NULL && updateAction == JXMenu::kDisableSingles)))
			{
			itemData.enabled = kJFalse;
			changed          = kJTrue;
			}
		if (itemData.isChecked)
			{
			itemData.isChecked = kJFalse;
			changed            = kJTrue;
			}

		if (changed)
			{
			itsBaseItemData->SetElement(i, itemData);
			}
		}
}
void
JXTextMenuData::UpdateItemFonts
	(
	const JFontID		oldID,
	const JSize			oldSize,
	const JFontStyle&	oldStyle,

	const JFontID		newID,
	const JSize			newSize,
	const JFontStyle&	newStyle
	)
{
	const JSize count = GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		TextItemData itemData = itsTextItemData->GetElement(i);
		if (itemData.fontID    == oldID &&
			itemData.fontSize  == oldSize &&
			itemData.fontStyle == oldStyle)
			{
			itemData.fontID    = newID;
			itemData.fontSize  = newSize;
			itemData.fontStyle = newStyle;
			itsTextItemData->SetElement(i, itemData);

			itsNeedGeomRecalcFlag = kJTrue;
			}
		}
}
Exemple #6
0
BOOL CXMLElement::Equals(CXMLElement* pXML) const
{
	if ( this == NULL || pXML == NULL ) return FALSE;
	if ( pXML == this ) return TRUE;

	if ( m_sName != pXML->m_sName ) return FALSE;
	if ( m_sValue != pXML->m_sValue ) return FALSE;

	if ( GetAttributeCount() != pXML->GetAttributeCount() ) return FALSE;
	if ( GetElementCount() != pXML->GetElementCount() ) return FALSE;

	for ( POSITION pos = GetAttributeIterator() ; pos ; )
	{
		CXMLAttribute* pAttribute1 = GetNextAttribute( pos );
		CXMLAttribute* pAttribute2 = pXML->GetAttribute( pAttribute1->m_sName );
		if ( pAttribute2 == NULL ) return FALSE;
		if ( ! pAttribute1->Equals( pAttribute2 ) ) return FALSE;
	}

	POSITION pos1 = GetElementIterator();
	POSITION pos2 = pXML->GetElementIterator();

	for ( ; pos1 && pos2 ; )
	{
		CXMLElement* pElement1 = GetNextElement( pos1 );
		CXMLElement* pElement2 = pXML->GetNextElement( pos2 );
		if ( pElement1 == NULL || pElement2 == NULL ) return FALSE;
		if ( ! pElement1->Equals( pElement2 ) ) return FALSE;
	}

	if ( pos1 != NULL || pos2 != NULL ) return FALSE;

	return TRUE;
}
JVariableList::MatchResult
JVariableList::FindUniqueVarName
	(
	const JCharacter*	prefix,
	JIndex*				index,
	JString*			maxPrefix
	)
	const
{
	assert( !JStringEmpty(prefix) );

	const JSize count = GetElementCount();
	JArray<JIndex> matchList;

	for (JIndex i=1; i<=count; i++)
		{
		const JString& name = GetVariableName(i);
		if (name == prefix)
			{
			*index     = i;
			*maxPrefix = name;
			return kSingleMatch;
			}
		else if (JStringBeginsWith(name, name.GetLength(), prefix))
			{
			matchList.AppendElement(i);
			}
		}

	const JSize matchCount = matchList.GetElementCount();
	if (matchCount == 0)
		{
		*index = 0;
		maxPrefix->Clear();
		return kNoMatch;
		}
	else if (matchCount == 1)
		{
		*index     = matchList.GetElement(1);
		*maxPrefix = GetVariableName(*index);
		return kSingleMatch;
		}
	else
		{
		*maxPrefix = GetVariableName( matchList.GetElement(1) );
		for (JIndex i=2; i<=matchCount; i++)
			{
			const JString& varName   = GetVariableName( matchList.GetElement(i) );
			const JSize matchLength  = JCalcMatchLength(*maxPrefix, varName);
			const JSize prefixLength = maxPrefix->GetLength();
			if (matchLength < prefixLength)
				{
				maxPrefix->RemoveSubstring(matchLength+1, prefixLength);
				}
			}
		*index = 0;
		return kMultipleMatch;
		}
}
Exemple #8
0
void SequenceElements::SetVisibilityForAllModels(bool visibility, int view)
{
    for(int i=0;i<GetElementCount(view);i++)
    {
        Element * e = GetElement(i, view);
        e->SetVisible(visibility);
    }
}
BOOL PanoramaViewDataList::SelectItem( int idx )
{
	if(idx < (int)GetElementCount()&& idx >=0 )
		m_nSelectItem = idx;
	else
		return FALSE;
	return TRUE;
}
Exemple #10
0
void
JXMenuData::DisableAll()
{
	const JSize count = GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		DisableItem(i);
		}
}
Exemple #11
0
void CXMLElement::Serialize(CArchive& ar)
{
	CXMLNode::Serialize( ar );

	if ( ar.IsStoring() )
	{
		ar.WriteCount( GetAttributeCount() );

		for ( POSITION pos = GetAttributeIterator() ; pos ; )
		{
			GetNextAttribute( pos )->Serialize( ar );
		}

		ar.WriteCount( GetElementCount() );

		for ( POSITION pos = GetElementIterator() ; pos ; )
		{
			GetNextElement( pos )->Serialize( ar );
		}
	}
	else // Loading
	{
		for ( int nCount = (int)ar.ReadCount() ; nCount > 0 ; nCount-- )
		{
			CXMLAttribute* pAttribute = new CXMLAttribute( this );
			pAttribute->Serialize( ar );

			// Skip attribute if name is missing
			if ( pAttribute->m_sName.IsEmpty() )
			{
				delete pAttribute;
				continue;
			}

			CString strNameLower( pAttribute->m_sName );
			strNameLower.MakeLower();

			// Delete the old attribute if one exists
			CXMLAttribute* pExisting;
			if ( m_pAttributes.Lookup( strNameLower, pExisting ) )
				delete pExisting;

			m_pAttributes.SetAt( strNameLower, pAttribute );

			if ( ! m_pAttributesInsertion.Find( strNameLower ) )
				m_pAttributesInsertion.AddTail( strNameLower );		// Track output order workaround
		}

		for ( int nCount = (int)ar.ReadCount() ; nCount > 0 ; nCount-- )
		{
			CXMLElement* pElement = new CXMLElement( this );
			pElement->Serialize( ar );
			m_pElements.AddTail( pElement );
		}
	}
}
Exemple #12
0
void
JXMenuData::DeleteAll()
{
	const JSize itemCount = GetElementCount();
	for (JIndex i=1; i<=itemCount; i++)
		{
		BaseItemData itemData = itsBaseItemData->GetElement(i);
		CleanOutBaseItem(&itemData);
		}
	itsBaseItemData->RemoveAll();
}
BOOL PanoramaViewDataList::SelectItem( PanoramaViewData* theData )
{
	for(int i=0;i< (int)GetElementCount();++i)
	{
		if( GetItem(i) == theData )
		{
			m_nSelectItem = i;
			return TRUE;
		}
	}
	return FALSE;
}
void
JMountPointList::DeleteAll()
{
	const JSize count = GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		JMountPoint info = GetElement(i);
		jdelete info.path;
		jdelete info.devicePath;
		}

	RemoveAll();
}
Exemple #15
0
OSStatus	CAAudioUnit::SetSampleRate (Float64			inSampleRate)
{
	OSStatus result;

	UInt32 elCount;
	require_noerr (result = GetElementCount(kAudioUnitScope_Input, elCount), home);
	if (elCount) {
		for (unsigned int i = 0; i < elCount; ++i) {
			require_noerr (result = SetSampleRate (kAudioUnitScope_Input, i, inSampleRate), home);
		}
	}

	require_noerr (result = GetElementCount(kAudioUnitScope_Output, elCount), home);
	if (elCount) {
		for (unsigned int i = 0; i < elCount; ++i) {
			require_noerr (result = SetSampleRate (kAudioUnitScope_Output, i, inSampleRate), home);
		}
	}

home:
	return result;
}
JBoolean
JFSBindingList::GetBinding
	(
	const JCharacter*	origFileName,
	const JFSBinding**	binding
	)
{
	// ignore # and ~ on end

	JString fileName = origFileName;
	CleanFileName(&fileName);

	// read content

	JString content;
	ifstream input(origFileName);
	content.Read(input, kContentLength);
	input.close();

	// scan bindings for match -- check content types first

	const JSize count = GetElementCount();
	for (JIndex j=0; j<=1; j++)
		{
		const JBoolean isContent = JNegate(j);
		for (JIndex i=1; i<=count; i++)
			{
			*binding = GetBinding(i);
			if ((**binding).IsContentBinding() == isContent &&
				(**binding).Match(fileName, content))
				{
				return kJTrue;
				}
			}
		}

	if (itsUseDefaultFlag && itsUserDefault != NULL)
		{
		*binding = itsUserDefault;
		return kJTrue;
		}

	if (itsUseDefaultFlag && itsSystemDefault != NULL)
		{
		*binding = itsSystemDefault;
		return kJTrue;
		}

	*binding = NULL;
	return kJFalse;
}
Exemple #17
0
JBoolean
JXMenuData::HasCheckboxes()
	const
{
	const JIndex count = GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		const BaseItemData itemData = itsBaseItemData->GetElement(i);
		if (itemData.type == JXMenu::kCheckboxType || itemData.type == JXMenu::kRadioType)
			{
			return kJTrue;
			}
		}

	return kJFalse;
}
Exemple #18
0
JBoolean
JXMenuData::HasSubmenus()
	const
{
	const JIndex count = GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		const BaseItemData itemData = itsBaseItemData->GetElement(i);
		if (itemData.submenu != NULL)
			{
			return kJTrue;
			}
		}

	return kJFalse;
}
Exemple #19
0
void SequenceElements::RenameTimingTrack(std::string oldname, std::string newname)
{
    // actual timing track name already updated ... we just need to update any effects that care about the timing track name
    // faces, state, piano, vumeter

    std::vector<RenderableEffect*> effects(GetEffectManager().size());
    int count = 0;
    for (int x = 0; x < GetEffectManager().size(); x++) {
        RenderableEffect *eff = GetEffectManager()[x];
        effects[x] = eff;
    }

    for (size_t i = 0; i < GetElementCount(); i++) {
        Element* elem = GetElement(i);
        if (elem->GetType() == "model") {
            for (int j = 0; j < elem->GetEffectLayerCount(); j++) {
                EffectLayer* layer = elem->GetEffectLayer(j);
                for (int k = 0; k < layer->GetEffectCount(); k++) {
                    Effect* eff = layer->GetEffect(k);
                    if (effects[eff->GetEffectIndex()] != nullptr) {
                        effects[eff->GetEffectIndex()]->RenameTimingTrack(oldname, newname, eff);
                    }
                }
            }
            for (int j = 0; j < elem->getStrandLayerCount(); j++) {
                StrandLayer* layer = elem->GetStrandLayer(j);
                for (int k = 0; k < layer->GetEffectCount(); k++) {
                    Effect* eff = layer->GetEffect(k);
                    if (effects[eff->GetEffectIndex()] != nullptr) {
                        effects[eff->GetEffectIndex()]->RenameTimingTrack(oldname, newname, eff);
                    }
                }
                for (int k = 0; k < layer->GetNodeLayerCount(); k++) {
                    NodeLayer* nlayer = layer->GetNodeLayer(k);
                    for (int l = 0; l < nlayer->GetEffectCount(); l++) {
                        Effect* eff = nlayer->GetEffect(l);
                        if (effects[eff->GetEffectIndex()] != nullptr) {
                            effects[eff->GetEffectIndex()]->RenameTimingTrack(oldname, newname, eff);
                        }
                    }
                }
            }
        }
    }
}
Exemple #20
0
static long ArrayElementCount (const ArgDesc* Arg)
/* Check if the type of the given argument is an array. If so, and if the
 * element count is known, return it. In all other cases, return UNSPECIFIED.
 */
{
    long Count;

    if (IsTypeArray (Arg->Type)) {
        Count = GetElementCount (Arg->Type);
        if (Count == FLEXIBLE) {
            /* Treat as unknown */
            Count = UNSPECIFIED;
        }
    } else {
        Count = UNSPECIFIED;
    }
    return Count;
}
Exemple #21
0
void
GFGClass::WriteProtected
	(
	ostream& 		os,
	const JBoolean	interface
	)
{
	const JSize count	= GetElementCount();
	for (JIndex i = 1; i <= count; i++)
		{
		GFGMemberFunction* fn	= NthElement(i);
		if (fn->IsUsed() &&
			fn->IsProtected())
			{
			WriteFunction(os, fn, interface);
			}
		}
}
Exemple #22
0
        Ptr<LispObject> getQualifiedName(Ptr<LispObject> pEnv)
        {
            typeCheck(pEnv, Type::Environment);

            auto name = ezStringBuilder();

            while(true)
            {
                name.Prepend(symbol::getValue(getName(pEnv)).GetData());
                pEnv = getParent(pEnv);
                if(isNil(pEnv))
                {
                    break;
                }
                name.Prepend('/');
            }

            return str::create(name.GetData(), name.GetElementCount());
        }
JBoolean
JVariableList::ParseVariableName
	(
	const JCharacter*	expr,
	const JSize			exprLength,
	JIndex*				index
	)
	const
{
	const JSize count = GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		const JString& name = GetVariableName(i);
		if (JStringsEqual(expr, exprLength, name))
			{
			*index = i;
			return kJTrue;
			}
		}

	return kJFalse;
}
Exemple #24
0
JBoolean
JXMenuData::FindSubmenu
	(
	JXMenu*	theMenu,
	JIndex*	index
	)
	const
{
	const JSize count = GetElementCount();
	for (JIndex i=1; i<=count; i++)
		{
		BaseItemData itemData = itsBaseItemData->GetElement(i);
		if (itemData.submenu == theMenu)
			{
			*index = i;
			return kJTrue;
			}
		}

	*index = 0;
	return kJFalse;
}
Exemple #25
0
static void DoCompare (const Type* lhs, const Type* rhs, typecmp_t* Result)
/* Recursively compare two types. */
{
    unsigned    Indirections;
    unsigned    ElementCount;
    SymEntry*   Sym1;
    SymEntry*   Sym2;
    SymTable*   Tab1;
    SymTable*   Tab2;
    FuncDesc*   F1;
    FuncDesc*   F2;


    /* Initialize stuff */
    Indirections = 0;
    ElementCount = 0;

    /* Compare two types. Determine, where they differ */
    while (lhs->C != T_END) {

        TypeCode LeftType, RightType;
        TypeCode LeftSign, RightSign;
        TypeCode LeftQual, RightQual;
        long LeftCount, RightCount;

        /* Check if the end of the type string is reached */
        if (rhs->C == T_END) {
            /* End of comparison reached */
            return;
        }

        /* Get the raw left and right types, signs and qualifiers */
        LeftType  = GetType (lhs);
        RightType = GetType (rhs);
        LeftSign  = GetSignedness (lhs);
        RightSign = GetSignedness (rhs);
        LeftQual  = GetQualifier (lhs);
        RightQual = GetQualifier (rhs);

        /* If the left type is a pointer and the right is an array, both
        ** are compatible.
        */
        if (LeftType == T_TYPE_PTR && RightType == T_TYPE_ARRAY) {
            RightType = T_TYPE_PTR;
        }

        /* If the raw types are not identical, the types are incompatible */
        if (LeftType != RightType) {
            SetResult (Result, TC_INCOMPATIBLE);
            return;
        }

        /* On indirection level zero, a qualifier or sign difference is
        ** accepted. The types are no longer equal, but compatible.
        */
        if (LeftSign != RightSign) {
            if (ElementCount == 0) {
                SetResult (Result, TC_SIGN_DIFF);
            } else {
                SetResult (Result, TC_INCOMPATIBLE);
                return;
            }
        }
        if (LeftQual != RightQual) {
            /* On the first indirection level, different qualifiers mean
            ** that the types are still compatible. On the second level,
            ** this is a (maybe minor) error, so we create a special
            ** return code, since a qualifier is dropped from a pointer.
            ** Starting from the next level, the types are incompatible
            ** if the qualifiers differ.
            */
            /* printf ("Ind = %d    %06X != %06X\n", Indirections, LeftQual, RightQual); */
            switch (Indirections) {

                case 0:
                    SetResult (Result, TC_STRICT_COMPATIBLE);
                    break;

                case 1:
                    /* A non const value on the right is compatible to a
                    ** const one to the left, same for volatile.
                    */
                    if ((LeftQual & T_QUAL_CONST) < (RightQual & T_QUAL_CONST) ||
                        (LeftQual & T_QUAL_VOLATILE) < (RightQual & T_QUAL_VOLATILE)) {
                        SetResult (Result, TC_QUAL_DIFF);
                    } else {
                        SetResult (Result, TC_STRICT_COMPATIBLE);
                    }
                    break;

                default:
                    SetResult (Result, TC_INCOMPATIBLE);
                    return;
            }
        }

        /* Check for special type elements */
        switch (LeftType) {

            case T_TYPE_PTR:
                ++Indirections;
                break;

            case T_TYPE_FUNC:
                /* Compare the function descriptors */
                F1 = GetFuncDesc (lhs);
                F2 = GetFuncDesc (rhs);

                /* If one of both functions has an empty parameter list (which
                ** does also mean, it is not a function definition, because the
                ** flag is reset in this case), it is considered equal to any
                ** other definition, provided that the other has no default
                ** promotions in the parameter list. If none of both parameter
                ** lists is empty, we have to check the parameter lists and
                ** other attributes.
                */
                if (F1->Flags & FD_EMPTY) {
                    if ((F2->Flags & FD_EMPTY) == 0) {
                        if (ParamsHaveDefaultPromotions (F2)) {
                            /* Flags differ */
                            SetResult (Result, TC_INCOMPATIBLE);
                            return;
                        }
                    }
                } else if (F2->Flags & FD_EMPTY) {
                    if (ParamsHaveDefaultPromotions (F1)) {
                        /* Flags differ */
                        SetResult (Result, TC_INCOMPATIBLE);
                        return;
                    }
                } else {

                    /* Check the remaining flags */
                    if ((F1->Flags & ~FD_IGNORE) != (F2->Flags & ~FD_IGNORE)) {
                        /* Flags differ */
                        SetResult (Result, TC_INCOMPATIBLE);
                        return;
                    }

                    /* Compare the parameter lists */
                    if (EqualFuncParams (F1, F2) == 0) {
                        /* Parameter list is not identical */
                        SetResult (Result, TC_INCOMPATIBLE);
                        return;
                    }
                }

                /* Keep on and compare the return type */
                break;

            case T_TYPE_ARRAY:
                /* Check member count */
                LeftCount  = GetElementCount (lhs);
                RightCount = GetElementCount (rhs);
                if (LeftCount  != UNSPECIFIED &&
                    RightCount != UNSPECIFIED &&
                    LeftCount  != RightCount) {
                    /* Member count given but different */
                    SetResult (Result, TC_INCOMPATIBLE);
                    return;
                }
                break;

            case T_TYPE_STRUCT:
            case T_TYPE_UNION:
                /* Compare the fields recursively. To do that, we fetch the
                ** pointer to the struct definition from the type, and compare
                ** the fields.
                */
                Sym1 = GetSymEntry (lhs);
                Sym2 = GetSymEntry (rhs);

                /* If one symbol has a name, the names must be identical */
                if (!HasAnonName (Sym1) || !HasAnonName (Sym2)) {
                    if (strcmp (Sym1->Name, Sym2->Name) != 0) {
                        /* Names are not identical */
                        SetResult (Result, TC_INCOMPATIBLE);
                        return;
                    }
                }

                /* Get the field tables from the struct entry */
                Tab1 = Sym1->V.S.SymTab;
                Tab2 = Sym2->V.S.SymTab;

                /* One or both structs may be forward definitions. In this case,
                ** the symbol tables are both non existant. Assume that the
                ** structs are equal in this case.
                */
                if (Tab1 != 0 && Tab2 != 0) {

                    if (EqualSymTables (Tab1, Tab2) == 0) {
                        /* Field lists are not equal */
                        SetResult (Result, TC_INCOMPATIBLE);
                        return;
                    }

                }

                /* Structs are equal */
                break;
        }

        /* Next type string element */
        ++lhs;
        ++rhs;
        ++ElementCount;
    }

    /* Check if end of rhs reached */
    if (rhs->C == T_END) {
        SetResult (Result, TC_EQUAL);
    } else {
        SetResult (Result, TC_INCOMPATIBLE);
    }
}
Exemple #26
0
int    CAAudioUnit::GetChannelInfo (AUChannelInfo** chaninfo, UInt32& cnt)
{
	// this is the default assumption of an audio effect unit
	Boolean* isWritable = 0;
	UInt32	dataSize = 0;
		// lets see if the unit has any channel restrictions
	OSStatus result = AudioUnitGetPropertyInfo (AU(),
						    kAudioUnitProperty_SupportedNumChannels,
						    kAudioUnitScope_Global, 0,
						    &dataSize, isWritable); //don't care if this is writable

	// if this property is NOT implemented an FX unit
	// is expected to deal with same channel valance in and out

	if (result)
	{
		if (Comp().Desc().IsEffect())
		{
			return 1;
		}
		else if (Comp().Desc().IsGenerator() || Comp().Desc().IsMusicDevice()) {
			// directly query Bus Formats
			// Note that that these may refer to different subBusses
			// (eg. Kick, Snare,.. on a Drummachine)
			// eventually the Bus-Name for each configuration should be exposed
			// for the User to select..

			UInt32 elCountIn, elCountOut;

			if (GetElementCount (kAudioUnitScope_Input, elCountIn)) return -1;
			if (GetElementCount (kAudioUnitScope_Output, elCountOut)) return -1;

			cnt = std::max(elCountIn, elCountOut);

			*chaninfo = (AUChannelInfo*) malloc (sizeof (AUChannelInfo) * cnt);

			for (unsigned int i = 0; i < elCountIn; ++i) {
				UInt32 numChans;
				if (NumberChannels (kAudioUnitScope_Input, i, numChans)) return -1;
				(*chaninfo)[i].inChannels = numChans;
			}
			for (unsigned int i = elCountIn; i < cnt; ++i) {
				(*chaninfo)[i].inChannels = 0;
			}

			for (unsigned int i = 0; i < elCountOut; ++i) {
				UInt32 numChans;
				if (NumberChannels (kAudioUnitScope_Output, i, numChans)) return -1;
				(*chaninfo)[i].outChannels = numChans;
			}
			for (unsigned int i = elCountOut; i < cnt; ++i) {
				(*chaninfo)[i].outChannels = 0;
			}
			return 0;
		}
		else
		{
			// the au should either really tell us about this
			// or we will assume the worst
			return -1;
		}
	}

	*chaninfo = (AUChannelInfo*) malloc (dataSize);
	cnt = dataSize / sizeof (AUChannelInfo);

	result = GetProperty (kAudioUnitProperty_SupportedNumChannels,
			      kAudioUnitScope_Global, 0,
			      *chaninfo, &dataSize);

	if (result) { return -1; }
	return 0;
}
Exemple #27
0
/**
 * Returns the size of the bulk data in bytes.
 *
 * @return Size of the bulk data in bytes
 */
int32 FUntypedBulkData::GetBulkDataSize() const
{
	return GetElementCount() * GetElementSize();
}
Exemple #28
0
bool		CAAudioUnit::CanDo (const CAAUChanHelper		&inputs,
								const CAAUChanHelper		&outputs) const

{
// first check our state
		// huh!
	if (inputs.mNumEls == 0 && outputs.mNumEls == 0) return false;

	UInt32 elCount;
	if (GetElementCount (kAudioUnitScope_Input, elCount)) { return false; }
	if (elCount != inputs.mNumEls) return false;

	if (GetElementCount (kAudioUnitScope_Output, elCount)) { return false; }
	if (elCount != outputs.mNumEls) return false;

// (1) special cases (effects and sources (generators and instruments) only)
	UInt32	dataSize = 0;
	if (GetPropertyInfo (kAudioUnitProperty_SupportedNumChannels,
									kAudioUnitScope_Global, 0, &dataSize, NULL) != noErr)
	{
		if (Comp().Desc().IsEffect() || Comp().Desc().IsOffline()) {
			UInt32 numChan = outputs.mNumEls > 0 ? outputs.mChans[0] : inputs.mChans[0];
			for (unsigned int in = 0; in < inputs.mNumEls; ++in)
				if (numChan != inputs.mChans[in]) return false;
			for (unsigned int out = 0; out < outputs.mNumEls; ++out)
				if (numChan != outputs.mChans[out]) return false;
			return true;
		}

			// in this case, all the channels have to match the current config
		if (Comp().Desc().IsGenerator() || Comp().Desc().IsMusicDevice()) {
			for (unsigned int in = 0; in < inputs.mNumEls; ++in) {
				UInt32 chan;
				if (NumberChannels (kAudioUnitScope_Input, in, chan)) return false;
				if (chan != UInt32(inputs.mChans[in])) return false;
			}
			for (unsigned int out = 0; out < outputs.mNumEls; ++out) {
				UInt32 chan;
				if (NumberChannels (kAudioUnitScope_Output, out, chan)) return false;
				if (chan != UInt32(outputs.mChans[out])) return false;
			}
			return true;
		}

			// if we get here we can't determine anything about channel capabilities
		return false;
	}

	StackAUChannelInfo info (dataSize);

	if (GetProperty (kAudioUnitProperty_SupportedNumChannels,
							kAudioUnitScope_Global, 0,
							info.mChanInfo, &dataSize) != noErr)
	{
		return false;
	}

	int numInfo = dataSize / sizeof(AUChannelInfo);

// (2) Test for dynamic capability (or no elements on that scope)
	SInt32 dynInChans = 0;
	if (ValidateDynamicScope (kAudioUnitScope_Input, dynInChans, info.mChanInfo, numInfo)) {
		if (CheckDynCount (dynInChans, inputs) == false) return false;
	}

	SInt32 dynOutChans = 0;
	if (ValidateDynamicScope (kAudioUnitScope_Output, dynOutChans, info.mChanInfo, numInfo)) {
		if (CheckDynCount (dynOutChans, outputs) == false) return false;
	}

	if (dynOutChans && dynInChans) { return true; }

// (3)	Just need to test one side
	if (dynInChans || (inputs.mNumEls == 0)) {
		return CheckOneSide (outputs, true, info.mChanInfo, numInfo);
	}

	if (dynOutChans || (outputs.mNumEls == 0)) {
		return CheckOneSide (inputs, false, info.mChanInfo, numInfo);
	}

// (4) - not a dynamic AU, has ins and outs, and has channel constraints so we test every possible pairing
	for (unsigned int in = 0; in < inputs.mNumEls; ++in)
	{
		bool testInAlready = false;
		for (unsigned int i = 0; i < in; ++i) {
			if (inputs.mChans[i] == inputs.mChans[in]) {
				testInAlready = true;
				break;
			}
		}
		if (!testInAlready) {
			for (unsigned int out = 0; out < outputs.mNumEls; ++out) {
					// try to save a little bit and not test the same pairing multiple times...
				bool testOutAlready = false;
				for (unsigned int i = 0; i < out; ++i) {
					if (outputs.mChans[i] == outputs.mChans[out]) {
						testOutAlready = true;
						break;
					}
				}
				if (!testOutAlready) {
					if (!ValidateChannelPair (inputs.mChans[in], outputs.mChans[out],info.mChanInfo, numInfo)) {
						return false;
					}
				}
			}
		}
	}

	return true;
}
CString PanoramaViewDataList::GetCreateName() const
{
	CString str;
	str.Format("View%d", GetElementCount()+1 );
	return str;
}
PanoramaViewData* PanoramaViewDataList::GetSelectItem() const
{
	if( m_nSelectItem < (int)GetElementCount() && m_nSelectItem >=0 )
		return (PanoramaViewData*)GetItem(m_nSelectItem);
	return NULL;
}