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
32 #ifdef HAVE_SYS_POLL_H
38 #include <asoundlib.h>
40 #include <pulse/xmalloc.h>
42 #include <pulsecore/core-error.h>
43 #include <pulsecore/core.h>
44 #include <pulsecore/module.h>
45 #include <pulsecore/memchunk.h>
46 #include <pulsecore/sink.h>
47 #include <pulsecore/modargs.h>
48 #include <pulsecore/core-util.h>
49 #include <pulsecore/sample-util.h>
50 #include <pulsecore/log.h>
51 #include <pulsecore/macro.h>
52 #include <pulsecore/thread.h>
53 #include <pulsecore/core-error.h>
55 #include "alsa-util.h"
56 #include "module-alsa-source-symdef.h"
58 PA_MODULE_AUTHOR("Lennart Poettering")
59 PA_MODULE_DESCRIPTION("ALSA Source")
60 PA_MODULE_VERSION(PACKAGE_VERSION
)
62 "source_name=<name for the source> "
63 "device=<ALSA device> "
64 "format=<sample format> "
65 "channels=<number of channels> "
67 "fragments=<number of fragments> "
68 "fragment_size=<fragment size> "
69 "channel_map=<channel map> "
70 "mmap=<enable memory mapping?>")
72 #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
;
98 static const char* const valid_modargs
[] = {
111 static int mmap_read(struct userdata
*u
) {
114 const snd_pcm_channel_area_t
*areas
;
115 snd_pcm_uframes_t offset
, frames
;
119 pa_assert(u
->source
);
125 if ((n
= snd_pcm_avail_update(u
->pcm_handle
)) < 0) {
128 pa_log_debug("snd_pcm_avail_update: Buffer underrun!");
130 if ((err
= snd_pcm_recover(u
->pcm_handle
, n
, 1)) == 0)
136 pa_log("snd_pcm_avail_update: %s", snd_strerror(n
));
140 /* pa_log("Got request for %i samples", (int) n); */
147 if ((err
= snd_pcm_mmap_begin(u
->pcm_handle
, &areas
, &offset
, &frames
)) < 0) {
150 pa_log_debug("snd_pcm_mmap_begin: Buffer underrun!");
152 if ((err
= snd_pcm_recover(u
->pcm_handle
, err
, 1)) == 0)
158 pa_log("Failed to write data to DSP: %s", snd_strerror(err
));
162 /* Check these are multiples of 8 bit */
163 pa_assert((areas
[0].first
& 7) == 0);
164 pa_assert((areas
[0].step
& 7)== 0);
166 /* We assume a single interleaved memory buffer */
167 pa_assert((areas
[0].first
>> 3) == 0);
168 pa_assert((areas
[0].step
>> 3) == u
->frame_size
);
170 p
= (uint8_t*) areas
[0].addr
+ (offset
* u
->frame_size
);
172 chunk
.memblock
= pa_memblock_new_fixed(u
->core
->mempool
, p
, frames
* u
->frame_size
, 1);
173 chunk
.length
= pa_memblock_get_length(chunk
.memblock
);
176 pa_source_post(u
->source
, &chunk
);
178 /* FIXME: Maybe we can do something to keep this memory block
179 * a little bit longer around? */
180 pa_memblock_unref_fixed(chunk
.memblock
);
182 if ((err
= snd_pcm_mmap_commit(u
->pcm_handle
, offset
, frames
)) < 0) {
185 pa_log_debug("snd_pcm_mmap_commit: Buffer underrun!");
187 if ((err
= snd_pcm_recover(u
->pcm_handle
, err
, 1)) == 0)
193 pa_log("Failed to write data to DSP: %s", snd_strerror(err
));
199 /* pa_log("wrote %i samples", (int) frames); */
203 static pa_usec_t
source_get_latency(struct userdata
*u
) {
205 snd_pcm_sframes_t frames
= 0;
210 snd_pcm_avail_update(u
->pcm_handle
);
212 if ((err
= snd_pcm_delay(u
->pcm_handle
, &frames
)) < 0) {
213 pa_log("Failed to get delay: %s", snd_strerror(err
));
218 r
= pa_bytes_to_usec(frames
* u
->frame_size
, &u
->source
->sample_spec
);
223 static int suspend(struct userdata
*u
) {
225 pa_assert(u
->pcm_handle
);
228 snd_pcm_close(u
->pcm_handle
);
229 u
->pcm_handle
= NULL
;
231 pa_log_debug("Device suspended...");
236 static int unsuspend(struct userdata
*u
) {
240 snd_pcm_uframes_t period_size
;
243 pa_assert(!u
->pcm_handle
);
245 pa_log_debug("Trying resume...");
247 snd_config_update_free_global();
248 if ((err
= snd_pcm_open(&u
->pcm_handle
, u
->device_name
, SND_PCM_STREAM_CAPTURE
, SND_PCM_NONBLOCK
)) < 0) {
249 pa_log("Error opening PCM device %s: %s", u
->device_name
, snd_strerror(err
));
253 ss
= u
->source
->sample_spec
;
254 nfrags
= u
->nfragments
;
255 period_size
= u
->fragment_size
/ u
->frame_size
;
258 if ((err
= pa_alsa_set_hw_params(u
->pcm_handle
, &ss
, &nfrags
, &period_size
, &b
)) < 0) {
259 pa_log("Failed to set hardware parameters: %s", snd_strerror(err
));
263 if (b
!= u
->use_mmap
) {
264 pa_log_warn("Resume failed, couldn't get original access mode.");
268 if (!pa_sample_spec_equal(&ss
, &u
->source
->sample_spec
)) {
269 pa_log_warn("Resume failed, couldn't restore original sample settings.");
273 if (nfrags
!= u
->nfragments
|| period_size
*u
->frame_size
!= u
->fragment_size
) {
274 pa_log_warn("Resume failed, couldn't restore original fragment settings.");
278 if ((err
= pa_alsa_set_sw_params(u
->pcm_handle
)) < 0) {
279 pa_log("Failed to set software parameters: %s", snd_strerror(err
));
283 snd_pcm_start(u
->pcm_handle
);
285 /* FIXME: We need to reload the volume somehow */
287 pa_log_debug("Resumed successfully...");
292 snd_pcm_close(u
->pcm_handle
);
293 u
->pcm_handle
= NULL
;
298 static int source_process_msg(pa_msgobject
*o
, int code
, void *data
, int64_t offset
, pa_memchunk
*chunk
) {
299 struct userdata
*u
= PA_SOURCE(o
)->userdata
;
303 case PA_SOURCE_MESSAGE_GET_LATENCY
: {
307 r
= source_get_latency(u
);
309 *((pa_usec_t
*) data
) = r
;
314 case PA_SOURCE_MESSAGE_SET_STATE
:
316 switch ((pa_source_state_t
) PA_PTR_TO_UINT(data
)) {
318 case PA_SOURCE_SUSPENDED
:
319 pa_assert(PA_SOURCE_OPENED(u
->source
->thread_info
.state
));
327 case PA_SOURCE_RUNNING
:
329 if (u
->source
->thread_info
.state
== PA_SOURCE_SUSPENDED
) {
330 if (unsuspend(u
) < 0)
336 case PA_SOURCE_DISCONNECTED
:
343 return pa_source_process_msg(o
, code
, data
, offset
, chunk
);
346 static int mixer_callback(snd_mixer_elem_t
*elem
, unsigned int mask
) {
347 struct userdata
*u
= snd_mixer_elem_get_callback_private(elem
);
350 pa_assert(u
->mixer_handle
);
352 if (mask
== SND_CTL_EVENT_MASK_REMOVE
)
355 if (mask
& SND_CTL_EVENT_MASK_VALUE
) {
356 pa_source_get_volume(u
->source
);
357 pa_source_get_mute(u
->source
);
363 static int source_get_volume_cb(pa_source
*s
) {
364 struct userdata
*u
= s
->userdata
;
369 pa_assert(u
->mixer_elem
);
371 for (i
= 0; i
< s
->sample_spec
.channels
; i
++) {
374 pa_assert(snd_mixer_selem_has_capture_channel(u
->mixer_elem
, i
));
376 if ((err
= snd_mixer_selem_get_capture_volume(u
->mixer_elem
, i
, &vol
)) < 0)
379 set_vol
= (long) roundf(((float) s
->volume
.values
[i
] * (u
->hw_volume_max
- u
->hw_volume_min
)) / PA_VOLUME_NORM
) + u
->hw_volume_min
;
381 /* Try to avoid superfluous volume changes */
383 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
));
389 pa_log_error("Unable to read volume: %s", snd_strerror(err
));
391 s
->get_volume
= NULL
;
392 s
->set_volume
= NULL
;
396 static int source_set_volume_cb(pa_source
*s
) {
397 struct userdata
*u
= s
->userdata
;
402 pa_assert(u
->mixer_elem
);
404 for (i
= 0; i
< s
->sample_spec
.channels
; i
++) {
408 pa_assert(snd_mixer_selem_has_capture_channel(u
->mixer_elem
, i
));
410 vol
= s
->volume
.values
[i
];
412 if (vol
> PA_VOLUME_NORM
)
413 vol
= PA_VOLUME_NORM
;
415 alsa_vol
= (long) roundf(((float) vol
* (u
->hw_volume_max
- u
->hw_volume_min
)) / PA_VOLUME_NORM
) + u
->hw_volume_min
;
417 if ((err
= snd_mixer_selem_set_capture_volume(u
->mixer_elem
, i
, alsa_vol
)) < 0)
424 pa_log_error("Unable to set volume: %s", snd_strerror(err
));
426 s
->get_volume
= NULL
;
427 s
->set_volume
= NULL
;
431 static int source_get_mute_cb(pa_source
*s
) {
432 struct userdata
*u
= s
->userdata
;
436 pa_assert(u
->mixer_elem
);
438 if ((err
= snd_mixer_selem_get_capture_switch(u
->mixer_elem
, 0, &sw
)) < 0) {
439 pa_log_error("Unable to get switch: %s", snd_strerror(err
));
451 static int source_set_mute_cb(pa_source
*s
) {
452 struct userdata
*u
= s
->userdata
;
456 pa_assert(u
->mixer_elem
);
458 if ((err
= snd_mixer_selem_set_capture_switch_all(u
->mixer_elem
, !s
->muted
)) < 0) {
459 pa_log_error("Unable to set switch: %s", snd_strerror(err
));
469 static void thread_func(void *userdata
) {
475 struct userdata
*u
= userdata
;
476 struct pollfd
*pollfd
= NULL
;
478 unsigned short revents
= 0;
479 snd_pcm_status_t
*status
;
482 snd_pcm_status_alloca(&status
);
484 pa_log_debug("Thread starting up");
486 if ((n_alsa_fds
= snd_pcm_poll_descriptors_count(u
->pcm_handle
)) < 0) {
487 pa_log("snd_pcm_poll_descriptors_count() failed: %s", snd_strerror(n_alsa_fds
));
491 pollfd
= pa_xnew0(struct pollfd
, POLLFD_ALSA_BASE
+ n_alsa_fds
);
493 pollfd
[POLLFD_ASYNCQ
].fd
= pa_asyncmsgq_get_fd(u
->asyncmsgq
);
494 pollfd
[POLLFD_ASYNCQ
].events
= POLLIN
;
496 if ((err
= snd_pcm_poll_descriptors(u
->pcm_handle
, pollfd
+POLLFD_ALSA_BASE
, n_alsa_fds
)) < 0) {
497 pa_log("snd_pcm_poll_descriptors() failed: %s", snd_strerror(err
));
502 pa_msgobject
*object
;
509 /* pa_log("loop"); */
511 /* Check whether there is a message for us to process */
512 if (pa_asyncmsgq_get(u
->asyncmsgq
, &object
, &code
, &data
, &offset
, &chunk
, 0) == 0) {
515 /* pa_log("processing msg"); */
517 if (!object
&& code
== PA_MESSAGE_SHUTDOWN
) {
518 pa_asyncmsgq_done(u
->asyncmsgq
, 0);
522 ret
= pa_asyncmsgq_dispatch(object
, code
, data
, offset
, &chunk
);
523 pa_asyncmsgq_done(u
->asyncmsgq
, ret
);
527 /* pa_log("loop2"); */
529 /* Render some data and write it to the dsp */
531 if (PA_SOURCE_OPENED(u
->source
->thread_info
.state
) && (revents
& POLLIN
)) {
533 pa_assert(u
->pcm_handle
);
537 if ((work_done
= mmap_read(u
)) < 0)
547 if ((err
= snd_pcm_status(u
->pcm_handle
, status
)) < 0) {
548 pa_log("Failed to query DSP status data: %s", snd_strerror(t
));
552 if (snd_pcm_status_get_avail_max(status
)*u
->frame_size
>= u
->hwbuf_size
)
553 pa_log_debug("Buffer overrun!");
555 l
= snd_pcm_status_get_avail(status
) * u
->frame_size
;
560 chunk
.memblock
= pa_memblock_new(u
->core
->mempool
, l
);
562 p
= pa_memblock_acquire(chunk
.memblock
);
563 t
= snd_pcm_readi(u
->pcm_handle
, (uint8_t*) p
, l
/ u
->frame_size
);
564 pa_memblock_release(chunk
.memblock
);
566 /* pa_log("wrote %i bytes of %u (%u)", t*u->frame_size, u->memchunk.length, l); */
571 pa_memblock_unref(chunk
.memblock
);
573 if ((t
= snd_pcm_recover(u
->pcm_handle
, t
, 1)) == 0)
577 pa_log_debug("EAGAIN");
580 pa_log("Failed to read data from DSP: %s", snd_strerror(t
));
587 chunk
.length
= t
* u
->frame_size
;
589 pa_source_post(u
->source
, &chunk
);
590 pa_memblock_unref(chunk
.memblock
);
594 if (t
* u
->frame_size
>= (unsigned) l
)
605 /* Hmm, nothing to do. Let's sleep */
606 if (pa_asyncmsgq_before_poll(u
->asyncmsgq
) < 0)
609 /* pa_log("polling for %i", POLLFD_ALSA_BASE + (PA_SOURCE_OPENED(u->source->thread_info.state) ? n_alsa_fds : 0)); */
610 r
= poll(pollfd
, POLLFD_ALSA_BASE
+ (PA_SOURCE_OPENED(u
->source
->thread_info
.state
) ? n_alsa_fds
: 0), -1);
611 /*pa_log("polling got dsp=%i amq=%i (%i)", r > 0 ? pollfd[POLLFD_DSP].revents : 0, r > 0 ? pollfd[POLLFD_ASYNCQ].revents : 0, r); */
612 /* pa_log("poll end"); */
614 pa_asyncmsgq_after_poll(u
->asyncmsgq
);
617 if (errno
== EINTR
) {
618 pollfd
[POLLFD_ASYNCQ
].revents
= 0;
623 pa_log("poll() failed: %s", pa_cstrerror(errno
));
629 if (PA_SOURCE_OPENED(u
->source
->thread_info
.state
)) {
630 if ((err
= snd_pcm_poll_descriptors_revents(u
->pcm_handle
, pollfd
+ POLLFD_ALSA_BASE
, n_alsa_fds
, &revents
)) < 0) {
631 pa_log("snd_pcm_poll_descriptors_revents() failed: %s", snd_strerror(err
));
635 /* pa_log("got alsa event"); */
639 pa_assert((pollfd
[POLLFD_ASYNCQ
].revents
& ~POLLIN
) == 0);
643 /* We have to continue processing messages until we receive the
644 * SHUTDOWN message */
645 pa_asyncmsgq_post(u
->core
->asyncmsgq
, PA_MSGOBJECT(u
->core
), PA_CORE_MESSAGE_UNLOAD_MODULE
, u
->module
, 0, NULL
, NULL
);
646 pa_asyncmsgq_wait_for(u
->asyncmsgq
, PA_MESSAGE_SHUTDOWN
);
649 pa_log_debug("Thread shutting down");
655 int pa__init(pa_core
*c
, pa_module
*m
) {
657 pa_modargs
*ma
= NULL
;
659 struct userdata
*u
= NULL
;
663 unsigned nfrags
, frag_size
;
664 snd_pcm_uframes_t period_size
;
666 snd_pcm_info_t
*pcm_info
= NULL
;
670 char *name_buf
= NULL
;
677 if (!(ma
= pa_modargs_new(m
->argument
, valid_modargs
))) {
678 pa_log("Failed to parse module arguments");
682 ss
= c
->default_sample_spec
;
683 if (pa_modargs_get_sample_spec_and_channel_map(ma
, &ss
, &map
, PA_CHANNEL_MAP_ALSA
) < 0) {
684 pa_log("Failed to parse sample specification");
688 frame_size
= pa_frame_size(&ss
);
690 /* Fix latency to 100ms */
691 nfrags
= DEFAULT_NFRAGS
;
692 frag_size
= pa_usec_to_bytes(DEFAULT_FRAGSIZE_MSEC
*1000, &ss
);
694 frag_size
= frame_size
;
696 if (pa_modargs_get_value_u32(ma
, "fragments", &nfrags
) < 0 || pa_modargs_get_value_u32(ma
, "fragment_size", &frag_size
) < 0) {
697 pa_log("Failed to parse buffer metrics");
700 period_size
= frag_size
/frame_size
;
702 if (pa_modargs_get_value_boolean(ma
, "mmap", &use_mmap
) < 0) {
703 pa_log("Failed to parse mmap argument.");
707 u
= pa_xnew0(struct userdata
, 1);
711 u
->use_mmap
= use_mmap
;
712 pa_assert_se(u
->asyncmsgq
= pa_asyncmsgq_new(0));
714 snd_config_update_free_global();
715 if ((err
= snd_pcm_open(&u
->pcm_handle
, dev
= pa_modargs_get_value(ma
, "device", DEFAULT_DEVICE
), SND_PCM_STREAM_CAPTURE
, SND_PCM_NONBLOCK
)) < 0) {
716 pa_log("Error opening PCM device %s: %s", dev
, snd_strerror(err
));
720 u
->device_name
= pa_xstrdup(dev
);
722 if ((err
= snd_pcm_info_malloc(&pcm_info
)) < 0 ||
723 (err
= snd_pcm_info(u
->pcm_handle
, pcm_info
)) < 0) {
724 pa_log("Error fetching PCM info: %s", snd_strerror(err
));
729 if ((err
= pa_alsa_set_hw_params(u
->pcm_handle
, &ss
, &nfrags
, &period_size
, &b
)) < 0) {
730 pa_log("Failed to set hardware parameters: %s", snd_strerror(err
));
734 if (use_mmap
&& !b
) {
735 pa_log_info("Device doesn't support mmap(), falling back to UNIX read/write mode.");
736 u
->use_mmap
= use_mmap
= b
;
740 pa_log_info("Successfully enabled mmap() mode.");
742 if ((err
= pa_alsa_set_sw_params(u
->pcm_handle
)) < 0) {
743 pa_log("Failed to set software parameters: %s", snd_strerror(err
));
747 /* ALSA might tweak the sample spec, so recalculate the frame size */
748 frame_size
= pa_frame_size(&ss
);
750 if (ss
.channels
!= map
.channels
)
751 /* Seems ALSA didn't like the channel number, so let's fix the channel map */
752 pa_channel_map_init_auto(&map
, ss
.channels
, PA_CHANNEL_MAP_ALSA
);
754 if ((err
= snd_mixer_open(&u
->mixer_handle
, 0)) < 0)
755 pa_log("Error opening mixer: %s", snd_strerror(err
));
758 if ((pa_alsa_prepare_mixer(u
->mixer_handle
, dev
) < 0) ||
759 !(u
->mixer_elem
= pa_alsa_find_elem(u
->mixer_handle
, "Capture", NULL
))) {
760 snd_mixer_close(u
->mixer_handle
);
761 u
->mixer_handle
= NULL
;
765 if ((name
= pa_modargs_get_value(ma
, "source_name", NULL
)))
768 name
= name_buf
= pa_sprintf_malloc("alsa_input.%s", dev
);
772 u
->source
= pa_source_new(c
, __FILE__
, name
, namereg_fail
, &ss
, &map
);
776 pa_log("Failed to create source object");
780 u
->source
->parent
.process_msg
= source_process_msg
;
781 u
->source
->userdata
= u
;
783 pa_source_set_module(u
->source
, m
);
784 pa_source_set_asyncmsgq(u
->source
, u
->asyncmsgq
);
785 pa_source_set_description(u
->source
, t
= pa_sprintf_malloc(
786 "ALSA PCM on %s (%s)",
788 snd_pcm_info_get_name(pcm_info
)));
791 u
->source
->is_hardware
= 1;
793 u
->frame_size
= frame_size
;
794 u
->fragment_size
= frag_size
= period_size
* frame_size
;
795 u
->nfragments
= nfrags
;
796 u
->hwbuf_size
= u
->fragment_size
* nfrags
;
798 pa_log_info("Using %u fragments of size %lu bytes.", nfrags
, (long unsigned) u
->fragment_size
);
800 if (u
->mixer_handle
) {
801 assert(u
->mixer_elem
);
803 if (snd_mixer_selem_has_capture_volume(u
->mixer_elem
)) {
806 for (i
= 0;i
< ss
.channels
;i
++) {
807 if (!snd_mixer_selem_has_capture_channel(u
->mixer_elem
, i
))
811 if (i
== ss
.channels
) {
812 u
->source
->get_volume
= source_get_volume_cb
;
813 u
->source
->set_volume
= source_set_volume_cb
;
814 snd_mixer_selem_get_capture_volume_range(u
->mixer_elem
, &u
->hw_volume_min
, &u
->hw_volume_max
);
818 if (snd_mixer_selem_has_capture_switch(u
->mixer_elem
)) {
819 u
->source
->get_mute
= source_get_mute_cb
;
820 u
->source
->set_mute
= source_set_mute_cb
;
823 u
->mixer_fdl
= pa_alsa_fdlist_new();
825 if (pa_alsa_fdlist_set_mixer(u
->mixer_fdl
, u
->mixer_handle
, c
->mainloop
) < 0) {
826 pa_log("failed to initialise file descriptor monitoring");
830 snd_mixer_elem_set_callback(u
->mixer_elem
, mixer_callback
);
831 snd_mixer_elem_set_callback_private(u
->mixer_elem
, u
);
835 if (!(u
->thread
= pa_thread_new(thread_func
, u
))) {
836 pa_log("Failed to create thread.");
839 /* Get initial mixer settings */
840 if (u
->source
->get_volume
)
841 u
->source
->get_volume(u
->source
);
842 if (u
->source
->get_mute
)
843 u
->source
->get_mute(u
->source
);
845 snd_pcm_start(u
->pcm_handle
);
855 snd_pcm_info_free(pcm_info
);
867 void pa__done(pa_core
*c
, pa_module
*m
) {
873 if (!(u
= m
->userdata
))
877 pa_source_disconnect(u
->source
);
880 pa_asyncmsgq_send(u
->asyncmsgq
, NULL
, PA_MESSAGE_SHUTDOWN
, NULL
, 0, NULL
);
881 pa_thread_free(u
->thread
);
885 pa_asyncmsgq_free(u
->asyncmsgq
);
888 pa_source_unref(u
->source
);
891 pa_alsa_fdlist_free(u
->mixer_fdl
);
894 snd_mixer_close(u
->mixer_handle
);
897 snd_pcm_drop(u
->pcm_handle
);
898 snd_pcm_close(u
->pcm_handle
);
901 pa_xfree(u
->device_name
);
904 snd_config_update_free_global();