|
Audacity
3.0.3
|
Go to the documentation of this file.
17 #include "../Audacity.h"
22 #include "../Project.h"
25 #include <wx/thread.h>
41 pthread_join(mThread, NULL);
43 bool TestDestroy() {
return mDestroy; }
47 spec.tv_nsec = ms * 1000 * 1000;
48 nanosleep(&spec, NULL);
50 static void *callback(
void *p) {
52 #if defined(__WXMAC__)
56 return (
void *) th->
Entry();
60 pthread_create(&mThread, NULL, callback,
this);
65 void SetPriority(
int priority)
90 void*
Entry()
override;
121 mTask->DoSome(0.05f);
151 return first.CmpNoCase(second);
178 wxThread::Sleep(200);
229 for(
unsigned int i=0;i<
mTasks.size();i++)
247 auto task = mtask.get();
252 for(
unsigned int i=0;i<
mQueues.size();i++)
263 queue->
AddTask(std::move(mtask));
271 auto newqueue = std::make_unique<ODWaveTrackTaskQueue>();
272 newqueue->AddTask(std::move(mtask));
273 mQueues.push_back(std::move(newqueue));
326 startThread->Create();
366 tasksInArray =
mTasks.size()>0;
390 tasksInArray =
mTasks.size()>0;
403 if( (!tasksInArray) || paused)
419 wxCommandEvent event( EVT_ODTASK_UPDATE );
420 wxTheApp->AddPendingEvent(event);
441 pMan->mPauseLock.Lock();
442 pMan->mPause = pause;
443 pMan->mPauseLock.Unlock();
447 pMan->mQueueNotEmptyCond->Signal();
470 const std::shared_ptr<Track> &newTrack)
473 for(
unsigned int i=0;i<
mQueues.size();i++)
475 mQueues[i]->ReplaceWaveTrack( oldTrack, newTrack );
482 const std::shared_ptr< WaveTrack > &track)
486 for(
unsigned int i=0;i<
mQueues.size();i++)
488 if(
mQueues[i]->ContainsWaveTrack(track.get()))
506 const std::shared_ptr< WaveTrack > &dependentTrack,
514 unsigned int dependentIndex = 0;
515 bool canMerge =
false;
518 for(
unsigned int i=0;i<
mQueues.size();i++)
520 if(
mQueues[i]->ContainsWaveTrack(masterTrack))
522 masterQueue =
mQueues[i].get();
524 else if(
mQueues[i]->ContainsWaveTrack(dependentTrack.get()))
526 dependentQueue =
mQueues[i].get();
531 if(masterQueue&&dependentQueue)
557 for(
unsigned int i=0;i<
mQueues.size();i++)
559 mQueues[i]->DemandTrackUpdate(track,seconds);
569 for(
unsigned int i=0;i<
mQueues.size();i++)
571 if(
mQueues[i]->IsFrontTaskComplete())
621 for(
unsigned int i=0;i<
mQueues.size();i++)
623 mQueues[i]->FillTipForWaveTrack(t, tip);
633 for(
unsigned int i=0;i<
mQueues.size();i++)
635 total+=
mQueues[i]->GetFrontTask()->PercentComplete();
641 return (
float) total/(totalTasks>0?totalTasks:1);
649 for(
unsigned int i=0;i<
mQueues.size();i++)
651 ret+=
mQueues[i]->GetNumTasks();
float GetOverallPercentComplete()
Gets the total percent complete for all tasks combined.
Holds a msgid for the translation catalog; may also bind format arguments.
volatile int mCurrentThreads
Number of threads currently running. Accessed thru multiple threads.
ODLock mCurrentThreadsMutex
volatile bool mTerminated
wxDEFINE_EVENT(EVT_ODTASK_UPDATE, wxCommandEvent)
A Track that contains audio waveform data.
std::vector< std::unique_ptr< ODWaveTrackTaskQueue > > mQueues
ODTask * GetFrontTask()
Schedules the front task for immediate execution.
void MakeWaveTrackIndependent(const std::shared_ptr< WaveTrack > &track)
if it shares a queue/task, creates a NEW queue/task for the track, and removes it from any previously...
bool MakeWaveTrackDependent(const std::shared_ptr< WaveTrack > &dependentTrack, WaveTrack *masterTrack)
A thread that executes a part of the task specified by an ODTask.
void AddTask(std::unique_ptr< ODTask > &&mtask)
Add a task to the queue.
static void Pause(bool pause=true)
void AddNewTask(std::unique_ptr< ODTask > &&mtask, bool lockMutex=true)
Adds a wavetrack, creates a queue member.
static ODManager * InstanceNormal()
Gets the singleton instance.
static bool IsInstanceCreated()
returns whether or not the singleton instance was created yet
static bool gManagerCreated
static ODManager * InstanceFirstTime()
Gets the singleton instance.
void DemandTrackUpdate(WaveTrack *track, double seconds)
changes the tasks associated with this Waveform to process the task from a different point in the tra...
void AddTask(ODTask *task)
Adds a task to the running queue. Thread-safe.
void SignalTaskQueueLoop()
Wakes the queue loop up by signalling its condition variable.
static void Quit()
Kills the ODMananger Thread.
void FillTipForWaveTrack(const WaveTrack *t, TranslatableString &tip)
fills in the status bar message for a given track
static void MarkLoadedODFlag()
sets a flag that is set if we have loaded some OD blockfiles from PCM.
void * Entry() override
Executes a part of the task.
static bool sHasLoadedOD
a flag that is set if we have loaded some OD blockfiles from PCM.
void RemoveTaskIfInQueue(ODTask *task)
removes a task from the active task queue
ODLock mQueueNotEmptyCondLock
void MakeWaveTrackIndependent(const std::shared_ptr< WaveTrack > &track)
static void UnmarkLoadedODFlag()
resets a flag that is set if we have loaded some OD blockfiles from PCM.
std::vector< ODTask * > mTasks
int GetTotalNumTasks()
Get Total Number of Tasks.
bool CanMergeWith(ODWaveTrackTaskQueue *otherQueue)
returns whether or not this queue's task list and another's can merge together, as when we make two m...
std::unique_ptr< ODCondition > mQueueNotEmptyCond
static std::unique_ptr< ODManager > pMan
A class representing a modular task to be used with the On-Demand structures.
A class representing a modular task to be used with the On-Demand structures.
void Start()
Start the main loop for the manager.
void MergeWaveTrack(const std::shared_ptr< WaveTrack > &track)
static ODLock gODInitedMutex
Abstract base class for an object holding data associated with points on a time axis.
ODTaskThread(ODTask *task)
void Init()
Launches a thread for the manager and starts accepting Tasks.
int CompareNoCaseFileName(const wxString &first, const wxString &second)
wxstring compare function for sorting case, which is needed to load correctly.
static bool HasLoadedODFlag()
returns a flag that is set if we have loaded some OD blockfiles from PCM.
void DecrementCurrentThreads()
Reduces the count of current threads running. Meant to be called when ODTaskThreads end in their own ...
virtual std::shared_ptr< WaveTrack > GetWaveTrack(int i)
static ODManager *(* Instance)()
void ReplaceWaveTrack(Track *oldTrack, const std::shared_ptr< Track > &newTrack)
replace the wavetrack whose wavecache the gui watches for updates
A singleton that manages currently running Tasks on an arbitrary number of threads.
int mMaxThreads
Maximum number of threads allowed out.
void UpdateQueues()
Remove references in our array to Tasks that have been completed/Schedule NEW ones.