bool PrivateDecoderCrystalHD::Reset(void)
{
    if (m_fetcher_thread)
    {
        m_fetcher_pause = true;
        int tries = 0;
        while (!m_fetcher_paused && (tries++ < 50))
            usleep(10000);
        if (!m_fetcher_paused)
            LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to pause fetcher thread");
    }

    QMutexLocker lock(&m_decoded_frames_lock);
    free_frame(m_frame);
    m_frame = NULL;

    for (int i = 0; i < m_decoded_frames.size(); i++)
        free_frame(m_decoded_frames[i]);
    m_decoded_frames.clear();

    for (int i = 0; i < m_packet_buffers.size(); i++)
        free_buffer(m_packet_buffers[i]);
    m_packet_buffers.clear();

    if (!m_device)
        return true;

    if (m_device_type != BC_70015)
    {
        INIT_ST;
        st = DtsFlushInput(m_device, 2);
        CHECK_ST;
    }
    return true;;
}
示例#2
0
/* Release all memory allocated for graphics frame */
void free_drawing_resource(void) {
	free_frame(&g_frame[0]);
	free_frame(&g_frame[1]);
	free_frame(&g_temp_frame);
	g_frame_group[0] = NULL;
	g_frame_group[1] = NULL;
    vm_timer_delete_precise(g_timer_id);
}
示例#3
0
void free_page_structure(uintptr_t vaddress, uintptr_t cr3) {
    v_address_t va;
    memcpy(&va, &vaddress, 8);

    puint_t* pml4 = (puint_t*)ALIGN(physical_to_virtual(cr3));
    if (!PRESENT(pml4[va.pml])) {
        return;
    }

    puint_t* pdpt = (puint_t*)ALIGN(physical_to_virtual(pml4[va.pml]));

    if (!PRESENT(pdpt[va.directory_ptr])) {
        return;
    }

    puint_t* pdir = (puint_t*)ALIGN(physical_to_virtual(pdpt[va.directory_ptr]));

    if (!PRESENT(pdir[va.directory])) {
        return;
    }

    puint_t* pt = (puint_t*)ALIGN(physical_to_virtual(pdir[va.directory]));
    pt[va.table] = 0; // free table entry

    // check for other table entries
    for (size_t i=0; i<512; i++) {
        if (pt[i] != 0)
            return;
    }

    free_frame(ALIGN(pdir[va.directory]));
    pdir[va.directory] = 0; // free pt address

    // check for other pdir adresses
    for (size_t i=0; i<512; i++) {
        if (pdir[i] != 0)
            return;
    }

    free_frame(ALIGN(pdpt[va.directory_ptr]));
    pdpt[va.directory_ptr] = 0; // free pdir address

    for (size_t i=0; i<512; i++) {
        if (pdpt[i] != 0)
            return;
    }

    free_frame(ALIGN(pml4[va.pml]));
    pml4[va.pml] = 0; // free pdpt address
}
示例#4
0
文件: frame.c 项目: JamesLinus/levos6
uintptr_t mm_free_pages(void *p, int n)
{
    while(n--)
        free_frame(p -= 0x1000);

    return 0;
}
示例#5
0
frame_t * evict_frame_using_aging(void)
{
	intmask mask = disable();
	//LOG(" Evict frame using AGING");
	print_fifo_list();
	frame_t * frame = fifo_head;
	frame_t * selected = NULL;
		while(frame != NULL){
			if(frame->type == PAGE)
			{
				if(selected == NULL)
					selected = frame;
				else if(frame->age < selected ->age)
				{
					selected = frame;
				}
			}
			frame = frame->next;
		}
		if(selected != NULL)
		{
			//LOG("Free frame %d", frame->id);
			evict_from_fifo_list(selected);
			free_frame(selected);
		}
		restore(mask);
		//kprintf("\n Evicted id %d", selected ->id);
		return selected;
}
void VideoStream::maintenance()
{
    uint32_t mm_time = _client.get_mm_time();

    remove_dead_frames(mm_time);
    if (!_update_mark && !_update_time && _frames_head != _frames_tail) {
        VideoFrame* tail = &_frames[frame_slot(_frames_tail)];

        ASSERT(tail->compressed_data);
        uint8_t* data = tail->compressed_data;
        uint32_t length = tail->compressed_data_size;
        int got_picture = 0;

        got_picture =_mjpeg_decoder->decode_data(data, length);
        if (got_picture) {
#ifdef WIN32
            _canvas.put_image(_dc, _pixmap, _dest, _clip);
#else
            _canvas.put_image(_pixmap, _dest, _clip);
#endif
            if (is_time_to_display(mm_time, tail->mm_time)) {
                _update_mark = _channel.invalidate(_dest, true);
                Platform::yield();
            } else {
                _update_time = tail->mm_time;
                _channel.stream_update_request(_update_time);
            }
        }
        free_frame(_frames_tail++);
    }
}
示例#7
0
文件: kheap.c 项目: itravers/PanicOS
/* Reduce the size of a given heap. */
static u32int contract(u32int new_size, heap_t *heap){
  // Sanity check. Make sure new heap size isn't bigger than total heap space.
  ASSERT(new_size < heap->end_address-heap->start_address);

  // Get the nearest following page boundary.
  if (new_size&0x1000){
    new_size &= 0x1000;
    new_size += 0x1000;
  }

  // Don't contract too far!
  if (new_size < HEAP_MIN_SIZE){
    new_size = HEAP_MIN_SIZE;
  }

  u32int old_size = heap->end_address-heap->start_address;
  u32int i = old_size - 0x1000;
  
  //Loop through heap from end and free frames
  while (new_size < i){
    free_frame(get_page(heap->start_address+i, 0, kernel_directory));
    i -= 0x1000;
  }

  heap->end_address = heap->start_address + new_size;
  return new_size;
}
示例#8
0
文件: id3v24.c 项目: suaff/audacious
static void free_frame_list (GList * list)
{
    for (GList * node = list; node; node = node->next)
        free_frame (node->data);

    g_list_free (list);
}
示例#9
0
static void tilem_animation_finalize(GObject *obj)
{
	TilemAnimation *anim = TILEM_ANIMATION(obj);
	TilemAnimFrame *frm;

	g_return_if_fail(TILEM_IS_ANIMATION(anim));

	while (anim->start) {
		frm = anim->start;
		anim->start = frm->next;
		free_frame(frm);
	}

	anim->start = anim->end = NULL;

	if (anim->temp_buffer)
		tilem_lcd_buffer_free(anim->temp_buffer);
	anim->temp_buffer = NULL;

	if (anim->palette)
		tilem_free(anim->palette);
	anim->palette = NULL;

	if (anim->static_pixbuf)
		g_object_unref(anim->static_pixbuf);
	anim->static_pixbuf = NULL;

	if (G_OBJECT_CLASS(tilem_animation_parent_class)->finalize)
		(*G_OBJECT_CLASS(tilem_animation_parent_class)->finalize)(obj);
}
示例#10
0
/**
 * Envoi d'une trame a tous les joueurs encore connectes (broadcast)
 * S'il y'a un probleme d'envoi, le joueur concerne est deconnecte et desinscrit
 * 
 * @param the_players Liste des joueurs
 * @param frame Trame a envoyer
 */
