Re: [pulseaudio-discuss] [PATCH v2 1/6] build-sys: add `check` test framework

2012-08-08 Thread rong deng
2012/8/9, Tanu Kaskinen :
> On Wed, 2012-08-08 at 22:16 +0800, rong deng wrote:
>> 2012/8/8, David Henningsson :
>> > But what about a user of e g Linux From Scratch or other minimalist
>> > distros, who just wants to set up and build PulseAudio as quick as
>> > possible? Why should (s)he be required to also bring in the check
>> > package just for building it?
>>
>> Other packages would already require the check package.
>> From the webpage of check framework: http://check.sourceforge.net/
>> there's a section called "Projects Using Check", there are several
>> common projects using it. e.g. XCB and gstreamer. So if the user wants
>> to install X environment he/she would already install XCB and the
>> check dependency is there.
>
> Note that check is only an optional dependency in gstreamer (I didn't
> check whether this is also the case with XCB, but I'd be surprised if it
> wasn't):
> http://cgit.freedesktop.org/gstreamer/gstreamer/tree/configure.ac#n557

Hi Tanu,

Thanks for your reminder, OK. Now I think it's a valid point. So I've
sent out a patch to make check optional. But by default it's enabled,
I think running tests is a good practice that should be encouraged.

>From my last time trying LFS, it was years ago, it runs tests for each
package to make sure the installation from LFS isn't misbehaved. But I
haven't checked the current status for LFS lately.

If you have time, or David has the time, please help to review that
patch. I've done some simple configurations it works for me.

Thanks!
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH] tests: make 'check' optional

2012-08-08 Thread Deng Zhengrong
---
 configure.ac|   15 ++-
 src/Makefile.am |   12 
 2 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index ffb2a35..9cb5aa6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -581,10 +581,21 @@ AC_CHECK_HEADERS_ONCE([valgrind/memcheck.h])
 
  check test framework 
 
-PKG_CHECK_MODULES(LIBCHECK, [ check ])
+AC_ARG_ENABLE([check],
+AS_HELP_STRING([--disable-check],[Disable unit tests]))
+
+AS_IF([test "x$enable_check" != "xno"],
+[PKG_CHECK_MODULES(LIBCHECK, [ check ], HAVE_LIBCHECK=1, HAVE_LIBCHECK=0)],
+HAVE_LIBCHECK=0)
+
+AS_IF([test "x$enable_check" = "xyes" && test "x$HAVE_LIBCHECK" = "x0"],
+[AC_MSG_ERROR([*** check library not found])])
+
 AC_SUBST(LIBCHECK_CFLAGS)
 AC_SUBST(LIBCHECK_LIBS)
 
+AM_CONDITIONAL([HAVE_LIBCHECK], [test "x$HAVE_LIBCHECK" = x1])
+
  json parsing 
 
 PKG_CHECK_MODULES(LIBJSON, [ json >= 0.9 ])
@@ -1393,6 +1404,7 @@ AS_IF([test "x$HAVE_SIMPLEDB" = "x1"], 
ENABLE_SIMPLEDB=yes, ENABLE_SIMPLEDB=no)
 AS_IF([test "x$HAVE_ESOUND" = "x1"], ENABLE_ESOUND=yes, ENABLE_ESOUND=no)
 AS_IF([test "x$HAVE_ESOUND" = "x1" -a "x$USE_PER_USER_ESOUND_SOCKET" = "x1"], 
ENABLE_PER_USER_ESOUND_SOCKET=yes, ENABLE_PER_USER_ESOUND_SOCKET=no)
 AS_IF([test "x$HAVE_GCOV" = "x1"], ENABLE_GCOV=yes, ENABLE_GCOV=no)
+AS_IF([test "x$HAVE_LIBCHECK" = "x1"], ENABLE_LIBCHECK=yes, ENABLE_LIBCHECK=no)
 AS_IF([test "x$enable_legacy_database_entry_format" != "xno"], 
ENABLE_LEGACY_DATABASE_ENTRY_FORMAT=yes, ENABLE_LEGACY_DATABASE_ENTRY_FORMAT=no)
 
 echo "
@@ -1440,6 +1452,7 @@ echo "
 Enable speex (resampler, AEC): ${ENABLE_SPEEX}
 Enable WebRTC echo canceller:  ${ENABLE_WEBRTC}
 Enable gcov coverage:  ${ENABLE_GCOV}
+Enable check unit tests:   ${ENABLE_LIBCHECK}
 Database
   tdb: ${ENABLE_TDB}
   gdbm:${ENABLE_GDBM}
diff --git a/src/Makefile.am b/src/Makefile.am
index 2f20df2..dfa055e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -297,6 +297,7 @@ TESTS_norun += \
alsa-time-test
 endif
 
+if HAVE_LIBCHECK
 TESTS_ENVIRONMENT=MAKE_CHECK=1
 TESTS = $(TESTS_default)
 
@@ -309,6 +310,17 @@ endif
 check-daemon: $(TESTS_daemon)
PATH=$(builddir):${PATH} $(top_srcdir)/src/tests/test-daemon.sh 
$(TESTS_daemon)
 
+else
+TESTS_ENVIRONMENT=
+TESTS =
+noinst_PROGRAMS =
+check_PROGRAMS =
+
+check-daemon:
+   @echo "Please don't specify \"--disable-check\" and make sure check 
library is installed!"
+
+endif
+
 mainloop_test_SOURCES = tests/mainloop-test.c
 mainloop_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
 mainloop_test_LDADD = $(AM_LDADD) libpulse.la libpulsecommon-@PA_MAJORMINOR@.la
-- 
1.7.7.6

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 1/3] Proper poll() emulation to fix pacat and friends on windows.

2012-08-08 Thread kugel
From: Thomas Martitz 

Currently, Windows versions of pacat and friends fail because the current
poll emulation is not sufficient (it only works for socket fds).

Luckily Gnulib has a much better emulation that seems to work perfect
all over. With this poll() works on pipes and files as well.

