Exemple #1
0
void
StreamClass_Destruction(StreamClass *t)
{
	LIST_TYPE(StreamComponent) *comp;
	LIST_TYPE(StreamComponent) *comp_tail;
	RootClass *r;

	verbose("StreamClass: %s; Destruction", ExternalReference_name(&t->rootClass.inst.ref));

	/* is it already destroyed */
	if(!t->rootClass.inst.AvailabilityStatus)
		return;

	/* Deactivate it if it is running */
	if(t->rootClass.inst.RunningStatus)
	{
		/* generates an IsStopped event */
		StreamClass_Deactivation(t);
	}

	/* do Destruction of all StreamComponents in the reverse order they appear in the list */
	comp = t->multiplex;
	/* find the tail */
	comp_tail = (comp != NULL) ? comp->prev : NULL;
	comp = comp_tail;
	while(comp)
	{
		/* only do Destruction if it is available */
		if((r = StreamComponent_rootClass(&comp->item)) != NULL
		&& r->inst.AvailabilityStatus)
			StreamComponent_Destruction(&comp->item);
		/* have we reached the head */
		comp = (comp->prev != comp_tail) ? comp->prev : NULL;
	}

	/* RootClass Destruction */

	/*
	 * spec says we should handle caching here
	 * rb-download caches everything
	 */

	free_StreamClassInstanceVars(&t->inst);

	/* generate an IsDeleted event */
	t->rootClass.inst.AvailabilityStatus = false;
	MHEGEngine_generateEvent(&t->rootClass.inst.ref, EventType_is_deleted, NULL);

	return;
}
Exemple #2
0
void
StreamClass_Preparation(StreamClass *t)
{
	LIST_TYPE(StreamComponent) *comp;

	verbose("StreamClass: %s; Preparation", ExternalReference_name(&t->rootClass.inst.ref));

	/* is it already prepared */
	if(t->rootClass.inst.AvailabilityStatus)
		return;

	default_StreamClassInstanceVars(t, &t->inst);

	/* do Activation of each initially active StreamComponent */
	comp = t->multiplex;
	while(comp)
	{
		if(StreamComponent_isInitiallyActive(&comp->item))
			StreamComponent_Activation(&comp->item);
		comp = comp->next;
	}

	/* finish the RootClass Preparation */
	t->rootClass.inst.AvailabilityStatus = true;

	/* generate IsAvailable event */
	MHEGEngine_generateEvent(&t->rootClass.inst.ref, EventType_is_available, NULL);

	/* generate an asynchronous ContentAvailable event */
	MHEGEngine_generateAsyncEvent(&t->rootClass.inst.ref, EventType_content_available, NULL);

	return;
}
Exemple #3
0
L4_ThreadId_t thread_new(AddrSpace_t *space)
{
    assert (space != NULL);

    L4_Word_t tno;
    L4_ThreadId_t tid;
    L4_ThreadId_t space_spec;
    L4_Word_t utcb_location;
    slab_t *sb;
    list_t *li;
    thread_t *this;

    mutex_lock(&thrlock);
    tno = threadno_find_free(bitmap, MAX_TASKS);
    if (!tno) {
        mutex_unlock(&thrlock);
        return L4_nilthread;
    }

    tid = L4_GlobalId(tno, 1);
    utcb_location = UTCB_AREA_LOCATION;

    space_spec = space->tid;
    tno = threadno_find_free(space->threads, MAX_THREADS_PER_TASK);
    if (!tno) {
        mutex_unlock(&thrlock);
        return L4_nilthread;
    }
    utcb_location += tno * UTCB_SIZE;

    sb = slab_alloc(&thrpool);
    if (!sb) {
        mutex_unlock(&thrlock);
        return L4_nilthread;
    }
    
    if (FALSE == (L4_ThreadControl(tid, space_spec, tid, space->pager, (void *) utcb_location))) {
        slab_free(&thrpool, sb);
        mutex_unlock(&thrlock);
        return L4_nilthread;
    }

    li = LIST_TYPE(sb->data);
    this = (thread_t *) li->data;
    list_push(&thread_list, li);

    this->tid = tid;
    this->space = space;
    this->index = tno;
    this->creation = L4_SystemClock();

    threadno_alloc(bitmap, L4_ThreadNo(tid));
    threadno_alloc(space->threads, tno);
    mutex_unlock(&thrlock);
    return tid;
}
Exemple #4
0
void
TextClass_render(TextClass *t, MHEGDisplay *d, XYPosition *pos, OriginalBoxSize *box)
{
	XYPosition ins_pos;
	OriginalBoxSize ins_box;
	LIST_TYPE(MHEGTextElement) *element;
	bool tabs;

	verbose("TextClass: %s; render", ExternalReference_name(&t->rootClass.inst.ref));

	if(!intersects(pos, box, &t->inst.Position, &t->inst.BoxSize, &ins_pos, &ins_box))
		return;

	MHEGDisplay_setClipRectangle(d, &ins_pos, &ins_box);

	/* draw the background */
	MHEGDisplay_fillRectangle(d, &ins_pos, &ins_box, &t->inst.BackgroundColour);

	/* layout the text if not already done */
	if(t->inst.element == NULL)
	{
		t->inst.element = MHEGFont_layoutText(&t->inst.Font, &t->inst.TextColour, &t->inst.TextData, &t->inst.BoxSize,
						      t->horizontal_justification, t->vertical_justification,
						      t->line_orientation, t->start_corner, t->text_wrapping);
	}

	/* tabs are treated as spaces if horizontal justification is not Justification_start */
	tabs = (t->horizontal_justification == Justification_start);

	/* draw each text element */
	element = t->inst.element;
	while(element)
	{
		MHEGDisplay_drawTextElement(d, &t->inst.Position, &t->inst.Font, &element->item, tabs);
		element = element->next;
	}

	MHEGDisplay_unsetClipRectangle(d);

	return;
}
Exemple #5
0
void
StreamClass_Deactivation(StreamClass *t)
{
	LIST_TYPE(StreamComponent) *comp;
	RootClass *r;

	verbose("StreamClass: %s; Deactivation", ExternalReference_name(&t->rootClass.inst.ref));

	/* are we already deactivated */
	if(!t->rootClass.inst.RunningStatus)
		return;

	/* disown all our StreamComponents */
	comp = t->multiplex;
	while(comp)
	{
		StreamComponent_registerStreamClass(&comp->item, NULL);
		comp = comp->next;
	}

	/* stop playing all active StreamComponents */
	MHEGStreamPlayer_stop(&t->inst.player);
	comp = t->multiplex;
	while(comp)
	{
		if((r = StreamComponent_rootClass(&comp->item)) != NULL
		&& r->inst.RunningStatus)
			StreamComponent_stop(&comp->item, &t->inst.player);
		comp = comp->next;
	}

	/* multiplex is now stopped */
	MHEGEngine_generateAsyncEvent(&t->rootClass.inst.ref, EventType_stream_stopped, NULL);

	/* finish our Deactivation */
	t->rootClass.inst.RunningStatus = false;
	MHEGEngine_generateEvent(&t->rootClass.inst.ref, EventType_is_stopped, NULL);

	return;
}
Exemple #6
0
void
StreamClass_Activation(StreamClass *t)
{
	LIST_TYPE(StreamComponent) *comp;
	RootClass *r;
	OctetString *service;

	verbose("StreamClass: %s; Activation", ExternalReference_name(&t->rootClass.inst.ref));

	/* RootClass Preparartion */
	/* is it already activated */
	if(t->rootClass.inst.RunningStatus)
		return;

	/* has it been prepared yet */
	if(!t->rootClass.inst.AvailabilityStatus)
	{
		/* generates an IsAvailable event */
		StreamClass_Preparation(t);
	}

	/* assume default is "rec://svc/cur", ie current channel */
	if(t->have_original_content
	&& (service = ContentBody_getReference(&t->original_content)) != NULL)
	{
		/*
		 * service can be:
		 * "dvb://<original_network_id>.[<transport_stream_id>].<service_id>"
		 * "rec://svc/def" - use the service we are downloading the carousel from
		 * "rec://svc/cur" - use the current service
		 * this will be the same as "def" unless SetData has been called on the StreamClass
		 * "rec://svc/lcn/X" - use logical channel number X (eg 1 for BBC1, 3 for ITV1, etc)
		 */
		if(OctetString_strncmp(service, "dvb:", 4) == 0)
		{
			MHEGStreamPlayer_setServiceID(&t->inst.player, si_get_service_id(service));
		}
		else if(OctetString_strncmp(service, "rec://svc/lcn/", 14) == 0)
		{
/* TODO */
printf("TODO: StreamClass: service='%.*s'\n", service->size, service->data);
		}
		else if(OctetString_strcmp(service, "rec://svc/def") == 0)
		{
			/* use the service ID we are currently tuned to */
			MHEGStreamPlayer_setServiceID(&t->inst.player, -1);
		}
		/* leave player's service ID as it is for "rec://svc/cur" */
		else if(OctetString_strcmp(service, "rec://svc/cur") != 0)
		{
			error("StreamClass: unexpected service '%.*s'", service->size, service->data);
		}
	}

	/* start playing all active StreamComponents */
	comp = t->multiplex;
	while(comp)
	{
		if((r = StreamComponent_rootClass(&comp->item)) != NULL
		&& r->inst.RunningStatus)
			StreamComponent_play(&comp->item, &t->inst.player);
		comp = comp->next;
	}
	MHEGStreamPlayer_play(&t->inst.player);

	/* multiplex is now playing */
	MHEGEngine_generateAsyncEvent(&t->rootClass.inst.ref, EventType_stream_playing, NULL);

	/* finish our Activation */
	t->rootClass.inst.RunningStatus = true;
	MHEGEngine_generateEvent(&t->rootClass.inst.ref, EventType_is_running, NULL);

	/* now we are fully activated, let our StreamComponents know who they belong to */
	comp = t->multiplex;
	while(comp)
	{
		StreamComponent_registerStreamClass(&comp->item, t);
		comp = comp->next;
	}

	return;
}
Exemple #7
0
AddrSpace_t *task_new(L4_ThreadId_t pager)
{
    L4_Word_t tno;
    L4_ThreadId_t tid;
    L4_ThreadId_t space_spec;
    L4_Word_t utcb_location;
    AddrSpace_t *space = NULL;
    slab_t *sb;
    list_t *li;
    thread_t *this;

    mutex_lock(&thrlock);
    tno = threadno_find_free(bitmap, MAX_TASKS);
    if (!tno) {
        mutex_unlock(&thrlock);
        return NULL;
    }

    tid = L4_GlobalId(tno, 1);
    utcb_location = UTCB_AREA_LOCATION;

    space_spec = tid;

    sb = slab_alloc(&thrpool);
    if (!sb) {
        mutex_unlock(&thrlock);
        return NULL;
    }
    
    if (FALSE == (L4_ThreadControl(tid, space_spec, L4_Myself(), L4_nilthread, (void *) utcb_location))) {
        slab_free(&thrpool, sb);
        mutex_unlock(&thrlock);
        return NULL;
    }

    space = address_space_new(tid, pager);
    if (!space) {
        L4_ThreadControl(tid, L4_nilthread, L4_nilthread, L4_nilthread, (void *) -1);
        slab_free(&thrpool, sb);
        mutex_unlock(&thrlock);
        return NULL;
    } else {
        /* set self space, and the specified pager
         * FIXME - using myself as the scheduler */
        L4_ThreadControl(tid, tid, L4_Myself(), pager, (void *) -1);
    }

    li = LIST_TYPE(sb->data);
    this = (thread_t *) li->data;
    list_push(&thread_list, li);

    this->tid = tid;
    this->space = space;
    this->index = 0;
    this->creation = L4_SystemClock();

    threadno_alloc(bitmap, L4_ThreadNo(tid));
    threadno_alloc(space->threads, 0);
    mutex_unlock(&thrlock);
    return space;
}
Exemple #8
0
#include "ffi_generate_ops.h"
#include "ffi_util.h"
#include "ffi_node_defines.h"
#include "ffi_generate_ops.h"
#include "ffi_offset_table.h"
#include "ffi_parser_util.h"
#include "ffi_dstru.h"

#include <stdio.h>

#define DEBUG

const char *TYPE_STRING_TAB[] = { LIST_TYPE(GENERATE_STRING) };
const char *OPERATION_STRING_TAB[] = { FFI_BYTECODE(GENERATE_STRING) };
const char *NONTERMINAL_STRING_TAB[] = { LIST_NTYPE(GENERATE_STRING) };
const char *DSTRU_STRING_TAB[] = { DYN_S_TYPE(GENERATE_STRING) };
const char *FLAGS_STRING_TAB[] = { OFFSET_TABLE_FLAG(GENERATE_STRING) };

void emit_human(struct ffi_instruction_obj *ins){
    int i;

#ifdef DEBUG
    printf("Insptr: %p, second check: %p\n", ins, ins->instructions[0].value);
#endif


    for (i=0; i<ins->instruction_count; i++)
        if(ins->instructions[i].operation)
            printf("[op: %16s | type: %13s | value: %8s]\n", 
                OPERATION_STRING_TAB[ins->instructions[i].operation],
                TYPE_STRING_TAB[ins->instructions[i].type],