void send_broadcast(Players the_players, Frame frame) {
    size_t i = 0;
    Player current_player;
    
    /*debug*/
    print_frame(frame);
    
    for(i=0; i < the_players->size; i++) {
        current_player = the_players->player[i];
        
        /* Envoi de la trame a tous les joueurs inscrits 
         * Desinscription et deconnexion du joueur en cas de deconnexion brutale 
         */
        if(current_player->is_registered) {
            if(send_frame(current_player->sock, frame) == ERROR) {
                /*debug*/
                printf("Suppression d'un joueurs");
                
                remove_player_by_sock(current_player->sock, the_players, 1);
            }
        }
    }
     
    free_frame(frame);
}
示例#11
0
文件: kheap.cpp 项目: zerotri/Amarant
static uint32_t contract(uint32_t new_size, heap_t *heap)
{
    // Sanity check.
    if(new_size < heap->end_address-heap->start_address)
		return 0;

    // Get the nearest following page boundary.
    if (new_size&0x1000)
    {
        new_size &= 0x1000;
        new_size += 0x1000;
    }

    // Don't contract too far!
    if (new_size < HEAP_MIN_SIZE)
        new_size = HEAP_MIN_SIZE;

    uint32_t old_size = heap->end_address-heap->start_address;
    uint32_t i = old_size - 0x1000;
    while (new_size < i)
    {
        free_frame(get_page(heap->start_address+i, 0, kernel_directory));
        i -= 0x1000;
    }

    heap->end_address = heap->start_address + new_size;
    return new_size;
}
示例#12
0
文件: frame.c 项目: olivermg/owlisp
frame_t* shrink_global_frame()
{
  frame_t* old_frame = global_frame;
  global_frame = global_frame->parent;
  free_frame( old_frame );

  return global_frame;
}
示例#13
0
int main() {
	char errbuf[PCAP_ERRBUF_SIZE];
	pcap_t *inject_int_desc = NULL;
	struct frame *frame = NULL;
	char *src_mac = "00:01:02:03:04:05";
	char *dst_mac = "ff:ff:ff:ff:ff:ff";
	char *src_ip = "208.96.55.76";
	char *dst_ip = "208.96.55.77";
	uint16_t etype = ETYPE_IP;
	int i, count = 100;

	/* create frame */
	if (!(frame = create_frame(1500))) {
		exit(1);
	}

	/* Create ip packet exit on failure */	
	if (!ipv4_simple_create(frame, 0, 0, DF, 0, 64, 1, src_ip, dst_ip)) {
		free_frame(&frame);
		exit(2);
	}
	
	/* Create ether header, exit on failure */
	if (!etherii_simple_create(frame, dst_mac, src_mac, etype)) {
		free_frame(&frame);
		exit(3);
	}

	/* open interface for injection via libpcap */
	if ((inject_int_desc = pcap_open_live("br0", BUFSIZ, 1, -1, errbuf)) == NULL)
	{
		printf ("\nError: %s\n", errbuf );
		free_frame(&frame);
		exit(1);
	}

	/* do actual injection */
	for (i = 0; i < count; ++i) {
		pcap_inject(inject_int_desc, frame->payload, frame->size);
	}
	pcap_close(inject_int_desc);
	
	free_frame(&frame);
	exit(0);

}
示例#14
0
void prepare_eval (control_par *cpar, int *n_fix) {
    int     i_img, i, filenumber, step_shake, count = 0;
	double  dummy;
    sequence_par *seq_par;
    FILE *fpp;
    
    int part_pointer; /* Holds index of particle later */
    
    frame frm;
    frame_init(&frm, cpar->num_cams, MAX_TARGETS);
    
	seq_par = read_sequence_par("parameters/sequence.par", cpar->num_cams);

	fpp = fopen ("parameters/dumbbell.par", "r");
    if (fpp){
        fscanf (fpp, "%lf", &dummy);
		fscanf (fpp, "%lf", &dummy);
	    fscanf (fpp, "%lf", &dummy);
	    fscanf (fpp, "%lf", &dummy);
		fscanf (fpp, "%d", &step_shake);
        fclose (fpp);
    }

    for (filenumber = seq_par->first; filenumber <= seq_par->last; \
        filenumber += step_shake)
    {
        read_frame(&frm, "res/db_is", NULL, NULL, seq_par->img_base_name,
            filenumber);

		for (i = 0; i < frm.num_parts; i++) {
            for (i_img = 0; i_img < cpar->num_cams; i_img++) {
                part_pointer = frm.correspond[i].p[i_img];
                if (part_pointer != CORRES_NONE) {
                    pix[i_img][count].x = frm.targets[i_img][part_pointer].x;
                    pix[i_img][count].y = frm.targets[i_img][part_pointer].y;
                } else {
                    pix[i_img][count].x = -999;
                    pix[i_img][count].y = -999;
                }
                
				if(pix[i_img][count].x>-999 && pix[i_img][count].y>-999){
				   pixel_to_metric (&crd[i_img][count].x, &crd[i_img][count].y,
                       pix[i_img][count].x, pix[i_img][count].y, cpar);
				}
				else{
                   crd[i_img][count].x=-1e10;
				   crd[i_img][count].y=-1e10;
				}
				crd[i_img][count].pnr=count;
			}
			count ++;
		}
	}
    free_frame(&frm);
	nfix=count;
}
int PrivateDecoderCrystalHD::GetFrame(AVStream *stream,
                                      AVFrame *picture,
                                      int *got_picture_ptr,
                                      AVPacket *pkt)
{
    int result = -1;
    if (!stream || !m_device || !picture)
        return result;

    AVCodecContext *avctx = stream->codec;
    if (!avctx || !StartFetcherThread())
        return result;

    if (pkt && pkt->size)
    {
        result = ProcessPacket(stream, pkt);
        if (result < 0)
            return result;
    }

    m_decoded_frames_lock.lock();
    int available = m_decoded_frames.size();
    m_decoded_frames_lock.unlock();
    if (!available)
        return result;

    if (avctx->get_buffer(avctx, picture) < 0)
    {
        LOG(VB_GENERAL, LOG_ERR, LOC +
            QString("%1 decoded frames available but no video buffers.")
                .arg(available));
        return -1;
    }

    m_decoded_frames_lock.lock();
    VideoFrame *frame = m_decoded_frames.takeLast();
    m_decoded_frames_lock.unlock();

    *got_picture_ptr = 1;
    picture->reordered_opaque = (int64_t)(frame->timecode /
                                          av_q2d(stream->time_base) / 10000000);
    LOG(VB_TIMESTAMP, LOG_DEBUG, LOC +
        QString("decoder output timecode %1 ms (pts %2)")
            .arg(frame->timecode / 10000).arg(picture->reordered_opaque));
    picture->interlaced_frame = frame->interlaced_frame;
    picture->top_field_first  = frame->top_field_first;
    picture->repeat_pict      = frame->repeat_pict;
    copy((VideoFrame*)picture->opaque, frame);
    if (frame->priv[0] && frame->qstride)
    {
        memcpy(picture->atsc_cc_buf, frame->priv[0], frame->qstride);
        picture->atsc_cc_len = frame->qstride;
    }
    free_frame(frame);
    return result;
}
void VideoStream::remove_dead_frames(uint32_t mm_time)
{
    while (_frames_head != _frames_tail) {
        if (int(_frames[frame_slot(_frames_tail)].mm_time - mm_time) >= MAX_UNDER) {
            return;
        }
        free_frame(_frames_tail);
        _frames_tail++;
    }
}
示例#17
0
void kma_free(void* ptr, kma_size_t size)
{

	kma_frame* ptr_to_frame = ptr - sizeof(kma_frame);

	//fprintf(stdout, "request, free: %p\n", ptr_to_frame);

	free_frame(ptr_to_frame);
	//print_debug();
}
static void free_oldest_frame (FragmentProtoAssembler *o)
{
    ASSERT(!LinkedList1_IsEmpty(&o->frames_used))
    
    // obtain oldest frame (first on the list)
    LinkedList1Node *list_node = LinkedList1_GetFirst(&o->frames_used);
    ASSERT(list_node)
    struct FragmentProtoAssembler_frame *frame = UPPER_OBJECT(list_node, struct FragmentProtoAssembler_frame, list_node);
    
    // free frame
    free_frame(o, frame);
}
void VideoStream::drop_one_frame()
{
    ASSERT(MAX_VIDEO_FRAMES > 2 && (_frames_head - _frames_tail) == MAX_VIDEO_FRAMES);
    int frame_index = _frames_head - _kill_mark++ % (MAX_VIDEO_FRAMES - 2) - 2;

    free_frame(frame_index);

    while (frame_index != _frames_tail) {
        --frame_index;
        _frames[frame_slot(frame_index + 1)] = _frames[frame_slot(frame_index)];
    }
    _frames_tail++;
}
示例#20
0
void free_window(window *Window)
{
    uint32_t i;
    if (Window)
    {
        for (i = 0; i < Window->size && Window->Frame[i]; i++)
        {
            free_frame(Window->Frame[i]);
        }
        free(Window->Frame);
        free(Window);
    }
}
示例#21
0
void page_directory_frame_remove_mapping_for_pid(pid32 pid)
{
	intmask mask = disable();
	struct	procent	*prptr;		/* Ptr to process table entry	*/
	struct procent *prptrNull;
	prptr = &proctab[pid];
	prptrNull = &proctab[0];
	pd_t * pd = prptr->pagedir;
	int pdframe = PA_TO_FRAMEID((uint32)pd);
	free_frame(&frames[pdframe]);
	//kprintf(" REM MAPPING dir from %d: 0x%08x to %d: 0x%08x",pid, prptr->pagedir, 0, prptrNull->pagedir);
	//kprintf(" tried to kill the page directory");
	restore(mask);
	return;
}
示例#22
0
文件: page.c 项目: henryxlau/OS
static bool file_load(uint8_t *kpage, struct page *p)
{
	file_seek(p->f, p->ofs);

	if(file_read(p->f, kpage, p->read) != (int) p->read)
	{
		free_frame(kpage);
		return false;
	}
	else
	{
		memset(kpage + p->read, 0, p->zero);
		return true;
	}
}
示例#23
0
/**
 * Repondre a une requete d'un joueur
 * NOTA: cette fonction est bloquante et attend une requete d'un joueur 
 * 
 * @param sock Socket du joueur ayant envoye une requete
 * @param the_players Liste des joueurs
 * @return Resultat de l'echange compose de 2 champs:
 *         - type: correspond le plus souvent au type de trame
 *                 ou a une fin de connexion
 *         - content: correspond au contenu brut de l'echange, a savoir
 *                    une structure Player, un identifiant ou un ordre.
 */
