Esempio n. 1
0
int init_best_audio_codec(sh_audio_t *sh_audio, char **audio_codec_list,
			  char **audio_fm_list)
{
    stringset_t selected;
    char *ac_l_default[2] = { "", (char *) NULL };
    // hack:
    if (!audio_codec_list)
	audio_codec_list = ac_l_default;
    // Go through the codec.conf and find the best codec...
    sh_audio->initialized = 0;
    stringset_init(&selected);
    while (!sh_audio->initialized && *audio_codec_list) {
	char *audio_codec = *(audio_codec_list++);
	if (audio_codec[0]) {
	    if (audio_codec[0] == '-') {
		// disable this codec:
		stringset_add(&selected, audio_codec + 1);
	    } else {
		// forced codec by name:
		mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Forced audio codec: %s\n",
		       audio_codec);
		init_audio(sh_audio, audio_codec, NULL, -1, &selected);
	    }
	} else {
	    int status;
	    // try in stability order: UNTESTED, WORKING, BUGGY.
	    // never try CRASHING.
	    if (audio_fm_list) {
		char **fmlist = audio_fm_list;
		// try first the preferred codec families:
		while (!sh_audio->initialized && *fmlist) {
		    char *audio_fm = *(fmlist++);
		    mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Trying to force audio codec driver family %s...\n",
			   audio_fm);
		    for (status = CODECS_STATUS__MAX;
			 status >= CODECS_STATUS__MIN; --status)
			if (init_audio(sh_audio, NULL, audio_fm, status, &selected))
			    break;
		}
	    }
	    if (!sh_audio->initialized)
		for (status = CODECS_STATUS__MAX; status >= CODECS_STATUS__MIN;
		     --status)
		    if (init_audio(sh_audio, NULL, NULL, status, &selected))
			break;
	}
    }
    stringset_free(&selected);

    if (!sh_audio->initialized) {
	mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Cannot find codec for audio format 0x%X.\n",
	       sh_audio->format);
	return 0;   // failed
    }

    mp_tmsg(MSGT_DECAUDIO, MSGL_INFO, "Selected audio codec: [%s] afm: %s (%s)\n",
	   sh_audio->codec->name, sh_audio->codec->drv, sh_audio->codec->info);
    return 1;   // success
}
Esempio n. 2
0
int init_best_audio_codec(sh_audio_t *sh_audio, char **audio_codec_list,
			  char **audio_fm_list)
{
    char *ac_l_default[2] = { "", (char *) NULL };
    // hack:
    if (!audio_codec_list)
	audio_codec_list = ac_l_default;
    // Go through the codec.conf and find the best codec...
    sh_audio->inited = 0;
    codecs_reset_selection(1);
    while (!sh_audio->inited && *audio_codec_list) {
	char *audio_codec = *(audio_codec_list++);
	if (audio_codec[0]) {
	    if (audio_codec[0] == '-') {
		// disable this codec:
		select_codec(audio_codec + 1, 1);
	    } else {
		// forced codec by name:
		mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_ForcedAudioCodec,
		       audio_codec);
		init_audio(sh_audio, audio_codec, NULL, -1);
	    }
	} else {
	    int status;
	    // try in stability order: UNTESTED, WORKING, BUGGY.
	    // never try CRASHING.
	    if (audio_fm_list) {
		char **fmlist = audio_fm_list;
		// try first the preferred codec families:
		while (!sh_audio->inited && *fmlist) {
		    char *audio_fm = *(fmlist++);
		    mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_TryForceAudioFmtStr,
			   audio_fm);
		    for (status = CODECS_STATUS__MAX;
			 status >= CODECS_STATUS__MIN; --status)
			if (init_audio(sh_audio, NULL, audio_fm, status))
			    break;
		}
	    }
	    if (!sh_audio->inited)
		for (status = CODECS_STATUS__MAX; status >= CODECS_STATUS__MIN;
		     --status)
		    if (init_audio(sh_audio, NULL, NULL, status))
			break;
	}
    }

    if (!sh_audio->inited) {
	mp_msg(MSGT_DECAUDIO, MSGL_ERR, MSGTR_CantFindAudioCodec,
	       sh_audio->format);
	mp_msg(MSGT_DECAUDIO, MSGL_HINT, MSGTR_RTFMCodecs);
	return 0;   // failed
    }

    mp_msg(MSGT_DECAUDIO, MSGL_INFO, MSGTR_SelectedAudioCodec,
	   sh_audio->codec->name, sh_audio->codec->drv, sh_audio->codec->info);
    return 1;   // success
}
int _tmain(int argc, _TCHAR* argv[])
{
	FILE * fp;

//	if((fp=fopen("mine.pcm","rb"))==NULL)//打开你的PCM 文件mine.spx
	if((fp=fopen("mine.spx","rb"))==NULL)//打开你的PCM 文件mine.spx
	{
		printf("cannot open this file\n");
	}
	char pcm_data[320];

	dsound_union_t * dsound_union_handle = (dsound_union_t *)malloc(sizeof(dsound_union_t));
	if(dsound_union_handle == NULL){
		printf("malloc failed .\n");
		exit(1);
	}

	init_audio(dsound_union_handle, 1, 16, 8000, 0);
	while(1){
		//fread((BYTE*)pcm_data,320,1,fp);
		if(feof(fp)){
			printf("over ....\n");
			destory_audio(dsound_union_handle);
			while(1);
			break;
		}
		/*fread((BYTE*)pcm_data,38,1,fp);
		play_audio(dsound_union_handle ,pcm_data, 38);*/
		fread((BYTE*)pcm_data,50,1,fp);
		play_audio(dsound_union_handle ,pcm_data, 50);
	}
	return 0;
}
Esempio n. 4
0
void init() {
    init_audio();
    init_input();
    sysclock_start();
    sei();
    task_create(handle_input, 10, true);
}
Esempio n. 5
0
void init_drivers(void)
{
   driver.video_data_own = false;
   driver.audio_data_own = false;
   driver.input_data_own = false;
#ifdef HAVE_CAMERA
   driver.camera_data_own = false;
#endif
#ifdef HAVE_LOCATION
   driver.location_data_own = false;
#endif
#ifdef HAVE_OSK
   driver.osk_data_own = false;
#endif
#ifdef HAVE_MENU
   // By default, we want the menu to persist through driver reinits.
   driver.menu_data_own = true;
#endif

   adjust_system_rates();

   g_extern.frame_count = 0;

   init_video_input();

   if (!driver.video_cache_context_ack && g_extern.system.hw_render_callback.context_reset)
      g_extern.system.hw_render_callback.context_reset();
   driver.video_cache_context_ack = false;

   init_audio();

#ifdef HAVE_CAMERA
   // Only initialize camera driver if we're ever going to use it.
   if (g_extern.camera_active)
      init_camera();
#endif

#ifdef HAVE_LOCATION
   // Only initialize location driver if we're ever going to use it.
   if (g_extern.location_active)
      init_location();
#endif

#ifdef HAVE_OSK
   init_osk();
#endif

#ifdef HAVE_MENU
   init_menu();

   if (driver.menu && driver.menu_ctx && driver.menu_ctx->context_reset)
      driver.menu_ctx->context_reset(driver.menu);
#endif

   // Keep non-throttled state as good as possible.
   if (driver.nonblock_state)
      driver_set_nonblock_state(driver.nonblock_state);

   g_extern.system.frame_time_last = 0;
}
Esempio n. 6
0
int main( int argc, char* argv[] ) {
	atexit(on_exit);

	OggPlayer ogg("../sample video/trailer_400p.ogg",AF_S16,2,44100,VF_BGRA);
	if(ogg.fail()) {
		SDL_SetError("Could not open ../sample video/trailer_400p.ogg");
		return -1;
	}

	SDL_Surface *screen;
	if(!init_audio((void*)&ogg) || !(screen=init_video(ogg.width(),ogg.height())))
		  return -2;

	ogg.play();

	bool running=true;
	while( ogg.playing() && running ) {
		SDL_Event event;
		while(SDL_PollEvent(&event))
			if(event.type==SDL_QUIT){ running = false; }

	    SDL_LockSurface( screen );
		ogg.video_read((char*)screen->pixels,screen->pitch);
	    SDL_UnlockSurface( screen );
		SDL_Flip(screen);
		SDL_Delay(0);
	}
	return 0;
}
Esempio n. 7
0
File: main.c Progetto: aravind2/mwtp
int main(void)
{
  init_other_hw(); /* Must call this first */
  init_timer();
  init_audio();
  init_turnled();
  init_inputs();

  enable_task(TURNLED_TASK);
  enable_task(AUDIO_TASK);
  enable_task(INPUTS_TASK);
  enable_task(COUNTDOWN_TASK);
   
  /* initialize display, cursor off */
  lcd_init(LCD_DISP_ON);

  init_clock();

  /* Enable interrupts */
  sei();

  for (;;) {                           /* loop forever */
    poll_inputs();
    poll_clock();
    sleep_until_interrupt();
  } /* end loop forever */
}
Esempio n. 8
0
/*only boot once*/extern void kaiwa_system_boot_init(void);/* 組み込み */
void game_system_init(void)
{
	/* ----- 模倣風設定ファイルの読み込み */
	ini_file_load();

	/* ----- 初期化 */
	psp_video_init01();
//	kanji_system_init();/* 組み込み */	/*(漢字システムが無いとエラーが表示できない。)*/
	psp_video_init02();
	psp_pad_init(); 	/* psp_video_init()より後でないと正常に pad check 出来ない。 */

	/* ----- ゲーム本体初期化 */
	init_audio();
//	init_math();
	#if (1==USE_KETM_IMAGE_CHACHE)
	init_imglist();
	#endif /*(1==USE_KETM_IMAGE_CHACHE)*/
//
	kaiwa_system_boot_init();/* 組み込み */
	kanji_system_boot_init();/* 組み込み */ 	/*(漢字システムが無いとエラーが表示できない。)*/
//未定	ending_system_init();/* 組み込み */
//
	font_system_boot_init();/*"256x256, SDLフォントをロード"*/

	/* ゲームコア game_core_init(); */
	#if (1)/*Guで描く前に必要な初期化*/
	cg.bomber_time = 0;
	#endif
	cg.game_continue_stage			= (1-1);	/* (0) 0は1面から開始という意味。 */
//
//	pl ay_music_num(BGM_27_menu01);
	cb.main_call_func = title_menu_start;	/* タイトルメニューへ移動 */
}
Esempio n. 9
0
void check_prefs_changed_audio (void)
{
    if (sound_available && sound_prefs_changed ()) {
		close_sound ();
		
		produce_sound = changed_produce_sound;
		if (produce_sound) {
			if (init_audio ()) {
				last_cycles = get_cycles () - 1;
				next_sample_evtime = scaled_sample_evtime;
			} else
				if (! sound_available) {
					write_log ("Sound is not supported.\n");
				} else {
					write_log ("Sorry, can't initialize sound.\n");
					produce_sound = 0;
					/* So we don't do this every frame */
					produce_sound = 0;
				}
		}
    }
    if (!produce_sound) {
		eventtab[ev_audio].active = 0;
		events_schedule ();
    }
}
Esempio n. 10
0
int main( int argc, char* argv[] ) {
	atexit(on_exit);

	OggPlayer ogg("../sample video/trailer_400p.ogg",AF_S16,2,44100,VF_BGRA);
	if(ogg.fail()) {
		SDL_SetError("Could not open ../sample video/trailer_400p.ogg");
		return -2;
	}

	if(!init_audio((void*)&ogg) || !init_video(ogg.width(),ogg.height()))
		return -3;

	glewInit();

	if (!GLEW_VERSION_2_0){
		SDL_SetError("OpenGL 2.0 not supported");
		return -1;
	}

	YUVFrame yuv_frame(ogg);

	ogg.play();

	bool running=true;

	while( ogg.playing() && running ) {
		SDL_Event event;
		while(SDL_PollEvent(&event)){
			if(event.type==SDL_QUIT || event.type==SDL_KEYDOWN){ running = false; }
		}
		yuv_frame.render();
		SDL_GL_SwapBuffers();
	}
	return 0;
}
Esempio n. 11
0
int16_t main(void) {
    init_clock();
    init_ui();
    init_pin();
    init_timer();
    init_i2c();
    InitUSB();
    init_oc();

    init_display(&i2c3, 0x70, 0x71);
    init_game(&timer1, &timer2, &A[0], &disp1, &disp2);
    init_gun(&D[13], &A[1], &A[2], &timer3);
    init_launcher(&D[5], &D[8], &D[3], &D[4]);
    init_shooter(&D[6], &D[9], &D[1], &D[2], &D[7], &D[0], &oc3, &oc4);
    init_baller(&D[10], &oc2, &timer4, &shooter, &launcher);
    init_pix(&D[11], &timer5, 30, 0.05);
    init_audio(&D[12]);

    uint8_t level = 0;
    uint8_t hit_flag = 0;
    while (1) {
        ServiceUSB(); // usb times out if not checked fast enough :/
        level = run_game(hit_flag);
        ServiceUSB();
        hit_flag = run_gun(level);
        ServiceUSB();
        run_baller(level);
    }
}
Esempio n. 12
0
int init(void)
{
  if (init_video() != 0)
    {
      fprintf(stderr, "Failed to initialize video\n");
      return -1;
    }

  if (init_script() != 0)
    {
      fprintf(stderr, "Failed to initialize scripting engine\n");
      return -1;
    }

  if (init_gfx() != 0)
    {
      fprintf(stderr, "Failed to initialize graphics\n");
      return -1;
    }

  if (init_audio() != 0)
    {
      fprintf(stderr, "Failed to initialize audio\n");
      return -1;
    }

  if (init_sdl() != 0)
    {
      fprintf(stderr, "Failed to initialize SDL\n");
      return -1;
    }

  return 0;
}
Esempio n. 13
0
File: main.c Progetto: callaa/luola
int main (int argc, char *argv[]) {
    int rval, r;
    /* Parse command line arguments */
    init_startup_options ();
    if (argc > 1) {
        for (r = 1; r < argc; r++) {
            if (strcmp (argv[r], "--help") == 0) {
                print_help ();
                return 0;
            } else if (strcmp (argv[r], "--version") == 0)
                show_version ();
            else if ((r = parse_argument (r, argc, argv)) == 0)
                return 0;
        }
    }
    /* Check if luola's home directory exists and create it if necessary */
    check_homedir ();

    /* Seed the random number generator */
    srand (time (NULL));

    /* Initialize */
    init_sdl ();
    init_video ();

    if (luola_options.sounds)
        init_audio ();

    if(init_font()) return 1;
    if(load_data()) return 1;

    scan_levels(0);
    scan_levels(1);
    if (game_settings.levels == NULL)
        no_levels_found ();

    init_level();
    init_hotseat();
    if (luola_options.mbg_anim)
        init_demos ();

    /* Set sound effect volume */
    audio_setsndvolume(game_settings.sound_vol);

    /* Enable key repeat (useful in menus. Will be disabled during game) */
    SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);

    /* Enter game loop */
    while (1) {
        /* Intro screen */
        rval = game_menu_screen ();
        if (rval == INTRO_RVAL_EXIT)
            break;
        /* Play ! */
        if (rval == INTRO_RVAL_STARTGAME)
            hotseat_game ();
    }
    return 0;
}
Esempio n. 14
0
void laserdisc_device::device_start()
{
	// initialize the various pieces
	init_disc();
	init_video();
	init_audio();

	// register callbacks
	config_register(machine(), "laserdisc", config_saveload_delegate(FUNC(laserdisc_device::config_load), this), config_saveload_delegate(FUNC(laserdisc_device::config_save), this));
}
Esempio n. 15
0
int
main(int argc, char** argv)
{
  const char*  devname = "default";
  int          verbose = 0;
  KCFileFormat format  = KC_FORMAT_ANY;
  int          c, rc;

  while ((c = getopt(argc, argv, "a:d:f:r:t:v?")) != -1)
    switch (c)
    {
      case 'a': amplitude  = kc_parse_arg_num(optarg, 0.0, 1.0, INT16_MAX); break;
      case 'd': devname    = optarg; break;
      case 'f': basefreq   = kc_parse_arg_num(optarg, 1.0, 1 << 20, 1.0); break;
      case 'r': samplerate = kc_parse_arg_num(optarg, 1.0, 1 << 24, 1.0); break;
      case 't': format     = kc_parse_arg_format(optarg); break;
      case 'v': verbose    = 1; break;
      case '?': exit_usage();
      default:  abort();
    }

  if (optind >= argc)
    exit_usage();

  setlocale(LC_ALL, "");
  stdout_isterm = isatty(STDOUT_FILENO);

  init_audio(devname);

  if (verbose && (rc = snd_pcm_dump(audio, output)) < 0)
    exit_snd_error(rc, "dump setup");

  if (8 * basefreq > samplerate)
  {
    fprintf(stderr, "Base frequency of %u Hz is out of range at %u samples per second\n",
            basefreq, samplerate);
    exit(1);
  }
  ratescale = 3373259426u / samplerate; // 2^30 * pi / samplerate
  periodbuf = malloc(periodsize * n_channels * sizeof(int16_t));

  for (int i = optind; i < argc; ++i)
    play_kcfile(argv[i], format);

  free(periodbuf);

  if ((rc = snd_pcm_drain(audio)) < 0)
    exit_snd_error(rc, "drain");

  if ((rc = snd_pcm_close(audio)) < 0)
    exit_snd_error(rc, "close");

  return 0;
}
Esempio n. 16
0
void rarch_console_rsound_stop(void)
{
   strlcpy(g_settings.audio.driver, config_get_default_audio(), sizeof(g_settings.audio.driver));

   // If driver already has started, it must be reinited.
   if (driver.audio_data)
   {
      uninit_audio();
      driver.audio_data = NULL;
      init_drivers_pre();
      init_audio();
   }
}
Esempio n. 17
0
void laserdisc_device::device_start()
{
	// if we have a palette and it's not started, wait for it
	if (m_overlay_palette != nullptr && !m_overlay_palette->started())
		throw device_missing_dependencies();

	// initialize the various pieces
	init_disc();
	init_video();
	init_audio();

	// register callbacks
	machine().configuration().config_register("laserdisc", config_saveload_delegate(FUNC(laserdisc_device::config_load), this), config_saveload_delegate(FUNC(laserdisc_device::config_save), this));
}
Esempio n. 18
0
void init_drivers(void)
{
   driver.video_data_own = !driver.video_data;
   driver.audio_data_own = !driver.audio_data;
   driver.input_data_own = !driver.input_data;
#ifdef HAVE_CAMERA
   driver.camera_data_own = !driver.camera_data;
#endif
#ifdef HAVE_LOCATION
   driver.location_data_own = !driver.location_data;
#endif
#ifdef HAVE_OSK
   driver.osk_data_own = !driver.osk_data;
#endif

   adjust_system_rates();

   g_extern.frame_count = 0;
   init_video_input();

   if (!driver.video_cache_context_ack && g_extern.system.hw_render_callback.context_reset)
      g_extern.system.hw_render_callback.context_reset();
   driver.video_cache_context_ack = false;

   init_audio();

#ifdef HAVE_CAMERA
   // Only init camera driver if we're ever going to use it.
   if (g_extern.camera_active)
      init_camera();
#endif

#ifdef HAVE_LOCATION
   // Only init location driver if we're ever going to use it.
   if (g_extern.location_active)
      init_location();
#endif

#ifdef HAVE_OSK
   init_osk();
#endif

   // Keep non-throttled state as good as possible.
   if (driver.nonblock_state)
      driver_set_nonblock_state(driver.nonblock_state);

   g_extern.system.frame_time_last = 0;
}
Esempio n. 19
0
bool rarch_console_rsound_start(const char *ip)
{
   strlcpy(g_settings.audio.driver, "rsound", sizeof(g_settings.audio.driver));
   strlcpy(g_settings.audio.device, ip, sizeof(g_settings.audio.device));
   driver.audio_data = NULL;

   // If driver already has started, it must be reinited.
   if (driver.audio_data)
   {
      uninit_audio();
      driver.audio_data = NULL;
      init_drivers_pre();
      init_audio();
   }
   return g_extern.audio_active;
}
Esempio n. 20
0
void laserdisc_device::device_start()
{
	// ensure that our screen is started first
	m_screen = machine().device<screen_device>(m_screen_name);
	assert(m_screen != NULL);
	if (!m_screen->started())
		throw device_missing_dependencies();

	// initialize the various pieces
	init_disc();
	init_video();
	init_audio();

	// register callbacks
	config_register(machine(), "laserdisc", config_saveload_delegate(FUNC(laserdisc_device::config_load), this), config_saveload_delegate(FUNC(laserdisc_device::config_save), this));
}
Esempio n. 21
0
static rtems_task gui_task(rtems_task_argument argument)
{
	init_fb_mtk(sysconfig_get_autostart_mode() == SC_AUTOSTART_FILE);
	sysconfig_set_mtk_language();
	sysconfig_set_mtk_wallpaper();
	init_input();
	input_add_callback(mtk_input);
	init_shortcuts();
	init_osc();
	init_messagebox();
	init_performance();
	init_renderer();
	init_cp();
	init_keyboard();
	init_ir();
	init_audio();
	init_midi();
	init_oscsettings();
	init_dmxspy();
	init_dmxdesk();
	init_dmx();
	init_videoin();
	init_rsswall();
	init_patcheditor();
	init_monitor();
	init_firstpatch();
	init_filemanager();
#ifdef WITH_PDF
	init_pdfreader();
#endif
	init_sysettings();
	init_about();
	init_flash();
	init_shutdown();

	cp_autostart();
	
	if(sysconfig_is_rescue())
		messagebox("Rescue mode", "You have booted in rescue mode.\n"
			"Your system will function as usual, using back-up software.\n"
			"From there, you can update the main software or perform\nother actions to fix the problem.\n");

	/* FIXME: work around "black screen" bug in MTK */
	mtk_cmd(1, "screen.refresh()");
	
	input_eventloop();
}
Esempio n. 22
0
	void init_builtin_commands() {
		LOG_D("command/init") << "Populating command map";
		init_app();
		init_audio();
		init_automation();
		init_edit();
		init_grid();
		init_help();
		init_keyframe();
		init_recent();
		init_subtitle();
		init_time();
		init_timecode();
		init_tool();
		init_video();
		init_visual_tools();
	}
