Re: [pulseaudio-discuss] [PATCH] module: new null-source module

2011-04-28 Thread Colin Guthrie
'Twas brillig, and Tanu Kaskinen at 27/04/11 12:59 did gyre and gimble:
 On Wed, 2011-04-27 at 14:50 +0300, Tanu Kaskinen wrote:
 From: Marc-André Lureau marcandre.lur...@gmail.com

 ---
  src/Makefile.am  |6 +
  src/modules/module-null-source.c |  294 
 ++
  2 files changed, 300 insertions(+), 0 deletions(-)
  create mode 100644 src/modules/module-null-source.c
 
 This module isn't actually used by anyone currently. We (at Nokia)
 switched to null-sink's monitor a long time ago (for reasons unknown to
 me), so the code hasn't had much testing lately. Even though there are
 no users for the module currently, I'm sending the patch anyway, just in
 case people think that the module might be useful in some situation.
 
 I quickly tested that I can record silence with parec from source.null -
 I can't give any further guarantees that the code is correct.

I have tested this but not 100% sure it's totally correct... I've
committed it anyway (we an always disable it easy enough if it doesn't
pass QA :p

I was able to load this and record from it but the vumeter in
pavucontrol was quite active and jumpy and when doing parec|pacat I did
get quite a lot of static (not a crazy amount, but more than I would
expect from pure silence... I doubt resampling would have caused the
level of static I saw).

So there might be some weirdness in there with the silence it produces
if anyone has a desire to have a peak

Cheers

Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH] module: new null-source module

2011-04-27 Thread Tanu Kaskinen
From: Marc-André Lureau marcandre.lur...@gmail.com

---
 src/Makefile.am  |6 +
 src/modules/module-null-source.c |  294 ++
 2 files changed, 300 insertions(+), 0 deletions(-)
 create mode 100644 src/modules/module-null-source.c

diff --git a/src/Makefile.am b/src/Makefile.am
index fb846cd..275334d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1024,6 +1024,7 @@ modlibexec_LTLIBRARIES += \
module-simple-protocol-tcp.la \
module-null-sink.la \
module-sine-source.la \
+   module-null-source.la \
module-detect.la \
module-volume-restore.la \
module-device-manager.la \
@@ -1289,6 +1290,7 @@ SYMDEF_FILES = \
module-tunnel-source-symdef.h \
module-null-sink-symdef.h \
module-sine-source-symdef.h \
+   module-null-source-symdef.h \
module-esound-sink-symdef.h \
module-zeroconf-publish-symdef.h \
module-zeroconf-discover-symdef.h \
@@ -1481,6 +1483,10 @@ module_sine_source_la_SOURCES = 
modules/module-sine-source.c
 module_sine_source_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_sine_source_la_LIBADD = $(MODULE_LIBADD)
 
+module_null_source_la_SOURCES = modules/module-null-source.c
+module_null_source_la_LDFLAGS = $(MODULE_LDFLAGS)
+module_null_source_la_LIBADD = $(MODULE_LIBADD)
+
 # Couplings
 
 module_combine_la_SOURCES = modules/module-combine.c
