Beispiel #1
0
/* Handles printing statistics depending upon whether or not we have 
   buffering going on */
void display_statistics (stat_format_t *stat_format,
			 buf_t *audio_buffer, 
			 data_source_t *source,
			 decoder_t *decoder)
{
  print_statistics_arg_t *pstats_arg;
  buffer_stats_t *buffer_stats;

  pstats_arg = new_print_statistics_arg(stat_format,
					source->transport->statistics(source),
					decoder->format->statistics(decoder));

  if (options.remote) {

    /* Display statistics via the remote interface */
    remote_time(pstats_arg->decoder_statistics->current_time,
                pstats_arg->decoder_statistics->total_time);

  } else {

	/* Disable/Enable statistics as needed */

	if (pstats_arg->decoder_statistics->total_time <
    	pstats_arg->decoder_statistics->current_time) {
      stat_format[2].enabled = 0;  /* Remaining playback time */
      stat_format[3].enabled = 0;  /* Total playback time */
	}

	if (pstats_arg->data_source_statistics->input_buffer_used) {
      stat_format[6].enabled = 1;  /* Input buffer fill % */
      stat_format[7].enabled = 1;  /* Input buffer state  */
	}

	if (audio_buffer) {
      /* Place a status update into the buffer */
      buffer_append_action_at_end(audio_buffer,
				  &print_statistics_action,
				  pstats_arg);

      /* And if we are not playing right now, do an immediate
    	 update just the output buffer */
      buffer_stats = buffer_statistics(audio_buffer);
      if (buffer_stats->paused || buffer_stats->prebuffering) {
    	pstats_arg = new_print_statistics_arg(stat_format,
					      NULL,
					      NULL);
    	print_statistics_action(audio_buffer, pstats_arg);
      }
      free(buffer_stats);

	} else
      print_statistics_action(NULL, pstats_arg);
  }
}
Beispiel #2
0
void display_statistics_quick (stat_format_t *stat_format,
			       buf_t *audio_buffer, 
			       data_source_t *source,
			       decoder_t *decoder)
{
  print_statistics_arg_t *pstats_arg;

  pstats_arg = new_print_statistics_arg(stat_format,
					source->transport->statistics(source),
					decoder->format->statistics(decoder));

  if (audio_buffer) {
    print_statistics_action(audio_buffer, pstats_arg);
  } else
    print_statistics_action(NULL, pstats_arg);
}
Beispiel #3
0
int progress_callback (void *arg, size_t dltotal, size_t dlnow,
		       size_t ultotal, size_t ulnow)
{
  http_private_t *myarg = arg;
  print_statistics_arg_t *pstats_arg;
  data_source_t *source = myarg->data_source;

  if (myarg->cancel_flag || sig_request.cancel)
    return -1;

  pstats_arg = new_print_statistics_arg(stat_format,
					source->transport->statistics(source),
					NULL);

  print_statistics_action(NULL, pstats_arg);

  if (myarg->cancel_flag || sig_request.cancel)
    return -1;

  return 0;
}