Esempio n. 23
0
void InputInterruptsInit()
{
    spi_init_master();
    init_lcdd();
    currentScreen = 0;
    currentSong = 0x08;
    
    init_audio();
    _delay_ms(10);
    
    beatIndex = 0;
    
    moveToMenu();
    
    ADMUX |= (1<<REFS0);
    ADMUX &=~(1<<REFS1);
    ADMUX |= (1<<ADLAR);
    ADCSRA |= (7<<ADPS0);
    ADCSRA |= (1<<ADEN);
    
    currentI = 0;
    high = 0;
    first = 0;
    
    unsigned char threshold  = 40;
    unsigned char status;
    unsigned char abuf = 128;
    DDRC &= ~(1 << DDC3);   // configure PC3 for touch interrupt
    PORTC |= (1 << PC3);//x and y coordinate of touch
    i2c_init(BDIV);
    // Set threshold of touch sensitivity of touch panel
    status=i2c_io(ADDR_TOUCH, &abuf, 1, &threshold, 1, NULL, 0);
    
    
    //set up interrupts
    TCCR1B |= (1 << WGM12);     // Set for CTC mode.  OCR1A = modulus
    TIMSK1 |= (1 << OCIE1A);    // Enable CTC interrupt
    sei();                      // Enable global interrupts
    OCR1A = 200;              // Set the counter modulus
    TCCR1B |= (1 << CS12);      // Set prescaler for divide by 256,
}
Esempio n. 24
0
//initialize the video, audio, and input systems on the platform
//  returns int - negative on failure, otherwise success
int platform_init(void) {
  int result;

  if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_TIMER) == 0) {
    result = init_video();
    if(result < 0) {
      return result;
    }

    result = init_audio();
    if(result < 0) {
      return result;
    }

    result = init_input();
    if(result < 0) {
      return result;
    }
  }

  return 0;
}
Esempio n. 25
0
int init(int bpp) {
	char wm_caption[20];

	fprintf(stdout, "Epiar %s\n", epiar_version);
	fprintf(stdout, "http://www.epiar.net/\n");
	fprintf(stdout, "\nPlease report all bugs at http://bugs.epiar.net/\n\n");

	setup_video(screen_width, screen_height, bpp, fullscreen);

	init_colors(); /* basically sets up common Uint32s to avoid calls to SDL_MapRGB() */

	/* load the main archive file (used throughout epiar) */
	if ((epiar_eaf = eaf_open_file(apply_game_path("epiar.eaf"))) == NULL)
		printf("Couldn't open epiar.eaf file.\n");
	if ((main_eaf = eaf_open_file(apply_game_path("main.eaf"))) == NULL)
		printf("Couldn't open epiar.eaf file.\n");

	init_audio();
	init_music();

	SDL_ShowCursor(0);

	sprintf(wm_caption, "Epiar [%s]", epiar_version);

	SDL_WM_SetCaption(wm_caption, wm_caption);

	load_input_cfg();

	init_trig();
	init_playlist();

	gui_init();

	init_plugins();

	srand(time(NULL));

	return (0);
}
Esempio n. 26
0
/* Initialise a single instance */
static GtkWidget* init_player(CustomData *data, guint decknumber, int autoconnect) {
    GtkWidget *playerUI;
    GstBus *bus;


    init_audio(data, decknumber, autoconnect);

    /* Create the GUI */
    playerUI = create_player_ui (data, decknumber);

    /* Instruct the bus to emit signals for each received message, and connect to the interesting signals */
    bus = gst_element_get_bus (data->pipeline);
    gst_bus_add_signal_watch (bus);
    g_signal_connect (G_OBJECT (bus), "message::error", (GCallback)error_cb, data);
    g_signal_connect (G_OBJECT (bus), "message::eos", (GCallback)eos_cb, data);
    g_signal_connect (G_OBJECT (bus), "message::state-changed", (GCallback)state_changed_cb, data);
    g_signal_connect (G_OBJECT (bus), "message::tag", (GCallback)tag_cb, data);
    gst_object_unref (bus);

    /* Register a function that GLib will call every second */
    g_timeout_add_seconds (1, (GSourceFunc)refresh_ui, data);

    return playerUI;
}
Esempio n. 27
0
/*!
 * Board specific initialization.
 */