Result* respond(int sock, Players the_players) {
    Result* result = NULL;
    Frame frame = recv_frame(sock);
    
    /*debug*/
    print_frame(frame);
    
    if(check_frame(frame) == SUCCESS) {
        
        /* Deconnexion du joueur */
        if(frame->pennant == SPECIAL_FRAME) {
            result = malloc(sizeof(Result));
            remove_player_by_sock(sock, the_players, 1);
            
            result->type = NOT_CONNECTED;
            result->content = NULL;
        
        /* Traitement du serveur a la requete du client */
        } else {
            switch(frame->id) {      
                case Connect:
                    result = respond_connect(sock, the_players, frame);
                    break;

                case Initiate:
                    result = respond_initiate(sock, the_players, frame);
                    break;

                case Order:
                    result = respond_order(sock, the_players, frame);
                    break;
                
                /* Type de trame inconnu ou non autorisee du protocole 
                 * @todo si type de trame existant, renvoyer une erreur specifique
                 */
                default:
                    PRINT_UNKNOWN_FRAME_TYPE(frame->id);
                    break;
            }
        }
    }
    
    if(frame != NULL) {
        free_frame(frame);
    }
    
    return result;
}
示例#24
0
文件: heap.c 项目: orodley/studix
size_t contract(Heap *heap, size_t new_size)
{
	// Sanity check.
	ASSERT(heap->start_addr + new_size < heap->end_addr);

	new_size = align_up(new_size);
	if (new_size < HEAP_MIN_SIZE)
		new_size = HEAP_MIN_SIZE;

	size_t old_size = heap->end_addr - heap->start_addr;
	for (size_t i = old_size - PAGE_SIZE; i > new_size; i -= PAGE_SIZE)
		free_frame(get_page(heap->start_addr + i, 0, kernel_dir));

	heap->end_addr = heap->start_addr + new_size;
	return new_size;
}
示例#25
0
void inverted_pagetable_remove_mappings_for_pid(pid32 pid)
{
	intmask mask = disable();
	int i;
	frame_t * frame = NULL;
	for(i = 0; i < NFRAMES; i++)
	{
		frame = &frames[i];
		if(frame->type == FREE)
			continue;
		else if(frame->pid == pid && frame->type == VPTBL)
			free_frame(frame);
	}
	restore(mask);
	return;

}
示例#26
0
/**
 * Repondre a une requete Initiate
 * @param sock Socket du joueur ayant envoye une demande de connexion
 * @param the_players Liste des joueurs
 * @param recv_frame Trame Initiate recue
 * @return Resultat de l'echange (cf. fonction respond pour plus d'informations)
 */
