Esempio n. 1
0
			void bps(uint64_t node, writer_type & bitout) const
			{
				bitout.writeBit(1);

				if ( CartesianTree<key_type>::getLeft(node) != CartesianTree<key_type>::n )
					bps(CartesianTree<key_type>::getLeft(node),bitout);

				if ( CartesianTree<key_type>::getRight(node) != CartesianTree<key_type>::n )
					bps(CartesianTree<key_type>::getRight(node),bitout);

				bitout.writeBit(0);
			}
Esempio n. 2
0
void cmd_mem(struct CONSOLE *cons, unsigned int memtotal)
{
	struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
	char s[30];
	sprintf(s, "total   %dMB", memtotal / (1024 * 1024));
	bps(cons->sht, 8, cons->cur_y, COL8_000084,COL8_FFFFFF,  s, 30);
	cons_newline(cons);
	sprintf(s, "free %dKB", memman_total(memman) / 1024);
	bps(cons->sht, 8, cons->cur_y, COL8_000084,COL8_FFFFFF,  s, 30);
	cons_newline(cons);
	cons_newline(cons);
	return;
}
Esempio n. 3
0
void cmd_dir(struct CONSOLE *cons)
{
	struct FILEINFO *finfo = (struct FILEINFO *) (ADR_DISKIMG + 0x002600);
	int i, j;
	char s[30];
	for (i = 0; i < 224; i++) {
		if (finfo[i].name[0] == 0x00) {
			break;
		}
		if (finfo[i].name[0] != 0xe5) {
			if ((finfo[i].type & 0x18) == 0) {
				sprintf(s, "filename.ext   %7d", finfo[i].size);
				for (j = 0; j < 8; j++) {
					s[j] = finfo[i].name[j];
				}
				s[ 9] = finfo[i].ext[0];
				s[10] = finfo[i].ext[1];
				s[11] = finfo[i].ext[2];
				bps(cons->sht, 8, cons->cur_y, COL8_000084,COL8_FFFFFF,  s, 30);
				cons_newline(cons);
			}
		}
	}
	cons_newline(cons);
	return;
}
Esempio n. 4
0
Shouter::Shouter()
    : Entry() {

    /*
    int vermaj,vermin,verpat;
    shout_version(&vermaj,&vermin,&verpat);
    func("Shouter::Shouter() using libshout version %i.%i.%i",vermaj,vermin,verpat);
    */

    ice = shout_new();

    //  to do this, more of the code must be changed
    //  shout_set_nonblocking(ice,1);

    running = false;
    retry = 0;
    errors = 0;

    /* setup defaults */
    host("localhost");
    ip("127.0.0.1");
    port(8000);
    pass("hackme");
    mount("live");
    login(SHOUT_PROTOCOL_HTTP); // defaults to icecast 2 login now
    name("Streaming with MuSE");
    url("http://muse.dyne.org");
    desc("Free Software Multiple Streaming Engine");
    bps("24000");
    freq("22050");
    channels("1");

    profile_changed = true;
}
Esempio n. 5
0
			::libmaus2::bitio::IndexedBitVector::unique_ptr_type bpsVector() const
			{
				::libmaus2::bitio::IndexedBitVector::unique_ptr_type IB ( new ::libmaus2::bitio::IndexedBitVector(2*n) );
				::libmaus2::bitio::BitWriter8 BW8(IB->A.get());
				bps(BW8);
				BW8.flush();
				IB->setupIndex();
				return UNIQUE_PTR_MOVE(IB);
			}
Esempio n. 6
0
			std::string bps() const
			{
				::std::ostringstream ostr;
				::std::ostream_iterator<uint8_t> ostrit(ostr);
				::libmaus2::bitio::BitWriterStream8 BWS8(ostrit);
				bps(BWS8);
				BWS8.flush();
				return ostr.str();
			}
Esempio n. 7
0
 Real BondFunctions::bps(const Bond& bond,
                         Rate yield,
                         const DayCounter& dayCounter,
                         Compounding compounding,
                         Frequency frequency,
                         Date settlement) {
     InterestRate y(yield, dayCounter, compounding, frequency);
     return bps(bond, y, settlement);
 }