static void __init board_init(void)
{
	int i, j;
	struct clk *clko2;
	struct clk *new_parent;
	int rate;
	int ret = gpio_request_array(board_gpios,
			ARRAY_SIZE(board_gpios));

	IOMUX_SETUP(common_pads);

	if (ret) {
		printk(KERN_ERR "%s gpio_request_array failed("
				"%d) for board_gpios\n", __func__, ret);
	}
	printk(KERN_ERR "------------ Board type H\n");

	gp_reg_id = plat_dvfscore.reg_id;
	soc_reg_id = plat_dvfscore.soc_id;
	pu_reg_id = plat_dvfscore.pu_id;

	imx6q_add_imx_uart(0, NULL);
	imx6q_add_imx_uart(1, NULL);
	imx6q_add_imx_uart(2, &plat_uart2);

	imx6q_add_ipuv3(0, &plat_ipu[0]);
	if (cpu_is_mx6q()) {
		imx6q_add_ipuv3(1, &plat_ipu[1]);
		j = ARRAY_SIZE(plat_fb);
	} else {
		j = ARRAY_SIZE(plat_fb) / 2;
		plat_ldb.ipu_id = 0;
		plat_ldb.disp_id = 1;
		plat_ldb.sec_ipu_id = 0;
		plat_ldb.sec_disp_id = 0;
	}
	for (i = 0; i < j; i++)
		fb_dev[i] = imx6q_add_ipuv3fb(i, &plat_fb[i]);

	imx6q_add_vdoa();

	imx6q_add_lcdif(&plat_lcdif);
	imx6q_add_ldb(&plat_ldb);
	imx6q_add_v4l2_output(0);
	imx6q_add_v4l2_capture(0, &plat_capture);
	imx6q_add_mipi_csi2(&plat_mipi_csi2);
	imx6q_add_imx_snvs_rtc();

	if (1 == caam_enabled)
		imx6q_add_imx_caam();

	imx6q_add_imx_i2c(0, &plat_i2c);
	imx6q_add_imx_i2c(2, &plat_i2c);
	i2c_register_board_info(0, mxc_i2c0_board_info,
			ARRAY_SIZE(mxc_i2c0_board_info));

	mxc_register_device(&platdev_i2c0mux, &plat_i2c0mux);
	i2c_register_board_info(3, mxc_i2c3_board_info,
			ARRAY_SIZE(mxc_i2c3_board_info));
	i2c_register_board_info(4, mxc_i2c4_board_info,
			ARRAY_SIZE(mxc_i2c4_board_info));
	i2c_register_board_info(5, mxc_i2c5_board_info,
			ARRAY_SIZE(mxc_i2c5_board_info));

	mxc_register_device(&platdev_i2c2mux, &plat_i2c2mux);
	i2c_register_board_info(6, mxc_i2c6_board_info,
			ARRAY_SIZE(mxc_i2c6_board_info));
	i2c_register_board_info(7, mxc_i2c7_board_info,
			ARRAY_SIZE(mxc_i2c7_board_info));

	/* SPI */
	imx6q_add_ecspi(0, &plat_spi);
	spi_device_init();

	imx6q_add_anatop_thermal_imx(1, &plat_anatop_thermal);
	imx6_init_fec(plat_fec);
	imx6q_add_pm_imx(0, &plat_pm);
	imx6q_add_sdhci_usdhc_imx(2, &plat_sd3);
	imx6q_add_sdhci_usdhc_imx(3, &plat_sd4);
	imx_add_viv_gpu(&imx6_gpu_data, &plat_gpu);
	init_usb();
	if (cpu_is_mx6q())
		imx6q_add_ahci(0, &plat_sata);
	imx6q_add_vpu();
	init_audio();
	platform_device_register(&platdev_vmmc_reg_devices);
	plat_asrc.asrc_core_clk = clk_get(NULL, "asrc_clk");
	plat_asrc.asrc_audio_clk = clk_get(NULL, "asrc_serial_clk");
	imx6q_add_asrc(&plat_asrc);

	/* release USB Hub reset */
	gpio_set_value(GP_USB_HUB_RESET, 1);

	imx6q_add_mxc_pwm(0);	/* RGB backlight */
	imx6q_add_mxc_pwm(1);	/* Buzzer */
	imx6q_add_mxc_pwm(2);	/* LVDS1 baclight */
	imx6q_add_mxc_pwm(3);	/* LVDS0 baclight */

	imx6q_add_mxc_pwm_backlight(0, &plat_di0_backlight);
	imx6q_add_mxc_pwm_backlight(2, &plat_lvds1_backlight);
	imx6q_add_mxc_pwm_backlight(3, &plat_lvds0_backlight);

	imx6q_add_otp();
	imx6q_add_viim();
	imx6q_add_imx2_wdt(0, NULL);
	imx6q_add_dma();

	imx6q_add_dvfs_core(&plat_dvfscore);

	add_device_buttons();

	clko2 = clk_get(NULL, "clko2_clk");
	if (IS_ERR(clko2))
		pr_err("can't get CLKO2 clock.\n");

	new_parent = clk_get(NULL, "osc_clk");
	if (!IS_ERR(new_parent)) {
		clk_set_parent(clko2, new_parent);
		clk_put(new_parent);
	}
	rate = clk_round_rate(clko2, 24000000);
	clk_set_rate(clko2, rate);
	clk_enable(clko2);
	pm_power_off = poweroff;
	imx6q_add_busfreq();

	gpio_set_value(GP_WL_EN, 1);		/* momentarily enable */
	gpio_set_value(GP_WL_BT_REG_EN, 1);
	mdelay(2);
	gpio_set_value(GP_WL_EN, 0);
	gpio_set_value(GP_WL_BT_REG_EN, 0);

	gpio_free(GP_WL_BT_RESET);
	gpio_free(GP_WL_EN);
	gpio_free(GP_WL_BT_REG_EN);
	mdelay(1);

	imx6q_add_sdhci_usdhc_imx(1, &plat_sd2);

	platform_device_register(&platdev_vwifi_reg_devices);
	platform_device_register(&platdev_leds_pwd);

	imx6q_add_pcie(&plat_pcie);

	imx6q_add_perfmon(0);
	imx6q_add_perfmon(1);
	imx6q_add_perfmon(2);
}
Esempio n. 28
0
static int ipmovie_read_header(AVFormatContext *s)
{
    IPMVEContext *ipmovie = s->priv_data;
    AVIOContext *pb = s->pb;
    AVPacket pkt;
    AVStream *st;
    unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
    int chunk_type, i;
    uint8_t signature_buffer[sizeof(signature)];

    ipmovie->avf = s;

    avio_read(pb, signature_buffer, sizeof(signature_buffer));
    while (memcmp(signature_buffer, signature, sizeof(signature))) {
        memmove(signature_buffer, signature_buffer + 1, sizeof(signature_buffer) - 1);
        signature_buffer[sizeof(signature_buffer) - 1] = avio_r8(pb);
        if (avio_feof(pb))
            return AVERROR_EOF;
    }
    /* initialize private context members */
    ipmovie->video_pts = ipmovie->audio_frame_count = 0;
    ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset =
    ipmovie->decode_map_chunk_offset = 0;

    /* on the first read, this will position the stream at the first chunk */
    ipmovie->next_chunk_offset = avio_tell(pb) + 4;

    for (i = 0; i < 256; i++)
        ipmovie->palette[i] = 0xFFU << 24;

    /* process the first chunk which should be CHUNK_INIT_VIDEO */
    if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO)
        return AVERROR_INVALIDDATA;

    /* peek ahead to the next chunk-- if it is an init audio chunk, process
     * it; if it is the first video chunk, this is a silent file */
    if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
        CHUNK_PREAMBLE_SIZE)
        return AVERROR(EIO);
    chunk_type = AV_RL16(&chunk_preamble[2]);
    avio_seek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);

    if (chunk_type == CHUNK_VIDEO)
        ipmovie->audio_type = AV_CODEC_ID_NONE;  /* no audio */
    else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
        return AVERROR_INVALIDDATA;

    /* initialize the stream decoders */
    st = avformat_new_stream(s, NULL);
    if (!st)
        return AVERROR(ENOMEM);
    avpriv_set_pts_info(st, 63, 1, 1000000);
    ipmovie->video_stream_index = st->index;
    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
    st->codec->codec_id = AV_CODEC_ID_INTERPLAY_VIDEO;
    st->codec->codec_tag = 0;  /* no fourcc */
    st->codec->width = ipmovie->video_width;
    st->codec->height = ipmovie->video_height;
    st->codec->bits_per_coded_sample = ipmovie->video_bpp;

    if (ipmovie->audio_type) {
        return init_audio(s);
    } else
       s->ctx_flags |= AVFMTCTX_NOHEADER;

    return 0;
}
Esempio n. 29
0
/* This function loads and processes a single chunk in an IP movie file.
 * It returns the type of chunk that was processed. */
