count corked streams per sink/source and make pa_sink_used_by() return only the number of streams that are not corked. Introduce pa_sink_linked_by() returning the number of streams connected at all. This will allow suspending of sinks/sources when all streams connected to a sink are corked.

git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1824 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2007-09-15 14:21:05 +00:00
parent 5ae4eed52e
commit 8389264d65
7 changed files with 64 additions and 7 deletions

View file

@ -101,6 +101,7 @@ pa_sink* pa_sink_new(
s->channel_map = *map;
s->inputs = pa_idxset_new(NULL, NULL);
s->n_corked = 0;
pa_cvolume_reset(&s->volume, spec->channels);
s->muted = 0;
@ -735,6 +736,20 @@ void pa_sink_set_description(pa_sink *s, const char *description) {
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
}
unsigned pa_sink_linked_by(pa_sink *s) {
unsigned ret;
pa_sink_assert_ref(s);
pa_assert(PA_SINK_LINKED(s->state));
ret = pa_idxset_size(s->inputs);
if (s->monitor_source)
ret += pa_source_used_by(s->monitor_source);
return ret;
}
unsigned pa_sink_used_by(pa_sink *s) {
unsigned ret;
@ -743,6 +758,10 @@ unsigned pa_sink_used_by(pa_sink *s) {
ret = pa_idxset_size(s->inputs);
pa_assert(ret >= s->n_corked);
ret -= s->n_corked;
if (s->monitor_source)
ret += pa_source_used_by(s->monitor_source);