Discussion:
[PATCH 1/4] roar: don't write warning messages to stderr
Johannes Weißl
2011-03-19 09:33:45 UTC
Permalink
This messes up curses display, e.g.:

(roaraudio: basic.c:143): Warning: roar_connect_raw(*): Can not connect to SLP located server, disabling cache
---
roar.c | 33 ++++++++++++++++++++++++++++++---
1 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/roar.c b/roar.c
index 6c7170c..2cf1b18 100644
--- a/roar.c
+++ b/roar.c
@@ -18,13 +18,14 @@
* 02111-1307, USA.
*/

+#include <roaraudio.h>
+
#include "op.h"
#include "mixer.h"
#include "xmalloc.h"
#include "utils.h"
#include "misc.h"
-
-#include <roaraudio.h>
+#include "debug.h"

// we do not use native 2^16-1 here as they use signed ints with 16 bit
// so we use 2^(16-1)-1 here.
@@ -49,6 +50,32 @@ static int op_roar_dummy(void)
return 0;
}

+static ssize_t op_roar_debug_write(struct roar_vio_calls *vio, void *buf_, size_t count)
+{
+ char *buf = (char *) buf_;
+ int len = count;
+ if (len > 0 && buf[len-1] == '\n')
+ len--;
+ if (len > 0)
+ d_print("%*s\n", len, buf);
+ return count;
+}
+
+static struct roar_vio_calls op_roar_debug_cbs = {
+ .write = op_roar_debug_write
+};
+
+static int op_roar_init(void)
+{
+#if DEBUG > 1
+ roar_debug_set_stderr_mode(ROAR_DEBUG_MODE_VIO);
+ roar_debug_set_stderr_vio(&op_roar_debug_cbs);
+#else
+ roar_debug_set_stderr_mode(ROAR_DEBUG_MODE_SYSLOG);
+#endif
+ return 0;
+}
+
static int op_roar_exit(void)
{
if (host != NULL)
@@ -284,7 +311,7 @@ static int op_roar_mixer_get_option(int key, char **val)
}

const struct output_plugin_ops op_pcm_ops = {
- .init = op_roar_dummy,
+ .init = op_roar_init,
.exit = op_roar_exit,
.open = op_roar_open,
.close = op_roar_close,
--
1.7.4.1
Johannes Weißl
2011-03-19 09:33:46 UTC
Permalink
Without this, pa_threaded_mainloop_wait() can deadlock. This happens
e.g. if the pulseaudio daemon is not yet spawned. Also auto-spawning of
the daemon works now (NOFAIL).
---
pulse.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/pulse.c b/pulse.c
index fd2af57..8b927a1 100644
--- a/pulse.c
+++ b/pulse.c
@@ -251,14 +251,19 @@ static int __pa_create_context(void)

pa_context_set_state_callback(pa_ctx, __pa_context_running_cb, NULL);

- rc = pa_context_connect(pa_ctx, NULL, PA_CONTEXT_NOFLAGS, NULL);
+ rc = pa_context_connect(pa_ctx, NULL, PA_CONTEXT_NOFAIL, NULL);
if (rc)
goto out_fail;

- pa_threaded_mainloop_wait(pa_ml);
-
- if (pa_context_get_state(pa_ctx) != PA_CONTEXT_READY)
- goto out_fail_connected;
+ for (;;) {
+ pa_context_state_t state;
+ state = pa_context_get_state(pa_ctx);
+ if (state == PA_CONTEXT_READY)
+ break;
+ if (!PA_CONTEXT_IS_GOOD(state))
+ goto out_fail_connected;
+ pa_threaded_mainloop_wait(pa_ml);
+ }

pa_threaded_mainloop_unlock(pa_ml);
--
1.7.4.1
Gregory Petrosyan
2011-03-29 08:54:49 UTC
Permalink
Post by Johannes Weißl
Without this, pa_threaded_mainloop_wait() can deadlock. This happens
e.g. if the pulseaudio daemon is not yet spawned. Also auto-spawning of
the daemon works now (NOFAIL).
Thanks — merged to maint and master!

Gregory
Johannes Weißl
2011-03-19 09:33:47 UTC
Permalink
Try to open output plugin with default sample format on startup. This
ensures that no audio server is chosen where only the libraries are
installed (and not the daemon). Currently cmus always selects roar for
me, although I have only the libraries installed.
---
output.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/output.c b/output.c
index 5a4f269..f5fdd1e 100644
--- a/output.c
+++ b/output.c
@@ -228,11 +228,17 @@ int op_select_any(void)
{
struct output_plugin *o;
int rc = -OP_ERROR_NO_PLUGIN;
+ sample_format_t sf = sf_channels(2) | sf_rate(44100) | sf_bits(16) | sf_signed(1);

list_for_each_entry(o, &op_head, node) {
rc = select_plugin(o);
- if (rc == 0)
+ if (rc != 0)
+ continue;
+ rc = o->pcm_ops->open(sf);
+ if (rc == 0) {
+ o->pcm_ops->close();
break;
+ }
}
return rc;
}
--
1.7.4.1
Gregory Petrosyan
2011-03-29 08:56:17 UTC
Permalink
Post by Johannes Weißl
Try to open output plugin with default sample format on startup. This
ensures that no audio server is chosen where only the libraries are
installed (and not the daemon). Currently cmus always selects roar for
me, although I have only the libraries installed.
Thanks! Merged to master.

Gregory
Johannes Weißl
2011-03-19 09:33:48 UTC
Permalink
Move roar behind pulseaudio. Now that the output plugins are tested,
pulseaudio isn't selected if the daemon is not installed.

The pulseaudio check is much cheaper than roar, so test it first
(roar connect blocks for 3-4 seconds).
---
pulse.c | 2 +-
roar.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pulse.c b/pulse.c
index 8b927a1..f7c3c14 100644
--- a/pulse.c
+++ b/pulse.c
@@ -586,5 +586,5 @@ const char * const op_mixer_options[] = {
NULL
};

-const int op_priority = -1;
+const int op_priority = -2;

diff --git a/roar.c b/roar.c
index 2cf1b18..2c1a99d 100644
--- a/roar.c
+++ b/roar.c
@@ -346,4 +346,4 @@ const char * const op_mixer_options[] = {
NULL
};

-const int op_priority = -2;
+const int op_priority = -1;
--
1.7.4.1
Gregory Petrosyan
2011-03-29 08:57:41 UTC
Permalink
Post by Johannes Weißl
Move roar behind pulseaudio. Now that the output plugins are tested,
pulseaudio isn't selected if the daemon is not installed.
The pulseaudio check is much cheaper than roar, so test it first
(roar connect blocks for 3-4 seconds).
Merged to master, thanks!

Gregory

Gregory Petrosyan
2011-03-29 08:55:24 UTC
Permalink
Post by Johannes Weißl
(roaraudio: basic.c:143): Warning: roar_connect_raw(*): Can not connect to SLP located server, disabling cache
Thanks! Merged to master.

Gregory
Loading...