diff --git a/src/modules/module-null-source.c b/src/modules/module-null-source.c
new file mode 100644
index 000..358ffc6
--- /dev/null
+++ b/src/modules/module-null-source.c
@@ -0,0 +1,294 @@
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2004-2008 Lennart Poettering
+  Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  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.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include config.h
+#endif
+
+#include stdlib.h
+#include sys/stat.h
+#include stdio.h
+#include errno.h
+#include string.h
+#include fcntl.h
+#include unistd.h
+#include limits.h
+
+#include pulse/rtclock.h
+#include pulse/timeval.h
+#include pulse/xmalloc.h
+
+#include pulsecore/core-error.h
+#include pulsecore/core-rtclock.h
+#include pulsecore/core-util.h
+#include pulsecore/log.h
+#include pulsecore/macro.h
+#include pulsecore/modargs.h
+#include pulsecore/module.h
+#include pulsecore/rtpoll.h
+#include pulsecore/source.h
+#include pulsecore/thread-mq.h
+#include pulsecore/thread.h
+
+#include module-null-source-symdef.h
+
+PA_MODULE_AUTHOR(Lennart Poettering  Marc-Andre Lureau);
+PA_MODULE_DESCRIPTION(Clocked NULL source);
+PA_MODULE_VERSION(PACKAGE_VERSION);
+PA_MODULE_LOAD_ONCE(FALSE);
+PA_MODULE_USAGE(
+format=sample format 
+channels=number of channels 
+rate=sample rate 
+source_name=name of source 
+channel_map=channel map 
+description=description for the source 
+latency_time=latency time in ms);
+
+#define DEFAULT_SOURCE_NAME source.null
+#define DEFAULT_LATENCY_TIME 20
+#define MAX_LATENCY_USEC (PA_USEC_PER_SEC * 2)
+
+struct userdata {
+pa_core *core;
+pa_module *module;
+pa_source *source;
+
+pa_thread *thread;
+pa_thread_mq thread_mq;
+pa_rtpoll *rtpoll;
+
+size_t block_size;
+
+pa_usec_t block_usec;
+pa_usec_t timestamp;
+pa_usec_t latency_time;
+};
+
+static const char* const valid_modargs[] = {
+rate,
+format,
+channels,
+source_name,
+channel_map,
+description,
+latency_time,
+NULL
+};
+
+static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t 
offset, pa_memchunk *chunk) {
+struct userdata *u = PA_SOURCE(o)-userdata;
+
+switch (code) {
+case PA_SOURCE_MESSAGE_SET_STATE:
+
+if (PA_PTR_TO_UINT(data) == PA_SOURCE_RUNNING)
+u-timestamp = pa_rtclock_now();
+
+break;
+
+case PA_SOURCE_MESSAGE_GET_LATENCY: {
+pa_usec_t now;
+
+now = pa_rtclock_now();
+*((pa_usec_t*) data) = u-timestamp  now ? u-timestamp - now : 0;
+
+return 0;
+}
+}
+
+return pa_source_process_msg(o, code, data, offset, chunk);
+}
+
+static void 

Re: [pulseaudio-discuss] [PATCH] module: new null-source module

2011-04-27 Thread Tanu Kaskinen
On Wed, 2011-04-27 at 14:50 +0300, Tanu Kaskinen wrote:
 From: Marc-André Lureau marcandre.lur...@gmail.com
 
 ---
  src/Makefile.am  |6 +
  src/modules/module-null-source.c |  294 
 ++
  2 files changed, 300 insertions(+), 0 deletions(-)
  create mode 100644 src/modules/module-null-source.c

This module isn't actually used by anyone currently. We (at Nokia)
switched to null-sink's monitor a long time ago (for reasons unknown to
me), so the code hasn't had much testing lately. Even though there are
no users for the module currently, I'm sending the patch anyway, just in
case people think that the module might be useful in some situation.

I quickly tested that I can record silence with parec from source.null -
I can't give any further guarantees that the code is correct.

-- 
Tanu

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] module: new null-source module

2011-04-27 Thread Colin Guthrie
'Twas brillig, and Tanu Kaskinen at 27/04/11 12:59 did gyre and gimble:
 On Wed, 2011-04-27 at 14:50 +0300, Tanu Kaskinen wrote:
 From: Marc-André Lureau marcandre.lur...@gmail.com

 ---
  src/Makefile.am  |6 +
  src/modules/module-null-source.c |  294 
 ++
  2 files changed, 300 insertions(+), 0 deletions(-)
  create mode 100644 src/modules/module-null-source.c
 
 This module isn't actually used by anyone currently. We (at Nokia)
 switched to null-sink's monitor a long time ago (for reasons unknown to
 me), so the code hasn't had much testing lately. Even though there are
 no users for the module currently, I'm sending the patch anyway, just in
 case people think that the module might be useful in some situation.
 
 I quickly tested that I can record silence with parec from source.null -
 I can't give any further guarantees that the code is correct.

Yeah due to the fact that a null sink has a null monitor, this module is
of limited usefulness, but I think it could still be useful in some
cases where you do want a null recording but don't want it polluted with
sinks.

I did actually have someone that wanted to hook up null sources and null
sinks to some Windows VMs a while back (several VMs but only one null
sink+monitor source). He was annoyed that he could record other VMs
output from within a separate VM on the monitor. Obviously he can
shuffle around the various streams and create multiple null sinks but it
would have actually been simpler to setup a null source in the first place.