static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
    AVPacket *pkt)
{
    unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
    int chunk_type;
    int chunk_size;
    unsigned char opcode_preamble[OPCODE_PREAMBLE_SIZE];
    unsigned char opcode_type;
    unsigned char opcode_version;
    int opcode_size;
    unsigned char scratch[1024];
    int i, j;
    int first_color, last_color;
    int audio_flags;
    unsigned char r, g, b;
    unsigned int width, height;

    /* see if there are any pending packets */
    chunk_type = load_ipmovie_packet(s, pb, pkt);
    if (chunk_type != CHUNK_DONE)
        return chunk_type;

    /* read the next chunk, wherever the file happens to be pointing */
    if (avio_feof(pb))
        return CHUNK_EOF;
    if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
        CHUNK_PREAMBLE_SIZE)
        return CHUNK_BAD;
    chunk_size = AV_RL16(&chunk_preamble[0]);
    chunk_type = AV_RL16(&chunk_preamble[2]);

    av_log(NULL, AV_LOG_TRACE, "chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size);

    switch (chunk_type) {

    case CHUNK_INIT_AUDIO:
        av_log(NULL, AV_LOG_TRACE, "initialize audio\n");
        break;

    case CHUNK_AUDIO_ONLY:
        av_log(NULL, AV_LOG_TRACE, "audio only\n");
        break;

    case CHUNK_INIT_VIDEO:
        av_log(NULL, AV_LOG_TRACE, "initialize video\n");
        break;

    case CHUNK_VIDEO:
        av_log(NULL, AV_LOG_TRACE, "video (and audio)\n");
        break;

    case CHUNK_SHUTDOWN:
        av_log(NULL, AV_LOG_TRACE, "shutdown\n");
        break;

    case CHUNK_END:
        av_log(NULL, AV_LOG_TRACE, "end\n");
        break;

    default:
        av_log(NULL, AV_LOG_TRACE, "invalid chunk\n");
        chunk_type = CHUNK_BAD;
        break;

    }

    while ((chunk_size > 0) && (chunk_type != CHUNK_BAD)) {

        /* read the next chunk, wherever the file happens to be pointing */
        if (avio_feof(pb)) {
            chunk_type = CHUNK_EOF;
            break;
        }
        if (avio_read(pb, opcode_preamble, CHUNK_PREAMBLE_SIZE) !=
            CHUNK_PREAMBLE_SIZE) {
            chunk_type = CHUNK_BAD;
            break;
        }

        opcode_size = AV_RL16(&opcode_preamble[0]);
        opcode_type = opcode_preamble[2];
        opcode_version = opcode_preamble[3];

        chunk_size -= OPCODE_PREAMBLE_SIZE;
        chunk_size -= opcode_size;
        if (chunk_size < 0) {
            av_log(NULL, AV_LOG_TRACE, "chunk_size countdown just went negative\n");
            chunk_type = CHUNK_BAD;
            break;
        }

        av_log(NULL, AV_LOG_TRACE, "  opcode type %02X, version %d, 0x%04X bytes: ",
                opcode_type, opcode_version, opcode_size);
        switch (opcode_type) {

        case OPCODE_END_OF_STREAM:
            av_log(NULL, AV_LOG_TRACE, "end of stream\n");
            avio_skip(pb, opcode_size);
            break;

        case OPCODE_END_OF_CHUNK:
            av_log(NULL, AV_LOG_TRACE, "end of chunk\n");
            avio_skip(pb, opcode_size);
            break;

        case OPCODE_CREATE_TIMER:
            av_log(NULL, AV_LOG_TRACE, "create timer\n");
            if ((opcode_version > 0) || (opcode_size != 6)) {
                av_log(NULL, AV_LOG_TRACE, "bad create_timer opcode\n");
                chunk_type = CHUNK_BAD;
                break;
            }
            if (avio_read(pb, scratch, opcode_size) !=
                opcode_size) {
                chunk_type = CHUNK_BAD;
                break;
            }
            s->frame_pts_inc = ((uint64_t)AV_RL32(&scratch[0])) * AV_RL16(&scratch[4]);
            av_log(NULL, AV_LOG_TRACE, "  %.2f frames/second (timer div = %d, subdiv = %d)\n",
                    1000000.0 / s->frame_pts_inc, AV_RL32(&scratch[0]),
                    AV_RL16(&scratch[4]));
            break;

        case OPCODE_INIT_AUDIO_BUFFERS:
            av_log(NULL, AV_LOG_TRACE, "initialize audio buffers\n");
            if (opcode_version > 1 || opcode_size > 10 || opcode_size < 6) {
                av_log(NULL, AV_LOG_TRACE, "bad init_audio_buffers opcode\n");
                chunk_type = CHUNK_BAD;
                break;
            }
            if (avio_read(pb, scratch, opcode_size) !=
                opcode_size) {
                chunk_type = CHUNK_BAD;
                break;
            }
            s->audio_sample_rate = AV_RL16(&scratch[4]);
            audio_flags = AV_RL16(&scratch[2]);
            /* bit 0 of the flags: 0 = mono, 1 = stereo */
            s->audio_channels = (audio_flags & 1) + 1;
            /* bit 1 of the flags: 0 = 8 bit, 1 = 16 bit */
            s->audio_bits = (((audio_flags >> 1) & 1) + 1) * 8;
            /* bit 2 indicates compressed audio in version 1 opcode */
            if ((opcode_version == 1) && (audio_flags & 0x4))
                s->audio_type = AV_CODEC_ID_INTERPLAY_DPCM;
            else if (s->audio_bits == 16)
                s->audio_type = AV_CODEC_ID_PCM_S16LE;
            else
                s->audio_type = AV_CODEC_ID_PCM_U8;
            av_log(NULL, AV_LOG_TRACE, "audio: %d bits, %d Hz, %s, %s format\n",
                    s->audio_bits, s->audio_sample_rate,
                    (s->audio_channels == 2) ? "stereo" : "mono",
                    (s->audio_type == AV_CODEC_ID_INTERPLAY_DPCM) ?
                    "Interplay audio" : "PCM");
            break;

        case OPCODE_START_STOP_AUDIO:
            av_log(NULL, AV_LOG_TRACE, "start/stop audio\n");
            avio_skip(pb, opcode_size);
            break;

        case OPCODE_INIT_VIDEO_BUFFERS:
            av_log(NULL, AV_LOG_TRACE, "initialize video buffers\n");
            if ((opcode_version > 2) || (opcode_size > 8) || opcode_size < 4
                || opcode_version == 2 && opcode_size < 8
            ) {
                av_log(NULL, AV_LOG_TRACE, "bad init_video_buffers opcode\n");
                chunk_type = CHUNK_BAD;
                break;
            }
            if (avio_read(pb, scratch, opcode_size) !=
                opcode_size) {
                chunk_type = CHUNK_BAD;
                break;
            }
            width  = AV_RL16(&scratch[0]) * 8;
            height = AV_RL16(&scratch[2]) * 8;
            if (width != s->video_width) {
                s->video_width = width;
                s->changed++;
            }
            if (height != s->video_height) {
                s->video_height = height;
                s->changed++;
            }
            if (opcode_version < 2 || !AV_RL16(&scratch[6])) {
                s->video_bpp = 8;
            } else {
                s->video_bpp = 16;
            }
            av_log(NULL, AV_LOG_TRACE, "video resolution: %d x %d\n",
                    s->video_width, s->video_height);
            break;

        case OPCODE_UNKNOWN_06:
        case OPCODE_UNKNOWN_0E:
        case OPCODE_UNKNOWN_10:
        case OPCODE_UNKNOWN_12:
        case OPCODE_UNKNOWN_13:
        case OPCODE_UNKNOWN_14:
        case OPCODE_UNKNOWN_15:
            av_log(NULL, AV_LOG_TRACE, "unknown (but documented) opcode %02X\n", opcode_type);
            avio_skip(pb, opcode_size);
            break;

        case OPCODE_SEND_BUFFER:
            av_log(NULL, AV_LOG_TRACE, "send buffer\n");
            avio_skip(pb, opcode_size);
            break;

        case OPCODE_AUDIO_FRAME:
            av_log(NULL, AV_LOG_TRACE, "audio frame\n");

            /* log position and move on for now */
            s->audio_chunk_offset = avio_tell(pb);
            s->audio_chunk_size = opcode_size;
            avio_skip(pb, opcode_size);
            break;

        case OPCODE_SILENCE_FRAME:
            av_log(NULL, AV_LOG_TRACE, "silence frame\n");
            avio_skip(pb, opcode_size);
            break;

        case OPCODE_INIT_VIDEO_MODE:
            av_log(NULL, AV_LOG_TRACE, "initialize video mode\n");
            avio_skip(pb, opcode_size);
            break;

        case OPCODE_CREATE_GRADIENT:
            av_log(NULL, AV_LOG_TRACE, "create gradient\n");
            avio_skip(pb, opcode_size);
            break;

        case OPCODE_SET_PALETTE:
            av_log(NULL, AV_LOG_TRACE, "set palette\n");
            /* check for the logical maximum palette size
             * (3 * 256 + 4 bytes) */
            if (opcode_size > 0x304 || opcode_size < 4) {
                av_log(NULL, AV_LOG_TRACE, "demux_ipmovie: set_palette opcode with invalid size\n");
                chunk_type = CHUNK_BAD;
                break;
            }
            if (avio_read(pb, scratch, opcode_size) != opcode_size) {
                chunk_type = CHUNK_BAD;
                break;
            }

            /* load the palette into internal data structure */
            first_color = AV_RL16(&scratch[0]);
            last_color = first_color + AV_RL16(&scratch[2]) - 1;
            /* sanity check (since they are 16 bit values) */
            if (   (first_color > 0xFF) || (last_color > 0xFF)
                || (last_color - first_color + 1)*3 + 4 > opcode_size) {
                av_log(NULL, AV_LOG_TRACE, "demux_ipmovie: set_palette indexes out of range (%d -> %d)\n",
                    first_color, last_color);
                chunk_type = CHUNK_BAD;
                break;
            }
            j = 4;  /* offset of first palette data */
            for (i = first_color; i <= last_color; i++) {
                /* the palette is stored as a 6-bit VGA palette, thus each
                 * component is shifted up to a 8-bit range */
                r = scratch[j++] * 4;
                g = scratch[j++] * 4;
                b = scratch[j++] * 4;
                s->palette[i] = (0xFFU << 24) | (r << 16) | (g << 8) | (b);
                s->palette[i] |= s->palette[i] >> 6 & 0x30303;
            }
            s->has_palette = 1;
            break;

        case OPCODE_SET_PALETTE_COMPRESSED:
            av_log(NULL, AV_LOG_TRACE, "set palette compressed\n");
            avio_skip(pb, opcode_size);
            break;

        case OPCODE_SET_DECODING_MAP:
            av_log(NULL, AV_LOG_TRACE, "set decoding map\n");

            /* log position and move on for now */
            s->decode_map_chunk_offset = avio_tell(pb);
            s->decode_map_chunk_size = opcode_size;
            avio_skip(pb, opcode_size);
            break;

        case OPCODE_VIDEO_DATA:
            av_log(NULL, AV_LOG_TRACE, "set video data\n");

            /* log position and move on for now */
            s->video_chunk_offset = avio_tell(pb);
            s->video_chunk_size = opcode_size;
            avio_skip(pb, opcode_size);
            break;

        default:
            av_log(NULL, AV_LOG_TRACE, "*** unknown opcode type\n");
            chunk_type = CHUNK_BAD;
            break;

        }
    }

    if (s->avf->nb_streams == 1 && s->audio_type)
        init_audio(s->avf);

    /* make a note of where the stream is sitting */
    s->next_chunk_offset = avio_tell(pb);

    /* dispatch the first of any pending packets */
    if ((chunk_type == CHUNK_VIDEO) || (chunk_type == CHUNK_AUDIO_ONLY))
        chunk_type = load_ipmovie_packet(s, pb, pkt);

    return chunk_type;
}
Esempio n. 30
0
File: main.c Progetto: dsqmoore/dsra
int main(int argc, const char * argv[])
{
	int list = 0;
	int i;
	const char * port = "4575";
	const char * device = NULL;
	for (i=1; i<=argc; i++)
	{
		if (!argv[i]) continue;
		if ((strcmp(argv[i],"-h")==0)||(strcmp(argv[i],"--help")==0)||(strcmp(argv[i],"-?")==0))
			usage();
		if (strncmp(argv[i],"-p=",3)==0)
		{
			port = argv[i]+3;
			continue;
		}
		if (strncmp(argv[i],"--port=",7)==0)
		{
			port = argv[i]+7;
			continue;
		}
		if (strcmp(argv[i],"-v")==0)
		{
			verbose = 1;
			continue;
		}
		if (strcmp(argv[i],"-l")==0)
		{
			list = 1;
			continue;
		}
		
		if (strcmp(argv[i],"--list")==0)
		{
			list = 1;
			continue;
		}
		if (strncmp(argv[i],"--dev=",6)==0)
		{
			device = argv[i]+6;
			continue;
		}
		printf("Unknown option: %s\n",argv[i]);
		usage();
	}
    if (init_audio()!=0)
        return 1;
	if ((dev=device_for_string(device))==-1)
	{
		fprintf(stderr,"Unknown device \"%s\"\n",device?device:"");
		cleanup_audio();
		return 1;
	} else {
		fprintf(stderr,"Using device \"%s\"\n",Pa_GetDeviceInfo(dev)->name);
	}
	if (list)
	{
		list_devices();
		cleanup_audio();
		return 0;
	}
	if (start_listening(port)!=0)
	{
		cleanup_audio();
		return 1;
	}
    cleanup_audio();
	return 0;
}