summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <arun.raghavan@collabora.co.uk>2011-08-12 16:34:28 +0530
committerArun Raghavan <arun.raghavan@collabora.co.uk>2011-08-15 11:51:34 +0530
commit485d4dd54260b680b0e5d0af35ad380280a4c826 (patch)
tree5707e468e14a842b185f78f254119e94f59aa4a7
parentb430407f47fac227b4a6952ab502705d83ff90f5 (diff)
downloadpulseaudio-panda-485d4dd54260b680b0e5d0af35ad380280a4c826.tar.gz
pulseaudio-panda-485d4dd54260b680b0e5d0af35ad380280a4c826.tar.bz2
pulseaudio-panda-485d4dd54260b680b0e5d0af35ad380280a4c826.zip
sink: Add a set_formats() API
This adds API to let external sources specify what formats a sink supports. Sinks must opt-in to allow this, and can perform some validation if required.
-rw-r--r--src/pulsecore/sink.c16
-rw-r--r--src/pulsecore/sink.h7
2 files changed, 23 insertions, 0 deletions
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 42a8eb3d..62776985 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -180,6 +180,7 @@ static void reset_callbacks(pa_sink *s) {
s->update_requested_latency = NULL;
s->set_port = NULL;
s->get_formats = NULL;
+ s->set_formats = NULL;
}
/* Called from main context */
@@ -3429,6 +3430,21 @@ pa_idxset* pa_sink_get_formats(pa_sink *s) {
}
/* Called from the main thread */
+/* Allows an external source to set what formats a sink supports if the sink
+ * permits this. The function makes a copy of the formats on success. */
+pa_bool_t pa_sink_set_formats(pa_sink *s, pa_idxset *formats) {
+ pa_assert(s);
+ pa_assert(formats);
+
+ if (s->set_formats)
+ /* Sink supports setting formats -- let's give it a shot */
+ return s->set_formats(s, formats);
+ else
+ /* Sink doesn't support setting this -- bail out */
+ return FALSE;
+}
+
+/* Called from the main thread */
/* Checks if the sink can accept this format */
pa_bool_t pa_sink_check_format(pa_sink *s, pa_format_info *f)
{
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 8aa04b86..0bd5e81e 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -223,6 +223,12 @@ struct pa_sink {
* in descending order of preference. */
pa_idxset* (*get_formats)(pa_sink *s); /* ditto */
+ /* Called to set the list of formats supported by the sink. Can be
+ * NULL if the sink does not support this. Returns TRUE on success,
+ * FALSE otherwise (for example when an unsupportable format is
+ * set). Makes a copy of the formats passed in. */
+ pa_bool_t (*set_formats)(pa_sink *s, pa_idxset *formats); /* ditto */
+
/* Contains copies of the above data so that the real-time worker
* thread can work without access locking */
struct {
@@ -434,6 +440,7 @@ void pa_sink_move_all_finish(pa_sink *s, pa_queue *q, pa_bool_t save);
void pa_sink_move_all_fail(pa_queue *q);
pa_idxset* pa_sink_get_formats(pa_sink *s);
+pa_bool_t pa_sink_set_formats(pa_sink *s, pa_idxset *formats);
pa_bool_t pa_sink_check_format(pa_sink *s, pa_format_info *f);
pa_idxset* pa_sink_check_formats(pa_sink *s, pa_idxset *in_formats);