Exemple #1
0
unsigned long output_alsa_abort_stream(struct output *h,
				       struct output_stream *s)
{
	unsigned long played;

	/* Lock stream access */
	pthread_mutex_lock(&h->mutex);

	/* Pause stream */
	s->is_playing = 0;
	s->abort = 1;

	/* Lock cache */
	cache_lock(s->cache);

	/* Calculate played status */
	played = s->played * 1000 / h->samplerate / h->channels;

	/* Add not played samples */
	played += cache_delay(s->cache);
	played += resample_delay(s->res);

	/* Unlock stream access */
	pthread_mutex_unlock(&h->mutex);

	return played;
}
Exemple #2
0
unsigned long output_alsa_get_status_stream(struct output *h,
					    struct output_stream *s,
					    enum output_stream_key key)
{
	unsigned long ret = 0;

	/* Lock stream access */
	pthread_mutex_lock(&h->mutex);

	switch(key)
	{
		case OUTPUT_STREAM_STATUS:
			if(s->end_of_stream)
				ret = STREAM_ENDED;
			else if(s->is_playing)
				ret = STREAM_PLAYING;
			else
				ret = STREAM_PAUSED;
			break;
		case OUTPUT_STREAM_PLAYED:
			ret = s->played * 1000 / h->samplerate / h->channels;
			break;
		case OUTPUT_STREAM_CACHE_STATUS:
			if(s->delay > 0 && cache_is_ready(s->cache) == 0)
				ret = CACHE_BUFFERING;
			else
				ret = CACHE_READY;
			break;
		case OUTPUT_STREAM_CACHE_FILLING:
			if(s->delay > 0)
				ret = cache_get_filling(s->cache);
			else
				ret = 100;
			break;
		case OUTPUT_STREAM_CACHE_DELAY:
			ret = cache_delay(s->cache);
			break;
		default:
			ret = 0;
	}

	/* Unlock stream access */
	pthread_mutex_unlock(&h->mutex);

	return ret;
}
Exemple #3
0
void cache_update(struct peer_cache *c)
{
  cache_delay(c, 1);
}