So I'll do some testing then grab it at some point (tho' need to spend
some time reviewing Margarita's work before next week otherwise Liam and
Mark will find some way to punish me!)

Cheers

Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] module: new null-source module

2011-04-27 Thread David Henningsson

On 2011-04-27 15:18, Colin Guthrie wrote:

'Twas brillig, and Tanu Kaskinen at 27/04/11 12:59 did gyre and gimble:

On Wed, 2011-04-27 at 14:50 +0300, Tanu Kaskinen wrote:

From: Marc-André Lureaumarcandre.lur...@gmail.com

---
  src/Makefile.am  |6 +
  src/modules/module-null-source.c |  294 ++
  2 files changed, 300 insertions(+), 0 deletions(-)
  create mode 100644 src/modules/module-null-source.c


This module isn't actually used by anyone currently. We (at Nokia)
switched to null-sink's monitor a long time ago (for reasons unknown to
me), so the code hasn't had much testing lately. Even though there are
no users for the module currently, I'm sending the patch anyway, just in
case people think that the module might be useful in some situation.

I quickly tested that I can record silence with parec from source.null -
I can't give any further guarantees that the code is correct.


Yeah due to the fact that a null sink has a null monitor, this module is
of limited usefulness, but I think it could still be useful in some
cases where you do want a null recording but don't want it polluted with
sinks.

I did actually have someone that wanted to hook up null sources and null
sinks to some Windows VMs a while back (several VMs but only one null
sink+monitor source). He was annoyed that he could record other VMs
output from within a separate VM on the monitor. Obviously he can
shuffle around the various streams and create multiple null sinks but it
would have actually been simpler to setup a null source in the first place.

So I'll do some testing then grab it at some point (tho' need to spend
some time reviewing Margarita's work before next week otherwise Liam and
Mark will find some way to punish me!)


FYI, I've done some review of that code already, and I agree with 
plbossart's comments recently about the jack detection being done the 
wrong way.


In addition, I don't think we (as in Canonical/Ubuntu) even got it to 
work yet even though we've tried it several times. You can see some of 
it here: https://bugs.launchpad.net/ubuntu/+source/alsa-lib/+bug/746023


So I don't think it's ready. The question about how we can make it ready 
might be a topic for next week's conference perhaps. See you!


--
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] module: new null-source module

2011-04-27 Thread David Henningsson

On 2011-04-27 16:55, David Henningsson wrote:

So I'll do some testing then grab it at some point (tho' need to spend
some time reviewing Margarita's work before next week otherwise Liam and
Mark will find some way to punish me!)


FYI, I've done some review of that code already, and I agree with
plbossart's comments recently about the jack detection being done the
wrong way.

In addition, I don't think we (as in Canonical/Ubuntu) even got it to
work yet even though we've tried it several times. You can see some of
it here: https://bugs.launchpad.net/ubuntu/+source/alsa-lib/+bug/746023

So I don't think it's ready. The question about how we can make it ready
might be a topic for next week's conference perhaps. See you!


Hmm, that was not supposed to go to the list.. *blushes*

Anyway, I haven't been much involved with the ucm stuff until a few 
weeks ago, but I'll see next week (during either the ASoC conference, 
LAC, or UDS) if I can grab one of these pandaboards, play around a 
little with UCM and get it explained to me (alsaucm could use a man 
page!), and see if I can understand why we never got those patches to 
work reliably in Ubuntu 11.04.


--
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] module: new null-source module

2011-04-27 Thread Mark Brown
On Wed, Apr 27, 2011 at 05:07:44PM +0200, David Henningsson wrote:

