示例#1
0
文件: player.c 项目: ayoucai/cmus
static void __producer_play(void)
{
	if (producer_status == PS_UNLOADED) {
		struct track_info *ti;

		if (get_next(&ti) == 0) {
			int rc;

			ip = ip_new(ti->filename);
			rc = ip_open(ip);
			if (rc) {
				player_ip_error(rc, "opening file `%s'", ti->filename);
				ip_delete(ip);
				track_info_unref(ti);
				file_changed(NULL);
			} else {
				ip_setup(ip);
				__producer_status_update(PS_PLAYING);
				file_changed(ti);
			}
		}
	} else if (producer_status == PS_PLAYING) {
		if (ip_seek(ip, 0.0) == 0) {
			reset_buffer();
		}
	} else if (producer_status == PS_STOPPED) {
		int rc;

		rc = ip_open(ip);
		if (rc) {
			player_ip_error(rc, "opening file `%s'", ip_get_filename(ip));
			ip_delete(ip);
			__producer_status_update(PS_UNLOADED);
		} else {
			ip_setup(ip);
			__producer_status_update(PS_PLAYING);
		}
	} else if (producer_status == PS_PAUSED) {
		__producer_status_update(PS_PLAYING);
	}
}
示例#2
0
/***********************************************************************************************
                        MAIN MENU FOR RETAIL

***********************************************************************************************/
int
main (void)
{
    struct tm intim;
    int Ret_val;
    double amount;
    unsigned char str[100] = "";
    pthread_t syncT;
    pthread_attr_t attr;
    int newprio;
    struct sched_param param;
    int ret;


//fp = fopen (logFile, "w+");
    fp = stdout;

    fprintf(fp,"Begun main()");
    fflush(fp);

    lk_open ();
    prn_open ();
    mscr_open ();
    lk_dispinit ();

    lk_dispclr();

    strcpy(DATABASE,"/mnt/jffs2/fps.sqlite");

    initialize_db ();

    open_sqlite (DATABASE);

    strcpy(CONFIG_FILE, get_config("CONFIG_FILE",tmpbuf,"0"));	//Need OFFICE ID From config file before init_globals
    read_config (CONFIG_FILE);
    strcpy(OFFICE_ID,getVal("office_id")); // Get from config file
    strcpy(SESSION_ID,"");

    fprintf(fp,"office_id:",OFFICE_ID);
    fflush(fp);

    init_globals();

    strcpy(IP,getVal("remote_url"));
    strcpy(shop_id,getVal("shop"));
    strcpy(terminal,getVal("terminal"));
    strcpy(tempFile,"/mnt/jffs2/dat");
    strcpy(svr_username,getVal("server_user"));
    strcpy(svr_password,getVal("server_pwd"));

    setAuthType();

    if(strcmp(toUpper(getVal("show_splash")),"TRUE")==0)
    {
        lk_disptext (1, 0, "        PDS ", 1);
        lk_disptext (3, 0, "     Govt of AP", 0);
        lk_disptext (4, 0, "    Version:0.9", 0);
        lk_disptext (5, 0, "  Enter to continue", 0);
        lk_getkey ();
        lk_dispclr ();
    }

    if(strcmp(toUpper(getVal("commMode")),"ETHERNET") == 0)
        ip_setup ();

    strcpy(background,getVal("background"));

    pthread_attr_init(&attr);
    pthread_attr_setschedpolicy(&attr, SCHED_OTHER);
    newprio = 1;
    param.sched_priority = newprio;
    pthread_attr_setschedparam(&attr,&param);

    if(strcmp(background,"true")==0) {
        fprintf(fp,"Starting a background thread");
        fflush(fp);

        if (pthread_create (&syncT, &attr, syncThread, NULL) != 0)
            fprintf (stderr, "Error creating the thread");
    }

    while(1) {
        ret = login();

        printFlag = FALSE;

        if(ret==USER)
            main_menu();
        else if(ret == ADMIN)
            admin_menu();
        else {
            lk_dispclr();
            lk_disptext (2, 0, "Invalid credentials", 0);
            lk_getkey ();
            lk_dispclr ();
        }
    }

    prn_close ();			// closing printer
    lk_close ();			// closing pinpad
    mscr_close ();		// closing magnetic swipe
    close_sqlite ();

    fprintf(fp,"Ended main()");
    fflush(fp);

    return SUCCESS;
}