Exemple #1
0
void MainIndexes::run()
{
	while(!done)
	{
// Wait for new assets to be released
		input_lock->lock("MainIndexes::run 1");
		if(done) return;
		interrupt_lock->lock("MainIndexes::run 2");
		load_next_assets();
		interrupt_flag = 0;






// test index of each asset
		MainProgressBar *progress = 0;
		for(int i = 0; i < current_assets.total && !interrupt_flag; i++)
		{
			Asset *current_asset = current_assets.values[i];
//printf("MainIndexes::run 3 %s %d %d\n", current_asset->path, current_asset->index_status, current_asset->audio_data);

			if(current_asset->index_status == INDEX_NOTTESTED && 
				current_asset->audio_data)
			{





// Doesn't exist if this returns 1.
				if(indexfile->open_index(current_asset))
				{
// Try to create index now.
					if(!progress)
					{
						if(mwindow->gui) mwindow->gui->lock_window("MainIndexes::run 1");
						progress = mwindow->mainprogress->start_progress(_("Building Indexes..."), 1);
						if(mwindow->gui) mwindow->gui->unlock_window();
					}

//printf("MainIndexes::run 5 %p %s\n", current_asset, current_asset->path);

					indexfile->create_index(current_asset, progress);
//printf("MainIndexes::run 6 %p %s\n", current_asset, current_asset->path);
					if(progress->is_cancelled()) interrupt_flag = 1;
//printf("MainIndexes::run 7 %p %s\n", current_asset, current_asset->path);
				}
				else
// Exists.  Update real thing.
				{
//printf("MainIndexes::run 8\n");
					if(current_asset->index_status == INDEX_NOTTESTED)
					{
						current_asset->index_status = INDEX_READY;
						if(mwindow->gui) mwindow->gui->lock_window("MainIndexes::run 2");
						mwindow->edl->set_index_file(current_asset);
						if(mwindow->gui) mwindow->gui->unlock_window();
					}
					indexfile->close_index();
				}


//printf("MainIndexes::run 8\n");
			}
//printf("MainIndexes::run 9\n");
		}

		if(progress)     // progress box is only created when an index is built
		{
			if(mwindow->gui) mwindow->gui->lock_window("MainIndexes::run 3");
			progress->stop_progress();
			delete progress;
			if(mwindow->gui) mwindow->gui->unlock_window();
			progress = 0;
		}






		interrupt_lock->unlock();
	}
}