Adding Marga and Liam, not cutting text as a result.

 On 2011-04-27 16:55, David Henningsson wrote:
 So I'll do some testing then grab it at some point (tho' need to spend
 some time reviewing Margarita's work before next week otherwise Liam and
 Mark will find some way to punish me!)

 FYI, I've done some review of that code already, and I agree with
 plbossart's comments recently about the jack detection being done the
 wrong way.

 In addition, I don't think we (as in Canonical/Ubuntu) even got it to
 work yet even though we've tried it several times. You can see some of
 it here: https://bugs.launchpad.net/ubuntu/+source/alsa-lib/+bug/746023

 So I don't think it's ready. The question about how we can make it ready
 might be a topic for next week's conference perhaps. See you!

 Hmm, that was not supposed to go to the list.. *blushes*

 Anyway, I haven't been much involved with the ucm stuff until a few  
 weeks ago, but I'll see next week (during either the ASoC conference,  
 LAC, or UDS) if I can grab one of these pandaboards, play around a  
 little with UCM and get it explained to me (alsaucm could use a man  
 page!), and see if I can understand why we never got those patches to  
 work reliably in Ubuntu 11.04.

You're not really supposed to use alsaucm directly except for testing
and developing new configurations, I'd not expect it to play nicely with
an application that's also driving UCM.

Sounds from a brief scan like the issue with the defaults getting lost
on boot is that Pulse needs to start storing the state itself (I'd
expect on a per use case basis) rather than relying on something else
doing so underneath it.  Trying to restore a state which may correspond
to a totally different use case is going to be fail, and restoring state
that is part of the use cases has obvious issues too.  But I've not read
the report properly so I'm mostly just guessing here.
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] module: new null-source module

2011-04-27 Thread David Henningsson

On 2011-04-27 20:06, Mark Brown wrote:

On Wed, Apr 27, 2011 at 05:07:44PM +0200, David Henningsson wrote:

Adding Marga and Liam, not cutting text as a result.


On 2011-04-27 16:55, David Henningsson wrote:

So I'll do some testing then grab it at some point (tho' need to spend
some time reviewing Margarita's work before next week otherwise Liam and
Mark will find some way to punish me!)


FYI, I've done some review of that code already, and I agree with
plbossart's comments recently about the jack detection being done the
wrong way.

In addition, I don't think we (as in Canonical/Ubuntu) even got it to
work yet even though we've tried it several times. You can see some of
it here: https://bugs.launchpad.net/ubuntu/+source/alsa-lib/+bug/746023

So I don't think it's ready. The question about how we can make it ready
might be a topic for next week's conference perhaps. See you!


Hmm, that was not supposed to go to the list.. *blushes*

Anyway, I haven't been much involved with the ucm stuff until a few
weeks ago, but I'll see next week (during either the ASoC conference,
LAC, or UDS) if I can grab one of these pandaboards, play around a
little with UCM and get it explained to me (alsaucm could use a man
page!), and see if I can understand why we never got those patches to
work reliably in Ubuntu 11.04.


You're not really supposed to use alsaucm directly except for testing
and developing new configurations,


That's reason enough to have a man page and some documentation, if you 
ask me. (Not claiming you're the only one missing documentation though.)



I'd not expect it to play nicely with
an application that's also driving UCM.

Sounds from a brief scan like the issue with the defaults getting lost
on boot is that Pulse needs to start storing the state itself (I'd
expect on a per use case basis) rather than relying on something else
doing so underneath it.  Trying to restore a state which may correspond
to a totally different use case is going to be fail, and restoring state
that is part of the use cases has obvious issues too.  But I've not read
the report properly so I'm mostly just guessing here.


The overall problem IMHO is that it is overly complex:

1) The kernel might set some basic volumes
2) Alsactl can store/restore volumes
3) Alsaucm can set volumes
4) PulseAudio (for the gdm user) can store/restore volumes
5) PulseAudio (for the logged on user) can store/restore volumes

As UCM adds yet another complexity to the equation, we need to get it 
right, avoid races and so on. If possible, I'd like to cut away a layer 
or two for simplicity and optimisation.


Btw, as I understand it, the code in PA for controlling hardware volumes 
through UCM is not yet a part of Maggie's patches. Is that correct?


--
David Henningsson, Canonical Ltd.
http://launchpad.net/~diwic
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] module: new null-source module

2011-04-27 Thread Mark Brown
On Wed, Apr 27, 2011 at 08:29:34PM +0200, David Henningsson wrote:
 On 2011-04-27 20:06, Mark Brown wrote:

 You're not really supposed to use alsaucm directly except for testing
 and developing new configurations,

 That's reason enough to have a man page and some documentation, if you  
 ask me. (Not claiming you're the only one missing documentation though.)

Meh, there's a reason I don't write userspace code :)

 The overall problem IMHO is that it is overly complex:

 1) The kernel might set some basic volumes