Esempio n. 8
0
void cons_putchar(struct CONSOLE *cons, int chr, char move)
{
	char s[2];
	s[0] = chr;
	s[1] = 0;
	if (s[0] == 0x09) {	// tab
		for (;;) {
			bps(cons->sht, cons->cur_x, cons->cur_y,  COL8_000084, COL8_FFFFFF," ", 1);
			cons->cur_x += 8;
			if (cons->cur_x == 8 + 240) {
				cons_newline(cons);
			}
			if (((cons->cur_x - 8) & 0x1f) == 0) {
				break;	// 32n
			}
		}
	} 
	
	else if (s[0] == 0x0a) {	// enter
		cons_newline(cons);
	} 
	else if (s[0] == 0x0d) 
	{
		
	} 
	
	else {
		bps(cons->sht, cons->cur_x, cons->cur_y,  COL8_000084,COL8_FFFFFF, s, 1);
		if (move != 0) {
			cons->cur_x += 8;
			if (cons->cur_x == 8 + 240) {
				cons_newline(cons);
			}
		}
	}
	return;
}
Esempio n. 9
0
void cmd_type(struct CONSOLE *cons, int *fat, char *cmdline)
{
	struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR;
	struct FILEINFO *finfo = file_search(cmdline + 5, (struct FILEINFO *) (ADR_DISKIMG + 0x002600), 224);
	char *p;
	int i;
	if (finfo != 0) {
		/* ƒtƒ@ƒCƒ‹‚ªŒ©‚‚©‚Á‚œê‡ */
		p = (char *) memman_alloc_4k(memman, finfo->size);
		file_loadfile(finfo->clustno, finfo->size, p, fat, (char *) (ADR_DISKIMG + 0x003e00));
		for (i = 0; i < finfo->size; i++) {
			cons_putchar(cons, p[i], 1);
		}
		memman_free_4k(memman, (int) p, finfo->size);
	} else {
		/* ƒtƒ@ƒCƒ‹‚ªŒ©‚‚©‚ç‚È‚©‚Á‚œê‡ */
		bps(cons->sht, 8, cons->cur_y, COL8_000084,COL8_FFFFFF,  "File not found.", 15);
		cons_newline(cons);
	}
	cons_newline(cons);
	return;
}
Esempio n. 10
0
void cons_runcmd(char *cmdline, struct CONSOLE *cons, int *fat, unsigned int memtotal)
{
	if (strcmp(cmdline, "mem") == 0) {
		cmd_mem(cons, memtotal);
	} else if (strcmp(cmdline, "clear") == 0) {
		cmd_cls(cons);
	} else if (strcmp(cmdline, "ls") == 0) {
		cmd_dir(cons);
	} else if (strncmp(cmdline, "cat ", 4) == 0) {
		cmd_type(cons, fat, cmdline);
	//} else if (strcmp(cmdline, "hlt") == 0) {
	//	cmd_hlt(cons, fat);
	} else if (cmdline[0] != 0) {
		if(cmd_app(cons,fat,cmdline) == 0)
		{
			bps(cons->sht, 8, cons->cur_y,  COL8_000084,COL8_FFFFFF, "Bad command.", 12);
			cons_newline(cons);
			cons_newline(cons);
		}
	}
	return;
}
Esempio n. 11
0
//SV-XXX: rearranged initialisation order to shut up gcc4
Grabber::Grabber()
	: vstart_(0), vstop_(0), 
	  hstart_(0), hstop_(0),
	  threshold_(48),
	  framebase_(0), frame_(0), crvec_(0), ref_(0),
	  inw_(0), inh_(0), outw_(0), outh_(0),
	  target_(0), tx_(0), rover_(0),
	  running_(0), status_(0), delta_(0.)
{
	bps(128);
	fps(1);

	/*XXX*/
	idle_low_ = 2;
	idle_high_ = 2;

	/* CCIR 601 */
	ymin_ = 16;
	ymax_ = 235;
	contrast_ = 1.0;
	for (int i = 0; i < 256; ++i)
		ynorm_[i] = i;
}
Esempio n. 12
0
bool Shouter::apply_profile() {
    char temp[256];
    func("Shouter::apply_profile() on shouter id %i",id);

    bool was_running = running, res = true;
    if(was_running) stop();

    if(shout_set_host(ice,host()))
        error("shout_set_host: %s",shout_get_error(ice));

    if( shout_set_port(ice,port()) )
        error("shout_set_port: %s",shout_get_error(ice));

    if( shout_set_password(ice,pass()) )
        error("shout_set_password: %s",shout_get_error(ice));

    // === fixes the format of the mountpoint
    if((mount())[0]!='/') {
        char tmp[MAX_VALUE_SIZE];
        sprintf(tmp,"/%s",mount());
        mount(tmp);
    }

    // use a .ogg termination on ogg streams
    // this fixes stream codec recognization in xmms et al.
    if(format == SHOUT_FORMAT_VORBIS)
        if(!strstr(mount(),".ogg")) {
            char tmp[MAX_VALUE_SIZE];
            sprintf(tmp,"%s.ogg",mount());
            mount(tmp);
        }


    if( shout_set_mount(ice,mount()) )
        error("shout_set_mount: %s",shout_get_error(ice));

    if( shout_set_name(ice,name()) )
        error("shout_set_name: %s",shout_get_error(ice));

    if( shout_set_url(ice,url()) )
        error("shout_set_url: %s",shout_get_error(ice));

    if( shout_set_description(ice,desc()) )
        error("shout_set_description: %s",shout_get_error(ice));


    //if( shout_set_bitrate(ice,_bps) )
    //  error("shout_set_bitrate: %s",shout_get_error(ice));

    if( shout_set_audio_info(ice, SHOUT_AI_BITRATE, bps()) )
        error("shout_set_audio_info %s: %s",SHOUT_AI_BITRATE, bps());

    if( shout_set_audio_info(ice, SHOUT_AI_SAMPLERATE, freq()) )
        error("shout_set_audio_info %s: %s",SHOUT_AI_SAMPLERATE, freq());

    if( shout_set_audio_info(ice, SHOUT_AI_CHANNELS, channels()) )
        error("shout_set_audio_info %s: %s",SHOUT_AI_CHANNELS, channels());

    func("Shouter audio info: %sKbp/s %sHz %s channels",
         shout_get_audio_info(ice, SHOUT_AI_BITRATE),
         shout_get_audio_info(ice, SHOUT_AI_SAMPLERATE),
         shout_get_audio_info(ice, SHOUT_AI_CHANNELS));

    if( shout_set_protocol(ice,login()) )
        error("shout_set_protocol %i: %s",login(),shout_get_error(ice));

    if( shout_set_format(ice,format) )
        error("shout_set_format: %s",shout_get_error(ice));

    if( shout_set_user(ice,"source") )
        error("shout_set_user: %s",shout_get_error(ice));

    snprintf(temp,256,"%s ver. %s",PACKAGE,VERSION);
    if( shout_set_agent(ice,temp) )
        error("shout_set_agent: %s",shout_get_error(ice));

    snprintf(streamurl,MAX_VALUE_SIZE,
             "http://%s:%i%s",host(),port(),mount());

    if(was_running) {
        res = start();
    }
    profile_changed = false;
    return res;
}
Esempio n. 13
0
			void bps(writer_type & bitout) const
			{
				bps(root,bitout);
			}
