summaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/alsa-util.c114
-rw-r--r--src/modules/module-combine.c4
-rw-r--r--src/modules/module-device-restore.c5
-rw-r--r--src/modules/module-oss.c12
-rw-r--r--src/modules/module-stream-restore.c5
5 files changed, 92 insertions, 48 deletions
diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
index e8c7e146..8fa405dd 100644
--- a/src/modules/alsa-util.c
+++ b/src/modules/alsa-util.c
@@ -421,6 +421,8 @@ int pa_alsa_set_hw_params(
ret = 0;
+ snd_pcm_nonblock(pcm_handle, 1);
+
finish:
return ret;
@@ -569,40 +571,60 @@ snd_pcm_t *pa_alsa_open_by_device_id(
continue;
d = pa_sprintf_malloc("%s:%s", device_table[i].name, dev_id);
- pa_log_debug("Trying %s...", d);
- if ((err = snd_pcm_open(&pcm_handle, d, mode,
- SND_PCM_NONBLOCK|
- SND_PCM_NO_AUTO_RESAMPLE|
- SND_PCM_NO_AUTO_CHANNELS|
- SND_PCM_NO_AUTO_FORMAT |
- SND_PCM_NO_SOFTVOL)) < 0) {
- pa_log_info("Couldn't open PCM device %s: %s", d, snd_strerror(err));
- pa_xfree(d);
- continue;
- }
+ for (;;) {
+ pa_log_debug("Trying %s...", d);
+
+ /* We don't pass SND_PCM_NONBLOCK here, since alsa-lib <=
+ * 1.0.17a would then ignore the SND_PCM_NO_xxx
+ * flags. Instead we enable nonblock mode afterwards via
+ * snd_pcm_nonblock(). Also see
+ * http://mailman.alsa-project.org/pipermail/alsa-devel/2008-August/010258.html */
+
+ if ((err = snd_pcm_open(&pcm_handle, d, mode,
+ /* SND_PCM_NONBLOCK| */
+ SND_PCM_NO_AUTO_RESAMPLE|
+ SND_PCM_NO_AUTO_CHANNELS|
+ SND_PCM_NO_AUTO_FORMAT)) < 0) {
+ pa_log_info("Couldn't open PCM device %s: %s", d, snd_strerror(err));
+ break;
+ }
- try_ss.channels = device_table[i].map.channels;
- try_ss.rate = ss->rate;
- try_ss.format = ss->format;
+ try_ss.channels = device_table[i].map.channels;
+ try_ss.rate = ss->rate;
+ try_ss.format = ss->format;
- if ((err = pa_alsa_set_hw_params(pcm_handle, &try_ss, nfrags, period_size, tsched_size, use_mmap, use_tsched, TRUE)) < 0) {
- pa_log_info("PCM device %s refused our hw parameters: %s", d, snd_strerror(err));
- pa_xfree(d);
- snd_pcm_close(pcm_handle);
- continue;
+ if ((err = pa_alsa_set_hw_params(pcm_handle, &try_ss, nfrags, period_size, tsched_size, use_mmap, use_tsched, TRUE)) < 0) {
+
+ if (!pa_startswith(d, "plug:") && !pa_startswith(d, "plughw:")) {
+ char *t;
+
+ t = pa_sprintf_malloc("plug:%s", d);
+ pa_xfree(d);
+ d = t;
+
+ snd_pcm_close(pcm_handle);
+ continue;
+ }
+
+ pa_log_info("PCM device %s refused our hw parameters: %s", d, snd_strerror(err));
+ snd_pcm_close(pcm_handle);
+ break;
+ }
+
+ *ss = try_ss;
+ *map = device_table[i].map;
+ pa_assert(map->channels == ss->channels);
+ *dev = d;
+ return pcm_handle;
}
- *ss = try_ss;
- *map = device_table[i].map;
- pa_assert(map->channels == ss->channels);
- *dev = d;
- return pcm_handle;
+ pa_xfree(d);
}
/* OK, we didn't find any good device, so let's try the raw plughw: stuff */
- d = pa_sprintf_malloc("plughw:%s", dev_id);
+ d = pa_sprintf_malloc("hw:%s", dev_id);
pa_log_debug("Trying %s as last resort...", d);
pcm_handle = pa_alsa_open_by_device_string(d, dev, ss, map, mode, nfrags, period_size, tsched_size, use_mmap, use_tsched);
pa_xfree(d);
@@ -636,8 +658,16 @@ snd_pcm_t *pa_alsa_open_by_device_string(
d = pa_xstrdup(device);
for (;;) {
+ pa_log_debug("Trying %s...", d);
- if ((err = snd_pcm_open(&pcm_handle, d, mode, SND_PCM_NONBLOCK|
+ /* We don't pass SND_PCM_NONBLOCK here, since alsa-lib <=
+ * 1.0.17a would then ignore the SND_PCM_NO_xxx flags. Instead
+ * we enable nonblock mode afterwards via
+ * snd_pcm_nonblock(). Also see
+ * http://mailman.alsa-project.org/pipermail/alsa-devel/2008-August/010258.html */
+
+ if ((err = snd_pcm_open(&pcm_handle, d, mode,
+ /*SND_PCM_NONBLOCK|*/
SND_PCM_NO_AUTO_RESAMPLE|
SND_PCM_NO_AUTO_CHANNELS|
SND_PCM_NO_AUTO_FORMAT)) < 0) {
@@ -648,24 +678,23 @@ snd_pcm_t *pa_alsa_open_by_device_string(
if ((err = pa_alsa_set_hw_params(pcm_handle, ss, nfrags, period_size, tsched_size, use_mmap, use_tsched, FALSE)) < 0) {
- if (err == -EPERM) {
- /* Hmm, some hw is very exotic, so we retry with plug, if without it didn't work */
+ /* Hmm, some hw is very exotic, so we retry with plug, if without it didn't work */
- if (pa_startswith(d, "hw:")) {
- char *t = pa_sprintf_malloc("plughw:%s", d+3);
- pa_log_debug("Opening the device as '%s' didn't work, retrying with '%s'.", d, t);
- pa_xfree(d);
- d = t;
+ if (!pa_startswith(d, "plug:") && !pa_startswith(d, "plughw:")) {
+ char *t;
- snd_pcm_close(pcm_handle);
- continue;
- }
-
- pa_log("Failed to set hardware parameters on %s: %s", d, snd_strerror(err));
+ t = pa_sprintf_malloc("plug:%s", d);
pa_xfree(d);
+ d = t;
+
snd_pcm_close(pcm_handle);
- return NULL;
+ continue;
}
+
+ pa_log("Failed to set hardware parameters on %s: %s", d, snd_strerror(err));
+ pa_xfree(d);
+ snd_pcm_close(pcm_handle);
+ return NULL;
}
*dev = d;
@@ -896,12 +925,17 @@ void pa_alsa_dump_status(snd_pcm_t *pcm) {
static void alsa_error_handler(const char *file, int line, const char *function, int err, const char *fmt,...) {
va_list ap;
+ char *alsa_file;
+
+ alsa_file = pa_sprintf_malloc("(alsa-lib)%s", file);
va_start(ap, fmt);
- pa_log_levelv_meta(PA_LOG_WARN, file, line, function, fmt, ap);
+ pa_log_levelv_meta(PA_LOG_INFO, alsa_file, line, function, fmt, ap);
va_end(ap);
+
+ pa_xfree(alsa_file);
}
static pa_atomic_t n_error_handler_installed = PA_ATOMIC_INIT(0);
diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c
index 9fd12e30..d61d127a 100644
--- a/src/modules/module-combine.c
+++ b/src/modules/module-combine.c
@@ -233,7 +233,7 @@ static void time_callback(pa_mainloop_api*a, pa_time_event* e, const struct time
adjust_rates(u);
pa_gettimeofday(&n);
- n.tv_sec += u->adjust_time;
+ n.tv_sec += (time_t) u->adjust_time;
u->sink->core->mainloop->time_restart(e, &n);
}
@@ -1159,7 +1159,7 @@ int pa__init(pa_module*m) {
if (u->adjust_time > 0) {
struct timeval tv;
pa_gettimeofday(&tv);
- tv.tv_sec += u->adjust_time;
+ tv.tv_sec += (time_t) u->adjust_time;
u->time_event = m->core->mainloop->time_new(m->core->mainloop, &tv, time_callback, u);
}
diff --git a/src/modules/module-device-restore.c b/src/modules/module-device-restore.c
index 920b4517..86a78810 100644
--- a/src/modules/module-device-restore.c
+++ b/src/modules/module-device-restore.c
@@ -288,6 +288,7 @@ int pa__init(pa_module*m) {
pa_source *source;
uint32_t idx;
pa_bool_t restore_volume = TRUE, restore_muted = TRUE;
+ int gdbm_cache_size;
pa_assert(m);
@@ -337,6 +338,10 @@ int pa__init(pa_module*m) {
goto fail;
}
+ /* By default the cache of gdbm is rather large, let's reduce it a bit to save memory */
+ gdbm_cache_size = 10;
+ gdbm_setopt(u->gdbm_file, GDBM_CACHESIZE, &gdbm_cache_size, sizeof(gdbm_cache_size));
+
pa_log_info("Sucessfully opened database file '%s'.", fname);
pa_xfree(fname);
diff --git a/src/modules/module-oss.c b/src/modules/module-oss.c
index 3333eb83..23a32549 100644
--- a/src/modules/module-oss.c
+++ b/src/modules/module-oss.c
@@ -899,7 +899,7 @@ static void thread_func(void *userdata) {
ssize_t l;
pa_bool_t loop = FALSE, work_done = FALSE;
- l = u->out_fragment_size;
+ l = (ssize_t) u->out_fragment_size;
if (u->use_getospace) {
audio_buf_info info;
@@ -920,14 +920,14 @@ static void thread_func(void *userdata) {
/* Round down to multiples of the fragment size,
* because OSS needs that (at least some versions
* do) */
- l = (l/u->out_fragment_size) * u->out_fragment_size;
+ l = (l/(ssize_t) u->out_fragment_size) * (ssize_t) u->out_fragment_size;
/* Hmm, so poll() signalled us that we can read
* something, but GETOSPACE told us there was nothing?
* Hmm, make the best of it, try to read some data, to
* avoid spinning forever. */
if (l <= 0 && (revents & POLLOUT)) {
- l = u->out_fragment_size;
+ l = (ssize_t) u->out_fragment_size;
loop = FALSE;
}
@@ -1010,7 +1010,7 @@ static void thread_func(void *userdata) {
pa_memchunk memchunk;
pa_bool_t loop = FALSE, work_done = FALSE;
- l = u->in_fragment_size;
+ l = (ssize_t) u->in_fragment_size;
if (u->use_getispace) {
audio_buf_info info;
@@ -1024,10 +1024,10 @@ static void thread_func(void *userdata) {
}
}
- l = (l/u->in_fragment_size) * u->in_fragment_size;
+ l = (l/(ssize_t) u->in_fragment_size) * (ssize_t) u->in_fragment_size;
if (l <= 0 && (revents & POLLIN)) {
- l = u->in_fragment_size;
+ l = (ssize_t) u->in_fragment_size;
loop = FALSE;
}
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 37e8b067..47f5d836 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -686,6 +686,7 @@ int pa__init(pa_module*m) {
pa_source_output *so;
uint32_t idx;
pa_bool_t restore_device = TRUE, restore_volume = TRUE, restore_muted = TRUE;
+ int gdbm_cache_size;
pa_assert(m);
@@ -746,6 +747,10 @@ int pa__init(pa_module*m) {
goto fail;
}
+ /* By default the cache of gdbm is rather large, let's reduce it a bit to save memory */
+ gdbm_cache_size = 10;
+ gdbm_setopt(u->gdbm_file, GDBM_CACHESIZE, &gdbm_cache_size, sizeof(gdbm_cache_size));
+
pa_log_info("Sucessfully opened database file '%s'.", fname);
pa_xfree(fname);