Пример #1
0
void JUCETaskCreate(void (*pvTaskCode)(void * ), const signed char *pcName,
					void *pvParameters, int uxPriority, int *pxCreatedTask)
{
	tasklistmutex.enter();
	if (arrayinited != true)
	{
		for (unsigned int i = 0; i < MAX_JUCETASKS; i++)
		{
			taskArray[i] = NULL;
		}
		arrayinited = true;
	}
	unsigned int thisID = MAX_JUCETASKS;
	for (unsigned int i = 0; i < MAX_JUCETASKS; i++)
	{
		if (taskArray[i] == NULL)
		{
			thisID = i;
			break;
		}
	}
	if (thisID == MAX_JUCETASKS) return;
	JUCETask *newtask;
	String newname = (const char*) pcName;
	newtask = new JUCETask(newname);
	newtask->TaskFunction = pvTaskCode;
	newtask->parameters = pvParameters;
	newtask->iD = thisID;
	taskArray[thisID] = newtask;
	if (pxCreatedTask != NULL) *pxCreatedTask = thisID;

	newtask->startThread(uxPriority);
	tasklistmutex.exit();
}
Пример #2
0
void MutexList_Del(CriticalSection *mutexPointer)
{
	queuelistmutex.enter();
	if (mutexPointer != NULL &&
		MutexList != NULL) 
	{
		MutexList_t *temp = MutexList;
		MutexList_t *prev = NULL;
		
		while (temp != NULL)
		{
			if (temp->mutexPointer == mutexPointer)
			{
				break;
			}
			prev = temp;
			temp = temp->next;
		}
		
		if (prev == NULL) 
		{
			MutexList = temp->next;
		} else {
			prev->next = temp->next;
		}
		
		delete temp;
		queuelistmutex.exit();
	}
}
Пример #3
0
void JUCETaskResume(int taskID)
{
	tasklistmutex.enter();
	JUCETask *thistask;
	thistask = taskArray[taskID];
	tasklistmutex.exit();
	if (thistask != NULL) thistask->startThread();
}
Пример #4
0
void MutexList_Add(CriticalSection *mutexPointer, int mutexID)
{
	queuelistmutex.enter();
	MutexList_t *root = MutexList;
	MutexList_t *newentry = new MutexList_t;
	newentry->mutexID = mutexID;
	newentry->mutexPointer = mutexPointer;
	newentry->next = root;
	MutexList = newentry;
	queuelistmutex.exit();
}
Пример #5
0
void JUCETaskSuspend(int taskID)
{
	tasklistmutex.enter();
	JUCETask *thistask;
	thistask = taskArray[taskID];
	tasklistmutex.exit();
	if (thistask != NULL) 
	{
		if (Thread::getCurrentThreadId() != thistask->getThreadId())
		{
			thistask->stopThread(5000);
		}
		
		else thistask->signalThreadShouldExit();
		
	}
	
}
Пример #6
0
void JUCETaskResumeAll(void)
{
	tasklistmutex.enter();
	JUCETask *thistaskArray[MAX_JUCETASKS];
	for (unsigned int i = 0; i < MAX_JUCETASKS; i++)
	{
		thistaskArray[i] = taskArray[i];		
	}
	tasklistmutex.exit();
	
	for (unsigned int i = 0; i < MAX_JUCETASKS; i++)
	{
		if (thistaskArray[i] != NULL)
		{
			thistaskArray[i]->startThread();
		}
		
	}
	
}
Пример #7
0
int MutexListList_GetID(CriticalSection *mutexPointer)
{
	queuelistmutex.enter();
	MutexList_t *temp = MutexList;
	int returnID = -1;
	
	while (temp != NULL)
	{
		if (temp->mutexPointer == mutexPointer)
		{
			returnID = temp->mutexID;
			break;
		}
		
		temp = temp->next;
	}
	queuelistmutex.exit();
	
	return returnID;
}
Пример #8
0
CriticalSection *MutexList_GetPointer(int mutexID)
{
	queuelistmutex.enter();
	MutexList_t *temp = MutexList;
	CriticalSection *returnPointer = NULL;
	
	while (temp != NULL)
	{
		if (temp->mutexID == mutexID)
		{
			returnPointer = temp->mutexPointer;
			break;
		}
		
		temp = temp->next;
	}
	
	queuelistmutex.exit();
	return returnPointer;
	
}
Пример #9
0
void JUCETaskSuspendAll(void)
{
	tasklistmutex.enter();
	JUCETask *thistaskArray[MAX_JUCETASKS];
	for (unsigned int i = 0; i < MAX_JUCETASKS; i++)
	{
		thistaskArray[i] = taskArray[i];		
	}
	tasklistmutex.exit();
	
	for (unsigned int i = 0; i < MAX_JUCETASKS; i++)
	{
		if (thistaskArray[i] != NULL)
		{
			if ( Thread::getCurrentThreadId() != thistaskArray[i]->getThreadId() )
			{
				thistaskArray[i]->stopThread(5000);
			}
			
		}
		
	}
	
}
Пример #10
0
void TrackComponent::mouseDown(const MouseEvent &e) {

	ModifierKeys modifiers = ModifierKeys::getCurrentModifiersRealtime();

    int posX;
	// check the mod keys ..
	if (modifiers.isPopupMenu() || modifiers.isCtrlDown())
	{
		ScopedPointer<PopupMenu> trackMenu_ = new PopupMenu();
		trackMenu_->clear();
		trackMenu_->addCommandItem(&_commands, MainWindow::showMixer);
		trackMenu_->addItem(1, "Add Region", true);
        MouseEvent ev = e.getEventRelativeTo(this);
        for(auto region : _regionComponents)
        {
            posX = ev.x;
            region->setBroughtToFrontOnMouseClick(true);
            if(region->getPositionX() < posX && posX < (region->getPositionX() + region->getRegionWidth()))
            {
                trackMenu_->addItem(2, "Remove Region", true);
            }
        }
        switch (trackMenu_->show())
        {
            case 1:
            {
                FileChooser chooser("Select an audio file to add...",
                                    File::nonexistent,
                                    "*.wav; *aif; *.flac");
                if (chooser.browseForFileToOpen()) {
                    File audioFile(chooser.getResult());
                    const String fileString = audioFile.getFullPathName();
                    String format;
                    if (fileString.contains(".wav"))
                        format = "WAV";
                    else if (fileString.contains(".aif") || fileString.contains(".aiff"))
                        format = "AIFF";
                    else if (fileString.contains(".flac"))
                        format = "FLAC";
                    AudioFormatManager formatManager;
                    formatManager.registerBasicFormats();
                    
                    AudioFormatReader* reader = formatManager.createReaderFor(audioFile);
                    Audio::Region* region = new Audio::SampleRegion(reader, 1, &audioFile);
                    Point<int> position = e.getPosition();
                    int x = position.getX();
                    
                    if (x > _mixerOffset)
                    {
                        int64 samplesRange = secondsToSamples(100, _sampleRate);
                        int64 positionSamples = pixelsToSamples(x - _mixerOffset, 100 * _pixelsPerClip, samplesRange);
                        
                        _track->add(positionSamples, region);
                        createRegionGUI(x, region, formatManager, audioFile);
                        getParentComponent()->resized();
                    }
                    else if (x < _mixerOffset)
                    {
                        _track->add(0, region);
                        createRegionGUI(_mixerOffset, region, formatManager, audioFile);
                        getParentComponent()->resized();
                    }
                }
            }
                break;
            case 2:
            {
                CriticalSection critical;
                critical.enter();
                for(size_t i = 0; i < _regionComponents.size(); ++i)
                {
                    
                    Rectangle<int> bounds_ = _regionComponents.at(i)->getBounds();
					posX = ev.x;
                    if((int)_regionComponents.at(i)->getPositionX() < posX && posX < ((int)_regionComponents.at(i)->getPositionX() + (int)_regionComponents.at(i)->getRegionWidth()))
                    {
                        _track->remove(_regionComponents.at(i)->getRegion(), _posX.at(i));
                        std::vector<RegionComponent*>::iterator regit = _regionComponents.begin() + i;
                        RegionComponent* component = _regionComponents.at(i);
                        removeChildComponent(_regionComponents.at(i));
                        _regionComponents.erase(regit);
                        delete component;
                        _regions.erase(_posX.at(i));
                        std::vector<int64>::iterator posit = _posX.begin() + i;;
                        _posX.erase(posit);
                        std::vector<int64>::iterator sampsit = _sizeSamps.begin() + i;;
                        _sizeSamps.erase(sampsit);
                    }
                }
                critical.exit();
            }
            default:
                break;
        }
    }
}