Changeset - 1f986f0a72d1
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 16 years ago 2009-07-24 20:30:00
ohnobinki@ohnopublishing.net
struct blendjob*-ized frame_finder()
1 file changed with 63 insertions and 42 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -292,53 +292,74 @@ void frame_num_struct_builder(struct ble
 

	
 

	
 

	
 
// Frame Assigner: matches your computer up with a lovely frame to render
 
// Major issue here, the client needs to know the frame number, AND the job number!
 
int frame_finder(){
 
	int your_frame = 0;  // your_frame is an interger value that will be given to the client as the frame number to render
 
	int finder_jobnum = 0;
 
	int frameset_count = 0; // the frameset number, note* frames in an animation don't start at zero
 
	short int done = 0;
 
	short int priority = 10;
 

	
 
	while(priority >= 1){ // start the scan for the next job with the highest priority, decreases priority before it loops
 
		finder_jobnum = hcfjob + 1; // reset it to start scanning at first uncompleted job for the pass at each priority level
 

	
 
		while(finder_jobnum <= highest_jobnum){  // This keeps increasing the finder_jobnum until it is higher than the highest_jobnum
 
			if(blendjob[finder_jobnum].priority == priority){  // looks for a job with the current priority value
 
				done = 1;									  // notice it starts by looking at the oldest job first
 
				break;
 
			}
 

	
 
			if((done) == 1)  // If it has found a job with the current priority value, it will break out of the loop
 
				break;    // If none is found it goes to the next job to see if it is of the current priority value
 
			else
 
				finder_jobnum++;
 
		} // End of increasing finder_jobnum
 
/**
 
  Frame Finder: matches your computer up with a lovely frame to render
 
  Major issue here, the client needs to know the frame number, AND the job number!
 
  Notice that this function starts by looking at the oldest job first
 

	
 
		if(done == 1) // if job has been found, it lets it out of the priority changer loop
 
			break;
 

	
 
		priority--; // end of decreasing priority
 
	}
 

	
 
	while(your_frame < blendjob[finder_jobnum].total_frames){ // Finds the frameset number with a frame that needs to be rendered
 
		if (blendjob[finder_jobnum].frameset[frameset_count].frame_status == 0)  // If frame that is not assigned has been found, frameset_count is not changed
 
			break;																// and frameset_count is used to give the frame number later in this funciton
 

	
 
		frameset_count++;  // If frame is assigned or done, it goes to next frame
 
  @return 0 success, other: error
 
*/
 
int frame_finder(struct blendjob *head, struct blendjob **job, struct frameset **frame)
 
{
 
  int your_frame;  // your_frame is an interger value that will be given to the client as the frame number to render
 
  
 
  unsigned short int found;
 
  unsigned short int priority;
 
  
 
  struct blendjob *blendjob_ptr;
 
  
 
  found = 0;
 
  while(!found)
 
    {
 
      /* enumerate through priority levels */
 
      for(priority = 10;
 
	  priority > 0
 
	    && !found; 
 
	  priority --)
 
	/* Find the job with the highest priority */
 
	for(blendjob_ptr = head; 
 
	    blendjob_ptr != NULL 
 
	      && !found; 
 
	    blendjob_ptr = blendjob_ptr->next)
 
	  if(blendjob_ptr->priority == priority)
 
	    found = 1;
 
      
 
      if(!found)
 
	{
 
	  fprintf(stderr, "out of jobs to render\n");
 
	  return 1;
 
	}
 

	
 
blendjob[jobnum].frameset[frameset_count].frame_status++; // sets the value of the frame to 2, which means its taken
 

	
 
your_frame = blendjob[jobnum].frameset[frameset_count].frame_num; //  Takes the frameset found in the while statement above, and extracts the frame number from it and assigns it to the int your_frame
 
      
 
      found = 0;
 
      for(your_frame = 0; 
 
	  your_frame < blendjob_ptr->total_frames;
 
	  your_frame ++)
 
	if(blendjob_ptr->frameset[your_frame].frame_status == 0)
 
	  found = 1;
 
      
 
      if(!found)
 
	{
 
	  /* there are no frames left in this job */
 
	  blendjob_ptr->priority --;
 
	  
 
	  /* If that job had no open frames for some reason, run the status report generator so that */
 
	  status_report_generator(&head);
 

	
 
if(your_frame == 0)  // If that job had no open frames for some reason, run the status report generator so that
 
	status_report_generator(blendjobs_head);  //the job priority can be changed to 0
 
	  /* should the job be removed now? */
 
	  fprintf(stderr, "Job %d is finished, this is probably the place to call the job-removal function\n", blendjob_ptr->jobnum);
 
	}
 
    } /* while(!found) */
 
  
 
  fprintf(stderr, "Missing apostrophe !!!!!!!!!!!!!!\n"); abort();
 
  /* sets the value of the frame to 1, which means its taken !!!!!! MISSSING APOSTROPHE!!!!!!! */
 
  blendjob_ptr->frameset[your_frame].frame_status++; 
 
  
 
  blendjob_ptr->frameset[your_frame].start_time = clock();
 

	
 
blendjob[jobnum].frameset[frameset_count].start_time = clock();
 
  *job = blendjob_ptr;
 
  *frame =  &blendjob_ptr->frameset[your_frame];
 

	
 
return your_frame; // your_frame is returned as the frame to be rendered
 
  return 0;
 
}
 

	
 
void blend_frame_watchdog(struct blendjob *blendjob_head)
0 comments (0 inline, 0 general)