2004-07-16 19:56:36 +00:00
|
|
|
/***
|
2006-06-19 21:53:48 +00:00
|
|
|
This file is part of PulseAudio.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2008-05-15 23:34:41 +00:00
|
|
|
Copyright 2004-2008 Lennart Poettering
|
2007-02-13 15:35:19 +00:00
|
|
|
Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is free software; you can redistribute it and/or modify
|
2004-11-14 14:58:54 +00:00
|
|
|
it under the terms of the GNU Lesser General Public License as published
|
2009-03-03 20:23:02 +00:00
|
|
|
by the Free Software Foundation; either version 2.1 of the License,
|
2004-07-16 19:56:36 +00:00
|
|
|
or (at your option) any later version.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is distributed in the hope that it will be useful, but
|
2004-07-16 19:56:36 +00:00
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2004-11-14 14:58:54 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2006-06-19 21:53:48 +00:00
|
|
|
along with PulseAudio; if not, write to the Free Software
|
2004-07-16 19:56:36 +00:00
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
USA.
|
|
|
|
|
***/
|
|
|
|
|
|
2004-07-16 19:16:42 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-07-16 17:03:11 +00:00
|
|
|
#include <stdio.h>
|
2006-01-10 17:51:06 +00:00
|
|
|
|
2004-07-16 17:03:11 +00:00
|
|
|
#include <asoundlib.h>
|
|
|
|
|
|
2008-08-18 19:55:55 +02:00
|
|
|
#ifdef HAVE_VALGRIND_MEMCHECK_H
|
|
|
|
|
#include <valgrind/memcheck.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulse/xmalloc.h>
|
2007-10-28 19:13:50 +00:00
|
|
|
#include <pulse/util.h>
|
2008-05-15 23:34:41 +00:00
|
|
|
#include <pulse/timeval.h>
|
2006-06-19 21:53:48 +00:00
|
|
|
|
|
|
|
|
#include <pulsecore/core-error.h>
|
|
|
|
|
#include <pulsecore/core.h>
|
|
|
|
|
#include <pulsecore/module.h>
|
|
|
|
|
#include <pulsecore/memchunk.h>
|
|
|
|
|
#include <pulsecore/sink.h>
|
|
|
|
|
#include <pulsecore/modargs.h>
|
|
|
|
|
#include <pulsecore/core-util.h>
|
|
|
|
|
#include <pulsecore/sample-util.h>
|
|
|
|
|
#include <pulsecore/log.h>
|
2007-10-28 19:13:50 +00:00
|
|
|
#include <pulsecore/macro.h>
|
|
|
|
|
#include <pulsecore/thread.h>
|
|
|
|
|
#include <pulsecore/core-error.h>
|
|
|
|
|
#include <pulsecore/thread-mq.h>
|
|
|
|
|
#include <pulsecore/rtpoll.h>
|
2008-05-15 23:34:41 +00:00
|
|
|
#include <pulsecore/time-smoother.h>
|
|
|
|
|
#include <pulsecore/rtclock.h>
|
2006-02-16 19:19:58 +00:00
|
|
|
|
2006-02-16 22:08:06 +00:00
|
|
|
#include "alsa-util.h"
|
2009-01-21 00:23:18 +01:00
|
|
|
#include "alsa-source.h"
|
2006-02-17 12:10:58 +00:00
|
|
|
#include "module-alsa-source-symdef.h"
|
2004-07-16 17:03:11 +00:00
|
|
|
|
2007-11-09 18:25:40 +00:00
|
|
|
PA_MODULE_AUTHOR("Lennart Poettering");
|
|
|
|
|
PA_MODULE_DESCRIPTION("ALSA Source");
|
|
|
|
|
PA_MODULE_VERSION(PACKAGE_VERSION);
|
|
|
|
|
PA_MODULE_LOAD_ONCE(FALSE);
|
2006-04-26 15:40:14 +00:00
|
|
|
PA_MODULE_USAGE(
|
2009-01-22 00:24:13 +01:00
|
|
|
"name=<name for the source, to be prefixed> "
|
2006-04-26 15:40:14 +00:00
|
|
|
"source_name=<name for the source> "
|
2009-05-28 02:39:22 +02:00
|
|
|
"source_properties=<properties for the source> "
|
2006-04-26 15:40:14 +00:00
|
|
|
"device=<ALSA device> "
|
2008-05-15 23:34:41 +00:00
|
|
|
"device_id=<ALSA card index> "
|
2006-04-26 15:40:14 +00:00
|
|
|
"format=<sample format> "
|
|
|
|
|
"rate=<sample rate> "
|
2008-05-15 23:34:41 +00:00
|
|
|
"channels=<number of channels> "
|
|
|
|
|
"channel_map=<channel map> "
|
2006-04-26 15:40:14 +00:00
|
|
|
"fragments=<number of fragments> "
|
|
|
|
|
"fragment_size=<fragment size> "
|
2008-05-15 23:34:41 +00:00
|
|
|
"mmap=<enable memory mapping?> "
|
|
|
|
|
"tsched=<enable system timer based scheduling mode?> "
|
|
|
|
|
"tsched_buffer_size=<buffer size when using timer based scheduling> "
|
2009-01-27 17:55:50 +01:00
|
|
|
"tsched_buffer_watermark=<upper fill watermark> "
|
Specifying ALSA mixer control
On Fri, Mar 27, 2009 at 7:21 AM, Lennart Poettering <lennart@poettering.net> wrote:
>> I tried installing the latest git sources on my Ubuntu Jaunty box but
>> it just broke sound in all my applications. For my own purposes, I'm
>> going to need to start with the Ubuntu-patched 0.9.14. However, if
>> you are willing to accept this patch I will forward port it so that it
>> applies to the latest sources. It's a completely harmless change, so
>> why not apply it?
>
> Yes, I am happy to apply it. Could you please update it for current git?
>
Great. An updated patch is attached. For symmetry, I added this
option to the alsa source module as well.
The Ubuntu folks have customized pulse so much that it is difficult
for me to get this version working on my system. For this patch I
have only made sure that it compiles. But it does pretty much the
same thing as the one for 0.9.14, which is working great for me.
Thanks,
Kyle
2009-03-30 12:49:37 -05:00
|
|
|
"ignore_dB=<ignore dB information from the device?> "
|
|
|
|
|
"control=<name of mixer control>");
|
2008-05-15 23:34:41 +00:00
|
|
|
|
|
|
|
|
static const char* const valid_modargs[] = {
|
2009-01-22 00:24:13 +01:00
|
|
|
"name",
|
2008-05-15 23:34:41 +00:00
|
|
|
"source_name",
|
2009-05-28 02:39:22 +02:00
|
|
|
"source_properties",
|
2008-05-15 23:34:41 +00:00
|
|
|
"device",
|
|
|
|
|
"device_id",
|
|
|
|
|
"format",
|
|
|
|
|
"rate",
|
|
|
|
|
"channels",
|
|
|
|
|
"channel_map",
|
|
|
|
|
"fragments",
|
|
|
|
|
"fragment_size",
|
|
|
|
|
"mmap",
|
|
|
|
|
"tsched",
|
|
|
|
|
"tsched_buffer_size",
|
|
|
|
|
"tsched_buffer_watermark",
|
2009-01-27 17:55:50 +01:00
|
|
|
"ignore_dB",
|
Specifying ALSA mixer control
On Fri, Mar 27, 2009 at 7:21 AM, Lennart Poettering <lennart@poettering.net> wrote:
>> I tried installing the latest git sources on my Ubuntu Jaunty box but
>> it just broke sound in all my applications. For my own purposes, I'm
>> going to need to start with the Ubuntu-patched 0.9.14. However, if
>> you are willing to accept this patch I will forward port it so that it
>> applies to the latest sources. It's a completely harmless change, so
>> why not apply it?
>
> Yes, I am happy to apply it. Could you please update it for current git?
>
Great. An updated patch is attached. For symmetry, I added this
option to the alsa source module as well.
The Ubuntu folks have customized pulse so much that it is difficult
for me to get this version working on my system. For this patch I
have only made sure that it compiles. But it does pretty much the
same thing as the one for 0.9.14, which is working great for me.
Thanks,
Kyle
2009-03-30 12:49:37 -05:00
|
|
|
"control",
|
2008-05-15 23:34:41 +00:00
|
|
|
NULL
|
|
|
|
|
};
|
2007-10-28 19:13:50 +00:00
|
|
|
|
|
|
|
|
int pa__init(pa_module*m) {
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_modargs *ma = NULL;
|
2007-10-28 19:13:50 +00:00
|
|
|
|
|
|
|
|
pa_assert(m);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2009-06-18 21:27:02 +02:00
|
|
|
pa_alsa_refcnt_inc();
|
2008-05-15 23:34:41 +00:00
|
|
|
|
2004-07-16 17:03:11 +00:00
|
|
|
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_log("Failed to parse module arguments");
|
2004-07-16 17:03:11 +00:00
|
|
|
goto fail;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-21 02:02:30 +01:00
|
|
|
if (!(m->userdata = pa_alsa_source_new(m, ma, __FILE__, NULL, NULL)))
|
2004-07-16 17:03:11 +00:00
|
|
|
goto fail;
|
2006-03-05 20:59:57 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_modargs_free(ma);
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
return 0;
|
2004-07-16 17:03:11 +00:00
|
|
|
|
|
|
|
|
fail:
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
if (ma)
|
|
|
|
|
pa_modargs_free(ma);
|
2004-07-16 17:03:11 +00:00
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
pa__done(m);
|
|
|
|
|
|
|
|
|
|
return -1;
|
2004-07-16 17:03:11 +00:00
|
|
|
}
|
|
|
|
|
|
2009-01-15 20:49:12 +01:00
|
|
|
int pa__get_n_used(pa_module *m) {
|
2009-01-21 00:23:18 +01:00
|
|
|
pa_source *source;
|
2009-01-15 20:49:12 +01:00
|
|
|
|
|
|
|
|
pa_assert(m);
|
2009-01-21 00:23:18 +01:00
|
|
|
pa_assert_se(source = m->userdata);
|
2009-01-15 20:49:12 +01:00
|
|
|
|
2009-01-21 00:23:18 +01:00
|
|
|
return pa_source_linked_by(source);
|
2009-01-15 20:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
void pa__done(pa_module*m) {
|
2009-01-21 00:23:18 +01:00
|
|
|
pa_source *source;
|
2007-10-28 19:13:50 +00:00
|
|
|
|
|
|
|
|
pa_assert(m);
|
2004-07-16 17:03:11 +00:00
|
|
|
|
2009-01-21 00:23:18 +01:00
|
|
|
if ((source = m->userdata))
|
|
|
|
|
pa_alsa_source_free(source);
|
2004-07-16 17:03:11 +00:00
|
|
|
|
2009-06-18 21:27:02 +02:00
|
|
|
pa_alsa_refcnt_dec();
|
2007-10-28 19:13:50 +00:00
|
|
|
}
|