Esempio n. 14
0
// the main function 
void HariMain(void)
{
	char *vram;
	int xsize;
	int ysize;
	unsigned int memtotal;
	struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR ;
	struct BOOTINFO *binfo;
	struct SHTCTL *shtctl;
	struct SHEET *sht_back, *sht_mouse, *sht_win,*sht_cons;
	unsigned char *buf_back, buf_mouse[256],*buf_win;
	int i;
	int fifobuf[128];
	char s[40];
	struct FIFO fifo;
	fifo_init(&fifo,128,fifobuf,0);
	static char keytable0[0x80] = {
		0,   0,   '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '^', 0,   0,
		'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '@', '[', 0,   0,   'A', 'S',
		'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', ':', 0,   0,   ']', 'Z', 'X', 'C', 'V',
		'B', 'N', 'M', ',', '.', '/', 0,   '*', 0,   ' ', 0,   0,   0,   0,   0,   0,
		0,   0,   0,   0,   0,   0,   0,   '7', '8', '9', '-', '4', '5', '6', '+', '1',
		'2', '3', '0', '.', 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
		0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
		0,   0,   0,   0x5c, 0,  0,   0,   0,   0,   0,   0,   0,   0,   0x5c, 0,  0
	};
	static char keytable1[0x80] = {
		0,   0,   '!', 0x22, '#', '$', '%', '&', 0x27, '(', ')', '~', '=', '~', 0,   0,
		'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '`', '{', 0,   0,   'A', 'S',
		'D', 'F', 'G', 'H', 'J', 'K', 'L', '+', '*', 0,   0,   '}', 'Z', 'X', 'C', 'V',
		'B', 'N', 'M', '<', '>', '?', 0,   '*', 0,   ' ', 0,   0,   0,   0,   0,   0,
		0,   0,   0,   0,   0,   0,   0,   '7', '8', '9', '-', '4', '5', '6', '+', '1',
		'2', '3', '0', '.', 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
		0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
		0,   0,   0,   '_', 0,   0,   0,   0,   0,   0,   0,   0,   0,   '|', 0,   0
	};
	
	
	init_gdtidt();
	init_pic();
	io_sti();
	
	init_pit(); // timer
	io_out8(PIC0_IMR, 0xf8); /* PIC1 (11111000) irq0 */
	io_out8(PIC1_IMR, 0xef); //11101111 , allow irq12 
	struct TIMER *timer;
	timer = timer_alloc();
	timer_set(timer,50,&fifo,1);
	
	init_keyboard(&fifo,256);	
	// memory test
	memtotal = memtest(0x00400000, 0xbfffffff); // available maxmium  address
	memman_init(memman);
	memman_free(memman,0x00001000,0x0009e000);
	memman_free(memman,0x00400000,memtotal-0x00400000);
		
	init_palette();
	binfo = (struct BOOTINFO *)  0x0ff0;
	xsize = binfo->scrnx;
	ysize = binfo->scrny;
	vram  = binfo->vram;
	// sheet setting
	shtctl = shtctl_init(memman, binfo->vram, binfo->scrnx, binfo->scrny);
	sht_back  = sheet_alloc(shtctl);
	sht_mouse = sheet_alloc(shtctl);
	sht_win   = sheet_alloc(shtctl);
	buf_back  = (unsigned char *) memman_alloc_4k(memman, binfo->scrnx * binfo->scrny);
	buf_win  = (unsigned char *) memman_alloc_4k(memman,160 * 52); // window sheet buffer
	sheet_setbuf(sht_back, buf_back, binfo->scrnx, binfo->scrny, -1);
	sheet_setbuf(sht_mouse, buf_mouse, 16, 16, 99); // col_inv 99
	sheet_setbuf(sht_win, buf_win,144,52,-1);


	/* initlize OS background */
	init_screen(buf_back,xsize,ysize);
	
	int mx,my; // mouse position
	// mouse cursor
	struct MOUSE_DEC mdec;
	enable_mouse(&fifo,512,&mdec); 
	init_mouse_cursor8(buf_mouse,99);
	// window a setting
	make_window8(buf_win,144,52,"task a",1);
	int cursor_x,cursor_c;  // cursor color
	make_textbox8(sht_win, 8,28,128,16,COL8_FFFFFF); // heigth is 16
	cursor_x = 8;
	cursor_c = COL8_FFFFFF;
	mx = (binfo->scrnx - 16) / 2;
	my = (binfo->scrny - 28 - 16) / 2;

	// task block
	struct TASK *curr,*console;
	curr = task_init(memman);
	fifo.task = curr;
	taskrun(curr,1,0); // set to level 1

	// sheet console
	unsigned char *buf_cons;	
	sht_cons = sheet_alloc(shtctl);
	buf_cons = (unsigned char *) memman_alloc_4k(memman, 256*165);
	sheet_setbuf(sht_cons,buf_cons,256,165,-1);
	make_shell(buf_cons,256,165,"console",0);
	//make_textbox8(sht_cons, 8,28,240,128,COL8_000084);
	console = task_alloc();
	console->tss.esp = memman_alloc_4k(memman,64*1024) + 64 * 1024 -8;
	console->tss.eip = (int) &task_console;
	console->tss.es = 1*8;
	console->tss.cs = 2*8;
	console->tss.ss = 1*8;
	console->tss.ds = 1*8;
	console->tss.fs = 1*8;
	console->tss.gs = 1*8;
	*((int *) (console->tss.esp + 4)) = (int) sht_cons; // memory share
	taskrun(console,2,2); // level2,different priorities 


	sheet_move(sht_back,0,0);// move background sheet 
	sheet_move(sht_mouse,mx,my);
	sheet_move(sht_win,8,56);
	sheet_move(sht_cons,100,200);
	


	sheet_updown(sht_back,0); // height 0, at the bottom
	sheet_updown(sht_cons,1);
	sheet_updown(sht_win,2);
	sheet_updown(sht_mouse,3);
	
	sprintf(s,"%3d %3d",mx,my);
	putfonts8_asc(binfo->vram, binfo->scrnx, 0, 0, COL8_FFFFFF, s);
	sprintf(s, "memory %dMB free %dkb", memtotal/(1024*1024), memman_total(memman)/1024);
	putfonts8_asc(buf_back, binfo->scrnx, 0, 32, COL8_FFFFFF, s);
	sheet_refresh(sht_back,0,0,binfo->scrnx,48);

	// tab key
	int key_to=0;
	int key_shift = 0;
	int key_leds = ((binfo->leds) >> 4) & 7; // caps,numlock,scrolllock

	for(;;)
	{
	io_cli(); // forbid all interrupts
	if(fifo_status(&fifo) == 0) 
		{task_sleep(curr);
		io_sti();
		}
	else {
		i=fifo_get(&fifo);
		io_sti(); // open interrupts
		if(255 < i && i < 512)
		{sprintf(s, "%02X", i-256);
		boxfill8(buf_back, binfo->scrnx, COL8_008400, 0, 16, 15, 31);
		putfonts8_asc(buf_back, binfo->scrnx, 0, 16, COL8_FFFFFF, s);
		sheet_refresh(sht_back,0,16,16,32);
		if(i<256 +0x80)
			{
			if(key_shift == 0)
				s[0]= keytable0[i-256];
			else
				s[0]= keytable1[i-256];
			}
		else 
			s[0] =0;
		if(s[0] >= 'A' && s[0]<= 'Z')
		{
			if(((key_leds & 4) == 0 && key_shift == 0) || 
			   ((key_leds & 4) == 1 && key_shift != 0))
			       s[0]+=0x20;
		}

		if (s[0] != 0) { // common character
				if (key_to == 0) {	/* ƒ^ƒXƒNA‚Ö */
					if (cursor_x < 128) {
							s[1] = 0;
							bps(sht_win, cursor_x, 28, COL8_FFFFFF, COL8_000000, s, 1);
							cursor_x += 8;
						}
				} 
				else// send to console
					fifo_put(&console->fifo, s[0] + 256);
				}
		if(i == 256 + 0x0e && cursor_x > 8)  // backspace key
			{
				if(key_to == 0)				
				{
					bps(sht_win,cursor_x,28,COL8_FFFFFF,COL8_000000," ",1);
					cursor_x -=8;
				}
				else
				{
					fifo_put(&console->fifo,8+256);
				}
			}

		if(i == 256 + 0x0f)  // Tab key
			{
				if(key_to == 0)
				{
					key_to =1;
					make_wtitle8(buf_win, sht_win->bxsize,"task a",0);
					shell_title(buf_cons, sht_cons->bxsize,"console",1);				
				}				
				else
				{
					key_to =0;
					make_wtitle8(buf_win, sht_win->bxsize,"task a",1);
					shell_title(buf_cons, sht_cons->bxsize,"console",0);
				}
				sheet_refresh(sht_win,0,0,sht_win->bxsize,21);
				sheet_refresh(sht_cons,0,0,sht_cons->bxsize,21);
			}
		if (i == 256 + 0x2a)
			key_shift |= 1;
		if (i == 256 + 0x36)
			key_shift |= 2;
		if (i == 256 + 0xaa)
			key_shift &= ~1;
		if (i == 256 + 0xb6) 
			key_shift &= ~2;
		if (i == 256 + 0x3a) // CapsLock
			key_leds ^= 4;		
		if (i == 256 + 0x45) // NumLock 
			key_leds ^= 2;		
		if (i == 256 + 0x46) // ScrollLock 
			key_leds ^= 1;
					
		boxfill8(sht_win ->buf, sht_win->bxsize, cursor_c,cursor_x,28,cursor_x+7,43);
		sheet_refresh(sht_win,cursor_x,28,cursor_x+8,44);

		}

		else if(511 < i && i < 768)
		{
		
		if(mouse_decode(&mdec,i-512) != 0) 
		  {	sprintf(s, "[lcr %4d %4d]", mdec.x,mdec.y);
			
			if((mdec.btn & 0x01) != 0) s[1]='L';
		        if((mdec.btn & 0x02) != 0) s[3]='R';
		        if((mdec.btn & 0x04) != 0) s[2]='C';	
			boxfill8(buf_back, binfo->scrnx, COL8_008484, 32, 16, 32+15*8-1, 31); // after filling,show ok
			putfonts8_asc(buf_back, binfo->scrnx, 32, 16, COL8_FFFFFF, s);
		 	sheet_refresh(sht_back,32,16,32+15*8,32);
			// the move of mouse 
			mx +=mdec.x;
			my +=mdec.y;
			if(mx <0) mx = 0;
			if(my <0) my = 0;
			if(mx > binfo->scrnx -1 )  mx =  binfo->scrnx -1;
			if(my > binfo->scrny -1 )  my =  binfo->scrny -1;  // control the mouse move area
		 	sprintf(s, "(%3d,%3d)", mx,my);
			boxfill8(buf_back, binfo->scrnx, COL8_008484, 0, 0,79, 15);
			putfonts8_asc(buf_back, binfo->scrnx, 0, 0, COL8_FFFFFF, s);
			sheet_refresh(sht_back,0,0,80,16);
			sheet_move(sht_mouse,mx,my);
			// move the window, vram -> sht -> move
		 	if((mdec.btn & 0x01) != 0)
				sheet_move(sht_win,mx-80,my-8);
		  }
		}

		else if(i == 1)
			{
				timer_set(timer,50,&fifo,0);
				boxfill8(sht_win->buf,sht_win->bxsize, COL8_000000, cursor_x, 28,cursor_x+7, 43);
				sheet_refresh(sht_win,cursor_x,28,cursor_x + 8, 44);
			}
		else if(i==0)
			{
				timer_set(timer,50,&fifo,1); // keep the data
				boxfill8(sht_win->buf,sht_win->bxsize, COL8_FFFFFF,cursor_x, 28,cursor_x + 7, 43);
				sheet_refresh(sht_win,cursor_x,28,cursor_x + 8, 44);
			}
			
	     }

	}
}
Esempio n. 15
0
int Grabber::command(int argc, const char*const* argv)
{
	Tcl& tcl = Tcl::instance();
	if (argc == 2) {
		if (strcmp(argv[1], "status") == 0) {
			sprintf(tcl.buffer(), "%d", status_);
			tcl.result(tcl.buffer());
			return (TCL_OK);
		}
		if (strcmp(argv[1], "need-capwin") == 0) {
			tcl.result("0");
			return (TCL_OK);
		}
	}
	if (argc == 3) {
		if (strcmp(argv[1], "send") == 0) {
			if (atoi(argv[2])) {
				if (!running_) {
					start();
					running_ = 1;
				}
			} else {
				if (running_) {
					stop();
					running_ = 0;
				}
			}
			return (TCL_OK);
		}
		if (strcmp(argv[1], "threshold") == 0) {
			threshold_ = 8*atoi(argv[2]);
			return (TCL_OK);
		}
		if (strcmp(argv[1], "fps") == 0) {
			/*XXX assume value in range */
			fps(atoi(argv[2]));
			return (TCL_OK);
		}
		if (strcmp(argv[1], "bps") == 0) {
			/*XXX assume value in range */
			bps(atoi(argv[2]));
			return (TCL_OK);
		}
		if (strcmp(argv[1], "fillrate") == 0) {
			/*XXX assume value in range */
			fillrate(atoi(argv[2]));
			return (TCL_OK);
		}
		if (strcmp(argv[1], "target") == 0) {
			target_ = (Module*)TclObject::lookup(argv[2]);
			return (TCL_OK);
		}
		if (strcmp(argv[1], "transmitter") == 0) {
			tx_ = (Transmitter*)TclObject::lookup(argv[2]);
			return (TCL_OK);
		}
		/*XXX*/
		if (strcmp(argv[1], "decimate") == 0 ||
		    strcmp(argv[1], "port") == 0 ||
		    strcmp(argv[1], "type") == 0 ||
			/* windows only */
			strcmp(argv[1], "useconfig") ==0)
			/* ignore */
			return (TCL_OK);
	}
	return (TclObject::command(argc, argv));
}
Esempio n. 16
0
bool OutLame::apply_profile() {


  if(enc_flags) lame_close(enc_flags);
  enc_flags = lame_init();

  lame_set_errorf(enc_flags,(void (*)(const char*, va_list))error);
  lame_set_debugf(enc_flags,(void (*)(const char*, va_list))func);
  lame_set_msgf(enc_flags,(void (*)(const char*, va_list))act);
  
  lame_set_num_samples(enc_flags,OUT_CHUNK);
  lame_set_num_channels(enc_flags,2); // the mixed input stream is stereo
  lame_set_in_samplerate(enc_flags,SAMPLE_RATE); // the mixed input stream is 44khz
  lame_set_error_protection(enc_flags,1); // 2 bytes per frame for a CRC checksum
  lame_set_compression_ratio(enc_flags,0);
  lame_set_quality(enc_flags,2); // 1..9 1=best 9=worst (suggested: 2, 5, 7)
  //  lame_set_VBR(enc_flags,vbr_abr);


  /* BITRATE */
  lame_set_brate(enc_flags,bps());

  Shouter *ice = (Shouter*)icelist.begin();
  while(ice) {
    char tmp[256];

    snprintf(tmp,256,"%u",bps());       ice->bps( tmp );
    snprintf(tmp,256,"%u",freq());      ice->freq( tmp );
    snprintf(tmp,256,"%u",channels());  ice->channels( tmp );
    
    ice = (Shouter*)ice->next;
  }

  lame_set_out_samplerate(enc_flags,freq());

  /* CHANNELS
     mode 2 (double channel) is unsupported */
  int mode;
  switch( channels() ) {
    /* 0,1,2,3 stereo,jstereo,dual channel,mono */
  case 1: mode = 3; break;
  case 2: mode = 1; break;
  default: mode = 3; break;
  }
  lame_set_mode(enc_flags,(MPEG_mode_e)mode);


  /* in case of VBR 
  func("reversed quality is %i, guessed bps %i",(int)fabs( 10 - quality()),bps());
  lame_set_VBR_q(enc_flags,(int)fabs( 10 - quality() ));
  lame_set_VBR_mean_bitrate_kbps(enc_flags,bps());
  */

  /* lame chooses for us frequency filtering when values are 0 */
  lame_set_lowpassfreq(enc_flags,lowpass());
  lame_set_highpassfreq(enc_flags,highpass());  
  
  int res = lame_init_params(enc_flags);
  if(res<0) {
    error("lame_init_params failed");
    lame_close(enc_flags);
    enc_flags = NULL;
  }

  return (res<0)?false:true;

}
Esempio n. 17
0
void HariMain(void)
{
	char *vram;
	int xsize;
	int ysize;
	unsigned int memtotal;
	struct MEMMAN *memman = (struct MEMMAN *) MEMMAN_ADDR ;
	struct BOOTINFO *binfo;	
	struct SHTCTL *shtctl;
	struct SHEET *sht_back, *sht_mouse, *sht_win;
	unsigned char *buf_back, buf_mouse[256],*buf_win;
	int i;
	int fifobuf[128];
	char s[40];
	struct FIFO fifo;
	fifo_init(&fifo,128,fifobuf);
	static char keytable[0x54] = {
		0,   0,   '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '^', 0,   0,
		'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '@', '[', 0,   0,   'A', 'S',
		'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', ':', 0,   0,   ']', 'Z', 'X', 'C', 'V',
		'B', 'N', 'M', ',', '.', '/', 0,   '*', 0,   ' ', 0,   0,   0,   0,   0,   0,
		0,   0,   0,   0,   0,   0,   0,   '7', '8', '9', '-', '4', '5', '6', '+', '1',
		'2', '3', '0', '.'
	};

	init_gdtidt();
	init_pic();
	io_sti();
	
	init_pit(); // timer
	io_out8(PIC0_IMR, 0xf8); /* PIC1 (11111001) irq0 */
	io_out8(PIC1_IMR, 0xef); //11101111 , allow irq12 
	struct TIMER *timer,*timer2,*timer3;
	timer = timer_alloc();
	timer2 = timer_alloc();
	timer3 = timer_alloc();
	timer_set(timer,1000,&fifo,10);
	timer_set(timer2,300,&fifo,3);
	timer_set(timer3,50,&fifo,1);
	
	init_keyboard(&fifo,256);	
	// memory test
	memtotal = memtest(0x00400000, 0xbfffffff); // available maxmium  address
	memman_init(memman);
	memman_free(memman,0x00001000,0x0009e000);
	memman_free(memman,0x00400000,memtotal-0x00400000);
		
	init_palette();
	binfo = (struct BOOTINFO *)  0x0ff0;
	xsize = binfo->scrnx;
	ysize = binfo->scrny;
	vram  = binfo->vram;
	// sheet setting
	shtctl = shtctl_init(memman, binfo->vram, binfo->scrnx, binfo->scrny);
	sht_back  = sheet_alloc(shtctl);
	sht_mouse = sheet_alloc(shtctl);
	sht_win   = sheet_alloc(shtctl);
	buf_back  = (unsigned char *) memman_alloc_4k(memman, binfo->scrnx * binfo->scrny);
	buf_win  = (unsigned char *) memman_alloc_4k(memman,160 * 52); // window sheet buffer
	sheet_setbuf(sht_back, buf_back, binfo->scrnx, binfo->scrny, -1);
	sheet_setbuf(sht_mouse, buf_mouse, 16, 16, 99); // col_inv 99
	sheet_setbuf(sht_win, buf_win,160,52,-1);
	/* initlize OS background */
	init_screen(buf_back,xsize,ysize);
	
	int mx,my; // mouse position
	// mouse cursor
	struct MOUSE_DEC mdec;
	enable_mouse(&fifo,512,&mdec); 
	init_mouse_cursor8(buf_mouse,99);
	make_window8(buf_win,160,52,"window");
	
	mx = (binfo->scrnx - 16) / 2;
	my = (binfo->scrny - 28 - 16) / 2;

	sheet_move(sht_back,0,0);// move background sheet 
	sheet_move(sht_mouse,mx,my);
	sheet_move(sht_win,80,72);

	sheet_updown(sht_back,0); // height 0, at the bottom
	sheet_updown(sht_win,1);
	sheet_updown(sht_mouse,2); // height 2,on the top
	
	sprintf(s,"%3d %3d",mx,my);
	putfonts8_asc(binfo->vram, binfo->scrnx, 0, 0, COL8_FFFFFF, s);
	sprintf(s, "memory %dMB free %dkb", memtotal/(1024*1024), memman_total(memman)/1024);
	putfonts8_asc(buf_back, binfo->scrnx, 0, 32, COL8_FFFFFF, s);
	sheet_refresh(sht_back,0,0,binfo->scrnx,48);

	int cursor_x,cursor_c;  // cursor color
	make_textbox8(sht_win, 8,28,144,16,COL8_FFFFFF); // heigth is 16
	cursor_x = 8;
	cursor_c = COL8_FFFFFF;


	for(;;)
	{
	//sprintf(s,"%010d",timerctl.count);
	//bps(sht_win,40,28, COL8_C6C6C6,COL8_000000,s,10);
	io_cli(); // forbid all interrupts
	if(fifo_status(&fifo) == 0) 
		io_stihlt();  // read data until it's empty
	else {
		i=fifo_get(&fifo);
		io_sti(); // open interrupts
		if(255 < i && i < 512)
		{sprintf(s, "%02X", i-256);
		boxfill8(buf_back, binfo->scrnx, COL8_008400, 0, 16, 15, 31);
		putfonts8_asc(buf_back, binfo->scrnx, 0, 16, COL8_FFFFFF, s);
		sheet_refresh(sht_back,0,16,16,32);
		if(i<256 +0x54)
			{
			if(keytable[i-256] != 0 && cursor_x < 144)
				{
					s[0]= keytable[i-256];
					s[1]= '\0';
					bps(sht_win,cursor_x,28, COL8_FFFFFF,COL8_000000,s,1); // 4th parm is background color 
					cursor_x +=8; // cursor move forward
				}
			}
		if(i == 256 + 0x0e && cursor_x > 8)
			{
				bps(sht_win,cursor_x,28,COL8_FFFFFF,COL8_000000," ",1);
				cursor_x -=8;
			
			}
		boxfill8(sht_win ->buf, sht_win->bxsize, cursor_c,cursor_x,28,cursor_x+7,43);
		sheet_refresh(sht_win,cursor_x,28,cursor_x+8,44);

		}

		else if(511 < i && i < 768)
		{
		
		if(mouse_decode(&mdec,i-512) != 0) 
		  {	sprintf(s, "[lcr %4d %4d]", mdec.x,mdec.y);
			
			if((mdec.btn & 0x01) != 0) s[1]='L';
		        if((mdec.btn & 0x02) != 0) s[3]='R';
		        if((mdec.btn & 0x04) != 0) s[2]='C';	
			boxfill8(buf_back, binfo->scrnx, COL8_008484, 32, 16, 32+15*8-1, 31); // after filling,show ok
			putfonts8_asc(buf_back, binfo->scrnx, 32, 16, COL8_FFFFFF, s);
		 	sheet_refresh(sht_back,32,16,32+15*8,32);
			// the move of mouse 
			mx +=mdec.x;
			my +=mdec.y;
			if(mx <0) mx = 0;
			if(my <0) my = 0;
			if(mx > binfo->scrnx -1 )  mx =  binfo->scrnx -1;
			if(my > binfo->scrny -1 )  my =  binfo->scrny -1;  // control the mouse move area
		 	sprintf(s, "(%3d,%3d)", mx,my);
			boxfill8(buf_back, binfo->scrnx, COL8_008484, 0, 0,79, 15);
			putfonts8_asc(buf_back, binfo->scrnx, 0, 0, COL8_FFFFFF, s);
			sheet_refresh(sht_back,0,0,80,16);
			sheet_move(sht_mouse,mx,my);
			// move the window, vram -> sht -> move
		 	if(mdec.btn & 0x01 != 0)
				sheet_move(sht_win,mx-80,my-8);
		  }
		}

		else if(i==10)
		{putfonts8_asc(buf_back, binfo->scrnx,0,64, COL8_FFFFFF,"10");
		sheet_refresh(sht_back,0,0,100,100);
		}
		else if(i ==3)
		{putfonts8_asc(buf_back, binfo->scrnx,0,80, COL8_FFFFFF,"3s");
		sheet_refresh(sht_back,0,0,100,100);
		}
		else if(i == 1)
			{
				timer_set(timer3,50,&fifo,0);
				boxfill8(sht_win->buf,sht_win->bxsize, COL8_000000, cursor_x, 28,cursor_x+7, 43);
				sheet_refresh(sht_win,cursor_x,28,cursor_x + 8, 44);
			}
		else if(i==0)
			{
				timer_set(timer3,50,&fifo,1); // keep the data
				boxfill8(sht_win->buf,sht_win->bxsize, COL8_FFFFFF,cursor_x, 28,cursor_x + 7, 43);
				sheet_refresh(sht_win,cursor_x,28,cursor_x + 8, 44);
			}
			
	     }

	}
}
Esempio n. 18
0
// sht: a sheet
void task_console(struct SHEET * sht)
{
//struct FIFO fifo;
struct TIMER *timer;
int i, fifobuf[128];
char s[10];
int count=0,cursor_x = 8, cursor_c = COL8_000000;
struct TASK *task = task_now();
timer = timer_alloc();
timer_set(timer,50,&task->fifo,1);
fifo_init(&task->fifo,128,fifobuf,task);
bps(sht, 8, 28, COL8_000000, COL8_FFFFFF, ">", 1);
for(;;)
{
	count++;
	io_cli();
	if(fifo_status(&task->fifo) == 0)
	{
		task_sleep(task);
		io_sti();
	}
	else
	{
	i = fifo_get(&task->fifo);
	io_sti();
	if(i <= 1)
	{	
		if(i== 1)
		{
			timer_set(timer,50,&task->fifo,0);
			cursor_c = COL8_FFFFFF;	
		}
		else
		{
			timer_set(timer,50,&task->fifo,1);
			cursor_c = COL8_000000;	
		}
		
	}

	if (256 <= i && i <= 511) {
				if (i == 8 + 256) {
					if (cursor_x > 16) {
						bps(sht, cursor_x, 28,  COL8_000000,COL8_FFFFFF, " ", 1);
						cursor_x -= 8;
					}
				} else {
					
					if (cursor_x < 240) {
						s[0] = i - 256;
						s[1] = 0;
						bps(sht, cursor_x, 28,  COL8_000000,COL8_FFFFFF, s, 1);
						cursor_x += 8;
					}
				}
	
	
}
boxfill8(sht->buf,sht->bxsize, cursor_c,cursor_x, 28,cursor_x + 7, 43);
	sheet_refresh(sht,cursor_x,28,cursor_x + 8, 44);
}
}
}