chiark
/
gitweb
/
~mdw
/
disorder
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge config aliasing bug fix.
[disorder]
/
lib
/
uaudio-alsa.c
diff --git
a/lib/uaudio-alsa.c
b/lib/uaudio-alsa.c
index be716cfcde8688fc5eff6d42bed01917f8f41f2b..721639c74a1c032da761578bb7340ae34834d36f 100644
(file)
--- a/
lib/uaudio-alsa.c
+++ b/
lib/uaudio-alsa.c
@@
-26,6
+26,7
@@
#include "mem.h"
#include "log.h"
#include "uaudio.h"
#include "mem.h"
#include "log.h"
#include "uaudio.h"
+#include "configuration.h"
/** @brief The current PCM handle */
static snd_pcm_t *alsa_pcm;
/** @brief The current PCM handle */
static snd_pcm_t *alsa_pcm;
@@
-135,7
+136,8
@@
static void alsa_start(uaudio_callback *callback,
alsa_open();
uaudio_thread_start(callback, userdata, alsa_play,
32 / uaudio_sample_size,
alsa_open();
uaudio_thread_start(callback, userdata, alsa_play,
32 / uaudio_sample_size,
- 4096 / uaudio_sample_size);
+ 4096 / uaudio_sample_size,
+ 0);
}
static void alsa_stop(void) {
}
static void alsa_stop(void) {
@@
-149,6
+151,11
@@
static int to_percent(long n) {
return (n - alsa_mixer_min) * 100 / (alsa_mixer_max - alsa_mixer_min);
}
return (n - alsa_mixer_min) * 100 / (alsa_mixer_max - alsa_mixer_min);
}
+/** @brief Convert a percentage to a level */
+static int from_percent(int n) {
+ return alsa_mixer_min + n * (alsa_mixer_max - alsa_mixer_min) / 100;
+}
+
static void alsa_open_mixer(void) {
int err;
snd_mixer_selem_id_t *id;
static void alsa_open_mixer(void) {
int err;
snd_mixer_selem_id_t *id;
@@
-159,8
+166,8
@@
static void alsa_open_mixer(void) {
snd_mixer_selem_id_alloca(&id);
if((err = snd_mixer_open(&alsa_mixer_handle, 0)))
fatal(0, "snd_mixer_open: %s", snd_strerror(err));
snd_mixer_selem_id_alloca(&id);
if((err = snd_mixer_open(&alsa_mixer_handle, 0)))
fatal(0, "snd_mixer_open: %s", snd_strerror(err));
- if((err = snd_mixer_attach(alsa_mixer_handle,
config->
device)))
- fatal(0, "snd_mixer_attach %s: %s",
config->
device, snd_strerror(err));
+ if((err = snd_mixer_attach(alsa_mixer_handle, device)))
+ fatal(0, "snd_mixer_attach %s: %s", device, snd_strerror(err));
if((err = snd_mixer_selem_register(alsa_mixer_handle,
0/*options*/, 0/*classp*/)))
fatal(0, "snd_mixer_selem_register %s: %s",
if((err = snd_mixer_selem_register(alsa_mixer_handle,
0/*options*/, 0/*classp*/)))
fatal(0, "snd_mixer_selem_register %s: %s",
@@
-240,6
+247,12
@@
static void alsa_set_volume(int *left, int *right) {
*right = to_percent(r);
}
*right = to_percent(r);
}
+static void alsa_configure(void) {
+ uaudio_set("device", config->device);
+ uaudio_set("mixer-control", config->mixer);
+ uaudio_set("mixer-channel", config->channel);
+}
+
const struct uaudio uaudio_alsa = {
.name = "alsa",
.options = alsa_options,
const struct uaudio uaudio_alsa = {
.name = "alsa",
.options = alsa_options,
@@
-251,6
+264,7
@@
const struct uaudio uaudio_alsa = {
.close_mixer = alsa_close_mixer,
.get_volume = alsa_get_volume,
.set_volume = alsa_set_volume,
.close_mixer = alsa_close_mixer,
.get_volume = alsa_get_volume,
.set_volume = alsa_set_volume,
+ .configure = alsa_configure
};
#endif
};
#endif