Result* respond_initiate(int sock, Players the_players, Frame frame) {
    /* Compteur persistant de joueurs connectes */
    static uint16_t nb_connected_players = 0;
    
    /* Resultat de l'echange */
    Result* result = NULL;
    
    /* Acquittement de la requete, negatif par defaut  */ 
    Frame ack_frame = create_ack(0);
    
    /* Verification de la requete du client */
    int format_check = ERROR;
    int constraint_check = ERROR;
    
    constraint_check = check_initiate_constraint(sock, nb_connected_players, the_players);
    format_check = check_initiate_format(frame);
    
    /* Traitement de la requete */
    if(constraint_check == SUCCESS && 
           format_check == SUCCESS) {
        
        /* Verification du nom d'application et de la version du protocole */
        if(check_appname(frame->data[0]->string.content) == SUCCESS &&
           check_version(frame->data[1]->string.content) == SUCCESS) {
            
            /* Creation du resultat de l'echange */
            result = malloc(sizeof(Result));
            result->type = Initiate;
            result->content = NULL;
            
            /* Connexion du nouveau joueur */
            the_players->player[nb_connected_players]->sock = sock;
            the_players->player[nb_connected_players]->is_connected = 1;
            
            nb_connected_players++;
            free_frame(ack_frame);
            ack_frame = create_ack(1);
        }
    }
    
    /* Envoi de l'acquittement */
    send_frame(sock, ack_frame);
    
    return result;
}
示例#27
0
文件: pmm.c 项目: Nov11/jamesos
void init_pmm(u32int start, u32int end)
{	
	//32MB最多(25) 那就是8k个页(13 + 12) 256个u32int(8 + 5 + 12)
	//一个页面足够存了
	pmm_location = align(start);
	frames = (u32int*)pmm_location;
	memset(frames, 0, 0x1000);
	pmm_location += 0x1000;
	u32int iter;
	for(iter = 0; iter < pmm_location; iter += 0x100){
		set_frame(iter);
		nframes++;
	}
	for(iter = pmm_location; iter < end; iter += 0x100){
		free_frame(iter);
		nframes++;
	}
}
示例#28
0
static void check_unpersistent() {
  char dirpath[512] = {0};
  struct list_head frame_head;
  struct frame_info *finfo;
  frame_t *frame;

  INIT_LIST_HEAD(&frame_head);

  sprintf(dirpath, "%s/%s", config.datadir, QNAME);

  // unpersist frame
  CU_ASSERT(unpersist_queue_context(dirpath, &frame_head) == RET_SUCCESS);
  CU_ASSERT_FATAL(! list_empty(&frame_head));

  finfo = list_first_entry(&frame_head, struct frame_info, list);
  CU_ASSERT_FATAL(finfo != NULL);

  // check unpersistent frame
  frame = finfo->frame;
  CU_ASSERT_FATAL(frame != NULL);
  CU_ASSERT(! list_empty(&frame->h_attrs));
  CU_ASSERT(! list_empty(&frame->h_data));
  CU_ASSERT(frame->size == 38);

  free_frame_info(finfo);

  // update sent index
  CU_ASSERT(update_index_sent(QNAME, frame) == RET_SUCCESS);

  free_frame(frame);
  sleep(1);

  INIT_LIST_HEAD(&frame_head);

  // unpersist again
  CU_ASSERT(unpersist_queue_context(dirpath, &frame_head) == RET_SUCCESS);
  CU_ASSERT_FATAL(list_empty(&frame_head));

  CU_ASSERT(unpersist() == RET_SUCCESS);
}
示例#29
0
frame_t * evict_frame_using_fifo(void)
{
	intmask mask = disable();
	//LOG(" Evict frame using FIFO");
	frame_t * frame = fifo_head;
	while(frame != NULL){
		if(frame->type == PAGE)
		{
			evict_from_fifo_list(frame);
			break;
		}
		frame = frame->next;
	}
	if(frame != NULL)
	{
		//LOG("Free frame %d", frame->id);
		free_frame(frame);
	}
	restore(mask);
	return frame;

}
示例#30
0
文件: pmm.c 项目: Nov11/jamesos
//without paging, memory alloc by pmm_alloc_page
//is in use until os quit,so
//they won't need to be freed
void pmm_free_page(u32int p)
{
	/*if(pmm_paging_active == 0){
		PANIC("no free until enabled paging");
	}
	
	if(p < pmm_location){
		return;
	}
	
	if(pmm_stack_max <= pmm_stack_loc){
		map(pmm_stack_max, p, PAGE_PRESENT | PAGE_WRITE);
		pmm_stack_max += 4096;
		//prt("not likely be here");
		return;
	}
	
	u32int* stack = (u32int*)pmm_stack_loc;
	*stack = p;
	pmm_stack_loc += sizeof(u32int);	
	*/
	free_frame(p);
}