4 This file is part of PulseAudio.
6 Copyright 2004-2006 Lennart Poettering
7 Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published
11 by the Free Software Foundation; either version 2 of the License,
12 or (at your option) any later version.
14 PulseAudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with PulseAudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
34 #include <pulse/introspect.h>
35 #include <pulse/utf8.h>
36 #include <pulse/xmalloc.h>
38 #include <pulsecore/sink-input.h>
39 #include <pulsecore/namereg.h>
40 #include <pulsecore/core-util.h>
41 #include <pulsecore/sample-util.h>
42 #include <pulsecore/core-subscribe.h>
43 #include <pulsecore/log.h>
44 #include <pulsecore/macro.h>
45 #include <pulsecore/play-memblockq.h>
49 #define MAX_MIX_CHANNELS 32
50 #define SILENCE_BUFFER_LENGTH (64*1024)
52 static PA_DEFINE_CHECK_TYPE(pa_sink
, pa_msgobject
);
54 static void sink_free(pa_object
*s
);
61 const pa_sample_spec
*spec
,
62 const pa_channel_map
*map
) {
74 pa_return_null_if_fail(pa_sample_spec_valid(spec
));
77 map
= pa_channel_map_init_auto(&tmap
, spec
->channels
, PA_CHANNEL_MAP_DEFAULT
);
79 pa_return_null_if_fail(map
&& pa_channel_map_valid(map
));
80 pa_return_null_if_fail(map
->channels
== spec
->channels
);
81 pa_return_null_if_fail(!driver
|| pa_utf8_valid(driver
));
82 pa_return_null_if_fail(name
&& pa_utf8_valid(name
) && *name
);
84 s
= pa_msgobject_new(pa_sink
);
86 if (!(name
= pa_namereg_register(core
, name
, PA_NAMEREG_SINK
, s
, fail
))) {
91 s
->parent
.parent
.free
= sink_free
;
92 s
->parent
.process_msg
= pa_sink_process_msg
;
95 s
->state
= PA_SINK_IDLE
;
96 s
->name
= pa_xstrdup(name
);
97 s
->description
= NULL
;
98 s
->driver
= pa_xstrdup(driver
);
101 s
->sample_spec
= *spec
;
102 s
->channel_map
= *map
;
104 s
->inputs
= pa_idxset_new(NULL
, NULL
);
106 pa_cvolume_reset(&s
->volume
, spec
->channels
);
108 s
->refresh_volume
= s
->refresh_mute
= 0;
112 s
->get_latency
= NULL
;
113 s
->set_volume
= NULL
;
114 s
->get_volume
= NULL
;
123 r
= pa_idxset_put(core
->sinks
, s
, &s
->index
);
124 pa_assert(s
->index
!= PA_IDXSET_INVALID
&& r
>= 0);
126 pa_sample_spec_snprint(st
, sizeof(st
), spec
);
127 pa_log_info("Created sink %u \"%s\" with sample spec \"%s\"", s
->index
, s
->name
, st
);
129 n
= pa_sprintf_malloc("%s.monitor", name
);
131 if (!(s
->monitor_source
= pa_source_new(core
, driver
, n
, 0, spec
, map
)))
132 pa_log_warn("failed to create monitor source.");
135 s
->monitor_source
->monitor_of
= s
;
136 d
= pa_sprintf_malloc("Monitor Source of %s", s
->name
);
137 pa_source_set_description(s
->monitor_source
, d
);
143 s
->thread_info
.inputs
= pa_hashmap_new(pa_idxset_trivial_hash_func
, pa_idxset_trivial_compare_func
);
144 s
->thread_info
.soft_volume
= s
->volume
;
145 s
->thread_info
.soft_muted
= s
->muted
;
146 s
->thread_info
.state
= s
->state
;
148 pa_subscription_post(core
, PA_SUBSCRIPTION_EVENT_SINK
| PA_SUBSCRIPTION_EVENT_NEW
, s
->index
);
150 pa_hook_fire(&core
->hooks
[PA_CORE_HOOK_SINK_NEW_POST
], s
);
155 static int sink_set_state(pa_sink
*s
, pa_sink_state_t state
) {
160 if (s
->state
== state
)
164 if ((ret
= s
->set_state(s
, state
)) < 0)
167 if (pa_asyncmsgq_send(s
->asyncmsgq
, PA_MSGOBJECT(s
), PA_SINK_MESSAGE_SET_STATE
, PA_UINT_TO_PTR(state
), 0, NULL
) < 0)
172 pa_hook_fire(&s
->core
->hooks
[PA_CORE_HOOK_SINK_STATE_CHANGED
], s
);
176 void pa_sink_disconnect(pa_sink
* s
) {
177 pa_sink_input
*i
, *j
= NULL
;
180 pa_return_if_fail(s
->state
!= PA_SINK_DISCONNECTED
);
182 pa_hook_fire(&s
->core
->hooks
[PA_CORE_HOOK_SINK_DISCONNECT
], s
);
184 pa_namereg_unregister(s
->core
, s
->name
);
185 pa_idxset_remove_by_data(s
->core
->sinks
, s
, NULL
);
187 while ((i
= pa_idxset_first(s
->inputs
, NULL
))) {
189 pa_sink_input_kill(i
);
193 if (s
->monitor_source
)
194 pa_source_disconnect(s
->monitor_source
);
196 sink_set_state(s
, PA_SINK_DISCONNECTED
);
198 s
->get_latency
= NULL
;
199 s
->get_volume
= NULL
;
200 s
->set_volume
= NULL
;
205 pa_subscription_post(s
->core
, PA_SUBSCRIPTION_EVENT_SINK
| PA_SUBSCRIPTION_EVENT_REMOVE
, s
->index
);
207 pa_hook_fire(&s
->core
->hooks
[PA_CORE_HOOK_SINK_DISCONNECT_POST
], s
);
210 static void sink_free(pa_object
*o
) {
211 pa_sink
*s
= PA_SINK(o
);
215 pa_assert(pa_sink_refcnt(s
) == 0);
217 if (s
->state
!= PA_SINK_DISCONNECTED
)
218 pa_sink_disconnect(s
);
220 pa_log_info("Freeing sink %u \"%s\"", s
->index
, s
->name
);
222 if (s
->monitor_source
) {
223 pa_source_unref(s
->monitor_source
);
224 s
->monitor_source
= NULL
;
227 pa_idxset_free(s
->inputs
, NULL
, NULL
);
229 while ((i
= pa_hashmap_steal_first(s
->thread_info
.inputs
)))
230 pa_sink_input_unref(i
);
232 pa_hashmap_free(s
->thread_info
.inputs
, NULL
, NULL
);
235 pa_memblock_unref(s
->silence
);
238 pa_xfree(s
->description
);
243 void pa_sink_set_asyncmsgq(pa_sink
*s
, pa_asyncmsgq
*q
) {
244 pa_sink_assert_ref(s
);
249 if (s
->monitor_source
)
250 pa_source_set_asyncmsgq(s
->monitor_source
, q
);
253 int pa_sink_update_status(pa_sink
*s
) {
254 pa_sink_assert_ref(s
);
256 if (s
->state
== PA_SINK_SUSPENDED
)
259 return sink_set_state(s
, pa_sink_used_by(s
) ? PA_SINK_RUNNING
: PA_SINK_IDLE
);
262 int pa_sink_suspend(pa_sink
*s
, int suspend
) {
263 pa_sink_assert_ref(s
);
266 return sink_set_state(s
, PA_SINK_SUSPENDED
);
268 return sink_set_state(s
, pa_sink_used_by(s
) ? PA_SINK_RUNNING
: PA_SINK_IDLE
);
271 void pa_sink_ping(pa_sink
*s
) {
272 pa_sink_assert_ref(s
);
274 pa_asyncmsgq_post(s
->asyncmsgq
, PA_MSGOBJECT(s
), PA_SINK_MESSAGE_PING
, NULL
, 0, NULL
, NULL
);
277 static unsigned fill_mix_info(pa_sink
*s
, pa_mix_info
*info
, unsigned maxinfo
) {
282 pa_sink_assert_ref(s
);
285 while ((i
= pa_hashmap_iterate(s
->thread_info
.inputs
, &state
, NULL
)) && maxinfo
> 0) {
286 pa_sink_input_assert_ref(i
);
288 if (pa_sink_input_peek(i
, &info
->chunk
, &info
->volume
) < 0)
291 info
->userdata
= pa_sink_input_ref(i
);
293 pa_assert(info
->chunk
.memblock
);
294 pa_assert(info
->chunk
.length
> 0);
304 static void inputs_drop(pa_sink
*s
, pa_mix_info
*info
, unsigned n
, size_t length
) {
308 unsigned n_unreffed
= 0;
310 pa_sink_assert_ref(s
);
312 /* We optimize for the case where the order of the inputs has not changed */
314 while ((i
= pa_hashmap_iterate(s
->thread_info
.inputs
, &state
, NULL
))) {
318 pa_sink_input_assert_ref(i
);
322 /* Let's try to find the matching entry info the pa_mix_info array */
323 for (j
= 0; j
< n
; j
++) {
325 if (info
[p
].userdata
== i
) {
336 pa_sink_input_drop(i
, length
);
339 pa_sink_input_unref(m
->userdata
);
341 if (m
->chunk
.memblock
)
342 pa_memblock_unref(m
->chunk
.memblock
);
343 pa_memchunk_reset(&m
->chunk
);
349 /* Now drop references to entries that are included in the
350 * pa_mix_info array but don't exist anymore */
352 if (n_unreffed
< n
) {
353 for (; n
> 0; info
++, n
--) {
355 pa_sink_input_unref(info
->userdata
);
356 if (info
->chunk
.memblock
)
357 pa_memblock_unref(info
->chunk
.memblock
);
362 void pa_sink_render(pa_sink
*s
, size_t length
, pa_memchunk
*result
) {
363 pa_mix_info info
[MAX_MIX_CHANNELS
];
366 pa_sink_assert_ref(s
);
372 n
= s
->thread_info
.state
== PA_SINK_RUNNING
? fill_mix_info(s
, info
, MAX_MIX_CHANNELS
) : 0;
376 if (length
> SILENCE_BUFFER_LENGTH
)
377 length
= SILENCE_BUFFER_LENGTH
;
379 if (!s
->silence
|| pa_memblock_get_length(s
->silence
) < length
) {
381 pa_memblock_unref(s
->silence
);
382 s
->silence
= pa_silence_memblock_new(s
->core
->mempool
, &s
->sample_spec
, length
);
385 result
->memblock
= pa_memblock_ref(s
->silence
);
386 result
->length
= length
;
392 *result
= info
[0].chunk
;
393 pa_memblock_ref(result
->memblock
);
395 if (result
->length
> length
)
396 result
->length
= length
;
398 pa_sw_cvolume_multiply(&volume
, &s
->thread_info
.soft_volume
, &info
[0].volume
);
400 if (s
->thread_info
.soft_muted
|| !pa_cvolume_is_norm(&volume
)) {
401 pa_memchunk_make_writable(result
, 0);
402 if (s
->thread_info
.soft_muted
|| pa_cvolume_is_muted(&volume
))
403 pa_silence_memchunk(result
, &s
->sample_spec
);
405 pa_volume_memchunk(result
, &s
->sample_spec
, &volume
);
409 result
->memblock
= pa_memblock_new(s
->core
->mempool
, length
);
411 ptr
= pa_memblock_acquire(result
->memblock
);
412 result
->length
= pa_mix(info
, n
, ptr
, length
, &s
->sample_spec
, &s
->thread_info
.soft_volume
, s
->thread_info
.soft_muted
);
413 pa_memblock_release(result
->memblock
);
418 if (s
->thread_info
.state
== PA_SINK_RUNNING
)
419 inputs_drop(s
, info
, n
, result
->length
);
421 if (s
->monitor_source
)
422 pa_source_post(s
->monitor_source
, result
);
427 void pa_sink_render_into(pa_sink
*s
, pa_memchunk
*target
) {
428 pa_mix_info info
[MAX_MIX_CHANNELS
];
431 pa_sink_assert_ref(s
);
433 pa_assert(target
->memblock
);
434 pa_assert(target
->length
);
438 n
= s
->thread_info
.state
== PA_SINK_RUNNING
? fill_mix_info(s
, info
, MAX_MIX_CHANNELS
) : 0;
441 pa_silence_memchunk(target
, &s
->sample_spec
);
443 if (target
->length
> info
[0].chunk
.length
)
444 target
->length
= info
[0].chunk
.length
;
446 if (s
->thread_info
.soft_muted
)
447 pa_silence_memchunk(target
, &s
->sample_spec
);
452 ptr
= pa_memblock_acquire(target
->memblock
);
453 src
= pa_memblock_acquire(info
[0].chunk
.memblock
);
455 memcpy((uint8_t*) ptr
+ target
->index
,
456 (uint8_t*) src
+ info
[0].chunk
.index
,
459 pa_memblock_release(target
->memblock
);
460 pa_memblock_release(info
[0].chunk
.memblock
);
462 pa_sw_cvolume_multiply(&volume
, &s
->thread_info
.soft_volume
, &info
[0].volume
);
464 if (!pa_cvolume_is_norm(&volume
))
465 pa_volume_memchunk(target
, &s
->sample_spec
, &volume
);
471 ptr
= pa_memblock_acquire(target
->memblock
);
473 target
->length
= pa_mix(info
, n
,
474 (uint8_t*) ptr
+ target
->index
,
477 &s
->thread_info
.soft_volume
,
478 s
->thread_info
.soft_muted
);
480 pa_memblock_release(target
->memblock
);
483 if (s
->thread_info
.state
== PA_SINK_RUNNING
)
484 inputs_drop(s
, info
, n
, target
->length
);
486 if (s
->monitor_source
)
487 pa_source_post(s
->monitor_source
, target
);
492 void pa_sink_render_into_full(pa_sink
*s
, pa_memchunk
*target
) {
496 pa_sink_assert_ref(s
);
498 pa_assert(target
->memblock
);
499 pa_assert(target
->length
);
510 pa_sink_render_into(s
, &chunk
);
519 void pa_sink_render_full(pa_sink
*s
, size_t length
, pa_memchunk
*result
) {
520 pa_sink_assert_ref(s
);
524 /*** This needs optimization ***/
526 result
->memblock
= pa_memblock_new(s
->core
->mempool
, result
->length
= length
);
529 pa_sink_render_into_full(s
, result
);
532 pa_usec_t
pa_sink_get_latency(pa_sink
*s
) {
535 pa_sink_assert_ref(s
);
538 return s
->get_latency(s
);
540 if (pa_asyncmsgq_send(s
->asyncmsgq
, PA_MSGOBJECT(s
), PA_SINK_MESSAGE_GET_LATENCY
, &usec
, 0, NULL
) < 0)
546 void pa_sink_set_volume(pa_sink
*s
, const pa_cvolume
*volume
) {
549 pa_sink_assert_ref(s
);
552 changed
= !pa_cvolume_equal(volume
, &s
->volume
);
555 if (s
->set_volume
&& s
->set_volume(s
) < 0)
556 s
->set_volume
= NULL
;
559 pa_asyncmsgq_post(s
->asyncmsgq
, PA_MSGOBJECT(s
), PA_SINK_MESSAGE_SET_VOLUME
, pa_xnewdup(struct pa_cvolume
, volume
, 1), 0, NULL
, pa_xfree
);
562 pa_subscription_post(s
->core
, PA_SUBSCRIPTION_EVENT_SINK
|PA_SUBSCRIPTION_EVENT_CHANGE
, s
->index
);
565 const pa_cvolume
*pa_sink_get_volume(pa_sink
*s
) {
566 struct pa_cvolume old_volume
;
568 pa_sink_assert_ref(s
);
570 old_volume
= s
->volume
;
572 if (s
->get_volume
&& s
->get_volume(s
) < 0)
573 s
->get_volume
= NULL
;
575 if (!s
->get_volume
&& s
->refresh_volume
)
576 pa_asyncmsgq_send(s
->asyncmsgq
, PA_MSGOBJECT(s
), PA_SINK_MESSAGE_GET_VOLUME
, &s
->volume
, 0, NULL
);
578 if (!pa_cvolume_equal(&old_volume
, &s
->volume
))
579 pa_subscription_post(s
->core
, PA_SUBSCRIPTION_EVENT_SINK
|PA_SUBSCRIPTION_EVENT_CHANGE
, s
->index
);
584 void pa_sink_set_mute(pa_sink
*s
, int mute
) {
587 pa_sink_assert_ref(s
);
589 changed
= s
->muted
!= mute
;
591 if (s
->set_mute
&& s
->set_mute(s
) < 0)
595 pa_asyncmsgq_post(s
->asyncmsgq
, PA_MSGOBJECT(s
), PA_SINK_MESSAGE_SET_MUTE
, PA_UINT_TO_PTR(mute
), 0, NULL
, NULL
);
598 pa_subscription_post(s
->core
, PA_SUBSCRIPTION_EVENT_SINK
|PA_SUBSCRIPTION_EVENT_CHANGE
, s
->index
);
601 int pa_sink_get_mute(pa_sink
*s
) {
604 pa_sink_assert_ref(s
);
606 old_muted
= s
->muted
;
608 if (s
->get_mute
&& s
->get_mute(s
) < 0)
611 if (!s
->get_mute
&& s
->refresh_mute
)
612 pa_asyncmsgq_send(s
->asyncmsgq
, PA_MSGOBJECT(s
), PA_SINK_MESSAGE_GET_MUTE
, &s
->muted
, 0, NULL
);
614 if (old_muted
!= s
->muted
)
615 pa_subscription_post(s
->core
, PA_SUBSCRIPTION_EVENT_SINK
|PA_SUBSCRIPTION_EVENT_CHANGE
, s
->index
);
620 void pa_sink_set_module(pa_sink
*s
, pa_module
*m
) {
621 pa_sink_assert_ref(s
);
628 if (s
->monitor_source
)
629 pa_source_set_module(s
->monitor_source
, m
);
631 pa_subscription_post(s
->core
, PA_SUBSCRIPTION_EVENT_SINK
|PA_SUBSCRIPTION_EVENT_CHANGE
, s
->index
);
634 void pa_sink_set_description(pa_sink
*s
, const char *description
) {
635 pa_sink_assert_ref(s
);
637 if (!description
&& !s
->description
)
640 if (description
&& s
->description
&& !strcmp(description
, s
->description
))
643 pa_xfree(s
->description
);
644 s
->description
= pa_xstrdup(description
);
646 if (s
->monitor_source
) {
649 n
= pa_sprintf_malloc("Monitor Source of %s", s
->description
? s
->description
: s
->name
);
650 pa_source_set_description(s
->monitor_source
, n
);
654 pa_subscription_post(s
->core
, PA_SUBSCRIPTION_EVENT_SINK
|PA_SUBSCRIPTION_EVENT_CHANGE
, s
->index
);
657 unsigned pa_sink_used_by(pa_sink
*s
) {
660 pa_sink_assert_ref(s
);
662 ret
= pa_idxset_size(s
->inputs
);
664 if (s
->monitor_source
)
665 ret
+= pa_source_used_by(s
->monitor_source
);
670 int pa_sink_process_msg(pa_msgobject
*o
, int code
, void *userdata
, int64_t offset
, pa_memchunk
*chunk
) {
671 pa_sink
*s
= PA_SINK(o
);
672 pa_sink_assert_ref(s
);
674 switch ((pa_sink_message_t
) code
) {
676 case PA_SINK_MESSAGE_ADD_INPUT
: {
677 pa_sink_input
*i
= PA_SINK_INPUT(userdata
);
678 pa_hashmap_put(s
->thread_info
.inputs
, PA_UINT32_TO_PTR(i
->index
), pa_sink_input_ref(i
));
680 /* Since the caller sleeps in pa_sink_input_put(), we can
681 * safely access data outside of thread_info even though
684 if ((i
->thread_info
.sync_prev
= i
->sync_prev
)) {
685 pa_assert(i
->sink
== i
->thread_info
.sync_prev
->sink
);
686 pa_assert(i
->sync_prev
->sync_next
== i
);
687 i
->thread_info
.sync_prev
->thread_info
.sync_next
= i
;
690 if ((i
->thread_info
.sync_next
= i
->sync_next
)) {
691 pa_assert(i
->sink
== i
->thread_info
.sync_next
->sink
);
692 pa_assert(i
->sync_next
->sync_prev
== i
);
693 i
->thread_info
.sync_next
->thread_info
.sync_prev
= i
;
699 case PA_SINK_MESSAGE_REMOVE_INPUT
: {
700 pa_sink_input
*i
= PA_SINK_INPUT(userdata
);
702 /* Since the caller sleeps in pa_sink_input_disconnect(),
703 * we can safely access data outside of thread_info even
704 * though it is mutable */
706 pa_assert(!i
->thread_info
.sync_prev
);
707 pa_assert(!i
->thread_info
.sync_next
);
709 if (i
->thread_info
.sync_prev
) {
710 i
->thread_info
.sync_prev
->thread_info
.sync_next
= i
->thread_info
.sync_prev
->sync_next
;
711 i
->thread_info
.sync_prev
= NULL
;
714 if (i
->thread_info
.sync_next
) {
715 i
->thread_info
.sync_next
->thread_info
.sync_prev
= i
->thread_info
.sync_next
->sync_prev
;
716 i
->thread_info
.sync_next
= NULL
;
719 if (pa_hashmap_remove(s
->thread_info
.inputs
, PA_UINT32_TO_PTR(i
->index
)))
720 pa_sink_input_unref(i
);
725 case PA_SINK_MESSAGE_REMOVE_INPUT_AND_BUFFER
: {
726 pa_sink_input_move_info
*info
= userdata
;
729 /* We don't support moving synchronized streams. */
730 pa_assert(!info
->sink_input
->sync_prev
);
731 pa_assert(!info
->sink_input
->sync_next
);
732 pa_assert(!info
->sink_input
->thread_info
.sync_next
);
733 pa_assert(!info
->sink_input
->thread_info
.sync_prev
);
735 if (info
->ghost_sink_input
) {
736 pa_assert(info
->buffer_bytes
> 0);
737 pa_assert(info
->buffer
);
739 volume_is_norm
= pa_cvolume_is_norm(&info
->sink_input
->thread_info
.volume
);
741 pa_log_debug("Buffering %u bytes ...", info
->buffer_bytes
);
743 while (info
->buffer_bytes
> 0) {
744 pa_memchunk memchunk
;
748 if (pa_sink_input_peek(info
->sink_input
, &memchunk
, &volume
) < 0)
751 n
= memchunk
.length
> info
->buffer_bytes
? info
->buffer_bytes
: memchunk
.length
;
752 pa_sink_input_drop(info
->sink_input
, n
);
755 if (!volume_is_norm
) {
756 pa_memchunk_make_writable(&memchunk
, 0);
757 pa_volume_memchunk(&memchunk
, &s
->sample_spec
, &volume
);
760 if (pa_memblockq_push(info
->buffer
, &memchunk
) < 0) {
761 pa_memblock_unref(memchunk
.memblock
);
765 pa_memblock_unref(memchunk
.memblock
);
766 info
->buffer_bytes
-= n
;
769 /* Add the remaining already resampled chunk to the buffer */
770 if (info
->sink_input
->thread_info
.resampled_chunk
.memblock
)
771 pa_memblockq_push(info
->buffer
, &info
->sink_input
->thread_info
.resampled_chunk
);
773 pa_memblockq_sink_input_set_queue(info
->ghost_sink_input
, info
->buffer
);
775 pa_log_debug("Buffered %u bytes ...", pa_memblockq_get_length(info
->buffer
));
778 /* Let's remove the sink input ...*/
779 if (pa_hashmap_remove(s
->thread_info
.inputs
, PA_UINT32_TO_PTR(info
->sink_input
->index
)))
780 pa_sink_input_unref(info
->sink_input
);
782 /* .. and add the ghost sink input instead */
783 if (info
->ghost_sink_input
) {
784 pa_hashmap_put(s
->thread_info
.inputs
, PA_UINT32_TO_PTR(info
->ghost_sink_input
->index
), pa_sink_input_ref(info
->ghost_sink_input
));
785 info
->ghost_sink_input
->thread_info
.sync_prev
= info
->ghost_sink_input
->thread_info
.sync_next
= NULL
;
791 case PA_SINK_MESSAGE_SET_VOLUME
:
792 s
->thread_info
.soft_volume
= *((pa_cvolume
*) userdata
);
795 case PA_SINK_MESSAGE_SET_MUTE
:
796 s
->thread_info
.soft_muted
= PA_PTR_TO_UINT(userdata
);
799 case PA_SINK_MESSAGE_GET_VOLUME
:
800 *((pa_cvolume
*) userdata
) = s
->thread_info
.soft_volume
;
803 case PA_SINK_MESSAGE_GET_MUTE
:
804 *((int*) userdata
) = s
->thread_info
.soft_muted
;
807 case PA_SINK_MESSAGE_PING
:
810 case PA_SINK_MESSAGE_SET_STATE
:
812 s
->thread_info
.state
= PA_PTR_TO_UINT(userdata
);
815 case PA_SINK_MESSAGE_GET_LATENCY
:
816 case PA_SINK_MESSAGE_MAX
: