summaryrefslogtreecommitdiff
path: root/src/xine-engine/audio_out.c
diff options
context:
space:
mode:
authorReinhard Nißl <rnissl@gmx.de>2011-01-22 14:54:31 +0100
committerReinhard Nißl <rnissl@gmx.de>2011-01-22 14:54:31 +0100
commit43fbcb6029f9a0f63ee8b61f63e54d74fc79de2a (patch)
treec4bf6e43457c3721b045bab870a481b63d92d5d1 /src/xine-engine/audio_out.c
parentc8e0257887a361a0b2b7a759309bcdb822d479b2 (diff)
downloadxine-lib-43fbcb6029f9a0f63ee8b61f63e54d74fc79de2a.tar.gz
xine-lib-43fbcb6029f9a0f63ee8b61f63e54d74fc79de2a.tar.bz2
Provide _x_query_buffers() to allow analyzing buffer usage by plugins
This function is similar to _x_query_buffer_usage() but retrieves also the total and available (= free) number of buffers besides the number of buffers ready for processing. For example if one wants to create a buffering algorithm based on the number of frames ready, it's not that easy to determine the maximum number of ready frames possible. In case one configures engine.buffers.video_num_frames:50 it may happen, that only 30 frames can actually be provided by the video out driver. Next a video codec like H.264 may hold several frames in its display picture buffer so that you may end up with only 13 ready frames at maximum. At the same time, the number of available (= free) frames will be 0 (or almost zero in case of vo). So it may be even easier to base the buffer algorithm on the number of free buffers. The reported numbers may also reveal that too few input buffers have been provided to compensate a large a/v offset at input stage. --HG-- extra : rebase_source : 255cb186891fbab5199a99031cf1b1e93ac19923
Diffstat (limited to 'src/xine-engine/audio_out.c')
-rw-r--r--src/xine-engine/audio_out.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c
index 5bb8242ae..4b2398bef 100644
--- a/src/xine-engine/audio_out.c
+++ b/src/xine-engine/audio_out.c
@@ -291,6 +291,7 @@ struct audio_fifo_s {
pthread_cond_t empty;
int num_buffers;
+ int num_buffers_max;
};
static int ao_get_property (xine_audio_port_t *this_gen, int property);
@@ -305,9 +306,10 @@ static audio_fifo_t *XINE_MALLOC fifo_new (xine_t *xine) {
if (!fifo)
return NULL;
- fifo->first = NULL;
- fifo->last = NULL;
- fifo->num_buffers = 0;
+ fifo->first = NULL;
+ fifo->last = NULL;
+ fifo->num_buffers = 0;
+ fifo->num_buffers_max = 0;
pthread_mutex_init (&fifo->mutex, NULL);
pthread_cond_init (&fifo->not_empty, NULL);
pthread_cond_init (&fifo->empty, NULL);
@@ -334,6 +336,10 @@ static void fifo_append_int (audio_fifo_t *fifo,
fifo->num_buffers++;
}
+
+ if (fifo->num_buffers_max < fifo->num_buffers)
+ fifo->num_buffers_max = fifo->num_buffers;
+
pthread_cond_signal (&fifo->not_empty);
}
@@ -1779,6 +1785,14 @@ static int ao_get_property (xine_audio_port_t *this_gen, int property) {
ret = this->audio_loop_running ? this->out_fifo->num_buffers : -1;
break;
+ case AO_PROP_BUFS_FREE:
+ ret = this->audio_loop_running ? this->free_fifo->num_buffers : -1;
+ break;
+
+ case AO_PROP_BUFS_TOTAL:
+ ret = this->audio_loop_running ? this->free_fifo->num_buffers_max : -1;
+ break;
+
case AO_PROP_NUM_STREAMS:
pthread_mutex_lock(&this->streams_lock);
ret = xine_list_size(this->streams);