static struct pbuf_node *create_new_pnode(rtp_packet * pkt) { struct pbuf_node *tmp; perf_record(UVP_CREATEPBUF, pkt->ts); tmp = malloc(sizeof(struct pbuf_node)); if (tmp != NULL) { tmp->magic = PBUF_MAGIC; tmp->nxt = NULL; tmp->prv = NULL; tmp->decoded = 0; tmp->rtp_timestamp = pkt->ts; tmp->mbit = pkt->m; gettimeofday(&(tmp->arrival_time), NULL); gettimeofday(&(tmp->playout_time), NULL); /* Playout delay... should really be adaptive, based on the */ /* jitter, but we use a (conservative) fixed 32ms delay for */ /* now (2 video frames at 60fps). */ tv_add(&(tmp->playout_time), 0.032); tmp->cdata = malloc(sizeof(struct coded_data)); if (tmp->cdata != NULL) { tmp->cdata->nxt = NULL; tmp->cdata->prv = NULL; tmp->cdata->seqno = pkt->seq; tmp->cdata->data = pkt; } else { free(pkt); free(tmp); return NULL; } } else { free(pkt); } return tmp; }
struct video_frame *display_get_frame(struct display *d) { perf_record(UVP_GETFRAME, d); assert(d->magic == DISPLAY_MAGIC); return display_device_table[d->index].func_getf(d->state); }
void display_put_frame(struct display *d, char *frame) { perf_record(UVP_PUTFRAME, frame); assert(d->magic == DISPLAY_MAGIC); display_device_table[d->index].func_putf(d->state, frame); }
//this defines the threaded function which performs the actual //reads and writes to the block device DWORD iomgr_diskmgr() { IOrequest *ptr; char *vidmem = (char*) 0xB8000; DWORD lastjob=0; devmgr_block_desc *myblock; flush_counter=time(); do { ptr=IOmgr_obtainjob(0,0,lastjob); while (IOmgr_pause) { #ifdef DEBUG_IOREADWRITE char *scrptr = (char*)0xB8000; if (*scrptr=='*') *scrptr='+'; else if (*scrptr=='+') *scrptr='='; else if (*scrptr=='=') *scrptr='?'; else *scrptr='*'; #endif }; if (ptr==0){ //Commit writes to the disk if a specified time interval has //been met. if ( (flush_counter - time() > flush_time) || (time() - flush_counter > flush_time ) || forceflush) { forceflush=0; if (shouldflush()) iomgr_flushmgr(); flush_counter=time(); }; continue;}; if (ptr!=0) { #ifdef DEBUG_IOREADWRITE printf("dex32_diskmgr: Job obtained. Processing...\n"); #endif sync_entercrit(&IOrequest_busy); /*Turn of task switching to improve performance*/ //disable_taskswitching(); do { //read or write data to the disk // sigwait=current_process->processid; if (ptr->type==IO_READ) { #ifdef USE_BENCHMARK int pstart = time(); #endif #ifdef DEBUG_READ printf("dex32_diskmgr: Reading block %d..\n",ptr->lowblock); #endif myblock = (devmgr_block_desc*)devmgr_devlist[ptr->deviceid]; devmgr_setcontext(ptr->deviceid); if (myblock->hdr.type!=DEVMGR_BLOCK) { printf("IO ERROR: Device %d is not a block device!\n",ptr->deviceid); } else { #ifdef DEBUG_READ printf("reading %d blocks starting at %d to location 0x%x.\n", ptr->num_of_blocks, ptr->lowblock,ptr->buf); #endif if (myblock->read_block(ptr->lowblock,ptr->buf,ptr->num_of_blocks)) { lastjob=ptr->lowblock; ptr->status=IO_COMPLETE; } else { #ifdef DEBUG_READ printf("io_mgr(): read error?\n"); #endif ptr->status=IO_ERROR; }; #ifdef DEBUG_READ printf("dex32_diskmgr: read block Done..\n"); #endif }; #ifdef USE_BENCHMARK int pstop = time(); perf_record(perf_monwrite,pstop-pstart); #endif } else if (ptr->type==IO_WRITE) { #ifdef DEBUG_IOREADWRITE printf("dex32_diskmgr: Writing block %d to device %d\n",ptr->lowblock,ptr->deviceid); #endif #ifdef USE_BENCHMARK int pstart = time(); #endif //obtain the device descriptor myblock = (devmgr_block_desc*)devmgr_devlist[ptr->deviceid]; devmgr_setcontext(ptr->deviceid); if (myblock->hdr.type!=DEVMGR_BLOCK) { printf("IO ERROR: Device %d is not a block device!\n",ptr->deviceid); } else if (myblock->write_block==0) { printf("IO ERROR: Device %d does not support writes!\n",ptr->deviceid); ptr->status=IO_ERROR; } else if (myblock->write_block(ptr->lowblock,ptr->buf,ptr->num_of_blocks)) { lastjob=ptr->lowblock; ptr->status=IO_COMPLETE; } else ptr->status=IO_ERROR; #ifdef DEBUG_IOREADWRITE printf("dex32_diskmgr: write block Done..\n"); #endif #ifdef USE_BENCHMARK int pstop = time(); perf_record(perf_monread,pstop-pstart); #endif } ptr= IOmgr_obtainjob(0,0,lastjob); } while (ptr!=0); sync_leavecrit(&IOrequest_busy); //enable_taskswitching(); /*Turn on task switiching*/ }; #ifdef DEBUG_IOREADWRITE char *scrptr = (char*)0xB8000; if (*scrptr=='|') *scrptr='/'; else if (*scrptr=='/') *scrptr='-'; else if (*scrptr=='-') *scrptr='\\'; else *scrptr='|'; #endif } while (1); ;};