This fixes the "Assertion (!e->dead) failed" error coming and lets pacat
and friends stream happily to/from a server (I didn't actually test parec).
---
 src/Makefile.am|7 +-
 src/pulse/mainloop.c   |   18 --
 src/pulsecore/poll-posix.c |  237 +
 src/pulsecore/poll-win32.c |  635 
 src/pulsecore/poll.c   |  237 -
 5 files changed, 878 insertions(+), 256 deletions(-)
 create mode 100644 src/pulsecore/poll-posix.c
 create mode 100644 src/pulsecore/poll-win32.c
 delete mode 100644 src/pulsecore/poll.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 7f947bd..c23754f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -589,7 +589,6 @@ libpulsecommon_@PA_MAJORMINOR@_la_SOURCES = \
pulsecore/pdispatch.c pulsecore/pdispatch.h \
pulsecore/pid.c pulsecore/pid.h \
pulsecore/pipe.c pulsecore/pipe.h \
-   pulsecore/poll.c pulsecore/poll.h \
pulsecore/memtrap.c pulsecore/memtrap.h \
pulsecore/aupdate.c pulsecore/aupdate.h \
pulsecore/proplist-util.c pulsecore/proplist-util.h \
@@ -612,6 +611,12 @@ libpulsecommon_@PA_MAJORMINOR@_la_SOURCES = \
pulsecore/sndfile-util.c pulsecore/sndfile-util.h \
pulsecore/socket.h
 
+if OS_IS_WIN32
+libpulsecommon_@PA_MAJORMINOR@_la_SOURCES += pulsecore/poll-win32.c 
pulsecore/poll.h
+else
+libpulsecommon_@PA_MAJORMINOR@_la_SOURCES += pulsecore/poll-posix.c 
pulsecore/poll.h
+endif
+
 libpulsecommon_@PA_MAJORMINOR@_la_CFLAGS = $(AM_CFLAGS) $(LIBSNDFILE_CFLAGS)
 libpulsecommon_@PA_MAJORMINOR@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
 libpulsecommon_@PA_MAJORMINOR@_la_LIBADD = $(AM_LIBADD) $(LIBWRAP_LIBS) 
$(WINSOCK_LIBS) $(LTLIBICONV) $(LIBSNDFILE_LIBS)
diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c
index 5c0345e..725bdb4 100644
--- a/src/pulse/mainloop.c
+++ b/src/pulse/mainloop.c
@@ -175,24 +175,6 @@ static pa_io_event* mainloop_io_new(
 e->callback = callback;
 e->userdata = userdata;
 
-#ifdef OS_IS_WIN32
-{
-fd_set xset;
-struct timeval tv;
-
-tv.tv_sec = 0;
-tv.tv_usec = 0;
-
-FD_ZERO (&xset);
-FD_SET (fd, &xset);
-
-if ((select(fd, NULL, NULL, &xset, &tv) == -1) && (WSAGetLastError() 
== WSAENOTSOCK)) {
-pa_log_warn("Cannot monitor non-socket file descriptors.");
-e->dead = TRUE;
-}
-}
-#endif
-
 PA_LLIST_PREPEND(pa_io_event, m->io_events, e);
 m->rebuild_pollfds = TRUE;
 m->n_io_events ++;
diff --git a/src/pulsecore/poll-posix.c b/src/pulsecore/poll-posix.c
new file mode 100644
index 000..cd888b5
--- /dev/null
+++ b/src/pulsecore/poll-posix.c
@@ -0,0 +1,237 @@
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2006 Pierre Ossman  for Cendio AB
+
+  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.1 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.
+***/
+
+/***
+   Based on work for the GNU C Library.
+   Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc.
+***/
+
+/* Poll the file descriptors described by the NFDS structures starting at
+   FDS.  If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
+   an event to occur; if TIMEOUT is -1, block until an event occurs.
+   Returns the number of file descriptors with events, zero if timed out,
+   or -1 for errors.  */
+
+#ifdef HAVE_CONFIG_H
+#include 
+#endif
+
+#ifdef HAVE_SYS_IOCTL_H
+#include 
+#endif
+
+#include 
+#include 
+
+#ifdef HAVE_SYS_SELECT_H
+#include 
+#endif
+
+#include 
+#include 
+#include 
+
+#include "poll.h"
+
+/* Mac OSX fails to implement poll() in a working way since 10.4. IOW, for
+ * several years. We need to enable a dirty workaround and emulate that call
+ * with select(), just like for Windows. sic! */
+
+#if !defined(HAVE_POLL_H) || defined(OS_IS_DARWIN)
+
+int pa_poll (struct pollfd *fds, unsigned long int nfds, int timeout) {
+struct timeval tv;
+fd_set rset, wset, xset;
+struct pollfd *f;
+ 

[pulseaudio-discuss] [PATCH 3/3] gccmacro: Disable printf-like format checking on mingw32 compilers.

2012-08-08 Thread kugel
From: Thomas Martitz 

There are tons of warnings, most of them because the function is not
recognized as printf-like.
---
 src/pulse/gccmacro.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pulse/gccmacro.h b/src/pulse/gccmacro.h
index 1e818ff..2e23ced 100644
--- a/src/pulse/gccmacro.h
+++ b/src/pulse/gccmacro.h
@@ -25,7 +25,7 @@
 /** \file
  * GCC attribute macros */
 
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(__MINGW32__)
 #define PA_GCC_PRINTF_ATTR(a,b) __attribute__ ((format (printf, a, b)))
 #else
 /** If we're in GNU C, use some magic for detecting invalid format strings */
-- 
1.7.10.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 2/3] pacat: Enable binary mode on Windows.

2012-08-08 Thread kugel
From: Thomas Martitz 

Without this reading from stdin will eventually end with EOF (if there happens
to be a newline sign in the stream), because read() returns 0.

This patch fixes raw data input and piping to pacat on Windows.
---
 src/utils/pacat.c |4 
 1 file changed, 4 insertions(+)

diff --git a/src/utils/pacat.c b/src/utils/pacat.c
index ec360f7..734017c 100644
--- a/src/utils/pacat.c
+++ b/src/utils/pacat.c
@@ -1129,6 +1129,10 @@ int main(int argc, char *argv[]) {
 pa_disable_sigpipe();
 
 if (raw) {
+#ifdef OS_IS_WIN32
+/* need to turn on binary mode for stdio io. Windows, meh */
+setmode(mode == PLAYBACK ? STDIN_FILENO : STDOUT_FILENO, O_BINARY);
+#endif
 if (!(stdio_event = mainloop_api->io_new(mainloop_api,
  mode == PLAYBACK ? 
STDIN_FILENO : STDOUT_FILENO,
  mode == PLAYBACK ? 
PA_IO_EVENT_INPUT : PA_IO_EVENT_OUTPUT,
-- 
1.7.10.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 0/3] Fixes for pulseaudio on Windows.

2012-08-08 Thread kugel
From: Thomas Martitz 

I've been tryng to run pulseaudio (including utils) on windows. This
series is the first to contribute fixes to achieve this.

One issue I came across is the assertion failue (!e->dead) in pacat. This
is fixed by the first patch. Uncovered by this and fixed by patch 2 is that
stdio needs to be switched to binary mode in order to pipe data through it.
Patch 3 works around massive build warnings on mingw32, but it's not mission
critical.

Thomas Martitz (3):
  Proper poll() emulation to fix pacat and friends on windows.
  pacat: Enable binary mode on Windows.
  gccmacro: Disable printf-like format checking on mingw32 compilers.

 src/Makefile.am|7 +-
 src/pulse/gccmacro.h   |2 +-
 src/pulse/mainloop.c   |   18 --
 src/pulsecore/poll-posix.c |  237 +
 src/pulsecore/poll-win32.c |  635 
 src/pulsecore/poll.c   |  237 -
 src/utils/pacat.c  |4 +
 7 files changed, 883 insertions(+), 257 deletions(-)
 create mode 100644 src/pulsecore/poll-posix.c
 create mode 100644 src/pulsecore/poll-win32.c
 delete mode 100644 src/pulsecore/poll.c

-- 
1.7.10.4

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH v2 1/6] build-sys: add `check` test framework

2012-08-08 Thread Tanu Kaskinen
On Wed, 2012-08-08 at 22:16 +0800, rong deng wrote:
> 2012/8/8, David Henningsson :
> > But what about a user of e g Linux From Scratch or other minimalist
> > distros, who just wants to set up and build PulseAudio as quick as
> > possible? Why should (s)he be required to also bring in the check
> > package just for building it?
> 
> Other packages would already require the check package.
> From the webpage of check framework: http://check.sourceforge.net/
> there's a section called "Projects Using Check", there are several
> common projects using it. e.g. XCB and gstreamer. So if the user wants
> to install X environment he/she would already install XCB and the
> check dependency is there.

Note that check is only an optional dependency in gstreamer (I didn't
check whether this is also the case with XCB, but I'd be surprised if it
wasn't):
http://cgit.freedesktop.org/gstreamer/gstreamer/tree/configure.ac#n557

-- 
Tanu

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] setting fragment count and size

2012-08-08 Thread Benjamin Reed
i have a low latency audio app that uses pulse audio through alsa. to get it to 
work i have to change default-fragments and default-fragment-size-msec to 4 and 
2. i'm using ubuntu and normally the values are set much higher. is there a way 
to change these values programatically so that things work even if users of the 
app do not change the /etc/pulse/daemon.conf file?

thanx
ben
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH v2 1/6] build-sys: add `check` test framework

2012-08-08 Thread David Henningsson

On 08/08/2012 04:16 PM, rong deng wrote:

2012/8/8, David Henningsson :

On 08/08/2012 03:21 PM, rong deng wrote:

2012/8/8, David Henningsson :

On 07/17/2012 08:45 AM, Deng Zhengrong wrote:

+ check test framework 
+
+PKG_CHECK_MODULES(LIBCHECK, [ check ])
+AC_SUBST(LIBCHECK_CFLAGS)
+AC_SUBST(LIBCHECK_LIBS)
+


Is it possible to make this build dependency optional? If so, please do,
because
1) if you just want to compile PulseAudio and not the tests, you
should be able to, and
2) I have to go through some administrative work if I have to bring
in
yet another build dependency to PulseAudio. :-/


Hi David,

Thanks for the review, I have a little different opinion:
1. when we're in the process of development, we should always run the
tests all the time to track any possible regressions. It's not a good
idea to bypass the tests, because that's the value of all these tests,
otherwise we could just delete them all. :)
2. it's sad to bring in yet another build dependency, but you know
life is not perfect... We've already added e.g. json lib before.
Besides, this check framework is already widely used in other
programs, e.g. gstreamer. and I've checked with several major linux
distribution that this can be easily installed. mostly install check
or check-devel or something similar. One command and it's all set. :)


But what about a user of e g Linux From Scratch or other minimalist
distros, who just wants to set up and build PulseAudio as quick as
possible? Why should (s)he be required to also bring in the check
package just for building it?


Other packages would already require the check package.
 From the webpage of check framework: http://check.sourceforge.net/
there's a section called "Projects Using Check", there are several
common projects using it. e.g. XCB and gstreamer.


Using pulseaudio without any of those projects is a perfectly valid use 
case, but that's not the main point.


Let me repeat my main point: Why should someone be required to also 
bring in the check package just for building it, if that person is not 
interested in running tests anyway? (Please answer without speculating 
about what other packages that user might be interested in.)


Bringing in a new mandatory dependency, that could be made optional, is 
very bad practice IMO.



--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH v2 1/6] build-sys: add `check` test framework

2012-08-08 Thread rong deng
2012/8/8, David Henningsson :
> On 08/08/2012 03:21 PM, rong deng wrote:
>> 2012/8/8, David Henningsson :
>>> On 07/17/2012 08:45 AM, Deng Zhengrong wrote:
 + check test framework 
 +
 +PKG_CHECK_MODULES(LIBCHECK, [ check ])
 +AC_SUBST(LIBCHECK_CFLAGS)
 +AC_SUBST(LIBCHECK_LIBS)
 +
>>>
>>> Is it possible to make this build dependency optional? If so, please do,
>>> because
>>>1) if you just want to compile PulseAudio and not the tests, you
>>> should be able to, and
>>>2) I have to go through some administrative work if I have to bring
>>> in
>>> yet another build dependency to PulseAudio. :-/
>>
>> Hi David,
>>
>> Thanks for the review, I have a little different opinion:
>> 1. when we're in the process of development, we should always run the
>> tests all the time to track any possible regressions. It's not a good
>> idea to bypass the tests, because that's the value of all these tests,
>> otherwise we could just delete them all. :)
>> 2. it's sad to bring in yet another build dependency, but you know
>> life is not perfect... We've already added e.g. json lib before.
>> Besides, this check framework is already widely used in other
>> programs, e.g. gstreamer. and I've checked with several major linux
>> distribution that this can be easily installed. mostly install check
>> or check-devel or something similar. One command and it's all set. :)
>
> But what about a user of e g Linux From Scratch or other minimalist
> distros, who just wants to set up and build PulseAudio as quick as
> possible? Why should (s)he be required to also bring in the check
> package just for building it?

Other packages would already require the check package.
>From the webpage of check framework: http://check.sourceforge.net/
there's a section called "Projects Using Check", there are several
common projects using it. e.g. XCB and gstreamer. So if the user wants
to install X environment he/she would already install XCB and the
check dependency is there.
If the user wants to use pulseaudio, the chances are that he/she would
have to install gstreamer later and this package requires check
package as well. e.g. I quick searched to this URL
http://orion.lcg.ufrj.br/RPMS/SPECS/gstreamer.spec and in it, it
"BuildRequires: check-devel" So I think bringing check package a bit
earlier in the compilation of LFS helps. :)

oh, I got to this URL as well.
http://www.linuxfromscratch.org/blfs/view/svn/general/check.html which
teaches LFS users to compile check from scratch, so I believe LFS
users are already used to this check package.


>
> For Ubuntu I've noticed that the "check" package is in main, so it's not
> as terrible as it was with json-c, but still.

Sounds good.
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH v2 1/6] build-sys: add `check` test framework

2012-08-08 Thread David Henningsson

On 08/08/2012 03:21 PM, rong deng wrote:

2012/8/8, David Henningsson :

On 07/17/2012 08:45 AM, Deng Zhengrong wrote:

+ check test framework 
+
+PKG_CHECK_MODULES(LIBCHECK, [ check ])
+AC_SUBST(LIBCHECK_CFLAGS)
+AC_SUBST(LIBCHECK_LIBS)
+


Is it possible to make this build dependency optional? If so, please do,
because
   1) if you just want to compile PulseAudio and not the tests, you
should be able to, and
   2) I have to go through some administrative work if I have to bring in
yet another build dependency to PulseAudio. :-/


Hi David,

Thanks for the review, I have a little different opinion:
1. when we're in the process of development, we should always run the
tests all the time to track any possible regressions. It's not a good
idea to bypass the tests, because that's the value of all these tests,
otherwise we could just delete them all. :)
2. it's sad to bring in yet another build dependency, but you know
life is not perfect... We've already added e.g. json lib before.
Besides, this check framework is already widely used in other
programs, e.g. gstreamer. and I've checked with several major linux
distribution that this can be easily installed. mostly install check
or check-devel or something similar. One command and it's all set. :)


But what about a user of e g Linux From Scratch or other minimalist 
distros, who just wants to set up and build PulseAudio as quick as 
possible? Why should (s)he be required to also bring in the check 
package just for building it?


For Ubuntu I've noticed that the "check" package is in main, so it's not 
as terrible as it was with json-c, but still.



--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] build-sys: Link utf8-test to libpulsecommon.

2012-08-08 Thread rong deng
2012/8/8, Chan-yeol Park :
> Hi
>
> On 08/08/2012 09:44 PM, rong deng wrote:
>> 2012/8/8, Chan-yeol Park :
>>> Hi Tanu,
>>>
>>> On 08/06/2012 09:07 PM, Tanu Kaskinen wrote:
 Fixes this:
 /usr/bin/ld: utf8_test-utf8-test.o: undefined reference to symbol
 'pa_log_set_level'
 /usr/bin/ld: note: 'pa_log_set_level' is defined in DSO
 /home/takaskin/dev/pulseaudio/src/.libs/libpulsecommon-2.98.so so try
 adding it to the linker command line
 /home/takaskin/dev/pulseaudio/src/.libs/libpulsecommon-2.98.so: could
 not
 read symbols: Invalid operation
 ---
src/Makefile.am |2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/src/Makefile.am b/src/Makefile.am
 index 7f947bd..faebe2a 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -321,7 +321,7 @@ thread_mainloop_test_LDFLAGS = $(AM_LDFLAGS)
 $(BINLDFLAGS)

utf8_test_SOURCES = tests/utf8-test.c
utf8_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
 -utf8_test_LDADD = $(AM_LDADD) libpulse.la
 +utf8_test_LDADD = $(AM_LDADD) libpulse.la
 libpulsecommon-@PA_MAJORMINOR@.la
utf8_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)

format_test_SOURCES = tests/format-test.c
>>> Before LIBCHECK_[CFLAGS,LIBS] are introduced, it was built fine to me.
>>> I am using ubuntu 12.04, gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
>> I'm the one who added the libcheck, but from here, I've no errors
>> compiling this test case... If you have any other problem regarding
>> this, feel free to ask me. :)
> Yes I think so. This could be gcc or another environment issue.
> Could you introduce your environment?

I'm using Fedora Core 16, nothing special, the normal gcc bundled with it...

For shell, I'm using zsh, but I don't it would cause this problem.
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH v2 1/6] build-sys: add `check` test framework

2012-08-08 Thread rong deng
2012/8/8, David Henningsson :
> On 07/17/2012 08:45 AM, Deng Zhengrong wrote:
>> + check test framework 
>> +
>> +PKG_CHECK_MODULES(LIBCHECK, [ check ])
>> +AC_SUBST(LIBCHECK_CFLAGS)
>> +AC_SUBST(LIBCHECK_LIBS)
>> +
>
> Is it possible to make this build dependency optional? If so, please do,
> because
>   1) if you just want to compile PulseAudio and not the tests, you
> should be able to, and
>   2) I have to go through some administrative work if I have to bring in
> yet another build dependency to PulseAudio. :-/

Hi David,

Thanks for the review, I have a little different opinion:
1. when we're in the process of development, we should always run the
tests all the time to track any possible regressions. It's not a good
idea to bypass the tests, because that's the value of all these tests,
otherwise we could just delete them all. :)
2. it's sad to bring in yet another build dependency, but you know
life is not perfect... We've already added e.g. json lib before.
Besides, this check framework is already widely used in other
programs, e.g. gstreamer. and I've checked with several major linux
distribution that this can be easily installed. mostly install check
or check-devel or something similar. One command and it's all set. :)

deng
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] build-sys: Link utf8-test to libpulsecommon.

2012-08-08 Thread Chan-yeol Park

Hi

On 08/08/2012 09:44 PM, rong deng wrote:

2012/8/8, Chan-yeol Park :

Hi Tanu,

On 08/06/2012 09:07 PM, Tanu Kaskinen wrote:

Fixes this:
/usr/bin/ld: utf8_test-utf8-test.o: undefined reference to symbol
'pa_log_set_level'
/usr/bin/ld: note: 'pa_log_set_level' is defined in DSO
/home/takaskin/dev/pulseaudio/src/.libs/libpulsecommon-2.98.so so try
adding it to the linker command line
/home/takaskin/dev/pulseaudio/src/.libs/libpulsecommon-2.98.so: could not
read symbols: Invalid operation
---
   src/Makefile.am |2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 7f947bd..faebe2a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -321,7 +321,7 @@ thread_mainloop_test_LDFLAGS = $(AM_LDFLAGS)
$(BINLDFLAGS)

   utf8_test_SOURCES = tests/utf8-test.c
   utf8_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
-utf8_test_LDADD = $(AM_LDADD) libpulse.la
+utf8_test_LDADD = $(AM_LDADD) libpulse.la
libpulsecommon-@PA_MAJORMINOR@.la
   utf8_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)

   format_test_SOURCES = tests/format-test.c

Before LIBCHECK_[CFLAGS,LIBS] are introduced, it was built fine to me.
I am using ubuntu 12.04, gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

I'm the one who added the libcheck, but from here, I've no errors
compiling this test case... If you have any other problem regarding
this, feel free to ask me. :)

Yes I think so. This could be gcc or another environment issue.
Could you introduce your environment?

Regards
Chanyeol


___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH v2 1/6] build-sys: add `check` test framework

2012-08-08 Thread David Henningsson

On 07/17/2012 08:45 AM, Deng Zhengrong wrote:

+ check test framework 
+
+PKG_CHECK_MODULES(LIBCHECK, [ check ])
+AC_SUBST(LIBCHECK_CFLAGS)
+AC_SUBST(LIBCHECK_LIBS)
+


Is it possible to make this build dependency optional? If so, please do, 
because
 1) if you just want to compile PulseAudio and not the tests, you 
should be able to, and
 2) I have to go through some administrative work if I have to bring in 
yet another build dependency to PulseAudio. :-/



--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH] build-sys: Link utf8-test to libpulsecommon.

2012-08-08 Thread rong deng
2012/8/8, Chan-yeol Park :
> Hi Tanu,
>
> On 08/06/2012 09:07 PM, Tanu Kaskinen wrote:
>> Fixes this:
>> /usr/bin/ld: utf8_test-utf8-test.o: undefined reference to symbol
>> 'pa_log_set_level'
>> /usr/bin/ld: note: 'pa_log_set_level' is defined in DSO
>> /home/takaskin/dev/pulseaudio/src/.libs/libpulsecommon-2.98.so so try
>> adding it to the linker command line
>> /home/takaskin/dev/pulseaudio/src/.libs/libpulsecommon-2.98.so: could not
>> read symbols: Invalid operation
>> ---
>>   src/Makefile.am |2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/src/Makefile.am b/src/Makefile.am
>> index 7f947bd..faebe2a 100644
>> --- a/src/Makefile.am
>> +++ b/src/Makefile.am
>> @@ -321,7 +321,7 @@ thread_mainloop_test_LDFLAGS = $(AM_LDFLAGS)
>> $(BINLDFLAGS)
>>
>>   utf8_test_SOURCES = tests/utf8-test.c
>>   utf8_test_CFLAGS = $(AM_CFLAGS) $(LIBCHECK_CFLAGS)
>> -utf8_test_LDADD = $(AM_LDADD) libpulse.la
>> +utf8_test_LDADD = $(AM_LDADD) libpulse.la
>> libpulsecommon-@PA_MAJORMINOR@.la
>>   utf8_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBCHECK_LIBS)
>>
>>   format_test_SOURCES = tests/format-test.c
> Before LIBCHECK_[CFLAGS,LIBS] are introduced, it was built fine to me.
> I am using ubuntu 12.04, gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

I'm the one who added the libcheck, but from here, I've no errors
compiling this test case... If you have any other problem regarding
this, feel free to ask me. :)
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH 0/4] Volume ramping

2012-08-08 Thread Rémi Denis-Courmont
Le mercredi 8 août 2012 11:44:51 Alexander E. Patrakov, vous avez écrit :
> 2012/8/8 Jaska Uimonen :
> > Not because it would take more resources, but because of
> > it is "hidden" sw volume.
> 
> Just for the record: i'd say that it is good exactly for those
> situations where you want a "hidden" volume that does not affect any
> slider in the mixer application.

Yeah, so would I.

In fact, I would like to export the replay gain to PA instead of applying it 
manually in the application.

-- 
Rémi Denis-Courmont, looking for a job
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] [PATCH 0/4] Volume ramping

2012-08-08 Thread Alexander E. Patrakov
2012/8/8 Jaska Uimonen :
> I decided to do add another software volume to sink and
> sink-input which is independent of the other volumes.
> I know that's not nice but it was really hard for me to
> try adding the ramping to the existing volume functionality.
> It would be nice if the ramping would in the end change
> the actual volume, but I also see some drawbacks with that.
>
> This kind of ramping is good for "transient" type ramps.
> I mean it is good for ramping up and down your stream or
> temporarily lowering and raising the volume of your stream.
> It is not that good for permanently changing your volume.
> Not because it would take more resources, but because of
> it is "hidden" sw volume.

Just for the record: i'd say that it is good exactly for those
situations where you want a "hidden" volume that does not affect any
slider in the mixer application.

-- 
Alexander E. Patrakov
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 4/4] volume ramp: add client api support for volume ramping

2012-08-08 Thread Jaska Uimonen
From: Jaska Uimonen 

---
 src/map-file|3 +
 src/pulse/introspect.c  |   83 
 src/pulse/introspect.h  |9 
 src/pulse/stream.c  |5 ++-
 src/pulsecore/native-common.h   |3 +
 src/pulsecore/pdispatch.c   |2 +
 src/pulsecore/protocol-native.c |   88 ++-
 7 files changed, 190 insertions(+), 3 deletions(-)

diff --git a/src/map-file b/src/map-file
index 69cf25b..2e2791a 100644
--- a/src/map-file
+++ b/src/map-file
@@ -91,12 +91,15 @@ pa_context_set_event_callback;
 pa_context_set_name;
 pa_context_set_sink_input_mute;
 pa_context_set_sink_input_volume;
+pa_context_set_sink_input_volume_ramp;
 pa_context_set_sink_mute_by_index;
 pa_context_set_sink_mute_by_name;
 pa_context_set_sink_port_by_index;
 pa_context_set_sink_port_by_name;
 pa_context_set_sink_volume_by_index;
 pa_context_set_sink_volume_by_name;
+pa_context_set_sink_volume_ramp_by_index;
+pa_context_set_sink_volume_ramp_by_name;
 pa_context_set_source_output_mute;
 pa_context_set_source_output_volume;
 pa_context_set_source_mute_by_index;
diff --git a/src/pulse/introspect.c b/src/pulse/introspect.c
index 38a9d1c..6d13d8f 100644
--- a/src/pulse/introspect.c
+++ b/src/pulse/introspect.c
@@ -1412,6 +1412,62 @@ pa_operation* 
pa_context_set_sink_volume_by_name(pa_context *c, const char *name
 return o;
 }
 
+pa_operation* pa_context_set_sink_volume_ramp_by_index(pa_context *c, uint32_t 
idx, const pa_cvolume *volume, uint32_t time, int type, pa_context_success_cb_t 
cb, void *userdata) {
+pa_operation *o;
+pa_tagstruct *t;
+uint32_t tag;
+
+pa_assert(c);
+pa_assert(PA_REFCNT_VALUE(c) >= 1);
+pa_assert(volume);
+
+PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
+PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, 
PA_ERR_BADSTATE);
+PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
+
+o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
+
+t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_VOLUME_RAMP, &tag);
+pa_tagstruct_putu32(t, idx);
+pa_tagstruct_puts(t, NULL);
+pa_tagstruct_put_cvolume(t, volume);
+pa_tagstruct_putu32(t, time);
+pa_tagstruct_putu8(t, type);
+pa_pstream_send_tagstruct(c->pstream, t);
+pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, 
pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) 
pa_operation_unref);
+
+return o;
+}
+
+pa_operation* pa_context_set_sink_volume_ramp_by_name(pa_context *c, const 
char *name, const pa_cvolume *volume, uint32_t time, int type, 
pa_context_success_cb_t cb, void *userdata) {
+pa_operation *o;
+pa_tagstruct *t;
+uint32_t tag;
+
+pa_assert(c);
+pa_assert(PA_REFCNT_VALUE(c) >= 1);
+pa_assert(name);
+pa_assert(volume);
+
+PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
+PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, 
PA_ERR_BADSTATE);
+PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
+PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID);
+
+o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
+
+t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_VOLUME_RAMP, &tag);
+pa_tagstruct_putu32(t, PA_INVALID_INDEX);
+pa_tagstruct_puts(t, name);
+pa_tagstruct_put_cvolume(t, volume);
+pa_tagstruct_putu32(t, time);
+pa_tagstruct_putu8(t, type);
+pa_pstream_send_tagstruct(c->pstream, t);
+pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, 
pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) 
pa_operation_unref);
+
+return o;
+}
+
 pa_operation* pa_context_set_sink_mute_by_index(pa_context *c, uint32_t idx, 
int mute, pa_context_success_cb_t cb, void *userdata) {
 pa_operation *o;
 pa_tagstruct *t;
@@ -1509,6 +1565,33 @@ pa_operation* pa_context_set_sink_input_mute(pa_context 
*c, uint32_t idx, int mu
 return o;
 }
 
+pa_operation* pa_context_set_sink_input_volume_ramp(pa_context *c, uint32_t 
idx, const pa_cvolume *volume, uint32_t time, int type, pa_context_success_cb_t 
cb, void *userdata) {
+pa_operation *o;
+pa_tagstruct *t;
+uint32_t tag;
+
+pa_assert(c);
+pa_assert(PA_REFCNT_VALUE(c) >= 1);
+pa_assert(volume);
+
+PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
+PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, 
PA_ERR_BADSTATE);
+PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID);
+
+o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
+
+t = pa_tagstruct_command(c, PA_COMMAND_SET_SINK_INPUT_VOLUME_RAMP, &tag);
+pa_tagstruct_putu32(t, idx);
+pa_tagstruct_puts(t, NULL);
+pa_tagstruct_put_cvolume(t, volume);
+pa_tagstruct_putu32(t, time);
+pa_tagstruct_putu8(t, 

[pulseaudio-discuss] [PATCH 3/4] volume ramp: add volume ramping to sink

2012-08-08 Thread Jaska Uimonen
From: Jaska Uimonen 

---
 src/pulsecore/sink.c |  109 +
 src/pulsecore/sink.h |8 
 2 files changed, 108 insertions(+), 9 deletions(-)

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index e4c343d..4bf6a83 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -318,6 +318,15 @@ pa_sink* pa_sink_new(
 &s->sample_spec,
 0);
 
+s->ramp.type = PA_VOLUME_RAMP_TYPE_LINEAR;
+s->ramp.length = 0;
+s->ramp.left = 0;
+s->ramp.start = 1.0;
+s->ramp.end = 1.0;
+s->ramp.curr = 1.0;
+pa_cvolume_reset(&s->ramp.end_mapped, data->sample_spec.channels);
+pa_cvolume_set(&s->ramp.end_mapped, data->sample_spec.channels, 
PA_VOLUME_NORM);
+
 s->thread_info.rtpoll = NULL;
 s->thread_info.inputs = pa_hashmap_new(pa_idxset_trivial_hash_func, 
pa_idxset_trivial_compare_func);
 s->thread_info.soft_volume =  s->soft_volume;
@@ -339,6 +348,8 @@ pa_sink* pa_sink_new(
 s->thread_info.volume_change_safety_margin = 
core->deferred_volume_safety_margin_usec;
 s->thread_info.volume_change_extra_delay = 
core->deferred_volume_extra_delay_usec;
 
+s->thread_info.ramp = s->ramp;
+
 /* FIXME: This should probably be moved to pa_sink_put() */
 pa_assert_se(pa_idxset_put(core->sinks, s, &s->index) >= 0);
 
@@ -1146,10 +1157,17 @@ void pa_sink_render(pa_sink*s, size_t length, 
pa_memchunk *result) {
 result,
 &s->sample_spec,
 result->length);
-} else if (!pa_cvolume_is_norm(&volume)) {
-pa_memchunk_make_writable(result, 0);
-pa_volume_memchunk(result, &s->sample_spec, &volume);
-}
+} else if (!pa_cvolume_is_norm(&volume) || 
!pa_cvolume_is_norm(&(s->thread_info.ramp.end_mapped)) || 
s->thread_info.ramp.left > 0) {
+   pa_memchunk_make_writable(result, 0);
+   if (s->thread_info.ramp.left > 0)
+   pa_volume_ramp_memchunk(result, &s->sample_spec, 
&(s->thread_info.ramp), &volume);
+   else {
+   if (!pa_cvolume_is_norm(&(s->thread_info.ramp.end_mapped)))
+   pa_sw_cvolume_multiply(&volume, &volume, 
&(s->thread_info.ramp.end_mapped));
+
+   pa_volume_memchunk(result, &s->sample_spec, &volume);
+   }
+   }
 } else {
 void *ptr;
 result->memblock = pa_memblock_new(s->core->mempool, length);
@@ -1160,6 +1178,16 @@ void pa_sink_render(pa_sink*s, size_t length, 
pa_memchunk *result) {
 &s->sample_spec,
 &s->thread_info.soft_volume,
 s->thread_info.soft_muted);
+
+   if (!pa_cvolume_is_norm(&(s->thread_info.ramp.end_mapped)) || 
s->thread_info.ramp.left > 0) {
+   pa_cvolume volume;
+   pa_cvolume_set(&volume, s->sample_spec.channels, PA_VOLUME_NORM);
+   if (s->thread_info.ramp.left > 0)
+   pa_volume_ramp_memchunk(result, &s->sample_spec, 
&(s->thread_info.ramp), &volume);
+   else
+   pa_volume_memchunk(result, &s->sample_spec, 
&(s->thread_info.ramp.end_mapped));
+   }
+
 pa_memblock_release(result->memblock);
 
 result->index = 0;
@@ -1227,10 +1255,17 @@ void pa_sink_render_into(pa_sink*s, pa_memchunk 
*target) {
 if (vchunk.length > length)
 vchunk.length = length;
 
-if (!pa_cvolume_is_norm(&volume)) {
-pa_memchunk_make_writable(&vchunk, 0);
-pa_volume_memchunk(&vchunk, &s->sample_spec, &volume);
-}
+   if (!pa_cvolume_is_norm(&volume) || 
!pa_cvolume_is_norm(&(s->thread_info.ramp.end_mapped)) || 
s->thread_info.ramp.left > 0) {
+   pa_memchunk_make_writable(&vchunk, 0);
+   if (s->thread_info.ramp.left > 0)
+   pa_volume_ramp_memchunk(&vchunk, &s->sample_spec, 
&(s->thread_info.ramp), &volume);
+   else {
+   if (!pa_cvolume_is_norm(&(s->thread_info.ramp.end_mapped)))
+   pa_sw_cvolume_multiply(&volume, &volume, 
&(s->thread_info.ramp.end_mapped));
+
+   pa_volume_memchunk(&vchunk, &s->sample_spec, &volume);
+   }
+   }
 
 pa_memchunk_memcpy(target, &vchunk);
 pa_memblock_unref(vchunk.memblock);
@@ -1247,6 +1282,15 @@ void pa_sink_render_into(pa_sink*s, pa_memchunk *target) 
{
 &s->thread_info.soft_volume,
 s->thread_info.soft_muted);
 
+   if (!pa_cvolume_is_norm(&(s->thread_info.ramp.end_mapped)) || 
s->thread_info.ramp.left > 0) {
+   pa_cvolume volume;
+   pa_cvolume_set(&volume, s->sample_spec.channels, PA_VOLUME_NORM);
+   if (s->thread_info.ramp.left > 0)
+   pa_volume_ramp_memchunk(target, &s->sample_spec, 
&(s

[pulseaudio-discuss] [PATCH 2/4] volume ramp: adding volume ramping to sink-input

2012-08-08 Thread Jaska Uimonen
From: Jaska Uimonen 

---
 src/pulsecore/sink-input.c |   87 
 src/pulsecore/sink-input.h |   11 +-
 2 files changed, 97 insertions(+), 1 deletions(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index f6f93b8..6384f1b 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -477,6 +477,27 @@ int pa_sink_input_new(
 reset_callbacks(i);
 i->userdata = NULL;
 
+if (data->flags & PA_SINK_INPUT_START_RAMP_MUTED) {
+   i->ramp.type = PA_VOLUME_RAMP_TYPE_LINEAR;
+   i->ramp.length = 0;
+   i->ramp.left = 0;
+   i->ramp.start = 0.0;
+   i->ramp.end = 0.0;
+   i->ramp.curr = 0.0;
+   pa_cvolume_reset(&i->ramp.end_mapped, data->sample_spec.channels);
+   pa_cvolume_set(&i->ramp.end_mapped, data->sample_spec.channels, 
PA_VOLUME_MUTED);
+}
+else {
+   i->ramp.type = PA_VOLUME_RAMP_TYPE_LINEAR;
+   i->ramp.length = 0;
+   i->ramp.left = 0;
+   i->ramp.start = 1.0;
+   i->ramp.end = 1.0;
+   i->ramp.curr = 1.0;
+   pa_cvolume_reset(&i->ramp.end_mapped, data->sample_spec.channels);
+   pa_cvolume_set(&i->ramp.end_mapped, data->sample_spec.channels, 
PA_VOLUME_NORM);
+}
+
 i->thread_info.state = i->state;
 i->thread_info.attached = FALSE;
 pa_atomic_store(&i->thread_info.drained, 1);
@@ -492,6 +513,8 @@ int pa_sink_input_new(
 i->thread_info.playing_for = 0;
 i->thread_info.direct_outputs = 
pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
 
+i->thread_info.ramp = i->ramp;
+
 pa_assert_se(pa_idxset_put(core->sink_inputs, i, &i->index) == 0);
 pa_assert_se(pa_idxset_put(i->sink->inputs, pa_sink_input_ref(i), NULL) == 
0);
 
@@ -894,6 +917,18 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength 
/* in sink frames */, p
 pa_volume_memchunk(&wchunk, &i->sink->sample_spec, 
&i->volume_factor_sink);
 }
 
+   /* check for possible volume ramp */
+   if (i->thread_info.ramp.left > 0) {
+   pa_cvolume volume_adj;
+pa_memchunk_make_writable(&wchunk, 0);
+   volume_adj.channels = i->sample_spec.channels;
+   pa_cvolume_set(&volume_adj, i->sample_spec.channels, 
PA_VOLUME_NORM);
+   pa_volume_ramp_memchunk(&wchunk, &i->sample_spec, 
&(i->thread_info.ramp), &volume_adj);
+   } else if 
(!pa_cvolume_is_norm(&(i->thread_info.ramp.end_mapped))) {
+pa_memchunk_make_writable(&wchunk, 0);
+   pa_volume_memchunk(&wchunk, &i->sample_spec, 
&(i->thread_info.ramp.end_mapped));
+   }
+
 pa_memblockq_push_align(i->thread_info.render_memblockq, 
&wchunk);
 } else {
 pa_memchunk rchunk;
@@ -910,6 +945,18 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength 
/* in sink frames */, p
 pa_volume_memchunk(&rchunk, &i->sink->sample_spec, 
&i->volume_factor_sink);
 }
 
+   /* check for possible volume ramp */
+   if (i->thread_info.ramp.left > 0) {
+   pa_cvolume volume_adj;
+   pa_memchunk_make_writable(&rchunk, 0);
+   volume_adj.channels = i->sample_spec.channels;
+   pa_cvolume_set(&volume_adj, i->sample_spec.channels, 
PA_VOLUME_NORM);
+   pa_volume_ramp_memchunk(&rchunk, &i->sample_spec, 
&(i->thread_info.ramp), &volume_adj);
+   } else if 
(!pa_cvolume_is_norm(&(i->thread_info.ramp.end_mapped))) {
+   pa_memchunk_make_writable(&rchunk, 0);
+   pa_volume_memchunk(&rchunk, &i->sample_spec, 
&(i->thread_info.ramp.end_mapped));
+   }
+
 pa_memblockq_push_align(i->thread_info.render_memblockq, 
&rchunk);
 pa_memblock_unref(rchunk.memblock);
 }
@@ -1204,6 +1251,39 @@ void pa_sink_input_set_volume(pa_sink_input *i, const 
pa_cvolume *volume, pa_boo
 pa_subscription_post(i->core, 
PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
 }
 
+/* Called from main thread */
+void pa_sink_input_set_volume_ramp(
+pa_sink_input *i,
+const pa_cvolume *volume,
+   uint32_t time,
+   uint8_t type,
+pa_bool_t send_msg,
+pa_bool_t save) {
+
+float temp;
+
+pa_sink_input_assert_ref(i);
+pa_assert_ctl_context();
+pa_assert(PA_SINK_INPUT_IS_LINKED(i->state));
+pa_assert(!volume || pa_cvolume_valid(volume));
+pa_assert(!volume || volume->channels == 1 || 
pa_cvolume_compatible(volume, &i->sample_spec));
+
+i->ramp.type = type;
+i->ramp.length = time * i->sink->default_sample_rate / 1000;
+i->ramp.left = i->ramp.length;
+i->ramp.start = i->ramp.end;
+i->ramp.end_mapped = *vol

[pulseaudio-discuss] [PATCH 1/4] volume ramp: additions to the low level infra

2012-08-08 Thread Jaska Uimonen
From: Jaska Uimonen 

---
 src/pulse/def.h |   22 +-
 src/pulsecore/sample-util.c |  201 +++
 src/pulsecore/sample-util.h |   17 
 3 files changed, 239 insertions(+), 1 deletions(-)

diff --git a/src/pulse/def.h b/src/pulse/def.h
index b939319..cc7405a 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -314,11 +314,15 @@ typedef enum pa_stream_flags {
  * consider absolute when the sink is in flat volume mode,
  * relative otherwise. \since 0.9.20 */
 
-PA_STREAM_PASSTHROUGH = 0x8U
+PA_STREAM_PASSTHROUGH = 0x8U,
 /**< Used to tag content that will be rendered by passthrough sinks.
  * The data will be left as is and not reformatted, resampled.
  * \since 1.0 */
 
+PA_STREAM_START_RAMP_MUTED = 0x10U
+/**< Used to tag content that the stream will be started ramp volume
+ * muted so that you can nicely fade it in */
+
 } pa_stream_flags_t;
 
 /** \cond fulldocs */
@@ -347,6 +351,7 @@ typedef enum pa_stream_flags {
 #define PA_STREAM_FAIL_ON_SUSPEND PA_STREAM_FAIL_ON_SUSPEND
 #define PA_STREAM_RELATIVE_VOLUME PA_STREAM_RELATIVE_VOLUME
 #define PA_STREAM_PASSTHROUGH PA_STREAM_PASSTHROUGH
+#define PA_STREAM_START_RAMP_MUTED PA_STREAM_START_RAMP_MUTED
 
 /** \endcond */
 
@@ -1006,6 +1011,21 @@ typedef enum pa_port_available {
 
 /** \endcond */
 
+
+/** Volume ramp type
+*/
+typedef enum pa_volume_ramp_type {
+PA_VOLUME_RAMP_TYPE_LINEAR = 0,/**< linear */
+PA_VOLUME_RAMP_TYPE_LOGARITHMIC = 1,   /**< logarithmic */
+PA_VOLUME_RAMP_TYPE_CUBIC = 2,
+} pa_volume_ramp_type_t;
+
+/** \cond fulldocs */
+#define PA_VOLUMER_RAMP_TYPE_LINEAR PA_VOLUMER_RAMP_TYPE_LINEAR
+#define PA_VOLUMER_RAMP_TYPE_LOGARITHMIC PA_VOLUMER_RAMP_TYPE_LOGARITHMIC
+#define PA_VOLUMER_RAMP_TYPE_CUBIC PA_VOLUMER_RAMP_TYPE_CUBIC
+/** \endcond */
+
 PA_C_DECL_END
 
 #endif
diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c
index 38201b2..fccabc1 100644
--- a/src/pulsecore/sample-util.c
+++ b/src/pulsecore/sample-util.c
@@ -1050,3 +1050,204 @@ size_t pa_convert_size(size_t size, const 
pa_sample_spec *from, const pa_sample_
 usec = pa_bytes_to_usec_round_up(size, from);
 return pa_usec_to_bytes_round_up(usec, to);
 }
+
+void calc_linear_integer_volume_no_mapping(int32_t [], float [], unsigned);
+void calc_linear_float_volume_no_mapping(float [], float [], unsigned);
+
+void calc_linear_integer_volume_no_mapping(int32_t linear[], float volume[], 
unsigned nchannels) {
+unsigned channel, padding;
+
+pa_assert(linear);
+pa_assert(volume);
+
+for (channel = 0; channel < nchannels; channel++)
+linear[channel] = (int32_t) lrint(volume[channel] * 0x1U);
+
+for (padding = 0; padding < VOLUME_PADDING; padding++, channel++)
+linear[channel] = linear[padding];
+}
+
+void calc_linear_float_volume_no_mapping(float linear[], float volume[], 
unsigned nchannels) {
+unsigned channel, padding;
+
+pa_assert(linear);
+pa_assert(volume);
+
+for (channel = 0; channel < nchannels; channel++)
+linear[channel] = volume[channel];
+
+for (padding = 0; padding < VOLUME_PADDING; padding++, channel++)
+linear[channel] = linear[padding];
+}
+
+typedef void (*pa_calc_volume_no_mapping_func_t) (void *volumes, float 
*volume, int channels);
+
+static const pa_calc_volume_no_mapping_func_t calc_volume_table_no_mapping[] = 
{
+  [PA_SAMPLE_U8]= (pa_calc_volume_no_mapping_func_t) 
calc_linear_integer_volume_no_mapping,
+  [PA_SAMPLE_ALAW]  = (pa_calc_volume_no_mapping_func_t) 
calc_linear_integer_volume_no_mapping,
+  [PA_SAMPLE_ULAW]  = (pa_calc_volume_no_mapping_func_t) 
calc_linear_integer_volume_no_mapping,
+  [PA_SAMPLE_S16LE] = (pa_calc_volume_no_mapping_func_t) 
calc_linear_integer_volume_no_mapping,
+  [PA_SAMPLE_S16BE] = (pa_calc_volume_no_mapping_func_t) 
calc_linear_integer_volume_no_mapping,
+  [PA_SAMPLE_FLOAT32LE] = (pa_calc_volume_no_mapping_func_t) 
calc_linear_float_volume_no_mapping,
+  [PA_SAMPLE_FLOAT32BE] = (pa_calc_volume_no_mapping_func_t) 
calc_linear_float_volume_no_mapping,
+  [PA_SAMPLE_S32LE] = (pa_calc_volume_no_mapping_func_t) 
calc_linear_integer_volume_no_mapping,
+  [PA_SAMPLE_S32BE] = (pa_calc_volume_no_mapping_func_t) 
calc_linear_integer_volume_no_mapping,
+  [PA_SAMPLE_S24LE] = (pa_calc_volume_no_mapping_func_t) 
calc_linear_integer_volume_no_mapping,
+  [PA_SAMPLE_S24BE] = (pa_calc_volume_no_mapping_func_t) 
calc_linear_integer_volume_no_mapping,
+  [PA_SAMPLE_S24_32LE]  = (pa_calc_volume_no_mapping_func_t) 
calc_linear_integer_volume_no_mapping,
+  [PA_SAMPLE_S24_32BE]  = (pa_calc_volume_no_mapping_func_t) 
calc_linear_integer_volume_no_mapping
+};
+
+static const unsigned format_sample_size_table[] = {
+  [PA_SAMPLE_U8]= 1,
+  [PA_SAMPLE_ALAW]  = 1,
+  [PA_SAMPLE_ULAW]  = 1,
+  [PA_SAMPLE_S16LE] = 2,
+  [PA_SAMPLE_S16BE] = 2,
+  [PA_SAMPLE_FLOAT32

[pulseaudio-discuss] [PATCH 0/4] Volume ramping

2012-08-08 Thread Jaska Uimonen
From: Jaska Uimonen 

This is my 5 cents to the volume ramping ideas/discussion
that has been going on in various forums. I just wanted to
publish it for comments etc. Maybe someone can even use
it...

I decided to do add another software volume to sink and
sink-input which is independent of the other volumes.
I know that's not nice but it was really hard for me to
try adding the ramping to the existing volume functionality.
It would be nice if the ramping would in the end change
the actual volume, but I also see some drawbacks with that.

This kind of ramping is good for "transient" type ramps.
I mean it is good for ramping up and down your stream or
temporarily lowering and raising the volume of your stream.
It is not that good for permanently changing your volume.
Not because it would take more resources, but because of
it is "hidden" sw volume.

Jaska Uimonen (4):
  volume ramp: additions to the low level infra
  volume ramp: adding volume ramping to sink-input
  volume ramp: add volume ramping to sink
  volume ramp: add client api support for volume ramping

 src/map-file|3 +
 src/pulse/def.h |   22 -
 src/pulse/introspect.c  |   83 
 src/pulse/introspect.h  |9 ++
 src/pulse/stream.c  |5 +-
 src/pulsecore/native-common.h   |3 +
 src/pulsecore/pdispatch.c   |2 +
 src/pulsecore/protocol-native.c |   88 +-
 src/pulsecore/sample-util.c |  201 +++
 src/pulsecore/sample-util.h |   17 
 src/pulsecore/sink-input.c  |   87 +
 src/pulsecore/sink-input.h  |   11 ++-
 src/pulsecore/sink.c|  109 +++--
 src/pulsecore/sink.h|8 ++
 14 files changed, 634 insertions(+), 14 deletions(-)

--
1.7.7.6

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss