Exemplo n.º 1
0
int32 aq_fillable(void)
{
    int fillable;
    if(!IS_STREAM_TRACE)
	return 0;
    if(play_mode->acntl(PM_REQ_GETFILLABLE, &fillable) != -1)
	return fillable;
    return device_qsize / Bps - aq_filled();
}
Exemplo n.º 2
0
double aq_filled_ratio(void)
{
    double ratio;

    if(!IS_STREAM_TRACE)
	return 1.0;
    ratio = (double)aq_filled() * Bps / device_qsize;
    if(ratio > 1.0)
	return 1.0; /* for safety */
    return ratio;
}
Exemplo n.º 3
0
static void display_aq_ratio(void)
{
    static int last_rate = -1;
    int rate, devsiz;

    if((devsiz = aq_get_dev_queuesize()) == 0)
        return;

    rate = (int)(((double)(aq_filled() + aq_soft_filled()) / devsiz)
                 * 100 + 0.5);
    if(rate > 999)
        rate = 1000;
    Panel->aq_ratio = rate;
    if(last_rate != rate) {
        last_rate = Panel->aq_ratio = rate;
        Panel->changed = 1;
    }
}
Exemplo n.º 4
0
int aq_flush(int discard)
{
    int rc;
    int more_trace;

    /* to avoid infinite loop */
    double t, timeout_expect;

    aq_add_count = 0;
    init_effect();

    if(discard)
    {
	trace_flush();
	if(play_mode->acntl(PM_REQ_DISCARD, NULL) != -1)
	{
	    flush_buckets();
	    return RC_NONE;
	}
	ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
		  "ERROR: Can't discard audio buffer");
    }

    if(!IS_STREAM_TRACE)
    {
	play_mode->acntl(PM_REQ_FLUSH, NULL);
	play_counter = play_offset_counter = 0;
	return RC_NONE;
    }

    rc = aq_soft_flush();
    if(RC_IS_SKIP_FILE(rc))
	return rc;

    more_trace = 1;
    t = get_current_calender_time();
    timeout_expect = t + (double)aq_filled() / play_mode->rate;

    while(more_trace || aq_filled() > 0)
    {
	rc = check_apply_control();
	if(RC_IS_SKIP_FILE(rc))
	{
	    play_mode->acntl(PM_REQ_DISCARD, NULL);
	    flush_buckets();
	    return rc;
	}
	more_trace = trace_loop();

	t = get_current_calender_time();
	if(t >= timeout_expect - 0.1)
	  break;

	if(!more_trace)
	  usleep((unsigned long)((timeout_expect - t) * 1000000));
	else
	  aq_wait_ticks();
    }

    trace_flush();
    play_mode->acntl(PM_REQ_FLUSH, NULL);
    flush_buckets();
    return RC_NONE;
}