[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-test2-103-g2d9ae49

Lennart Poettering gitmailer-noreply at 0pointer.de
Sat Feb 21 17:00:34 PST 2009


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  1a45569b3e60807ee57ba2e6c15fbbb441871c61 (commit)

- Log -----------------------------------------------------------------
2d9ae49... rework suspending/resuming
504384a... initialize selem index
194d899... make sure we don't choke on overly long lines in .desktop files
edfa39a... make sure we don't choke on PULSE_PROP_OVERRIDE
77779ea... rework logging to make it more modular
9b74afc... make string translatable (fixes #483)
fa5e10f... fix wording, closes #484
-----------------------------------------------------------------------

Summary of changes:
 src/daemon/cmdline.c                            |    6 +-
 src/daemon/main.c                               |   20 ++-
 src/modules/alsa/alsa-util.c                    |    3 +-
 src/modules/bluetooth/module-bluetooth-device.c |  147 ++++++++++-------
 src/modules/module-augment-properties.c         |    2 +
 src/pulsecore/cli-command.c                     |    6 +-
 src/pulsecore/conf-parser.c                     |    4 +-
 src/pulsecore/log.c                             |  197 +++++++++++++----------
 src/pulsecore/log.h                             |   44 ++++--
 src/pulsecore/proplist-util.c                   |    5 +-
 src/tests/envelope-test.c                       |    2 +-
 src/tests/memblockq-test.c                      |    2 +-
 src/tests/mix-test.c                            |    2 +-
 src/tests/remix-test.c                          |    2 +-
 src/tests/resampler-test.c                      |    2 +-
 15 files changed, 264 insertions(+), 180 deletions(-)

-----------------------------------------------------------------------

commit fa5e10f5fa1418457e40fd0debf4bd42d4650910
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Feb 21 16:58:24 2009 +0100

    fix wording, closes #484

diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c
index 43a4a32..f4224ea 100644
--- a/src/daemon/cmdline.c
+++ b/src/daemon/cmdline.c
@@ -299,7 +299,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
 
             case ARG_DISALLOW_EXIT:
                 if ((conf->disallow_exit = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
-                    pa_log(_("--disallow-exit boolean argument"));
+                    pa_log(_("--disallow-exit expects boolean argument"));
                     goto fail;
                 }
                 break;
@@ -330,14 +330,14 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
 
             case ARG_LOG_TIME:
                 if ((conf->log_time = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
-                    pa_log(_("--log-time boolean argument"));
+                    pa_log(_("--log-time expects boolean argument"));
                     goto fail;
                 }
                 break;
 
             case ARG_LOG_META:
                 if ((conf->log_meta = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
-                    pa_log(_("--log-meta boolean argument"));
+                    pa_log(_("--log-meta expects boolean argument"));
                     goto fail;
                 }
                 break;

commit 9b74afcfa3fd3a870aa485fe7f70b5751bfb5158
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Feb 21 17:01:01 2009 +0100

    make string translatable (fixes #483)

diff --git a/src/daemon/main.c b/src/daemon/main.c
index d176f45..0675f19 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -506,8 +506,9 @@ int main(int argc, char *argv[]) {
         if ((conf->high_priority && !allow_high_priority) ||
             (conf->realtime_scheduling && !allow_realtime))
             pa_log_notice(_("Called SUID root and real-time and/or high-priority scheduling was requested in the configuration. However, we lack the necessary privileges:\n"
-                            "We are not in group '"PA_REALTIME_GROUP"', PolicyKit refuse to grant us the requested privileges and we have no increase RLIMIT_NICE/RLIMIT_RTPRIO resource limits.\n"
-                            "For enabling real-time/high-priority scheduling please acquire the appropriate PolicyKit privileges, or become a member of '"PA_REALTIME_GROUP"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."));
+                            "We are not in group '%s', PolicyKit refuse to grant us the requested privileges and we have no increase RLIMIT_NICE/RLIMIT_RTPRIO resource limits.\n"
+                            "For enabling real-time/high-priority scheduling please acquire the appropriate PolicyKit privileges, or become a member of '%s', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."),
+                          PA_REALTIME_GROUP, PA_REALTIME_GROUP);
 
 
         if (!allow_realtime)

commit 77779ead6d09604573b7170fa27fb9a5926cd02e
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Feb 21 22:45:56 2009 +0100

    rework logging to make it more modular

diff --git a/src/daemon/main.c b/src/daemon/main.c
index 0675f19..b630bd1 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -351,8 +351,9 @@ int main(int argc, char *argv[]) {
     int autospawn_fd = -1;
     pa_bool_t autospawn_locked = FALSE;
 
-    pa_log_set_maximal_level(PA_LOG_INFO);
     pa_log_set_ident("pulseaudio");
+    pa_log_set_level(PA_LOG_INFO);
+    pa_log_set_flags(PA_LOG_COLORS|PA_LOG_PRINT_FILE|PA_LOG_PRINT_LEVEL, PA_LOG_RESET);
 
 #if defined(__linux__) && defined(__OPTIMIZE__)
     /*
@@ -432,11 +433,13 @@ int main(int argc, char *argv[]) {
         goto finish;
     }
 
-    pa_log_set_maximal_level(conf->log_level);
-    pa_log_set_target(conf->auto_log_target ? PA_LOG_STDERR : conf->log_target, NULL);
-    pa_log_set_show_meta(conf->log_meta);
+    pa_log_set_level(conf->log_level);
+    pa_log_set_target(conf->auto_log_target ? PA_LOG_STDERR : conf->log_target);
+    if (conf->log_meta)
+        pa_log_set_flags(PA_LOG_PRINT_META, PA_LOG_SET);
+    if (conf->log_time)
+        pa_log_set_flags(PA_LOG_PRINT_TIME, PA_LOG_SET);
     pa_log_set_show_backtrace(conf->log_backtrace);
-    pa_log_set_show_time(conf->log_time);
 
     pa_log_debug("Started as real root: %s, suid root: %s", pa_yes_no(real_root), pa_yes_no(suid_root));
 
@@ -771,7 +774,7 @@ int main(int argc, char *argv[]) {
 #endif
 
         if (conf->auto_log_target)
-            pa_log_set_target(PA_LOG_SYSLOG, NULL);
+            pa_log_set_target(PA_LOG_SYSLOG);
 
 #ifdef HAVE_SETSID
         setsid();
diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c
index 7066e7e..4ce87d6 100644
--- a/src/pulsecore/cli-command.c
+++ b/src/pulsecore/cli-command.c
@@ -1350,7 +1350,7 @@ static int pa_cli_command_log_level(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
         return -1;
     }
 
-    pa_log_set_maximal_level(level);
+    pa_log_set_level(level);
 
     return 0;
 }
@@ -1374,7 +1374,7 @@ static int pa_cli_command_log_meta(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
         return -1;
     }
 
-    pa_log_set_show_meta(b);
+    pa_log_set_flags(PA_LOG_PRINT_META, b ? PA_LOG_SET : PA_LOG_UNSET);
 
     return 0;
 }
@@ -1398,7 +1398,7 @@ static int pa_cli_command_log_time(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
         return -1;
     }
 
-    pa_log_set_show_time(b);
+    pa_log_set_flags(PA_LOG_PRINT_TIME, b ? PA_LOG_SET : PA_LOG_UNSET);
 
     return 0;
 }
diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c
index 89b75da..9931586 100644
--- a/src/pulsecore/log.c
+++ b/src/pulsecore/log.c
@@ -51,18 +51,21 @@
 
 #include "log.h"
 
-#define ENV_LOGLEVEL "PULSE_LOG"
-#define ENV_LOGMETA "PULSE_LOG_META"
-#define ENV_LOGTIME "PULSE_LOG_TIME"
-#define ENV_LOGBACKTRACE "PULSE_LOG_BACKTRACE"
-
-static char *log_ident = NULL, *log_ident_local = NULL;
-static pa_log_target_t log_target = PA_LOG_STDERR;
-static pa_log_func_t user_log_func = NULL;
-static pa_log_level_t maximal_level = PA_LOG_ERROR;
-static unsigned show_backtrace = 0;
-static pa_bool_t show_meta = FALSE;
-static pa_bool_t show_time = FALSE;
+#define ENV_LOG_SYSLOG "PULSE_LOG_SYSLOG"
+#define ENV_LOG_LEVEL "PULSE_LOG"
+#define ENV_LOG_COLORS "PULSE_LOG_COLORS"
+#define ENV_LOG_PRINT_TIME "PULSE_LOG_TIME"
+#define ENV_LOG_PRINT_FILE "PULSE_LOG_FILE"
+#define ENV_LOG_PRINT_META "PULSE_LOG_META"
+#define ENV_LOG_PRINT_LEVEL "PULSE_LOG_LEVEL"
+#define ENV_LOG_BACKTRACE "PULSE_LOG_BACKTRACE"
+
+static char *ident = NULL; /* in local charset format */
+static pa_log_target_t target = PA_LOG_STDERR, target_override;
+static pa_bool_t target_override_set = FALSE;
+static pa_log_level_t maximum_level = PA_LOG_ERROR, maximum_level_override = PA_LOG_ERROR;
+static unsigned show_backtrace = 0, show_backtrace_override = 0;
+static pa_log_flags_t flags = 0, flags_override = 0;
 
 #ifdef HAVE_SYSLOG_H
 static const int level_to_syslog[] = {
@@ -83,12 +86,10 @@ static const char level_to_char[] = {
 };
 
 void pa_log_set_ident(const char *p) {
-    pa_xfree(log_ident);
-    pa_xfree(log_ident_local);
+    pa_xfree(ident);
 
-    log_ident = pa_xstrdup(p);
-    if (!(log_ident_local = pa_utf8_to_locale(log_ident)))
-        log_ident_local = pa_xstrdup(log_ident);
+    if (!(ident = pa_utf8_to_locale(p)))
+        ident = pa_ascii_filter(p);
 }
 
 /* To make valgrind shut up. */
@@ -97,29 +98,30 @@ static void ident_destructor(void) {
     if (!pa_in_valgrind())
         return;
 
-    pa_xfree(log_ident);
-    pa_xfree(log_ident_local);
+    pa_xfree(ident);
 }
 
-void pa_log_set_maximal_level(pa_log_level_t l) {
+void pa_log_set_level(pa_log_level_t l) {
     pa_assert(l < PA_LOG_LEVEL_MAX);
 
-    maximal_level = l;
+    maximum_level = l;
 }
 
-void pa_log_set_target(pa_log_target_t t, pa_log_func_t func) {
-    pa_assert(t == PA_LOG_USER || !func);
+void pa_log_set_target(pa_log_target_t t) {
+    pa_assert(t < PA_LOG_TARGET_MAX);
 
-    log_target = t;
-    user_log_func = func;
+    target = t;
 }
 
-void pa_log_set_show_meta(pa_bool_t b) {
-    show_meta = b;
-}
+void pa_log_set_flags(pa_log_flags_t _flags, pa_log_merge_t merge) {
+    pa_assert(!(_flags & ~(PA_LOG_COLORS|PA_LOG_PRINT_TIME|PA_LOG_PRINT_FILE|PA_LOG_PRINT_META|PA_LOG_PRINT_LEVEL)));
 
-void pa_log_set_show_time(pa_bool_t b) {
-    show_time = b;
+    if (merge == PA_LOG_SET)
+        flags |= _flags;
+    else if (merge == PA_LOG_UNSET)
+        flags &= ~_flags;
+    else
+        flags = _flags;
 }
 
 void pa_log_set_show_backtrace(unsigned nlevels) {
@@ -135,8 +137,7 @@ static char* get_backtrace(unsigned show_nframes) {
     unsigned j, n;
     size_t a;
 
-    if (show_nframes <= 0)
-        return NULL;
+    pa_assert(show_nframes > 0);
 
     n_frames = backtrace(trace, PA_ELEMENTSOF(trace));
 
@@ -182,6 +183,50 @@ static char* get_backtrace(unsigned show_nframes) {
 
 #endif
 
+static void init_defaults(void) {
+    const char *e;
+
+    if (!ident) {
+        char binary[256];
+        if (pa_get_binary_name(binary, sizeof(binary)))
+            pa_log_set_ident(binary);
+    }
+
+    if (getenv(ENV_LOG_SYSLOG)) {
+        target_override = PA_LOG_SYSLOG;
+        target_override_set = TRUE;
+    }
+
+    if ((e = getenv(ENV_LOG_LEVEL))) {
+        maximum_level_override = (pa_log_level_t) atoi(e);
+
+        if (maximum_level_override >= PA_LOG_LEVEL_MAX)
+            maximum_level_override = PA_LOG_LEVEL_MAX-1;
+    }
+
+    if (getenv(ENV_LOG_COLORS))
+        flags_override |= PA_LOG_COLORS;
+
+    if (getenv(ENV_LOG_PRINT_TIME))
+        flags_override |= PA_LOG_PRINT_TIME;
+
+    if (getenv(ENV_LOG_PRINT_FILE))
+        flags_override |= PA_LOG_PRINT_FILE;
+
+    if (getenv(ENV_LOG_PRINT_META))
+        flags_override |= PA_LOG_PRINT_META;
+
+    if (getenv(ENV_LOG_PRINT_LEVEL))
+        flags_override |= PA_LOG_PRINT_LEVEL;
+
+    if ((e = getenv(ENV_LOG_BACKTRACE))) {
+        show_backtrace_override = (unsigned) atoi(e);
+
+        if (show_backtrace_override <= 0)
+            show_backtrace_override = 0;
+    }
+}
+
 void pa_log_levelv_meta(
         pa_log_level_t level,
         const char*file,
@@ -190,14 +235,13 @@ void pa_log_levelv_meta(
         const char *format,
         va_list ap) {
 
-    const char *e;
     char *t, *n;
     int saved_errno = errno;
     char *bt = NULL;
-    pa_log_level_t ml;
-#ifdef HAVE_EXECINFO_H
-    unsigned show_bt;
-#endif
+    pa_log_target_t _target;
+    pa_log_level_t _maximum_level;
+    unsigned _show_backtrace;
+    pa_log_flags_t _flags;
 
     /* We don't use dynamic memory allocation here to minimize the hit
      * in RT threads */
@@ -206,30 +250,30 @@ void pa_log_levelv_meta(
     pa_assert(level < PA_LOG_LEVEL_MAX);
     pa_assert(format);
 
-    ml = maximal_level;
-
-    if (PA_UNLIKELY((e = getenv(ENV_LOGLEVEL)))) {
-        pa_log_level_t eml = (pa_log_level_t) atoi(e);
+    PA_ONCE_BEGIN {
+        init_defaults();
+    } PA_ONCE_END;
 
-        if (eml > ml)
-            ml = eml;
-    }
+    _target = target_override_set ? target_override : target;
+    _maximum_level = PA_MAX(maximum_level, maximum_level_override);
+    _show_backtrace = PA_MAX(show_backtrace, show_backtrace_override);
+    _flags = flags | flags_override;
 
-    if (PA_LIKELY(level > ml)) {
+    if (PA_LIKELY(level > _maximum_level)) {
         errno = saved_errno;
         return;
     }
 
     pa_vsnprintf(text, sizeof(text), format, ap);
 
-    if ((show_meta || getenv(ENV_LOGMETA)) && file && line > 0 && func)
+    if ((_flags & PA_LOG_PRINT_META) && file && line > 0 && func)
         pa_snprintf(location, sizeof(location), "[%s:%i %s()] ", file, line, func);
-    else if (file)
+    else if (_flags & (PA_LOG_PRINT_META|PA_LOG_PRINT_FILE))
         pa_snprintf(location, sizeof(location), "%s: ", pa_path_get_filename(file));
     else
         location[0] = 0;
 
-    if (show_time || getenv(ENV_LOGTIME)) {
+    if (_flags & PA_LOG_PRINT_TIME) {
         static pa_usec_t start, last;
         pa_usec_t u, a, r;
 
@@ -257,16 +301,8 @@ void pa_log_levelv_meta(
         timestamp[0] = 0;
 
 #ifdef HAVE_EXECINFO_H
-    show_bt = show_backtrace;
-
-    if ((e = getenv(ENV_LOGBACKTRACE))) {
-        unsigned ebt = (unsigned) atoi(e);
-
-        if (ebt > show_bt)
-            show_bt = ebt;
-    }
-
-    bt = get_backtrace(show_bt);
+    if (_show_backtrace > 0)
+        bt = get_backtrace(_show_backtrace);
 #endif
 
     if (!pa_utf8_valid(text))
@@ -282,14 +318,15 @@ void pa_log_levelv_meta(
         if (t[strspn(t, "\t ")] == 0)
             continue;
 
-        switch (log_target) {
+        switch (_target) {
+
             case PA_LOG_STDERR: {
                 const char *prefix = "", *suffix = "", *grey = "";
                 char *local_t;
 
 #ifndef OS_IS_WIN32
                 /* Yes indeed. Useless, but fun! */
-                if (isatty(STDERR_FILENO)) {
+                if ((_flags & PA_LOG_COLORS) && isatty(STDERR_FILENO)) {
                     if (level <= PA_LOG_ERROR)
                         prefix = "\x1B[1;31m";
                     else if (level <= PA_LOG_WARN)
@@ -305,13 +342,15 @@ void pa_log_levelv_meta(
 
                 /* We shouldn't be using dynamic allocation here to
                  * minimize the hit in RT threads */
-                local_t = pa_utf8_to_locale(t);
-                if (!local_t)
+                if ((local_t = pa_utf8_to_locale(t)))
+                    t = local_t;
+
+                if (_flags & PA_LOG_PRINT_LEVEL)
                     fprintf(stderr, "%s%c: %s%s%s%s%s%s\n", timestamp, level_to_char[level], location, prefix, t, grey, pa_strempty(bt), suffix);
-                else {
-                    fprintf(stderr, "%s%c: %s%s%s%s%s%s\n", timestamp, level_to_char[level], location, prefix, local_t, grey, pa_strempty(bt), suffix);
-                    pa_xfree(local_t);
-                }
+                else
+                    fprintf(stderr, "%s%s%s%s%s%s%s\n", timestamp, location, prefix, t, grey, pa_strempty(bt), suffix);
+
+                pa_xfree(local_t);
 
                 break;
             }
@@ -320,29 +359,17 @@ void pa_log_levelv_meta(
             case PA_LOG_SYSLOG: {
                 char *local_t;
 
-                openlog(log_ident_local ? log_ident_local : "???", LOG_PID, LOG_USER);
-
-                local_t = pa_utf8_to_locale(t);
-                if (!local_t)
-                    syslog(level_to_syslog[level], "%s%s%s%s", timestamp, location, t, pa_strempty(bt));
-                else {
-                    syslog(level_to_syslog[level], "%s%s%s%s", timestamp, location, local_t, pa_strempty(bt));
-                    pa_xfree(local_t);
-                }
-
-                closelog();
-                break;
-            }
-#endif
+                openlog(ident, LOG_PID, LOG_USER);
 
-            case PA_LOG_USER: {
-                char x[1024];
+                if ((local_t = pa_utf8_to_locale(t)))
+                    t = local_t;
 
-                pa_snprintf(x, sizeof(x), "%s%s%s", timestamp, location, t);
-                user_log_func(level, x);
+                syslog(level_to_syslog[level], "%s%s%s%s", timestamp, location, t, pa_strempty(bt));
+                pa_xfree(local_t);
 
                 break;
             }
+#endif
 
             case PA_LOG_NULL:
             default:
@@ -350,8 +377,8 @@ void pa_log_levelv_meta(
         }
     }
 
-    errno = saved_errno;
     pa_xfree(bt);
+    errno = saved_errno;
 }
 
 void pa_log_level_meta(
diff --git a/src/pulsecore/log.h b/src/pulsecore/log.h
index 77adb79..6e7bfc3 100644
--- a/src/pulsecore/log.h
+++ b/src/pulsecore/log.h
@@ -35,8 +35,8 @@
 typedef enum pa_log_target {
     PA_LOG_STDERR,  /* default */
     PA_LOG_SYSLOG,
-    PA_LOG_USER,    /* to user specified function */
-    PA_LOG_NULL     /* to /dev/null */
+    PA_LOG_NULL,    /* to /dev/null */
+    PA_LOG_TARGET_MAX
 } pa_log_target_t;
 
 typedef enum pa_log_level {
@@ -48,18 +48,33 @@ typedef enum pa_log_level {
     PA_LOG_LEVEL_MAX
 } pa_log_level_t;
 
+typedef enum pa_log_flags {
+    PA_LOG_COLORS      = 0x01, /* Show colorful output */
+    PA_LOG_PRINT_TIME  = 0x02, /* Show time */
+    PA_LOG_PRINT_FILE  = 0x04, /* Show source file */
+    PA_LOG_PRINT_META  = 0x08, /* Show extended locaton information */
+    PA_LOG_PRINT_LEVEL = 0x10, /* Show log level prefix */
+} pa_log_flags_t;
+
+typedef enum pa_log_merge {
+    PA_LOG_SET,
+    PA_LOG_UNSET,
+    PA_LOG_RESET
+} pa_log_merge_t;
+
 /* Set an identification for the current daemon. Used when logging to syslog. */
 void pa_log_set_ident(const char *p);
 
-typedef void (*pa_log_func_t)(pa_log_level_t t, const char*s);
-
-/* Set another log target. If t is PA_LOG_USER you may specify a function that is called every log string */
-void pa_log_set_target(pa_log_target_t t, pa_log_func_t func);
+/* Set a log target. */
+void pa_log_set_target(pa_log_target_t t);
 
 /* Maximal log level */
-void pa_log_set_maximal_level(pa_log_level_t l);
-void pa_log_set_show_meta(pa_bool_t b);
-void pa_log_set_show_time(pa_bool_t b);
+void pa_log_set_level(pa_log_level_t l);
+
+/* Set flags */
+void pa_log_set_flags(pa_log_flags_t flags, pa_log_merge_t merge);
+
+/* Enable backtrace */
 void pa_log_set_show_backtrace(unsigned nlevels);
 
 void pa_log_level_meta(
@@ -68,6 +83,7 @@ void pa_log_level_meta(
         int line,
         const char *func,
         const char *format, ...) PA_GCC_PRINTF_ATTR(5,6);
+
 void pa_log_levelv_meta(
         pa_log_level_t level,
         const char*file,
@@ -76,8 +92,14 @@ void pa_log_levelv_meta(
         const char *format,
         va_list ap);
 
-void pa_log_level(pa_log_level_t level, const char *format, ...) PA_GCC_PRINTF_ATTR(2,3);
-void pa_log_levelv(pa_log_level_t level, const char *format, va_list ap);
+void pa_log_level(
+        pa_log_level_t level,
+        const char *format, ...) PA_GCC_PRINTF_ATTR(2,3);
+
+void pa_log_levelv(
+        pa_log_level_t level,
+        const char *format,
+        va_list ap);
 
 #if __STDC_VERSION__ >= 199901L
 
diff --git a/src/tests/envelope-test.c b/src/tests/envelope-test.c
index 4a72f5a..11a80a1 100644
--- a/src/tests/envelope-test.c
+++ b/src/tests/envelope-test.c
@@ -203,7 +203,7 @@ int main(int argc, char *argv[]) {
     };
 
     oil_init();
-    pa_log_set_maximal_level(PA_LOG_DEBUG);
+    pa_log_set_level(PA_LOG_DEBUG);
 
     pa_assert_se(pool = pa_mempool_new(FALSE, 0));
     pa_assert_se(envelope = pa_envelope_new(&ss));
diff --git a/src/tests/memblockq-test.c b/src/tests/memblockq-test.c
index c53945b..b01a4fd 100644
--- a/src/tests/memblockq-test.c
+++ b/src/tests/memblockq-test.c
@@ -61,7 +61,7 @@ int main(int argc, char *argv[]) {
     pa_memchunk chunk1, chunk2, chunk3, chunk4;
     pa_memchunk silence;
 
-    pa_log_set_maximal_level(PA_LOG_DEBUG);
+    pa_log_set_level(PA_LOG_DEBUG);
 
     p = pa_mempool_new(FALSE, 0);
 
diff --git a/src/tests/mix-test.c b/src/tests/mix-test.c
index cc21ab0..db8ac6e 100644
--- a/src/tests/mix-test.c
+++ b/src/tests/mix-test.c
@@ -199,7 +199,7 @@ int main(int argc, char *argv[]) {
     pa_cvolume v;
 
     oil_init();
-    pa_log_set_maximal_level(PA_LOG_DEBUG);
+    pa_log_set_level(PA_LOG_DEBUG);
 
     pa_assert_se(pool = pa_mempool_new(FALSE, 0));
 
diff --git a/src/tests/remix-test.c b/src/tests/remix-test.c
index 3538d7d..3da4ee3 100644
--- a/src/tests/remix-test.c
+++ b/src/tests/remix-test.c
@@ -56,7 +56,7 @@ int main(int argc, char *argv[]) {
     pa_mempool *pool;
 
     oil_init();
-    pa_log_set_maximal_level(PA_LOG_DEBUG);
+    pa_log_set_level(PA_LOG_DEBUG);
 
     pa_assert_se(pool = pa_mempool_new(FALSE, 0));
 
diff --git a/src/tests/resampler-test.c b/src/tests/resampler-test.c
index 2d59186..da8d375 100644
--- a/src/tests/resampler-test.c
+++ b/src/tests/resampler-test.c
@@ -199,7 +199,7 @@ int main(int argc, char *argv[]) {
     pa_cvolume v;
 
     oil_init();
-    pa_log_set_maximal_level(PA_LOG_DEBUG);
+    pa_log_set_level(PA_LOG_DEBUG);
 
     pa_assert_se(pool = pa_mempool_new(FALSE, 0));
 

commit edfa39a2af1c653fd8ccd6c34d7d2e49505d325f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Feb 21 23:46:31 2009 +0100

    make sure we don't choke on PULSE_PROP_OVERRIDE

diff --git a/src/pulsecore/proplist-util.c b/src/pulsecore/proplist-util.c
index 7ba2fd7..af5f0aa 100644
--- a/src/pulsecore/proplist-util.c
+++ b/src/pulsecore/proplist-util.c
@@ -135,8 +135,9 @@ void pa_init_proplist(pa_proplist *p) {
 
                 k = pa_xstrndup(*e+skip, kl);
 
-                if (override || !pa_proplist_contains(p, k))
-                    pa_proplist_sets(p, k, *e+skip+kl+1);
+                if (!pa_streq(k, "OVERRIDE"))
+                    if (override || !pa_proplist_contains(p, k))
+                        pa_proplist_sets(p, k, *e+skip+kl+1);
                 pa_xfree(k);
             }
         }

commit 194d8991d7a5b6cf1822f3a4d7459b12975b4107
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Feb 21 23:47:08 2009 +0100

    make sure we don't choke on overly long lines in .desktop files

diff --git a/src/modules/module-augment-properties.c b/src/modules/module-augment-properties.c
index 90bfbe7..9911186 100644
--- a/src/modules/module-augment-properties.c
+++ b/src/modules/module-augment-properties.c
@@ -195,6 +195,8 @@ static pa_hook_result_t process(struct userdata *u, pa_proplist *p) {
 
     time(&now);
 
+    pa_log_debug("Looking for .desktop file for %s", pn);
+
     if ((r = pa_hashmap_get(u->cache, pn))) {
         if (now-r->timestamp > STAT_INTERVAL) {
             r->timestamp = now;
diff --git a/src/pulsecore/conf-parser.c b/src/pulsecore/conf-parser.c
index b7ec2b3..1d98f36 100644
--- a/src/pulsecore/conf-parser.c
+++ b/src/pulsecore/conf-parser.c
@@ -127,7 +127,7 @@ static int parse_line(const char *filename, unsigned line, char **section, const
 int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, void *userdata) {
     int r = -1;
     unsigned line = 0;
-    int do_close = !f;
+    pa_bool_t do_close = !f;
     char *section = NULL;
 
     pa_assert(filename);
@@ -144,7 +144,7 @@ int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, void
     }
 
     while (!feof(f)) {
-        char l[256];
+        char l[4096];
 
         if (!fgets(l, sizeof(l), f)) {
             if (feof(f))

commit 504384a041cf1f9ccdd51390a037887c448189b9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Feb 22 00:45:34 2009 +0100

    initialize selem index

diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index 4340cb3..016e52a 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -1027,6 +1027,7 @@ snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const
     pa_assert(name);
 
     snd_mixer_selem_id_set_name(sid, name);
+    snd_mixer_selem_id_set_index(sid, 0);
 
     if ((elem = snd_mixer_find_selem(mixer, sid))) {
 
@@ -1043,6 +1044,7 @@ snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const
 
     if (fallback) {
         snd_mixer_selem_id_set_name(sid, fallback);
+        snd_mixer_selem_id_set_index(sid, 0);
 
         if ((fallback_elem = snd_mixer_find_selem(mixer, sid))) {
 
@@ -1085,7 +1087,6 @@ success:
     return elem;
 }
 
-
 int pa_alsa_find_mixer_and_elem(
         snd_pcm_t *pcm,
         snd_mixer_t **_m,

commit 2d9ae496c953ce62765f8f7f5b87fcab5e325c52
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Feb 22 02:00:25 2009 +0100

    rework suspending/resuming

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 559d95b..b2fb1db 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -712,13 +712,13 @@ static int stop_stream_fd(struct userdata *u) {
         bt_audio_error_t error;
         uint8_t buf[BT_SUGGESTED_BUFFER_SIZE];
     } msg;
+    int r = 0;
 
     pa_assert(u);
     pa_assert(u->rtpoll);
     pa_assert(u->rtpoll_item);
     pa_assert(u->stream_fd >= 0);
 
-    /* FIXME: HSP, only when sink&source suspended */
     pa_rtpoll_item_free(u->rtpoll_item);
     u->rtpoll_item = NULL;
 
@@ -727,20 +727,21 @@ static int stop_stream_fd(struct userdata *u) {
     msg.start_req.h.name = BT_STOP_STREAM;
     msg.start_req.h.length = sizeof(msg.start_req);
 
-    if (service_send(u, &msg.start_req.h) < 0)
-        return -1;
-
-    if (service_expect(u, &msg.rsp, sizeof(msg), BT_STOP_STREAM, sizeof(msg.start_rsp)) < 0)
-        return -1;
+    if (service_send(u, &msg.start_req.h) < 0 ||
+        service_expect(u, &msg.rsp, sizeof(msg), BT_STOP_STREAM, sizeof(msg.start_rsp)) < 0)
+        r = -1;
 
     pa_close(u->stream_fd);
     u->stream_fd = -1;
 
-    return 0;
+    return r;
 }
 
 static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
     struct userdata *u = PA_SINK(o)->userdata;
+    pa_bool_t failed = FALSE;
+    int r;
+
     pa_assert(u->sink == PA_SINK(o));
 
     pa_log_debug("got message: %d", code);
@@ -753,19 +754,26 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
                 case PA_SINK_SUSPENDED:
                     pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state));
 
-                    stop_stream_fd(u); /* FIXME: return value */
+                    /* Stop the device if the source is suspended as well */
+                    if (!u->source || u->source->state == PA_SOURCE_SUSPENDED)
+                        /* We deliberately ignore whether stopping
+                         * actually worked. Since the stream_fd is
+                         * closed it doesn't really matter */
+                        stop_stream_fd(u);
 
                     break;
 
                 case PA_SINK_IDLE:
                 case PA_SINK_RUNNING:
-                    if (PA_SINK_IS_OPENED(u->sink->thread_info.state))
+                    if (u->sink->thread_info.state != PA_SINK_SUSPENDED)
                         break;
 
-                    if (u->rtpoll_item == NULL)
-                        start_stream_fd(u); /* FIXME: return value */
-                    u->started_at = pa_rtclock_usec();
+                    /* Resume the device if the source was suspended as well */
+                    if (!u->source || u->source->state == PA_SOURCE_SUSPENDED)
+                        if (start_stream_fd(u) < 0)
+                            failed = TRUE;
 
+                    u->started_at = pa_rtclock_usec();
                     break;
 
                 case PA_SINK_UNLINKED:
@@ -779,14 +787,17 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
             *((pa_usec_t*) data) = 0;
             return 0;
         }
-
     }
 
-    return pa_sink_process_msg(o, code, data, offset, chunk);
+    r = pa_sink_process_msg(o, code, data, offset, chunk);
+
+    return (r < 0 || !failed) ? r : -1;
 }
 
 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;
+    pa_bool_t failed = FALSE;
+    int r;
 
     pa_assert(u->source == PA_SOURCE(o));
 
@@ -798,13 +809,26 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
             switch ((pa_source_state_t) PA_PTR_TO_UINT(data)) {
 
                 case PA_SOURCE_SUSPENDED:
+                    pa_assert(PA_SOURCE_IS_OPENED(u->source->thread_info.state));
+
+                    /* Stop the device if the sink is suspended as well */
+                    if (!u->sink || u->sink->state == PA_SINK_SUSPENDED)
+                        stop_stream_fd(u);
+
                     pa_smoother_pause(u->read_smoother, pa_rtclock_usec());
                     break;
 
                 case PA_SOURCE_IDLE:
                 case PA_SOURCE_RUNNING:
-                    if (u->source->thread_info.state == PA_SOURCE_SUSPENDED)
-                        pa_smoother_resume(u->read_smoother, pa_rtclock_usec());
+                    if (u->source->thread_info.state != PA_SOURCE_SUSPENDED)
+                        break;
+
+                    /* Resume the device if the sink was suspended as well */
+                    if (!u->sink || u->sink->thread_info.state == PA_SINK_SUSPENDED)
+                        if (start_stream_fd(u) < 0)
+                            failed = TRUE;
+
+                    pa_smoother_resume(u->read_smoother, pa_rtclock_usec());
                     break;
 
                 case PA_SOURCE_UNLINKED:
@@ -821,7 +845,9 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
 
     }
 
-    return pa_source_process_msg(o, code, data, offset, chunk);
+    r = pa_source_process_msg(o, code, data, offset, chunk);
+
+    return (r < 0 || !failed) ? r : -1;
 }
 
 static int hsp_process_render(struct userdata *u) {
@@ -1057,12 +1083,13 @@ static void thread_func(void *userdata) {
     for (;;) {
         struct pollfd *pollfd;
         int ret;
+        pa_bool_t disable_timer = TRUE;
 
-        pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
+        pollfd = u->rtpoll_item ? pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL) : NULL;
 
         if (u->source && PA_SOURCE_IS_LINKED(u->source->thread_info.state)) {
 
-            if (pollfd->revents & POLLIN) {
+            if (pollfd && (pollfd->revents & POLLIN)) {
 
                 if (hsp_process_push(u) < 0)
                     goto fail;
@@ -1077,73 +1104,73 @@ static void thread_func(void *userdata) {
             if (u->sink->thread_info.rewind_requested)
                 pa_sink_process_rewind(u->sink, 0);
 
-            if (pollfd->revents & POLLOUT)
-                writable = TRUE;
+            if (pollfd) {
+                if (pollfd->revents & POLLOUT)
+                    writable = TRUE;
 
-            if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state)) && !do_write && writable) {
-                pa_usec_t time_passed;
-                uint64_t should_have_written;
+                if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state)) && !do_write && writable) {
+                    pa_usec_t time_passed;
+                    uint64_t should_have_written;
 
-                /* Hmm, there is no input stream we could synchronize
-                 * to. So let's do things by time */
+                    /* Hmm, there is no input stream we could synchronize
+                     * to. So let's do things by time */
 
-                time_passed = pa_rtclock_usec() - u->started_at;
-                should_have_written = pa_usec_to_bytes(time_passed, &u->sink->sample_spec);
+                    time_passed = pa_rtclock_usec() - u->started_at;
+                    should_have_written = pa_usec_to_bytes(time_passed, &u->sink->sample_spec);
 
-                do_write = u->write_index <= should_have_written ;
+                    do_write = u->write_index <= should_have_written ;
 /*                 pa_log_debug("Time has come: %s", pa_yes_no(do_write)); */
-            }
+                }
 
-            if (writable && do_write) {
+                if (writable && do_write) {
 
-                if (u->profile == PROFILE_A2DP) {
-                    if (a2dp_process_render(u) < 0)
-                        goto fail;
-                } else {
-                    if (hsp_process_render(u) < 0)
-                        goto fail;
-                }
+                    if (u->profile == PROFILE_A2DP) {
+                        if (a2dp_process_render(u) < 0)
+                            goto fail;
+                    } else {
+                        if (hsp_process_render(u) < 0)
+                            goto fail;
+                    }
 
-                do_write = FALSE;
-                writable = FALSE;
-            }
+                    do_write = FALSE;
+                    writable = FALSE;
+                }
 
-            if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state)) && !do_write) {
-                pa_usec_t time_passed, next_write_at, sleep_for;
+                if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state)) && !do_write) {
+                    pa_usec_t time_passed, next_write_at, sleep_for;
 
-                /* Hmm, there is no input stream we could synchronize
-                 * to. So let's estimate when we need to wake up the latest */
+                    /* Hmm, there is no input stream we could synchronize
+                     * to. So let's estimate when we need to wake up the latest */
 
-                time_passed = pa_rtclock_usec() - u->started_at;
-                next_write_at = pa_bytes_to_usec(u->write_index, &u->sink->sample_spec);
-                sleep_for = time_passed < next_write_at ? next_write_at - time_passed : 0;
+                    time_passed = pa_rtclock_usec() - u->started_at;
+                    next_write_at = pa_bytes_to_usec(u->write_index, &u->sink->sample_spec);
+                    sleep_for = time_passed < next_write_at ? next_write_at - time_passed : 0;
 
 /*                 pa_log("Sleeping for %lu; time passed %lu, next write at %lu", (unsigned long) sleep_for, (unsigned long) time_passed, (unsigned long)next_write_at); */
 
-                pa_rtpoll_set_timer_relative(u->rtpoll, sleep_for);
+                    pa_rtpoll_set_timer_relative(u->rtpoll, sleep_for);
+                    disable_timer = FALSE;
+                }
             }
-        } else
+        }
+
+        if (disable_timer)
             pa_rtpoll_set_timer_disabled(u->rtpoll);
 
         /* Hmm, nothing to do. Let's sleep */
-        pollfd->events = (short) (((u->sink && PA_SINK_IS_OPENED(u->sink->thread_info.state) && !writable) ? POLLOUT : 0) |
-                                  (u->source && PA_SOURCE_IS_OPENED(u->source->thread_info.state) ? POLLIN : 0));
+        if (pollfd)
+            pollfd->events = (short) (((u->sink && PA_SINK_IS_OPENED(u->sink->thread_info.state) && !writable) ? POLLOUT : 0) |
+                                      (u->source && PA_SOURCE_IS_OPENED(u->source->thread_info.state) ? POLLIN : 0));
 
-    poll_run:
         if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
             goto fail;
 
         if (ret == 0)
             goto finish;
 
-        if (!u->rtpoll_item) {
-            pa_rtpoll_set_timer_disabled(u->rtpoll);
-            goto poll_run;
-        }
-
-        pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
+        pollfd = u->rtpoll_item ? pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL) : NULL;
 
-        if (pollfd->revents & ~(POLLOUT|POLLIN)) {
+        if (pollfd && (pollfd->revents & ~(POLLOUT|POLLIN))) {
             pa_log_error("FD error.");
             goto fail;
         }

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list