This is clearly going to happen if only as a function of the device
having power on defaults - there's no might about it, there *will* be an
initial state from the hardware but this should be consistent for every
boot so not really any issue here.

 2) Alsactl can store/restore volumes

With UCM this shouldn't really happen (and if it does it should happen
before UCM gets into play so the UCM configuration can just overwrite
anything that happens).

 3) Alsaucm can set volumes

Not exactly, this should (unless I've gravely misunderstood the
implementation, which is possible) be done by PulseAudio setting a use
case with UCM.

 4) PulseAudio (for the gdm user) can store/restore volumes
 5) PulseAudio (for the logged on user) can store/restore volumes

Presumably PulseAudio already gets the interface between these two
right.  The theory with UCM (again, assuming no massive misunderstandings 
of the final implementation on my part) is that when UCM is in play
these volumes should be set using the volume controls that the UCM
config told PulseAudio to use for the current use case and that
PulseAudio should just ignore anything else.  Setting the use case will
both set most of the controls and tell PulseAudio which controls it
should play with for runtime control, and whoever writes the use case
configuration for a given system needs to make sure that those don't
interfere with each other.

 As UCM adds yet another complexity to the equation, we need to get it  
 right, avoid races and so on. If possible, I'd like to cut away a layer  
 or two for simplicity and optimisation.

Hopefully the above clarifies; like I say, UCM configurations do have
provision for telling the system audio daemon which controls it can play
with.  Only one thing, PulseAudio, should ever be applying configuration
so there shouldn't be much problem with races.

 Btw, as I understand it, the code in PA for controlling hardware volumes  
 through UCM is not yet a part of Maggie's patches. Is that correct?

Dunno, not checked.
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] module: new null-source module

2011-04-27 Thread Liam Girdwood
On Wed, 2011-04-27 at 20:29 +0200, David Henningsson wrote:

 
 The overall problem IMHO is that it is overly complex:
 
 1) The kernel might set some basic volumes
 2) Alsactl can store/restore volumes
 3) Alsaucm can set volumes
 4) PulseAudio (for the gdm user) can store/restore volumes
 5) PulseAudio (for the logged on user) can store/restore volumes
 
 As UCM adds yet another complexity to the equation, we need to get it 
 right, avoid races and so on. If possible, I'd like to cut away a layer 
 or two for simplicity and optimisation.

I agree on simplification, but UCM actually removes a layer of
complexity here as it abstracts numerous vendor/card specific Alsa mixer
controls into pre-defined use cases. i.e. we no longer have to guess
about whether device X has a control n1 or n2 or n2... to configure
audio playback on headphones etc.

Lets discuss this more in person next week !
 
 
 Btw, as I understand it, the code in PA for controlling hardware volumes 
 through UCM is not yet a part of Maggie's patches. Is that correct?
 

Yes, Maggies code is initial and basic support for UCM in pulseaudio.
It's not intended to be full UCM support (this would take a lot longer)
as it's really to get the ball rolling.

The patches basically provide the ability to :-

1) Store UCM verb and devices configuration in proplists.
2) Allow pulseaudio to change the UCM usecase verb and device.
3) Implement a jack sense module that listens for jack events.
4) Act on jack events to change UCM device.

We should probably get 1 and 2 upstream first. I know she is working on
something else atm and will probably be back to this in a few weeks
time.

Liam


___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] module: new null-source module

2011-04-27 Thread Mark Brown
On Wed, Apr 27, 2011 at 08:04:06PM +0100, Liam Girdwood wrote:
 On Wed, 2011-04-27 at 20:29 +0200, David Henningsson wrote:

 The patches basically provide the ability to :-

 1) Store UCM verb and devices configuration in proplists.
 2) Allow pulseaudio to change the UCM usecase verb and device.
 3) Implement a jack sense module that listens for jack events.
 4) Act on jack events to change UCM device.

 We should probably get 1 and 2 upstream first. I know she is working on
 something else atm and will probably be back to this in a few weeks
 time.

I agree on this - apart from anything else if people are happy with the
basic mechanics it'll save on review time of those bits.
___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss