SHA256
1
0
forked from pool/alsa-utils
alsa-utils/0006-Revert-wrong-parts-of-alsactl-use-snd_config_imake-f.patch

270 lines
9.3 KiB
Diff

From b4ff58b685fe9da25901cd3e395dd2f2d64532df Mon Sep 17 00:00:00 2001
From: Clemens Ladisch <clemens@ladisch.de>
Date: Wed, 26 May 2010 10:37:58 +0200
Subject: [PATCH 06/13] Revert wrong parts of "alsactl: use snd_config_imake* functions"
This reverts the parts of commit e509df69a5100df28921980362488f6947df0aae
that accidentally reverted a bunch of earlier commits.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
---
alsactl/alsactl.h | 10 ++++----
alsactl/state.c | 22 +++++++++++---------
alsactl/utils.c | 6 ++++-
configure.in | 2 +-
seq/aconnect/aconnect.c | 49 ++++++++++++++--------------------------------
5 files changed, 38 insertions(+), 51 deletions(-)
diff --git a/alsactl/alsactl.h b/alsactl/alsactl.h
index 89ad295..be90efb 100644
--- a/alsactl/alsactl.h
+++ b/alsactl/alsactl.h
@@ -34,16 +34,16 @@ extern char *statefile;
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
#define cerror(cond, ...) do {\
- if (cond) { \
- fprintf(stderr, "%s: %s:%d: ", command, __FUNCTION__, __LINE__); \
+ if (cond || debugflag) { \
+ fprintf(stderr, "%s%s: %s:%d: ", debugflag ? "WARNING: " : "", command, __FUNCTION__, __LINE__); \
fprintf(stderr, __VA_ARGS__); \
putc('\n', stderr); \
} \
} while (0)
#else
#define cerror(cond, args...) do {\
- if (cond) { \
- fprintf(stderr, "%s: %s:%d: ", command, __FUNCTION__, __LINE__); \
+ if (cond || debugflag) { \
+ fprintf(stderr, "%s%s: %s:%d: ", debugflag ? "WARNING: " : "", command, __FUNCTION__, __LINE__); \
fprintf(stderr, ##args); \
putc('\n', stderr); \
} \
@@ -78,7 +78,7 @@ int generate_names(const char *cfgfile);
int file_map(const char *filename, char **buf, size_t *bufsize);
void file_unmap(void *buf, size_t bufsize);
size_t line_width(const char *buf, size_t bufsize, size_t pos);
-void initfailed(int cardnumber, const char *reason);
+void initfailed(int cardnumber, const char *reason, int exitcode);
static inline int hextodigit(int c)
{
diff --git a/alsactl/state.c b/alsactl/state.c
index 01b1cd6..7eb107f 100644
--- a/alsactl/state.c
+++ b/alsactl/state.c
@@ -1131,7 +1131,6 @@ static int restore_config_value2(snd_ctl_t *handle, snd_ctl_elem_info_t *info,
}
snd_ctl_elem_value_set_byte(ctl, idx, val);
return 1;
- break;
default:
break;
}
@@ -1418,6 +1417,7 @@ static int set_controls(int card, snd_config_t *top, int doit)
snd_ctl_card_info_alloca(&info);
sprintf(name, "hw:%d", card);
+ dbg("device='%s', doit=%i", name, doit);
err = snd_ctl_open(&handle, name, 0);
if (err < 0) {
error("snd_ctl_open error: %s", snd_strerror(err));
@@ -1429,6 +1429,7 @@ static int set_controls(int card, snd_config_t *top, int doit)
goto _close;
}
id = snd_ctl_card_info_get_id(info);
+ dbg("card-info-id: '%s'", id);
err = snd_config_searchv(top, &control, "state", id, "control", 0);
if (err < 0) {
if (force_restore) {
@@ -1454,24 +1455,25 @@ static int set_controls(int card, snd_config_t *top, int doit)
goto _close;
}
+ dbg("maxnumid=%i", maxnumid);
/* check if we have additional controls in driver */
/* in this case we should go through init procedure */
if (!doit && maxnumid >= 0) {
- snd_ctl_elem_id_t *id;
snd_ctl_elem_info_t *info;
- snd_ctl_elem_id_alloca(&id);
snd_ctl_elem_info_alloca(&info);
snd_ctl_elem_info_set_numid(info, maxnumid+1);
if (snd_ctl_elem_info(handle, info) == 0) {
/* not very informative */
/* but value is used for check only */
err = -EAGAIN;
+ dbg("more controls than maxnumid?");
goto _close;
}
}
_close:
snd_ctl_close(handle);
+ dbg("result code: %i", err);
return err;
}
@@ -1596,9 +1598,9 @@ int load_state(const char *file, const char *initfile, const char *cardname,
err = init(initfile, cardname1);
if (err < 0) {
finalerr = err;
- initfailed(card, "init");
+ initfailed(card, "init", err);
}
- initfailed(card, "restore");
+ initfailed(card, "restore", -ENOENT);
}
if (first)
finalerr = 0; /* no cards, no error code */
@@ -1631,14 +1633,14 @@ int load_state(const char *file, const char *initfile, const char *cardname,
sprintf(cardname1, "%i", card);
err = init(initfile, cardname1);
if (err < 0) {
- initfailed(card, "init");
+ initfailed(card, "init", err);
finalerr = err;
}
}
if ((err = set_controls(card, config, 1))) {
if (!force_restore)
finalerr = err;
- initfailed(card, "restore");
+ initfailed(card, "restore", err);
}
}
} else {
@@ -1653,12 +1655,12 @@ int load_state(const char *file, const char *initfile, const char *cardname,
if (do_init && set_controls(cardno, config, 0)) {
err = init(initfile, cardname);
if (err < 0) {
- initfailed(cardno, "init");
- return err;
+ initfailed(cardno, "init", err);
+ finalerr = err;
}
}
if ((err = set_controls(cardno, config, 1))) {
- initfailed(cardno, "restore");
+ initfailed(cardno, "restore", err);
if (!force_restore)
return err;
}
diff --git a/alsactl/utils.c b/alsactl/utils.c
index ab4dbd4..a27eb6e 100644
--- a/alsactl/utils.c
+++ b/alsactl/utils.c
@@ -79,19 +79,23 @@ size_t line_width(const char *buf, size_t bufsize, size_t pos)
return count - pos;
}
-void initfailed(int cardnumber, const char *reason)
+void initfailed(int cardnumber, const char *reason, int exitcode)
{
int fp;
char *str;
+ char sexitcode[16];
if (statefile == NULL)
return;
if (snd_card_get_name(cardnumber, &str) < 0)
return;
+ sprintf(sexitcode, "%i", exitcode);
fp = open(statefile, O_WRONLY|O_CREAT|O_APPEND, 0644);
write(fp, str, strlen(str));
write(fp, ":", 1);
write(fp, reason, strlen(reason));
+ write(fp, ":", 1);
+ write(fp, sexitcode, strlen(sexitcode));
write(fp, "\n", 1);
close(fp);
free(str);
diff --git a/configure.in b/configure.in
index 66b785f..8bae007 100644
--- a/configure.in
+++ b/configure.in
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(aplay/aplay.c)
AC_PREFIX_DEFAULT(/usr)
-AM_INIT_AUTOMAKE(alsa-utils, 1.0.22)
+AM_INIT_AUTOMAKE(alsa-utils, 1.0.23)
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION([0.15])
diff --git a/seq/aconnect/aconnect.c b/seq/aconnect/aconnect.c
index 1a50666..8c66cfd 100644
--- a/seq/aconnect/aconnect.c
+++ b/seq/aconnect/aconnect.c
@@ -192,52 +192,33 @@ static void remove_connection(snd_seq_t *seq, snd_seq_client_info_t *cinfo,
snd_seq_port_info_t *pinfo, int count)
{
snd_seq_query_subscribe_t *query;
+ snd_seq_port_info_t *port;
+ snd_seq_port_subscribe_t *subs;
snd_seq_query_subscribe_alloca(&query);
snd_seq_query_subscribe_set_root(query, snd_seq_port_info_get_addr(pinfo));
-
snd_seq_query_subscribe_set_type(query, SND_SEQ_QUERY_SUBS_READ);
snd_seq_query_subscribe_set_index(query, 0);
- for (; snd_seq_query_port_subscribers(seq, query) >= 0;
- snd_seq_query_subscribe_set_index(query, snd_seq_query_subscribe_get_index(query) + 1)) {
- snd_seq_port_info_t *port;
- snd_seq_port_subscribe_t *subs;
+
+ snd_seq_port_info_alloca(&port);
+ snd_seq_port_subscribe_alloca(&subs);
+
+ while (snd_seq_query_port_subscribers(seq, query) >= 0) {
const snd_seq_addr_t *sender = snd_seq_query_subscribe_get_root(query);
const snd_seq_addr_t *dest = snd_seq_query_subscribe_get_addr(query);
- snd_seq_port_info_alloca(&port);
- if (snd_seq_get_any_port_info(seq, dest->client, dest->port, port) < 0)
- continue;
- if (!(snd_seq_port_info_get_capability(port) & SND_SEQ_PORT_CAP_SUBS_WRITE))
- continue;
- if (snd_seq_port_info_get_capability(port) & SND_SEQ_PORT_CAP_NO_EXPORT)
- continue;
- snd_seq_port_subscribe_alloca(&subs);
- snd_seq_port_subscribe_set_queue(subs, snd_seq_query_subscribe_get_queue(query));
- snd_seq_port_subscribe_set_sender(subs, sender);
- snd_seq_port_subscribe_set_dest(subs, dest);
- snd_seq_unsubscribe_port(seq, subs);
- }
- snd_seq_query_subscribe_set_type(query, SND_SEQ_QUERY_SUBS_WRITE);
- snd_seq_query_subscribe_set_index(query, 0);
- for (; snd_seq_query_port_subscribers(seq, query) >= 0;
- snd_seq_query_subscribe_set_index(query, snd_seq_query_subscribe_get_index(query) + 1)) {
- snd_seq_port_info_t *port;
- snd_seq_port_subscribe_t *subs;
- const snd_seq_addr_t *dest = snd_seq_query_subscribe_get_root(query);
- const snd_seq_addr_t *sender = snd_seq_query_subscribe_get_addr(query);
- snd_seq_port_info_alloca(&port);
- if (snd_seq_get_any_port_info(seq, sender->client, sender->port, port) < 0)
- continue;
- if (!(snd_seq_port_info_get_capability(port) & SND_SEQ_PORT_CAP_SUBS_READ))
+ if (snd_seq_get_any_port_info(seq, dest->client, dest->port, port) < 0 ||
+ !(snd_seq_port_info_get_capability(port) & SND_SEQ_PORT_CAP_SUBS_WRITE) ||
+ (snd_seq_port_info_get_capability(port) & SND_SEQ_PORT_CAP_NO_EXPORT)) {
+ snd_seq_query_subscribe_set_index(query, snd_seq_query_subscribe_get_index(query) + 1);
continue;
- if (snd_seq_port_info_get_capability(port) & SND_SEQ_PORT_CAP_NO_EXPORT)
- continue;
- snd_seq_port_subscribe_alloca(&subs);
+ }
snd_seq_port_subscribe_set_queue(subs, snd_seq_query_subscribe_get_queue(query));
snd_seq_port_subscribe_set_sender(subs, sender);
snd_seq_port_subscribe_set_dest(subs, dest);
- snd_seq_unsubscribe_port(seq, subs);
+ if (snd_seq_unsubscribe_port(seq, subs) < 0) {
+ snd_seq_query_subscribe_set_index(query, snd_seq_query_subscribe_get_index(query) + 1);
+ }
}
}
--
1.7.2.1