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
31 #ifdef HAVE_SYS_POLL_H
37 #include <asoundlib.h>
39 #include <pulse/xmalloc.h>
40 #include <pulse/util.h>
42 #include <pulsecore/core.h>
43 #include <pulsecore/module.h>
44 #include <pulsecore/memchunk.h>
45 #include <pulsecore/sink.h>
46 #include <pulsecore/modargs.h>
47 #include <pulsecore/core-util.h>
48 #include <pulsecore/sample-util.h>
49 #include <pulsecore/log.h>
50 #include <pulsecore/macro.h>
51 #include <pulsecore/thread.h>
52 #include <pulsecore/core-error.h>
54 #include "alsa-util.h"
55 #include "module-alsa-sink-symdef.h"
57 PA_MODULE_AUTHOR("Lennart Poettering")
58 PA_MODULE_DESCRIPTION("ALSA Sink")
59 PA_MODULE_VERSION(PACKAGE_VERSION
)
61 "sink_name=<name for the sink> "
62 "device=<ALSA device> "
63 "format=<sample format> "
64 "channels=<number of channels> "
66 "fragments=<number of fragments> "
67 "fragment_size=<fragment size> "
68 "channel_map=<channel map> "
69 "mmap=<enable memory mapping?>")
71 #define DEFAULT_DEVICE "default"
73 #define DEFAULT_NFRAGS 4
74 #define DEFAULT_FRAGSIZE_MSEC 25
81 pa_asyncmsgq
*asyncmsgq
;
83 snd_pcm_t
*pcm_handle
;
85 pa_alsa_fdlist
*mixer_fdl
;
86 snd_mixer_t
*mixer_handle
;
87 snd_mixer_elem_t
*mixer_elem
;
88 long hw_volume_max
, hw_volume_min
;
90 size_t frame_size
, fragment_size
, hwbuf_size
;
101 static const char* const valid_modargs
[] = {
114 static int mmap_write(struct userdata
*u
) {
117 const snd_pcm_channel_area_t
*areas
;
118 snd_pcm_uframes_t offset
, frames
;
128 if ((n
= snd_pcm_avail_update(u
->pcm_handle
)) < 0) {
131 pa_log_debug("snd_pcm_avail_update: Buffer underrun!");
135 if ((err
= snd_pcm_recover(u
->pcm_handle
, n
, 1)) == 0)
141 pa_log("snd_pcm_avail_update: %s", snd_strerror(n
));
145 /* pa_log("Got request for %i samples", (int) n); */
152 if ((err
= snd_pcm_mmap_begin(u
->pcm_handle
, &areas
, &offset
, &frames
)) < 0) {
155 pa_log_debug("snd_pcm_mmap_begin: Buffer underrun!");
159 if ((err
= snd_pcm_recover(u
->pcm_handle
, err
, 1)) == 0)
165 pa_log("Failed to write data to DSP: %s", snd_strerror(err
));
169 /* Check these are multiples of 8 bit */
170 pa_assert((areas
[0].first
& 7) == 0);
171 pa_assert((areas
[0].step
& 7)== 0);
173 /* We assume a single interleaved memory buffer */
174 pa_assert((areas
[0].first
>> 3) == 0);
175 pa_assert((areas
[0].step
>> 3) == u
->frame_size
);
177 p
= (uint8_t*) areas
[0].addr
+ (offset
* u
->frame_size
);
179 chunk
.memblock
= pa_memblock_new_fixed(u
->core
->mempool
, p
, frames
* u
->frame_size
, 1);
180 chunk
.length
= pa_memblock_get_length(chunk
.memblock
);
183 pa_sink_render_into_full(u
->sink
, &chunk
);
185 /* FIXME: Maybe we can do something to keep this memory block
186 * a little bit longer around? */
187 pa_memblock_unref_fixed(chunk
.memblock
);
189 if ((err
= snd_pcm_mmap_commit(u
->pcm_handle
, offset
, frames
)) < 0) {
192 pa_log_debug("snd_pcm_mmap_commit: Buffer underrun!");
196 if ((err
= snd_pcm_recover(u
->pcm_handle
, err
, 1)) == 0)
202 pa_log("Failed to write data to DSP: %s", snd_strerror(err
));
208 /* pa_log("wrote %i samples", (int) frames); */
212 static pa_usec_t
sink_get_latency(struct userdata
*u
) {
214 snd_pcm_sframes_t frames
= 0;
219 snd_pcm_avail_update(u
->pcm_handle
);
221 if ((err
= snd_pcm_delay(u
->pcm_handle
, &frames
)) < 0) {
222 pa_log("Failed to get delay: %s", snd_strerror(err
));
227 r
= pa_bytes_to_usec(frames
* u
->frame_size
, &u
->sink
->sample_spec
);
229 if (u
->memchunk
.memblock
)
230 r
+= pa_bytes_to_usec(u
->memchunk
.length
, &u
->sink
->sample_spec
);
235 static int suspend(struct userdata
*u
) {
237 pa_assert(u
->pcm_handle
);
239 snd_pcm_drain(u
->pcm_handle
); /* Let's suspend */
240 snd_pcm_close(u
->pcm_handle
);
241 u
->pcm_handle
= NULL
;
243 pa_log_debug("Device suspended...");
248 static int unsuspend(struct userdata
*u
) {
252 snd_pcm_uframes_t period_size
;
255 pa_assert(!u
->pcm_handle
);
257 pa_log_debug("Trying resume...");
259 snd_config_update_free_global();
260 if ((err
= snd_pcm_open(&u
->pcm_handle
, u
->device_name
, SND_PCM_STREAM_PLAYBACK
, SND_PCM_NONBLOCK
)) < 0) {
261 pa_log("Error opening PCM device %s: %s", u
->device_name
, snd_strerror(err
));
265 ss
= u
->sink
->sample_spec
;
266 nfrags
= u
->nfragments
;
267 period_size
= u
->fragment_size
/ u
->frame_size
;
270 if ((err
= pa_alsa_set_hw_params(u
->pcm_handle
, &ss
, &nfrags
, &period_size
, &b
)) < 0) {
271 pa_log("Failed to set hardware parameters: %s", snd_strerror(err
));
275 if (b
!= u
->use_mmap
) {
276 pa_log_warn("Resume failed, couldn't get original access mode.");
280 if (!pa_sample_spec_equal(&ss
, &u
->sink
->sample_spec
)) {
281 pa_log_warn("Resume failed, couldn't restore original sample settings.");
285 if (nfrags
!= u
->nfragments
|| period_size
*u
->frame_size
!= u
->fragment_size
) {
286 pa_log_warn("Resume failed, couldn't restore original fragment settings.");
290 /* FIXME: We need to reload the volume somehow */
294 pa_log_debug("Resumed successfully...");
299 snd_pcm_close(u
->pcm_handle
);
300 u
->pcm_handle
= NULL
;
305 static int sink_process_msg(pa_msgobject
*o
, int code
, void *data
, pa_memchunk
*chunk
) {
306 struct userdata
*u
= PA_SINK(o
)->userdata
;
310 case PA_SINK_MESSAGE_GET_LATENCY
: {
314 r
= sink_get_latency(u
);
316 *((pa_usec_t
*) data
) = r
;
321 case PA_SINK_MESSAGE_SET_STATE
:
323 switch ((pa_sink_state_t
) PA_PTR_TO_UINT(data
)) {
325 case PA_SINK_SUSPENDED
:
326 pa_assert(PA_SINK_OPENED(u
->sink
->thread_info
.state
));
334 case PA_SINK_RUNNING
:
336 if (u
->sink
->thread_info
.state
== PA_SINK_SUSPENDED
) {
337 if (unsuspend(u
) < 0)
343 case PA_SINK_DISCONNECTED
:
350 return pa_sink_process_msg(o
, code
, data
, chunk
);
353 static int mixer_callback(snd_mixer_elem_t
*elem
, unsigned int mask
) {
354 struct userdata
*u
= snd_mixer_elem_get_callback_private(elem
);
357 pa_assert(u
->mixer_handle
);
359 if (mask
== SND_CTL_EVENT_MASK_REMOVE
)
362 if (mask
& SND_CTL_EVENT_MASK_VALUE
) {
363 pa_sink_get_volume(u
->sink
);
364 pa_sink_get_mute(u
->sink
);
370 static int sink_get_volume_cb(pa_sink
*s
) {
371 struct userdata
*u
= s
->userdata
;
376 pa_assert(u
->mixer_elem
);
378 for (i
= 0; i
< s
->sample_spec
.channels
; i
++) {
381 pa_assert(snd_mixer_selem_has_playback_channel(u
->mixer_elem
, i
));
383 if ((err
= snd_mixer_selem_get_playback_volume(u
->mixer_elem
, i
, &vol
)) < 0)
386 set_vol
= (long) roundf(((float) s
->volume
.values
[i
] * (u
->hw_volume_max
- u
->hw_volume_min
)) / PA_VOLUME_NORM
) + u
->hw_volume_min
;
388 /* Try to avoid superfluous volume changes */
390 s
->volume
.values
[i
] = (pa_volume_t
) roundf(((float) (vol
- u
->hw_volume_min
) * PA_VOLUME_NORM
) / (u
->hw_volume_max
- u
->hw_volume_min
));
396 pa_log_error("Unable to read volume: %s", snd_strerror(err
));
398 s
->get_volume
= NULL
;
399 s
->set_volume
= NULL
;
403 static int sink_set_volume_cb(pa_sink
*s
) {
404 struct userdata
*u
= s
->userdata
;
409 pa_assert(u
->mixer_elem
);
411 for (i
= 0; i
< s
->sample_spec
.channels
; i
++) {
415 pa_assert(snd_mixer_selem_has_playback_channel(u
->mixer_elem
, i
));
417 vol
= s
->volume
.values
[i
];
419 if (vol
> PA_VOLUME_NORM
)
420 vol
= PA_VOLUME_NORM
;
422 alsa_vol
= (long) roundf(((float) vol
* (u
->hw_volume_max
- u
->hw_volume_min
)) / PA_VOLUME_NORM
) + u
->hw_volume_min
;
424 if ((err
= snd_mixer_selem_set_playback_volume(u
->mixer_elem
, i
, alsa_vol
)) < 0)
431 pa_log_error("Unable to set volume: %s", snd_strerror(err
));
433 s
->get_volume
= NULL
;
434 s
->set_volume
= NULL
;
438 static int sink_get_mute_cb(pa_sink
*s
) {
439 struct userdata
*u
= s
->userdata
;
443 pa_assert(u
->mixer_elem
);
445 if ((err
= snd_mixer_selem_get_playback_switch(u
->mixer_elem
, 0, &sw
)) < 0) {
446 pa_log_error("Unable to get switch: %s", snd_strerror(err
));
458 static int sink_set_mute_cb(pa_sink
*s
) {
459 struct userdata
*u
= s
->userdata
;
463 pa_assert(u
->mixer_elem
);
465 if ((err
= snd_mixer_selem_set_playback_switch_all(u
->mixer_elem
, !s
->muted
)) < 0) {
466 pa_log_error("Unable to set switch: %s", snd_strerror(err
));
476 static void thread_func(void *userdata
) {
482 struct userdata
*u
= userdata
;
483 struct pollfd
*pollfd
= NULL
;
485 unsigned short revents
= 0;
486 snd_pcm_status_t
*status
;
489 snd_pcm_status_alloca(&status
);
491 pa_log_debug("Thread starting up");
493 if ((n_alsa_fds
= snd_pcm_poll_descriptors_count(u
->pcm_handle
)) < 0) {
494 pa_log("snd_pcm_poll_descriptors_count() failed: %s", snd_strerror(n_alsa_fds
));
498 pollfd
= pa_xnew0(struct pollfd
, POLLFD_ALSA_BASE
+ n_alsa_fds
);
500 pollfd
[POLLFD_ASYNCQ
].fd
= pa_asyncmsgq_get_fd(u
->asyncmsgq
);
501 pollfd
[POLLFD_ASYNCQ
].events
= POLLIN
;
503 if ((err
= snd_pcm_poll_descriptors(u
->pcm_handle
, pollfd
+POLLFD_ALSA_BASE
, n_alsa_fds
)) < 0) {
504 pa_log("snd_pcm_poll_descriptors() failed: %s", snd_strerror(err
));
509 pa_msgobject
*object
;
515 /* pa_log("loop"); */
517 /* Check whether there is a message for us to process */
518 if (pa_asyncmsgq_get(u
->asyncmsgq
, &object
, &code
, &data
, &chunk
, 0) == 0) {
521 /* pa_log("processing msg"); */
523 if (!object
&& code
== PA_MESSAGE_SHUTDOWN
) {
524 pa_asyncmsgq_done(u
->asyncmsgq
, 0);
528 ret
= pa_asyncmsgq_dispatch(object
, code
, data
, &chunk
);
529 pa_asyncmsgq_done(u
->asyncmsgq
, ret
);
533 /* pa_log("loop2"); */
535 /* Render some data and write it to the dsp */
537 if (PA_SINK_OPENED(u
->sink
->thread_info
.state
) && ((revents
& POLLOUT
) || u
->first
== 1)) {
539 pa_assert(u
->pcm_handle
);
543 if ((work_done
= mmap_write(u
)) < 0)
549 snd_pcm_hwsync(u
->pcm_handle
);
550 if ((err
= snd_pcm_status(u
->pcm_handle
, status
)) >= 0)
551 l
= snd_pcm_status_get_avail(status
) * u
->frame_size
;
553 l
= u
->fragment_size
;
561 if (u
->memchunk
.length
<= 0)
562 pa_sink_render(u
->sink
, l
, &u
->memchunk
);
564 pa_assert(u
->memchunk
.length
> 0);
566 p
= pa_memblock_acquire(u
->memchunk
.memblock
);
567 t
= snd_pcm_writei(u
->pcm_handle
, (const uint8_t*) p
+ u
->memchunk
.index
, u
->memchunk
.length
/ u
->frame_size
);
568 pa_memblock_release(u
->memchunk
.memblock
);
570 /* pa_log("wrote %i bytes of %u (%u)", t*u->frame_size, u->memchunk.length, l); */
577 pa_log_debug("Buffer underrun!");
581 if ((t
= snd_pcm_recover(u
->pcm_handle
, t
, 1)) == 0)
585 pa_log_debug("EAGAIN");
588 pa_log("Failed to write data to DSP: %s", snd_strerror(t
));
594 u
->memchunk
.index
+= t
* u
->frame_size
;
595 u
->memchunk
.length
-= t
* u
->frame_size
;
597 if (u
->memchunk
.length
<= 0) {
598 pa_memblock_unref(u
->memchunk
.memblock
);
599 pa_memchunk_reset(&u
->memchunk
);
602 l
-= t
* u
->frame_size
;
614 pa_log_info("Starting playback.");
615 snd_pcm_start(u
->pcm_handle
);
623 /* Hmm, nothing to do. Let's sleep */
624 if (pa_asyncmsgq_before_poll(u
->asyncmsgq
) < 0)
627 /* pa_log("polling for %i", POLLFD_ALSA_BASE + (PA_SINK_OPENED(u->sink->thread_info.state) ? n_alsa_fds : 0)); */
628 r
= poll(pollfd
, POLLFD_ALSA_BASE
+ (PA_SINK_OPENED(u
->sink
->thread_info
.state
) ? n_alsa_fds
: 0), -1);
629 /*pa_log("polling got dsp=%i amq=%i (%i)", r > 0 ? pollfd[POLLFD_DSP].revents : 0, r > 0 ? pollfd[POLLFD_ASYNCQ].revents : 0, r); */
630 /* pa_log("poll end"); */
632 pa_asyncmsgq_after_poll(u
->asyncmsgq
);
635 if (errno
== EINTR
) {
636 pollfd
[POLLFD_ASYNCQ
].revents
= 0;
641 pa_log("poll() failed: %s", pa_cstrerror(errno
));
647 if (PA_SINK_OPENED(u
->sink
->thread_info
.state
)) {
648 if ((err
= snd_pcm_poll_descriptors_revents(u
->pcm_handle
, pollfd
+ POLLFD_ALSA_BASE
, n_alsa_fds
, &revents
)) < 0) {
649 pa_log("snd_pcm_poll_descriptors_revents() failed: %s", snd_strerror(err
));
653 /* pa_log("got alsa event"); */
657 pa_assert((pollfd
[POLLFD_ASYNCQ
].revents
& ~POLLIN
) == 0);
661 /* We have to continue processing messages until we receive the
662 * SHUTDOWN message */
663 pa_asyncmsgq_post(u
->core
->asyncmsgq
, PA_MSGOBJECT(u
->core
), PA_CORE_MESSAGE_UNLOAD_MODULE
, u
->module
, NULL
, NULL
);
664 pa_asyncmsgq_wait_for(u
->asyncmsgq
, PA_MESSAGE_SHUTDOWN
);
667 pa_log_debug("Thread shutting down");
672 int pa__init(pa_core
*c
, pa_module
*m
) {
674 pa_modargs
*ma
= NULL
;
676 struct userdata
*u
= NULL
;
680 uint32_t nfrags
, frag_size
;
681 snd_pcm_uframes_t period_size
;
683 snd_pcm_info_t
*pcm_info
= NULL
;
687 char *name_buf
= NULL
;
694 if (!(ma
= pa_modargs_new(m
->argument
, valid_modargs
))) {
695 pa_log("Failed to parse module arguments");
699 ss
= c
->default_sample_spec
;
700 if (pa_modargs_get_sample_spec_and_channel_map(ma
, &ss
, &map
, PA_CHANNEL_MAP_ALSA
) < 0) {
701 pa_log("Failed to parse sample specification and channel map");
705 frame_size
= pa_frame_size(&ss
);
707 nfrags
= DEFAULT_NFRAGS
;
708 frag_size
= pa_usec_to_bytes(DEFAULT_FRAGSIZE_MSEC
*1000, &ss
);
710 frag_size
= frame_size
;
712 if (pa_modargs_get_value_u32(ma
, "fragments", &nfrags
) < 0 || pa_modargs_get_value_u32(ma
, "fragment_size", &frag_size
) < 0) {
713 pa_log("Failed to parse buffer metrics");
716 period_size
= frag_size
/frame_size
;
718 if (pa_modargs_get_value_boolean(ma
, "mmap", &use_mmap
) < 0) {
719 pa_log("Failed to parse mmap argument.");
723 u
= pa_xnew0(struct userdata
, 1);
727 u
->use_mmap
= use_mmap
;
729 pa_assert_se(u
->asyncmsgq
= pa_asyncmsgq_new(0));
731 snd_config_update_free_global();
732 if ((err
= snd_pcm_open(&u
->pcm_handle
, dev
= pa_modargs_get_value(ma
, "device", DEFAULT_DEVICE
), SND_PCM_STREAM_PLAYBACK
, SND_PCM_NONBLOCK
)) < 0) {
733 pa_log("Error opening PCM device %s: %s", dev
, snd_strerror(err
));
737 u
->device_name
= pa_xstrdup(dev
);
739 if ((err
= snd_pcm_info_malloc(&pcm_info
)) < 0 ||
740 (err
= snd_pcm_info(u
->pcm_handle
, pcm_info
)) < 0) {
741 pa_log("Error fetching PCM info: %s", snd_strerror(err
));
746 if ((err
= pa_alsa_set_hw_params(u
->pcm_handle
, &ss
, &nfrags
, &period_size
, &b
)) < 0) {
747 pa_log("Failed to set hardware parameters: %s", snd_strerror(err
));
751 if (use_mmap
&& !b
) {
752 pa_log_info("Device doesn't support mmap(), falling back to UNIX read/write mode.");
753 u
->use_mmap
= use_mmap
= b
;
757 pa_log_info("Successfully enabled mmap() mode.");
759 /* ALSA might tweak the sample spec, so recalculate the frame size */
760 frame_size
= pa_frame_size(&ss
);
762 if (ss
.channels
!= map
.channels
)
763 /* Seems ALSA didn't like the channel number, so let's fix the channel map */
764 pa_channel_map_init_auto(&map
, ss
.channels
, PA_CHANNEL_MAP_ALSA
);
766 if ((err
= snd_mixer_open(&u
->mixer_handle
, 0)) < 0)
767 pa_log_warn("Error opening mixer: %s", snd_strerror(err
));
770 if ((pa_alsa_prepare_mixer(u
->mixer_handle
, dev
) < 0) ||
771 !(u
->mixer_elem
= pa_alsa_find_elem(u
->mixer_handle
, "PCM", "Master"))) {
773 snd_mixer_close(u
->mixer_handle
);
774 u
->mixer_handle
= NULL
;
778 if ((name
= pa_modargs_get_value(ma
, "sink_name", NULL
)))
781 name
= name_buf
= pa_sprintf_malloc("alsa_output.%s", dev
);
785 u
->sink
= pa_sink_new(c
, __FILE__
, name
, namereg_fail
, &ss
, &map
);
789 pa_log("Failed to create sink object");
793 u
->sink
->parent
.process_msg
= sink_process_msg
;
794 u
->sink
->userdata
= u
;
796 pa_sink_set_module(u
->sink
, m
);
797 pa_sink_set_asyncmsgq(u
->sink
, u
->asyncmsgq
);
798 pa_sink_set_description(u
->sink
, t
= pa_sprintf_malloc(
799 "ALSA PCM on %s (%s)",
801 snd_pcm_info_get_name(pcm_info
)));
804 u
->sink
->is_hardware
= 1;
806 u
->frame_size
= frame_size
;
807 u
->fragment_size
= frag_size
= period_size
* frame_size
;
808 u
->nfragments
= nfrags
;
809 u
->hwbuf_size
= u
->fragment_size
* nfrags
;
811 pa_log_info("Using %u fragments of size %lu bytes.", nfrags
, (long unsigned) u
->fragment_size
);
813 pa_memchunk_reset(&u
->memchunk
);
815 if (u
->mixer_handle
) {
816 /* Initialize mixer code */
818 pa_assert(u
->mixer_elem
);
820 if (snd_mixer_selem_has_playback_volume(u
->mixer_elem
)) {
823 for (i
= 0;i
< ss
.channels
; i
++) {
824 if (!snd_mixer_selem_has_playback_channel(u
->mixer_elem
, i
))
828 if (i
== ss
.channels
) {
829 u
->sink
->get_volume
= sink_get_volume_cb
;
830 u
->sink
->set_volume
= sink_set_volume_cb
;
831 snd_mixer_selem_get_playback_volume_range(u
->mixer_elem
, &u
->hw_volume_min
, &u
->hw_volume_max
);
835 if (snd_mixer_selem_has_playback_switch(u
->mixer_elem
)) {
836 u
->sink
->get_mute
= sink_get_mute_cb
;
837 u
->sink
->set_mute
= sink_set_mute_cb
;
840 u
->mixer_fdl
= pa_alsa_fdlist_new();
842 if (pa_alsa_fdlist_set_mixer(u
->mixer_fdl
, u
->mixer_handle
, c
->mainloop
) < 0) {
843 pa_log("failed to initialise file descriptor monitoring");
847 snd_mixer_elem_set_callback(u
->mixer_elem
, mixer_callback
);
848 snd_mixer_elem_set_callback_private(u
->mixer_elem
, u
);
852 if (!(u
->thread
= pa_thread_new(thread_func
, u
))) {
853 pa_log("Failed to create thread.");
857 /* Get initial mixer settings */
858 if (u
->sink
->get_volume
)
859 u
->sink
->get_volume(u
->sink
);
860 if (u
->sink
->get_mute
)
861 u
->sink
->get_mute(u
->sink
);
871 snd_pcm_info_free(pcm_info
);
883 void pa__done(pa_core
*c
, pa_module
*m
) {
889 if (!(u
= m
->userdata
))
893 pa_sink_disconnect(u
->sink
);
896 pa_asyncmsgq_send(u
->asyncmsgq
, NULL
, PA_MESSAGE_SHUTDOWN
, NULL
, NULL
);
897 pa_thread_free(u
->thread
);
901 pa_asyncmsgq_free(u
->asyncmsgq
);
904 pa_sink_unref(u
->sink
);
906 if (u
->memchunk
.memblock
)
907 pa_memblock_unref(u
->memchunk
.memblock
);
910 pa_alsa_fdlist_free(u
->mixer_fdl
);
913 snd_mixer_close(u
->mixer_handle
);
916 snd_pcm_drop(u
->pcm_handle
);
917 snd_pcm_close(u
->pcm_handle
);
920 pa_xfree(u
->device_name
);
923 snd_config_update_free_global();