mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-28 05:40:23 -04:00
Renamed ERR to SNDERR. Added s16 pseudo meter scope. Fixed plug hw_refine/params
This commit is contained in:
parent
84732560a9
commit
bbaeb29a74
26 changed files with 503 additions and 313 deletions
|
|
@ -45,10 +45,10 @@
|
|||
#include <errno.h>
|
||||
|
||||
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
|
||||
#define ERR(...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, 0, __VA_ARGS__)
|
||||
#define SNDERR(...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, 0, __VA_ARGS__)
|
||||
#define SYSERR(...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, errno, __VA_ARGS__)
|
||||
#else
|
||||
#define ERR(args...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, 0, ##args)
|
||||
#define SNDERR(args...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, 0, ##args)
|
||||
#define SYSERR(args...) snd_lib_error(__FILE__, __LINE__, __FUNCTION__, errno, ##args)
|
||||
#endif
|
||||
|
||||
|
|
|
|||
18
src/conf.c
18
src/conf.c
|
|
@ -438,7 +438,7 @@ static int parse_def(snd_config_t *father, input_t *input)
|
|||
if (_snd_config_search(father, id, -1, &n) == 0) {
|
||||
if (mode != REMOVE) {
|
||||
if (n->type != SND_CONFIG_TYPE_COMPOUND) {
|
||||
ERR("%s is not a compound", id);
|
||||
SNDERR("%s is not a compound", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
n->u.compound.join = 1;
|
||||
|
|
@ -449,7 +449,7 @@ static int parse_def(snd_config_t *father, input_t *input)
|
|||
snd_config_delete(n);
|
||||
}
|
||||
if (mode == NOCREATE) {
|
||||
ERR("%s does not exists", id);
|
||||
SNDERR("%s does not exists", id);
|
||||
free(id);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
|
@ -471,7 +471,7 @@ static int parse_def(snd_config_t *father, input_t *input)
|
|||
} else {
|
||||
n = NULL;
|
||||
if (mode == NOCREATE) {
|
||||
ERR("%s does not exists", id);
|
||||
SNDERR("%s does not exists", id);
|
||||
free(id);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
|
@ -481,7 +481,7 @@ static int parse_def(snd_config_t *father, input_t *input)
|
|||
{
|
||||
if (n) {
|
||||
if (n->type != SND_CONFIG_TYPE_COMPOUND) {
|
||||
ERR("%s is not a compound", id);
|
||||
SNDERR("%s is not a compound", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -522,7 +522,7 @@ static int parse_def(snd_config_t *father, input_t *input)
|
|||
free(s);
|
||||
if (n) {
|
||||
if (n->type != SND_CONFIG_TYPE_REAL) {
|
||||
ERR("%s is not a real", id);
|
||||
SNDERR("%s is not a real", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -537,7 +537,7 @@ static int parse_def(snd_config_t *father, input_t *input)
|
|||
free(s);
|
||||
if (n) {
|
||||
if (n->type != SND_CONFIG_TYPE_INTEGER) {
|
||||
ERR("%s is not an integer", id);
|
||||
SNDERR("%s is not an integer", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -551,7 +551,7 @@ static int parse_def(snd_config_t *father, input_t *input)
|
|||
}
|
||||
if (n) {
|
||||
if (n->type != SND_CONFIG_TYPE_STRING) {
|
||||
ERR("%s is not a string", id);
|
||||
SNDERR("%s is not a string", id);
|
||||
free(s);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
|
@ -636,14 +636,14 @@ int snd_config_load(snd_config_t *config, snd_input_t *in)
|
|||
assert(0);
|
||||
break;
|
||||
}
|
||||
ERR("%s:%d:%d:%s", fd->name ? fd->name : "",
|
||||
SNDERR("%s:%d:%d:%s", fd->name ? fd->name : "",
|
||||
fd->line, fd->column, str);
|
||||
}
|
||||
snd_config_delete(config);
|
||||
goto _end;
|
||||
}
|
||||
if (get_char(&input) != EOF) {
|
||||
ERR("%s:%d:%d:Unexpected }", fd->name ? fd->name : "",
|
||||
SNDERR("%s:%d:%d:Unexpected }", fd->name ? fd->name : "",
|
||||
fd->line, fd->column);
|
||||
snd_config_delete(config);
|
||||
err = -EINVAL;
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ int snd_ctl_open(snd_ctl_t **ctlp, const char *name)
|
|||
err = sscanf(name, "shm:%256[^,],%256[^,]", socket, sname);
|
||||
if (err == 2)
|
||||
return snd_ctl_shm_open(ctlp, name, socket, sname);
|
||||
ERR("Unknown control %s", name);
|
||||
SNDERR("Unknown control %s", name);
|
||||
return -ENOENT;
|
||||
}
|
||||
if (snd_config_get_type(ctl_conf) != SND_CONFIG_TYPE_COMPOUND)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ static int snd_ctl_shm_action(snd_ctl_t *ctl)
|
|||
if (err != 1)
|
||||
return -EBADFD;
|
||||
if (ctrl->cmd) {
|
||||
ERR("Server has not done the cmd");
|
||||
SNDERR("Server has not done the cmd");
|
||||
return -EBADFD;
|
||||
}
|
||||
return ctrl->result;
|
||||
|
|
@ -74,7 +74,7 @@ static int snd_ctl_shm_action_fd(snd_ctl_t *ctl, int *fd)
|
|||
if (err != 1)
|
||||
return -EBADFD;
|
||||
if (ctrl->cmd) {
|
||||
ERR("Server has not done the cmd");
|
||||
SNDERR("Server has not done the cmd");
|
||||
return -EBADFD;
|
||||
}
|
||||
return ctrl->result;
|
||||
|
|
@ -419,7 +419,7 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *socket,
|
|||
|
||||
result = make_local_socket(socket);
|
||||
if (result < 0) {
|
||||
ERR("server for socket %s is not running", socket);
|
||||
SNDERR("server for socket %s is not running", socket);
|
||||
goto _err;
|
||||
}
|
||||
sock = result;
|
||||
|
|
@ -434,23 +434,23 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *socket,
|
|||
req->namelen = snamelen;
|
||||
err = write(sock, req, reqlen);
|
||||
if (err < 0) {
|
||||
ERR("write error");
|
||||
SNDERR("write error");
|
||||
result = -errno;
|
||||
goto _err;
|
||||
}
|
||||
if ((size_t) err != reqlen) {
|
||||
ERR("write size error");
|
||||
SNDERR("write size error");
|
||||
result = -EINVAL;
|
||||
goto _err;
|
||||
}
|
||||
err = read(sock, &ans, sizeof(ans));
|
||||
if (err < 0) {
|
||||
ERR("read error");
|
||||
SNDERR("read error");
|
||||
result = -errno;
|
||||
goto _err;
|
||||
}
|
||||
if (err != sizeof(ans)) {
|
||||
ERR("read size error");
|
||||
SNDERR("read size error");
|
||||
result = -EINVAL;
|
||||
goto _err;
|
||||
}
|
||||
|
|
@ -520,7 +520,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
|
|||
if (strcmp(id, "server") == 0) {
|
||||
err = snd_config_get_string(n, &server);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -528,25 +528,25 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
|
|||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
ERR("sname is not defined");
|
||||
SNDERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!server) {
|
||||
ERR("server is not defined");
|
||||
SNDERR("server is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
err = snd_config_searchv(snd_config, &sconfig, "server", server, 0);
|
||||
if (err < 0) {
|
||||
ERR("Unknown server %s", server);
|
||||
SNDERR("Unknown server %s", server);
|
||||
return -EINVAL;
|
||||
}
|
||||
snd_config_for_each(i, next, conf) {
|
||||
|
|
@ -557,7 +557,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
|
|||
if (strcmp(id, "host") == 0) {
|
||||
err = snd_config_get_string(n, &host);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -565,7 +565,7 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
|
|||
if (strcmp(id, "socket") == 0) {
|
||||
err = snd_config_get_string(n, &socket);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -573,31 +573,31 @@ int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *conf)
|
|||
if (strcmp(id, "port") == 0) {
|
||||
err = snd_config_get_integer(n, &port);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!host) {
|
||||
ERR("host is not defined");
|
||||
SNDERR("host is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!socket) {
|
||||
ERR("socket is not defined");
|
||||
SNDERR("socket is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
h = gethostbyname(host);
|
||||
if (!h) {
|
||||
ERR("Cannot resolve %s", host);
|
||||
SNDERR("Cannot resolve %s", host);
|
||||
return -EINVAL;
|
||||
}
|
||||
local = is_local(h);
|
||||
if (!local) {
|
||||
ERR("%s is not the local host", host);
|
||||
SNDERR("%s is not the local host", host);
|
||||
return -EINVAL;
|
||||
}
|
||||
return snd_ctl_shm_open(handlep, name, socket, sname);
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ int snd_instr_iwffff_open_rom(snd_iwffff_handle_t **handle, int card, int bank,
|
|||
next_ffff = lseek(fd, 0, SEEK_CUR) + ffff.length;
|
||||
if (file == index) {
|
||||
#ifdef IW_ROM_DEBUG
|
||||
ERR("file header at 0x%x size 0x%x\n", rom_pos - sizeof(ffff), ffff.length);
|
||||
SNDERR("file header at 0x%x size 0x%x\n", rom_pos - sizeof(ffff), ffff.length);
|
||||
#endif
|
||||
iwf = malloc(sizeof(*iwf));
|
||||
if (iwf == NULL) {
|
||||
|
|
@ -504,7 +504,7 @@ static int load_iw_patch(snd_iwffff_handle_t *iwf, iwffff_instrument_t *instr,
|
|||
unsigned char *current;
|
||||
|
||||
#ifdef IW_ROM_DEBUG
|
||||
ERR("load_iw_patch - nlayers = %i\n", snd_LE_to_host_16(*(((unsigned short *)patch) + 8/2));
|
||||
SNDERR("load_iw_patch - nlayers = %i\n", snd_LE_to_host_16(*(((unsigned short *)patch) + 8/2));
|
||||
#endif
|
||||
instr->layer_type = patch[6];
|
||||
instr->exclusion = patch[7];
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ libpcm_la_SOURCES = atomic.c mask.c interval.c \
|
|||
pcm_shm.c pcm_file.c pcm_share.c pcm_null.c pcm_meter.c \
|
||||
pcm_params.c
|
||||
noinst_HEADERS = atomic.h pcm_local.h pcm_plugin.h mask.h mask_inline.h \
|
||||
interval.h interval_inline.h plugin_ops.h
|
||||
interval.h interval_inline.h plugin_ops.h pcm_meter.h
|
||||
|
||||
all: libpcm.la
|
||||
|
||||
|
|
|
|||
|
|
@ -620,26 +620,26 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
|
|||
}
|
||||
if (strcmp(name, "null") == 0)
|
||||
return snd_pcm_null_open(pcmp, name, stream, mode);
|
||||
ERR("Unknown PCM %s", name);
|
||||
SNDERR("Unknown PCM %s", name);
|
||||
return -ENOENT;
|
||||
}
|
||||
if (snd_config_get_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
ERR("Invalid type for PCM %s definition", name);
|
||||
SNDERR("Invalid type for PCM %s definition", name);
|
||||
return -EINVAL;
|
||||
}
|
||||
err = snd_config_search(pcm_conf, "type", &conf);
|
||||
if (err < 0) {
|
||||
ERR("type is not defined");
|
||||
SNDERR("type is not defined");
|
||||
return err;
|
||||
}
|
||||
err = snd_config_get_string(conf, &str);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", snd_config_get_id(conf));
|
||||
SNDERR("Invalid type for %s", snd_config_get_id(conf));
|
||||
return err;
|
||||
}
|
||||
err = snd_config_searchv(snd_config, &type_conf, "pcmtype", str, 0);
|
||||
if (err < 0) {
|
||||
ERR("Unknown PCM type %s", str);
|
||||
SNDERR("Unknown PCM type %s", str);
|
||||
return err;
|
||||
}
|
||||
snd_config_for_each(i, next, type_conf) {
|
||||
|
|
@ -650,7 +650,7 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "lib") == 0) {
|
||||
err = snd_config_get_string(n, &lib);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -658,29 +658,29 @@ int snd_pcm_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "open") == 0) {
|
||||
err = snd_config_get_string(n, &open);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
if (!open) {
|
||||
ERR("open is not defined");
|
||||
SNDERR("open is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!lib)
|
||||
lib = "libasound.so";
|
||||
h = dlopen(lib, RTLD_NOW);
|
||||
if (!h) {
|
||||
ERR("Cannot open shared library %s", lib);
|
||||
SNDERR("Cannot open shared library %s", lib);
|
||||
return -ENOENT;
|
||||
}
|
||||
open_func = dlsym(h, open);
|
||||
dlclose(h);
|
||||
if (!open_func) {
|
||||
ERR("symbol %s is not defined inside %s", open, lib);
|
||||
SNDERR("symbol %s is not defined inside %s", open, lib);
|
||||
return -ENXIO;
|
||||
}
|
||||
return open_func(pcmp, name, pcm_conf, stream, mode);
|
||||
|
|
|
|||
|
|
@ -581,7 +581,7 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -590,30 +590,30 @@ int _snd_pcm_adpcm_open(snd_pcm_t **pcmp, const char *name,
|
|||
const char *f;
|
||||
err = snd_config_get_string(n, &f);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat == SND_PCM_FORMAT_UNKNOWN) {
|
||||
ERR("Unknown sformat");
|
||||
SNDERR("Unknown sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (snd_pcm_format_linear(sformat) != 1 &&
|
||||
sformat != SND_PCM_FORMAT_IMA_ADPCM) {
|
||||
ERR("Invalid sformat");
|
||||
SNDERR("Invalid sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
ERR("sname is not defined");
|
||||
SNDERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (sformat == SND_PCM_FORMAT_UNKNOWN) {
|
||||
ERR("sformat is not defined");
|
||||
SNDERR("sformat is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
/* This is needed cause snd_config_update may destroy config */
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -463,30 +463,30 @@ int _snd_pcm_alaw_open(snd_pcm_t **pcmp, const char *name,
|
|||
const char *f;
|
||||
err = snd_config_get_string(n, &f);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat == SND_PCM_FORMAT_UNKNOWN) {
|
||||
ERR("Unknown sformat");
|
||||
SNDERR("Unknown sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (snd_pcm_format_linear(sformat) != 1 &&
|
||||
sformat != SND_PCM_FORMAT_A_LAW) {
|
||||
ERR("Invalid sformat");
|
||||
SNDERR("Invalid sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
ERR("sname is not defined");
|
||||
SNDERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (sformat == SND_PCM_FORMAT_UNKNOWN) {
|
||||
ERR("sformat is not defined");
|
||||
SNDERR("sformat is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
/* This is needed cause snd_config_update may destroy config */
|
||||
|
|
|
|||
|
|
@ -208,16 +208,16 @@ int _snd_pcm_copy_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
ERR("sname is not defined");
|
||||
SNDERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
/* This is needed cause snd_config_update may destroy config */
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name, const char *fname, int
|
|||
strcmp(fmt, "raw") == 0)
|
||||
format = SND_PCM_FILE_FORMAT_RAW;
|
||||
else {
|
||||
ERR("file format %s is unknown", fmt);
|
||||
SNDERR("file format %s is unknown", fmt);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (fname) {
|
||||
|
|
@ -480,7 +480,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -488,7 +488,7 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "format") == 0) {
|
||||
err = snd_config_get_string(n, &format);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -498,21 +498,21 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (err < 0) {
|
||||
err = snd_config_get_integer(n, &fd);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
ERR("sname is not defined");
|
||||
SNDERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!fname && fd < 0) {
|
||||
ERR("file is not defined");
|
||||
SNDERR("file is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (fname) {
|
||||
|
|
|
|||
|
|
@ -688,12 +688,12 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (err < 0) {
|
||||
err = snd_config_get_string(n, &str);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
card = snd_card_get_index(str);
|
||||
if (card < 0) {
|
||||
ERR("Invalid value for %s", id);
|
||||
SNDERR("Invalid value for %s", id);
|
||||
return card;
|
||||
}
|
||||
}
|
||||
|
|
@ -702,7 +702,7 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (strcmp(id, "device") == 0) {
|
||||
err = snd_config_get_integer(n, &device);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return err;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -710,16 +710,16 @@ int _snd_pcm_hw_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (strcmp(id, "subdevice") == 0) {
|
||||
err = snd_config_get_integer(n, &subdevice);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return err;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (card < 0) {
|
||||
ERR("card is not defined");
|
||||
SNDERR("card is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
return snd_pcm_hw_open(pcmp, name, card, device, subdevice, stream, mode);
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -361,29 +361,29 @@ int _snd_pcm_linear_open(snd_pcm_t **pcmp, const char *name,
|
|||
const char *f;
|
||||
err = snd_config_get_string(n, &f);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat == SND_PCM_FORMAT_UNKNOWN) {
|
||||
ERR("Unknown sformat %s", f);
|
||||
SNDERR("Unknown sformat %s", f);
|
||||
return err;
|
||||
}
|
||||
if (snd_pcm_format_linear(sformat) != 1) {
|
||||
ERR("sformat is not linear");
|
||||
SNDERR("sformat is not linear");
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
ERR("sname is not defined");
|
||||
SNDERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (sformat == SND_PCM_FORMAT_UNKNOWN) {
|
||||
ERR("sformat is not defined");
|
||||
SNDERR("sformat is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
/* This is needed cause snd_config_update may destroy config */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
/*
|
||||
* PCM - Meter plugin
|
||||
* Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org>
|
||||
*
|
||||
* Copyright (c) 2001 by Abramo Bagnara <abramo@alsa-project.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
|
@ -20,88 +19,180 @@
|
|||
*/
|
||||
|
||||
#include <byteswap.h>
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
#include <asm/atomic.h>
|
||||
#include "pcm_local.h"
|
||||
#include "pcm_plugin.h"
|
||||
#include "list.h"
|
||||
#include "pcm_meter.h"
|
||||
|
||||
#define FPS 50
|
||||
#define FREQUENCY 50
|
||||
|
||||
typedef struct _snd_pcm_meter_scope snd_pcm_meter_scope_t;
|
||||
typedef struct _snd_pcm_meter_s16 {
|
||||
snd_pcm_adpcm_state_t *adpcm_states;
|
||||
unsigned int index;
|
||||
snd_pcm_uframes_t old;
|
||||
} snd_pcm_meter_s16_t;
|
||||
|
||||
struct _snd_pcm_meter_scope {
|
||||
snd_pcm_t *pcm;
|
||||
char *name;
|
||||
void (*init)(snd_pcm_meter_scope_t *scope);
|
||||
void (*start)(snd_pcm_meter_scope_t *scope);
|
||||
void (*stop)(snd_pcm_meter_scope_t *scope);
|
||||
void (*update)(snd_pcm_meter_scope_t *scope);
|
||||
void (*reset)(snd_pcm_meter_scope_t *scope);
|
||||
void (*close)(snd_pcm_meter_scope_t *scope);
|
||||
void *private_data;
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
typedef struct _snd_pcm_meter {
|
||||
snd_pcm_t *slave;
|
||||
int close_slave;
|
||||
snd_pcm_uframes_t rptr;
|
||||
snd_pcm_uframes_t buf_size;
|
||||
snd_pcm_channel_area_t *buf_areas;
|
||||
snd_pcm_uframes_t now;
|
||||
char *buf;
|
||||
pthread_t thread;
|
||||
int closed;
|
||||
struct list_head scopes;
|
||||
int running;
|
||||
atomic_t reset;
|
||||
pthread_mutex_t update_mutex;
|
||||
pthread_mutex_t running_mutex;
|
||||
pthread_cond_t running_cond;
|
||||
} snd_pcm_meter_t;
|
||||
|
||||
void debug_init(snd_pcm_meter_scope_t *scope ATTRIBUTE_UNUSED)
|
||||
{
|
||||
fprintf(stderr, "init\n");
|
||||
}
|
||||
|
||||
void debug_start(snd_pcm_meter_scope_t *scope ATTRIBUTE_UNUSED)
|
||||
{
|
||||
fprintf(stderr, "start\n");
|
||||
}
|
||||
|
||||
void debug_stop(snd_pcm_meter_scope_t *scope ATTRIBUTE_UNUSED)
|
||||
{
|
||||
fprintf(stderr, "\nstop\n");
|
||||
}
|
||||
|
||||
void debug_update(snd_pcm_meter_scope_t *scope ATTRIBUTE_UNUSED)
|
||||
int s16_open(snd_pcm_meter_scope_t *scope)
|
||||
{
|
||||
snd_pcm_meter_t *meter = scope->pcm->private_data;
|
||||
fprintf(stderr, "update %08ld\r", meter->now);
|
||||
snd_pcm_t *spcm = meter->slave;
|
||||
snd_pcm_channel_area_t *a;
|
||||
unsigned int c;
|
||||
snd_pcm_meter_s16_t *s16;
|
||||
int index;
|
||||
if (spcm->format == SND_PCM_FORMAT_S16 &&
|
||||
spcm->access == SND_PCM_ACCESS_MMAP_NONINTERLEAVED) {
|
||||
meter->buf16 = (int16_t *) meter->buf;
|
||||
return -EINVAL;
|
||||
}
|
||||
switch (spcm->format) {
|
||||
case SND_PCM_FORMAT_A_LAW:
|
||||
case SND_PCM_FORMAT_MU_LAW:
|
||||
case SND_PCM_FORMAT_IMA_ADPCM:
|
||||
index = snd_pcm_linear_put_index(SND_PCM_FORMAT_S16, SND_PCM_FORMAT_S16);
|
||||
break;
|
||||
case SND_PCM_FORMAT_S8:
|
||||
case SND_PCM_FORMAT_S16_LE:
|
||||
case SND_PCM_FORMAT_S16_BE:
|
||||
case SND_PCM_FORMAT_S24_LE:
|
||||
case SND_PCM_FORMAT_S24_BE:
|
||||
case SND_PCM_FORMAT_S32_LE:
|
||||
case SND_PCM_FORMAT_S32_BE:
|
||||
case SND_PCM_FORMAT_U8:
|
||||
case SND_PCM_FORMAT_U16_LE:
|
||||
case SND_PCM_FORMAT_U16_BE:
|
||||
case SND_PCM_FORMAT_U24_LE:
|
||||
case SND_PCM_FORMAT_U24_BE:
|
||||
case SND_PCM_FORMAT_U32_LE:
|
||||
case SND_PCM_FORMAT_U32_BE:
|
||||
index = snd_pcm_linear_convert_index(spcm->format, SND_PCM_FORMAT_S16);
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
s16 = calloc(1, sizeof(*s16));
|
||||
if (!s16)
|
||||
return -ENOMEM;
|
||||
s16->index = index;
|
||||
if (spcm->format == SND_PCM_FORMAT_IMA_ADPCM) {
|
||||
s16->adpcm_states = calloc(spcm->channels, sizeof(*s16->adpcm_states));
|
||||
if (!s16->adpcm_states) {
|
||||
free(s16);
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
meter->buf16 = malloc(meter->buf_size * 2 * spcm->channels);
|
||||
if (!meter->buf16) {
|
||||
if (s16->adpcm_states)
|
||||
free(s16->adpcm_states);
|
||||
free(s16);
|
||||
return -ENOMEM;
|
||||
}
|
||||
a = calloc(spcm->channels, sizeof(*a));
|
||||
if (!a) {
|
||||
free(meter->buf16);
|
||||
if (s16->adpcm_states)
|
||||
free(s16->adpcm_states);
|
||||
free(s16);
|
||||
return -ENOMEM;
|
||||
}
|
||||
meter->buf16_areas = a;
|
||||
for (c = 0; c < spcm->channels; c++, a++) {
|
||||
a->addr = meter->buf16 + c * meter->buf_size;
|
||||
a->first = 0;
|
||||
a->step = 16;
|
||||
}
|
||||
scope->private_data = s16;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void debug_reset(snd_pcm_meter_scope_t *scope ATTRIBUTE_UNUSED)
|
||||
void s16_close(snd_pcm_meter_scope_t *scope)
|
||||
{
|
||||
fprintf(stderr, "\nreset\n");
|
||||
snd_pcm_meter_t *meter = scope->pcm->private_data;
|
||||
snd_pcm_meter_s16_t *s16 = scope->private_data;
|
||||
if (s16->adpcm_states)
|
||||
free(s16->adpcm_states);
|
||||
free(s16);
|
||||
free(meter->buf16);
|
||||
meter->buf16 = NULL;
|
||||
free(meter->buf16_areas);
|
||||
}
|
||||
|
||||
void debug_close(snd_pcm_meter_scope_t *scope ATTRIBUTE_UNUSED)
|
||||
void s16_start(snd_pcm_meter_scope_t *scope ATTRIBUTE_UNUSED)
|
||||
{
|
||||
fprintf(stderr, "\nclose\n");
|
||||
}
|
||||
|
||||
snd_pcm_meter_scope_t debug_scope = {
|
||||
name: "debug",
|
||||
init: debug_init,
|
||||
start: debug_start,
|
||||
stop: debug_stop,
|
||||
update: debug_update,
|
||||
reset: debug_reset,
|
||||
close: debug_close,
|
||||
void s16_stop(snd_pcm_meter_scope_t *scope ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void s16_update(snd_pcm_meter_scope_t *scope)
|
||||
{
|
||||
snd_pcm_meter_t *meter = scope->pcm->private_data;
|
||||
snd_pcm_meter_s16_t *s16 = scope->private_data;
|
||||
snd_pcm_t *spcm = meter->slave;
|
||||
snd_pcm_sframes_t size;
|
||||
snd_pcm_uframes_t offset;
|
||||
size = meter->now - s16->old;
|
||||
if (size < 0)
|
||||
size += spcm->boundary;
|
||||
offset = s16->old % meter->buf_size;
|
||||
while (size > 0) {
|
||||
snd_pcm_uframes_t frames = size;
|
||||
snd_pcm_uframes_t cont = meter->buf_size - offset;
|
||||
if (frames > cont)
|
||||
frames = cont;
|
||||
switch (spcm->format) {
|
||||
case SND_PCM_FORMAT_A_LAW:
|
||||
snd_pcm_alaw_decode(meter->buf16_areas, offset,
|
||||
meter->buf_areas, offset,
|
||||
spcm->channels, frames,
|
||||
s16->index);
|
||||
break;
|
||||
case SND_PCM_FORMAT_MU_LAW:
|
||||
snd_pcm_mulaw_decode(meter->buf16_areas, offset,
|
||||
meter->buf_areas, offset,
|
||||
spcm->channels, frames,
|
||||
s16->index);
|
||||
break;
|
||||
case SND_PCM_FORMAT_IMA_ADPCM:
|
||||
snd_pcm_adpcm_decode(meter->buf16_areas, offset,
|
||||
meter->buf_areas, offset,
|
||||
spcm->channels, frames,
|
||||
s16->index,
|
||||
s16->adpcm_states);
|
||||
break;
|
||||
default:
|
||||
snd_pcm_linear_convert(meter->buf16_areas, offset,
|
||||
meter->buf_areas, offset,
|
||||
spcm->channels, frames,
|
||||
s16->index);
|
||||
break;
|
||||
}
|
||||
if (frames == cont)
|
||||
offset = 0;
|
||||
else
|
||||
offset += frames;
|
||||
size -= frames;
|
||||
}
|
||||
s16->old = meter->now;
|
||||
}
|
||||
|
||||
void s16_reset(snd_pcm_meter_scope_t *scope)
|
||||
{
|
||||
snd_pcm_meter_t *meter = scope->pcm->private_data;
|
||||
snd_pcm_meter_s16_t *s16 = scope->private_data;
|
||||
s16->old = meter->now;
|
||||
}
|
||||
|
||||
snd_pcm_meter_scope_t s16_scope = {
|
||||
name: "s16",
|
||||
open: s16_open,
|
||||
start: s16_start,
|
||||
stop: s16_stop,
|
||||
update: s16_update,
|
||||
reset: s16_reset,
|
||||
close: s16_close,
|
||||
pcm: NULL,
|
||||
active: 0,
|
||||
list: { 0, 0 },
|
||||
private_data: NULL,
|
||||
};
|
||||
|
|
@ -111,7 +202,6 @@ void snd_pcm_meter_add_scope(snd_pcm_t *pcm, snd_pcm_meter_scope_t *scope)
|
|||
snd_pcm_meter_t *meter = pcm->private_data;
|
||||
scope->pcm = pcm;
|
||||
list_add_tail(&scope->list, &meter->scopes);
|
||||
scope->init(scope);
|
||||
}
|
||||
|
||||
void snd_pcm_meter_add_frames(snd_pcm_t *pcm,
|
||||
|
|
@ -201,11 +291,12 @@ static void *snd_pcm_meter_thread(void *data)
|
|||
snd_pcm_t *spcm = meter->slave;
|
||||
struct list_head *pos;
|
||||
snd_pcm_meter_scope_t *scope;
|
||||
int reset;
|
||||
struct timespec delay = {
|
||||
tv_sec: 0,
|
||||
tv_nsec: 1000000000 / FPS,
|
||||
};
|
||||
int err, reset;
|
||||
list_for_each(pos, &meter->scopes) {
|
||||
scope = list_entry(pos, snd_pcm_meter_scope_t, list);
|
||||
err = scope->open(scope);
|
||||
scope->active = (err >= 0);
|
||||
}
|
||||
while (!meter->closed) {
|
||||
snd_pcm_sframes_t now;
|
||||
snd_pcm_status_t status;
|
||||
|
|
@ -238,7 +329,7 @@ static void *snd_pcm_meter_thread(void *data)
|
|||
if ((snd_pcm_uframes_t) now >= pcm->boundary)
|
||||
now -= pcm->boundary;
|
||||
}
|
||||
meter->now = now % meter->buf_size;
|
||||
meter->now = now;
|
||||
if (pcm->stream == SND_PCM_STREAM_CAPTURE)
|
||||
reset = snd_pcm_meter_update_scope(pcm);
|
||||
else {
|
||||
|
|
@ -248,27 +339,33 @@ static void *snd_pcm_meter_thread(void *data)
|
|||
atomic_dec(&meter->reset);
|
||||
}
|
||||
}
|
||||
if (reset) {
|
||||
list_for_each(pos, &meter->scopes) {
|
||||
scope = list_entry(pos, snd_pcm_meter_scope_t, list);
|
||||
if (scope->active)
|
||||
scope->reset(scope);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!meter->running) {
|
||||
list_for_each(pos, &meter->scopes) {
|
||||
scope = list_entry(pos, snd_pcm_meter_scope_t, list);
|
||||
scope->start(scope);
|
||||
if (scope->active)
|
||||
scope->start(scope);
|
||||
}
|
||||
meter->running = 1;
|
||||
} else if (reset) {
|
||||
list_for_each(pos, &meter->scopes) {
|
||||
scope = list_entry(pos, snd_pcm_meter_scope_t, list);
|
||||
scope->reset(scope);
|
||||
}
|
||||
}
|
||||
list_for_each(pos, &meter->scopes) {
|
||||
scope = list_entry(pos, snd_pcm_meter_scope_t, list);
|
||||
scope->update(scope);
|
||||
if (scope->active)
|
||||
scope->update(scope);
|
||||
}
|
||||
nanosleep(&delay, NULL);
|
||||
nanosleep(&meter->delay, NULL);
|
||||
}
|
||||
list_for_each(pos, &meter->scopes) {
|
||||
scope = list_entry(pos, snd_pcm_meter_scope_t, list);
|
||||
scope->close(scope);
|
||||
if (scope->active)
|
||||
scope->close(scope);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -278,19 +375,13 @@ static int snd_pcm_meter_close(snd_pcm_t *pcm)
|
|||
{
|
||||
snd_pcm_meter_t *meter = pcm->private_data;
|
||||
int err = 0;
|
||||
meter->closed = 1;
|
||||
pthread_mutex_lock(&meter->running_mutex);
|
||||
pthread_cond_signal(&meter->running_cond);
|
||||
pthread_mutex_unlock(&meter->running_mutex);
|
||||
err = pthread_join(meter->thread, 0);
|
||||
assert(err == 0);
|
||||
pthread_mutex_destroy(&meter->update_mutex);
|
||||
pthread_mutex_destroy(&meter->running_mutex);
|
||||
pthread_cond_destroy(&meter->running_cond);
|
||||
if (meter->close_slave)
|
||||
err = snd_pcm_close(meter->slave);
|
||||
free(meter);
|
||||
return 0;
|
||||
return err;
|
||||
}
|
||||
|
||||
static int snd_pcm_meter_nonblock(snd_pcm_t *pcm, int nonblock)
|
||||
|
|
@ -518,12 +609,22 @@ static int snd_pcm_meter_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
|
|||
a->first = 0;
|
||||
a->step = slave->sample_bits;
|
||||
}
|
||||
meter->closed = 0;
|
||||
err = pthread_create(&meter->thread, NULL, snd_pcm_meter_thread, pcm);
|
||||
assert(err == 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_pcm_meter_hw_free(snd_pcm_t *pcm)
|
||||
{
|
||||
snd_pcm_meter_t *meter = pcm->private_data;
|
||||
int err;
|
||||
meter->closed = 1;
|
||||
pthread_mutex_lock(&meter->running_mutex);
|
||||
pthread_cond_signal(&meter->running_cond);
|
||||
pthread_mutex_unlock(&meter->running_mutex);
|
||||
err = pthread_join(meter->thread, 0);
|
||||
assert(err == 0);
|
||||
if (meter->buf) {
|
||||
free(meter->buf);
|
||||
free(meter->buf_areas);
|
||||
|
|
@ -595,17 +696,19 @@ snd_pcm_fast_ops_t snd_pcm_meter_fast_ops = {
|
|||
mmap_forward: snd_pcm_meter_mmap_forward,
|
||||
};
|
||||
|
||||
int snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int close_slave)
|
||||
int snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name, unsigned int frequency,
|
||||
snd_pcm_t *slave, int close_slave)
|
||||
{
|
||||
snd_pcm_t *pcm;
|
||||
snd_pcm_meter_t *meter;
|
||||
int err;
|
||||
assert(pcmp);
|
||||
meter = calloc(1, sizeof(snd_pcm_meter_t));
|
||||
if (!meter)
|
||||
return -ENOMEM;
|
||||
meter->slave = slave;
|
||||
meter->close_slave = close_slave;
|
||||
meter->delay.tv_sec = 0;
|
||||
meter->delay.tv_nsec = 1000000000 / frequency;
|
||||
INIT_LIST_HEAD(&meter->scopes);
|
||||
|
||||
pcm = calloc(1, sizeof(snd_pcm_t));
|
||||
|
|
@ -629,14 +732,18 @@ int snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name, snd_pcm_t *slave, int
|
|||
pcm->appl_ptr = slave->appl_ptr;
|
||||
*pcmp = pcm;
|
||||
|
||||
#if 1
|
||||
snd_pcm_meter_add_scope(pcm, &debug_scope);
|
||||
#endif
|
||||
pthread_mutex_init(&meter->update_mutex, NULL);
|
||||
pthread_mutex_init(&meter->running_mutex, NULL);
|
||||
pthread_cond_init(&meter->running_cond, NULL);
|
||||
err = pthread_create(&meter->thread, NULL, snd_pcm_meter_thread, pcm);
|
||||
assert(err == 0);
|
||||
#if 1
|
||||
snd_pcm_meter_add_scope(pcm, &s16_scope);
|
||||
#endif
|
||||
#if 1
|
||||
{
|
||||
extern snd_pcm_meter_scope_t level_scope;
|
||||
snd_pcm_meter_add_scope(pcm, &level_scope);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -648,6 +755,7 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name,
|
|||
const char *sname = NULL;
|
||||
int err;
|
||||
snd_pcm_t *spcm;
|
||||
long frequency = -1;
|
||||
snd_config_for_each(i, next, conf) {
|
||||
snd_config_t *n = snd_config_iterator_entry(i);
|
||||
const char *id = snd_config_get_id(n);
|
||||
|
|
@ -658,16 +766,24 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
if (strcmp(id, "frequency") == 0) {
|
||||
err = snd_config_get_integer(n, &frequency);
|
||||
if (err < 0) {
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
ERR("sname is not defined");
|
||||
SNDERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -679,7 +795,7 @@ int _snd_pcm_meter_open(snd_pcm_t **pcmp, const char *name,
|
|||
free((void *) sname);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_pcm_meter_open(pcmp, name, spcm, 1);
|
||||
err = snd_pcm_meter_open(pcmp, name, frequency < 0 ? FREQUENCY : frequency, spcm, 1);
|
||||
if (err < 0)
|
||||
snd_pcm_close(spcm);
|
||||
return err;
|
||||
|
|
|
|||
63
src/pcm/pcm_meter.h
Normal file
63
src/pcm/pcm_meter.h
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* PCM - Meter plugin
|
||||
* Copyright (c) 2001 by Abramo Bagnara <abramo@alsa-project.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <pthread.h>
|
||||
#include <asm/atomic.h>
|
||||
#include "list.h"
|
||||
#include "pcm_local.h"
|
||||
#include "pcm_plugin.h"
|
||||
|
||||
typedef struct _snd_pcm_meter_scope snd_pcm_meter_scope_t;
|
||||
|
||||
struct _snd_pcm_meter_scope {
|
||||
snd_pcm_t *pcm;
|
||||
int active;
|
||||
char *name;
|
||||
int (*open)(snd_pcm_meter_scope_t *scope);
|
||||
void (*start)(snd_pcm_meter_scope_t *scope);
|
||||
void (*stop)(snd_pcm_meter_scope_t *scope);
|
||||
void (*update)(snd_pcm_meter_scope_t *scope);
|
||||
void (*reset)(snd_pcm_meter_scope_t *scope);
|
||||
void (*close)(snd_pcm_meter_scope_t *scope);
|
||||
void *private_data;
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
typedef struct _snd_pcm_meter {
|
||||
snd_pcm_t *slave;
|
||||
int close_slave;
|
||||
snd_pcm_uframes_t rptr;
|
||||
snd_pcm_uframes_t buf_size;
|
||||
snd_pcm_channel_area_t *buf_areas;
|
||||
snd_pcm_uframes_t now;
|
||||
unsigned char *buf;
|
||||
struct list_head scopes;
|
||||
int closed;
|
||||
int running;
|
||||
atomic_t reset;
|
||||
pthread_t thread;
|
||||
pthread_mutex_t update_mutex;
|
||||
pthread_mutex_t running_mutex;
|
||||
pthread_cond_t running_cond;
|
||||
int16_t *buf16;
|
||||
snd_pcm_channel_area_t *buf16_areas;
|
||||
struct timespec delay;
|
||||
} snd_pcm_meter_t;
|
||||
|
||||
|
|
@ -469,7 +469,7 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -478,30 +478,30 @@ int _snd_pcm_mulaw_open(snd_pcm_t **pcmp, const char *name,
|
|||
const char *f;
|
||||
err = snd_config_get_string(n, &f);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat == SND_PCM_FORMAT_UNKNOWN) {
|
||||
ERR("Unknown sformat");
|
||||
SNDERR("Unknown sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (snd_pcm_format_linear(sformat) != 1 &&
|
||||
sformat != SND_PCM_FORMAT_MU_LAW) {
|
||||
ERR("Invalid sformat");
|
||||
SNDERR("Invalid sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
ERR("sname is not defined");
|
||||
SNDERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (sformat == SND_PCM_FORMAT_UNKNOWN) {
|
||||
ERR("sformat is not defined");
|
||||
SNDERR("sformat is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
/* This is needed cause snd_config_update may destroy config */
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ static int snd_pcm_multi_hw_refine(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
|||
for (k = 0; k < multi->slaves_count; ++k) {
|
||||
err = snd_pcm_multi_hw_refine_sprepare(pcm, k, &sparams[k]);
|
||||
if (err < 0) {
|
||||
ERR("Slave PCM #%d not useable", k);
|
||||
SNDERR("Slave PCM #%d not useable", k);
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
|
@ -605,7 +605,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
continue;
|
||||
if (strcmp(id, "slave") == 0) {
|
||||
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
slave = n;
|
||||
|
|
@ -613,21 +613,21 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
}
|
||||
if (strcmp(id, "binding") == 0) {
|
||||
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
binding = n;
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!slave) {
|
||||
ERR("slave is not defined");
|
||||
SNDERR("slave is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!binding) {
|
||||
ERR("binding is not defined");
|
||||
SNDERR("binding is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
snd_config_for_each(i, inext, slave) {
|
||||
|
|
@ -641,14 +641,14 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
errno = 0;
|
||||
cchannel = strtol(id, &p, 10);
|
||||
if (errno || *p || cchannel < 0) {
|
||||
ERR("Invalid channel number: %s", id);
|
||||
SNDERR("Invalid channel number: %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if ((unsigned)cchannel >= channels_count)
|
||||
channels_count = cchannel + 1;
|
||||
}
|
||||
if (channels_count == 0) {
|
||||
ERR("No cannels defined");
|
||||
SNDERR("No cannels defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
slaves_id = calloc(slaves_count, sizeof(*slaves_id));
|
||||
|
|
@ -674,7 +674,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (strcmp(id, "name") == 0) {
|
||||
err = snd_config_get_string(n, &name);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
goto _free;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -682,22 +682,22 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (strcmp(id, "channels") == 0) {
|
||||
err = snd_config_get_integer(n, &channels);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
goto _free;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
err = -EINVAL;
|
||||
goto _free;
|
||||
}
|
||||
if (!name) {
|
||||
ERR("name is not defined");
|
||||
SNDERR("name is not defined");
|
||||
err = -EINVAL;
|
||||
goto _free;
|
||||
}
|
||||
if (channels < 0) {
|
||||
ERR("channels is not defined");
|
||||
SNDERR("channels is not defined");
|
||||
err = -EINVAL;
|
||||
goto _free;
|
||||
}
|
||||
|
|
@ -716,7 +716,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
const char *id = snd_config_get_id(m);
|
||||
cchannel = strtol(id, 0, 10);
|
||||
if (cchannel < 0) {
|
||||
ERR("Invalid channel number: %s", id);
|
||||
SNDERR("Invalid channel number: %s", id);
|
||||
err = -EINVAL;
|
||||
goto _free;
|
||||
}
|
||||
|
|
@ -732,7 +732,7 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (err < 0) {
|
||||
err = snd_config_get_integer(n, &val);
|
||||
if (err < 0) {
|
||||
ERR("Invalid value for %s", id);
|
||||
SNDERR("Invalid value for %s", id);
|
||||
goto _free;
|
||||
}
|
||||
sprintf(buf, "%ld", val);
|
||||
|
|
@ -747,23 +747,23 @@ int _snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (strcmp(id, "schannel") == 0) {
|
||||
err = snd_config_get_integer(n, &schannel);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
goto _free;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
err = -EINVAL;
|
||||
goto _free;
|
||||
}
|
||||
if (slave < 0 || (unsigned int)slave >= slaves_count) {
|
||||
ERR("Invalid or missing sidx");
|
||||
SNDERR("Invalid or missing sidx");
|
||||
err = -EINVAL;
|
||||
goto _free;
|
||||
}
|
||||
if (schannel < 0 ||
|
||||
(unsigned int) schannel >= slaves_channels[slave]) {
|
||||
ERR("Invalid or missing schannel");
|
||||
SNDERR("Invalid or missing schannel");
|
||||
err = -EINVAL;
|
||||
goto _free;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ int _snd_pcm_null_open(snd_pcm_t **pcmp, const char *name,
|
|||
continue;
|
||||
if (strcmp(id, "type") == 0)
|
||||
continue;
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
return snd_pcm_null_open(pcmp, name, stream, mode);
|
||||
|
|
|
|||
|
|
@ -995,6 +995,7 @@ void snd_pcm_hw_params_choose(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
|||
snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_CHANNELS, 0);
|
||||
snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_RATE, 0);
|
||||
snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_TIME, 0);
|
||||
snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_PERIOD_SIZE, 0);
|
||||
snd_pcm_hw_param_set_last(pcm, params, SND_PCM_HW_PARAM_BUFFER_SIZE, 0);
|
||||
snd_pcm_hw_param_set_first(pcm, params, SND_PCM_HW_PARAM_TICK_TIME, 0);
|
||||
}
|
||||
|
|
@ -1972,7 +1973,7 @@ int snd_pcm_hw_refine_slave(snd_pcm_t *pcm, snd_pcm_hw_params_t *params,
|
|||
return err;
|
||||
err = sprepare(pcm, &sparams);
|
||||
if (err < 0) {
|
||||
ERR("Slave PCM not useable");
|
||||
SNDERR("Slave PCM not useable");
|
||||
return err;
|
||||
}
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -453,14 +453,19 @@ static int snd_pcm_plug_hw_refine_schange(snd_pcm_t *pcm, snd_pcm_hw_params_t *p
|
|||
_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,
|
||||
&access_mask);
|
||||
}
|
||||
snd_interval_copy(&buffer_size, snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE));
|
||||
snd_interval_unfloor(&buffer_size);
|
||||
crate = snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE);
|
||||
srate = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE);
|
||||
snd_interval_muldiv(&buffer_size, srate, crate, &t);
|
||||
err = _snd_pcm_hw_param_set_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE, &t);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (snd_pcm_hw_param_always_eq(params, SND_PCM_HW_PARAM_RATE, sparams))
|
||||
links |= (SND_PCM_HW_PARBIT_PERIOD_SIZE |
|
||||
SND_PCM_HW_PARBIT_BUFFER_SIZE);
|
||||
else {
|
||||
snd_interval_copy(&buffer_size, snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE));
|
||||
snd_interval_unfloor(&buffer_size);
|
||||
crate = snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE);
|
||||
srate = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE);
|
||||
snd_interval_muldiv(&buffer_size, srate, crate, &t);
|
||||
err = _snd_pcm_hw_param_set_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE, &t);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
err = _snd_pcm_hw_params_refine(sparams, links, params);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -483,9 +488,9 @@ static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
|
|||
unsigned int rate_min, srate_min;
|
||||
int rate_mindir, srate_mindir;
|
||||
format_mask = snd_pcm_hw_param_get_mask(params,
|
||||
SND_PCM_HW_PARAM_FORMAT);
|
||||
SND_PCM_HW_PARAM_FORMAT);
|
||||
sformat_mask = snd_pcm_hw_param_get_mask(sparams,
|
||||
SND_PCM_HW_PARAM_FORMAT);
|
||||
SND_PCM_HW_PARAM_FORMAT);
|
||||
snd_mask_none(&fmt_mask);
|
||||
for (format = 0; format <= SND_PCM_FORMAT_LAST; snd_enum_incr(format)) {
|
||||
snd_pcm_format_t f;
|
||||
|
|
@ -515,14 +520,19 @@ static int snd_pcm_plug_hw_refine_cchange(snd_pcm_t *pcm ATTRIBUTE_UNUSED,
|
|||
return err;
|
||||
}
|
||||
|
||||
sbuffer_size = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE);
|
||||
crate = snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE);
|
||||
srate = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE);
|
||||
snd_interval_muldiv(sbuffer_size, crate, srate, &t);
|
||||
snd_interval_floor(&t);
|
||||
err = _snd_pcm_hw_param_set_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE, &t);
|
||||
if (err < 0)
|
||||
return err;
|
||||
if (snd_pcm_hw_param_always_eq(params, SND_PCM_HW_PARAM_RATE, sparams))
|
||||
links |= (SND_PCM_HW_PARBIT_PERIOD_SIZE |
|
||||
SND_PCM_HW_PARBIT_BUFFER_SIZE);
|
||||
else {
|
||||
sbuffer_size = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_BUFFER_SIZE);
|
||||
crate = snd_pcm_hw_param_get_interval(params, SND_PCM_HW_PARAM_RATE);
|
||||
srate = snd_pcm_hw_param_get_interval(sparams, SND_PCM_HW_PARAM_RATE);
|
||||
snd_interval_muldiv(sbuffer_size, crate, srate, &t);
|
||||
snd_interval_floor(&t);
|
||||
err = _snd_pcm_hw_param_set_interval(params, SND_PCM_HW_PARAM_BUFFER_SIZE, &t);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
err = _snd_pcm_hw_params_refine(params, links, sparams);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
|
@ -721,24 +731,24 @@ int _snd_pcm_plug_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (strcmp(id, "ttable") == 0) {
|
||||
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
tt = n;
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
ERR("sname is not defined");
|
||||
SNDERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (tt) {
|
||||
|
|
|
|||
|
|
@ -572,7 +572,7 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -581,16 +581,16 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
|
|||
const char *f;
|
||||
err = snd_config_get_string(n, &f);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat == SND_PCM_FORMAT_UNKNOWN) {
|
||||
ERR("Unknown sformat");
|
||||
SNDERR("Unknown sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (snd_pcm_format_linear(sformat) != 1) {
|
||||
ERR("sformat is not linear");
|
||||
SNDERR("sformat is not linear");
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -598,20 +598,20 @@ int _snd_pcm_rate_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "srate") == 0) {
|
||||
err = snd_config_get_integer(n, &srate);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
ERR("sname is not defined");
|
||||
SNDERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (srate < 0) {
|
||||
ERR("srate is not defined");
|
||||
SNDERR("srate is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
/* This is needed cause snd_config_update may destroy config */
|
||||
|
|
|
|||
|
|
@ -808,7 +808,7 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt
|
|||
cchannel = strtol(snd_config_get_id(in), &p, 10);
|
||||
if (errno || *p ||
|
||||
cchannel < 0 || (unsigned int) cchannel > tt_csize) {
|
||||
ERR("Invalid client channel: %s", snd_config_get_id(in));
|
||||
SNDERR("Invalid client channel: %s", snd_config_get_id(in));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (snd_config_get_type(in) != SND_CONFIG_TYPE_COMPOUND)
|
||||
|
|
@ -824,7 +824,7 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt
|
|||
if (errno || *p ||
|
||||
schannel < 0 || (unsigned int) schannel > tt_ssize ||
|
||||
(schannels > 0 && schannel >= schannels)) {
|
||||
ERR("Invalid slave channel: %s", id);
|
||||
SNDERR("Invalid slave channel: %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
err = snd_config_get_real(jn, &value);
|
||||
|
|
@ -832,7 +832,7 @@ int snd_pcm_route_load_ttable(snd_config_t *tt, snd_pcm_route_ttable_entry_t *tt
|
|||
long v;
|
||||
err = snd_config_get_integer(jn, &v);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
value = v;
|
||||
|
|
@ -874,7 +874,7 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -883,16 +883,16 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
|
|||
const char *f;
|
||||
err = snd_config_get_string(n, &f);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat == SND_PCM_FORMAT_UNKNOWN) {
|
||||
ERR("Unknown sformat");
|
||||
SNDERR("Unknown sformat");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (snd_pcm_format_linear(sformat) != 1) {
|
||||
ERR("sformat is not linear");
|
||||
SNDERR("sformat is not linear");
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -900,28 +900,28 @@ int _snd_pcm_route_open(snd_pcm_t **pcmp, const char *name,
|
|||
if (strcmp(id, "schannels") == 0) {
|
||||
err = snd_config_get_integer(n, &schannels);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (strcmp(id, "ttable") == 0) {
|
||||
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
tt = n;
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
ERR("sname is not defined");
|
||||
SNDERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!tt) {
|
||||
ERR("ttable is not defined");
|
||||
SNDERR("ttable is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -613,7 +613,7 @@ static int snd_pcm_share_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
|
|||
spcm->tick_time, 0);
|
||||
_err:
|
||||
if (err < 0) {
|
||||
ERR("slave is already running with different setup");
|
||||
SNDERR("slave is already running with different setup");
|
||||
err = -EBUSY;
|
||||
goto _end;
|
||||
}
|
||||
|
|
@ -1200,11 +1200,11 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname,
|
|||
|
||||
for (k = 0; k < channels_count; ++k) {
|
||||
if (channels_map[k] < 0 || channels_map[k] > 31) {
|
||||
ERR("Invalid slave channel (%d) in binding", channels_map[k]);
|
||||
SNDERR("Invalid slave channel (%d) in binding", channels_map[k]);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (slave_map[channels_map[k]]) {
|
||||
ERR("Repeated slave channel (%d) in binding", channels_map[k]);
|
||||
SNDERR("Repeated slave channel (%d) in binding", channels_map[k]);
|
||||
return -EINVAL;
|
||||
}
|
||||
slave_map[channels_map[k]] = 1;
|
||||
|
|
@ -1314,7 +1314,7 @@ int snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, const char *sname,
|
|||
unsigned int k;
|
||||
for (k = 0; k < sh->channels_count; ++k) {
|
||||
if (slave_map[sh->slave_channels[k]]) {
|
||||
ERR("Slave channel %d is already in use", sh->slave_channels[k]);
|
||||
SNDERR("Slave channel %d is already in use", sh->slave_channels[k]);
|
||||
Pthread_mutex_unlock(&slave->mutex);
|
||||
close(sd[0]);
|
||||
close(sd[1]);
|
||||
|
|
@ -1383,7 +1383,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -1392,12 +1392,12 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
const char *f;
|
||||
err = snd_config_get_string(n, &f);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
sformat = snd_pcm_format_value(f);
|
||||
if (sformat == SND_PCM_FORMAT_UNKNOWN) {
|
||||
ERR("Unknown format %s", f);
|
||||
SNDERR("Unknown format %s", f);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -1405,7 +1405,7 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (strcmp(id, "schannels") == 0) {
|
||||
err = snd_config_get_integer(n, &schannels_count);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -1413,28 +1413,28 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (strcmp(id, "srate") == 0) {
|
||||
err = snd_config_get_integer(n, &srate);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (strcmp(id, "binding") == 0) {
|
||||
if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
binding = n;
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
ERR("sname is not defined");
|
||||
SNDERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!binding) {
|
||||
ERR("binding is not defined");
|
||||
SNDERR("binding is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
snd_config_for_each(i, next, binding) {
|
||||
|
|
@ -1445,14 +1445,14 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
errno = 0;
|
||||
cchannel = strtol(id, &p, 10);
|
||||
if (errno || *p || cchannel < 0) {
|
||||
ERR("Invalid client channel in binding: %s", id);
|
||||
SNDERR("Invalid client channel in binding: %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if ((unsigned)cchannel >= channels_count)
|
||||
channels_count = cchannel + 1;
|
||||
}
|
||||
if (channels_count == 0) {
|
||||
ERR("No bindings defined");
|
||||
SNDERR("No bindings defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
channels_map = calloc(channels_count, sizeof(*channels_map));
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ static int snd_pcm_shm_action(snd_pcm_t *pcm)
|
|||
if (err != 1)
|
||||
return -EBADFD;
|
||||
if (ctrl->cmd) {
|
||||
ERR("Server has not done the cmd");
|
||||
SNDERR("Server has not done the cmd");
|
||||
return -EBADFD;
|
||||
}
|
||||
return ctrl->result;
|
||||
|
|
@ -109,7 +109,7 @@ static int snd_pcm_shm_action_fd(snd_pcm_t *pcm, int *fd)
|
|||
if (err != 1)
|
||||
return -EBADFD;
|
||||
if (ctrl->cmd) {
|
||||
ERR("Server has not done the cmd");
|
||||
SNDERR("Server has not done the cmd");
|
||||
return -EBADFD;
|
||||
}
|
||||
return ctrl->result;
|
||||
|
|
@ -580,7 +580,7 @@ int snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, const char *socket, con
|
|||
|
||||
result = make_local_socket(socket);
|
||||
if (result < 0) {
|
||||
ERR("server for socket %s is not running", socket);
|
||||
SNDERR("server for socket %s is not running", socket);
|
||||
goto _err;
|
||||
}
|
||||
sock = result;
|
||||
|
|
@ -600,7 +600,7 @@ int snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, const char *socket, con
|
|||
goto _err;
|
||||
}
|
||||
if ((size_t) err != reqlen) {
|
||||
ERR("write size error");
|
||||
SNDERR("write size error");
|
||||
result = -EINVAL;
|
||||
goto _err;
|
||||
}
|
||||
|
|
@ -611,7 +611,7 @@ int snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, const char *socket, con
|
|||
goto _err;
|
||||
}
|
||||
if (err != sizeof(ans)) {
|
||||
ERR("read size error");
|
||||
SNDERR("read size error");
|
||||
result = -EINVAL;
|
||||
goto _err;
|
||||
}
|
||||
|
|
@ -739,7 +739,7 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (strcmp(id, "server") == 0) {
|
||||
err = snd_config_get_string(n, &server);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -747,25 +747,25 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (strcmp(id, "sname") == 0) {
|
||||
err = snd_config_get_string(n, &sname);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!sname) {
|
||||
ERR("sname is not defined");
|
||||
SNDERR("sname is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!server) {
|
||||
ERR("server is not defined");
|
||||
SNDERR("server is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
err = snd_config_searchv(snd_config, &sconfig, "server", server, 0);
|
||||
if (err < 0) {
|
||||
ERR("Unknown server %s", server);
|
||||
SNDERR("Unknown server %s", server);
|
||||
return -EINVAL;
|
||||
}
|
||||
snd_config_for_each(i, next, sconfig) {
|
||||
|
|
@ -776,7 +776,7 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (strcmp(id, "host") == 0) {
|
||||
err = snd_config_get_string(n, &host);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -784,7 +784,7 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (strcmp(id, "socket") == 0) {
|
||||
err = snd_config_get_string(n, &socket);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -792,31 +792,31 @@ int _snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name, snd_config_t *conf,
|
|||
if (strcmp(id, "port") == 0) {
|
||||
err = snd_config_get_integer(n, &port);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!host) {
|
||||
ERR("host is not defined");
|
||||
SNDERR("host is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!socket) {
|
||||
ERR("socket is not defined");
|
||||
SNDERR("socket is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
h = gethostbyname(host);
|
||||
if (!h) {
|
||||
ERR("Cannot resolve %s", host);
|
||||
SNDERR("Cannot resolve %s", host);
|
||||
return -EINVAL;
|
||||
}
|
||||
local = is_local(h);
|
||||
if (!local) {
|
||||
ERR("%s is not the local host", host);
|
||||
SNDERR("%s is not the local host", host);
|
||||
return -EINVAL;
|
||||
}
|
||||
return snd_pcm_shm_open(pcmp, name, socket, sname, stream, mode);
|
||||
|
|
|
|||
|
|
@ -190,26 +190,26 @@ int snd_rawmidi_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
|
|||
err = sscanf(name, "hw:%d,%d", &card, &dev);
|
||||
if (err == 2)
|
||||
return snd_rawmidi_hw_open(inputp, outputp, name, card, dev, -1, mode);
|
||||
ERR("Unknown RAWMIDI %s", name);
|
||||
SNDERR("Unknown RAWMIDI %s", name);
|
||||
return -ENOENT;
|
||||
}
|
||||
if (snd_config_get_type(rawmidi_conf) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
ERR("Invalid type for RAWMIDI %s definition", name);
|
||||
SNDERR("Invalid type for RAWMIDI %s definition", name);
|
||||
return -EINVAL;
|
||||
}
|
||||
err = snd_config_search(rawmidi_conf, "type", &conf);
|
||||
if (err < 0) {
|
||||
ERR("type is not defined");
|
||||
SNDERR("type is not defined");
|
||||
return err;
|
||||
}
|
||||
err = snd_config_get_string(conf, &str);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", snd_config_get_id(conf));
|
||||
SNDERR("Invalid type for %s", snd_config_get_id(conf));
|
||||
return err;
|
||||
}
|
||||
err = snd_config_searchv(snd_config, &type_conf, "rawmiditype", str, 0);
|
||||
if (err < 0) {
|
||||
ERR("Unknown RAWMIDI type %s", str);
|
||||
SNDERR("Unknown RAWMIDI type %s", str);
|
||||
return err;
|
||||
}
|
||||
snd_config_for_each(i, next, type_conf) {
|
||||
|
|
@ -220,7 +220,7 @@ int snd_rawmidi_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
|
|||
if (strcmp(id, "lib") == 0) {
|
||||
err = snd_config_get_string(n, &lib);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -228,29 +228,29 @@ int snd_rawmidi_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
|
|||
if (strcmp(id, "open") == 0) {
|
||||
err = snd_config_get_string(n, &open);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
if (!open) {
|
||||
ERR("open is not defined");
|
||||
SNDERR("open is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!lib)
|
||||
lib = "libasound.so";
|
||||
h = dlopen(lib, RTLD_NOW);
|
||||
if (!h) {
|
||||
ERR("Cannot open shared library %s", lib);
|
||||
SNDERR("Cannot open shared library %s", lib);
|
||||
return -ENOENT;
|
||||
}
|
||||
open_func = dlsym(h, open);
|
||||
dlclose(h);
|
||||
if (!open_func) {
|
||||
ERR("symbol %s is not defined inside %s", open, lib);
|
||||
SNDERR("symbol %s is not defined inside %s", open, lib);
|
||||
return -ENXIO;
|
||||
}
|
||||
err = open_func(inputp, outputp, name, rawmidi_conf, mode);
|
||||
|
|
|
|||
|
|
@ -55,26 +55,26 @@ int snd_seq_open(snd_seq_t **seqp, const char *name,
|
|||
if (err < 0) {
|
||||
if (strcmp(name, "hw") == 0)
|
||||
return snd_seq_hw_open(seqp, name, streams, mode);
|
||||
ERR("Unknown SEQ %s", name);
|
||||
SNDERR("Unknown SEQ %s", name);
|
||||
return -ENOENT;
|
||||
}
|
||||
if (snd_config_get_type(seq_conf) != SND_CONFIG_TYPE_COMPOUND) {
|
||||
ERR("Invalid type for SEQ %s definition", name);
|
||||
SNDERR("Invalid type for SEQ %s definition", name);
|
||||
return -EINVAL;
|
||||
}
|
||||
err = snd_config_search(seq_conf, "type", &conf);
|
||||
if (err < 0) {
|
||||
ERR("type is not defined");
|
||||
SNDERR("type is not defined");
|
||||
return err;
|
||||
}
|
||||
err = snd_config_get_string(conf, &str);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", snd_config_get_id(conf));
|
||||
SNDERR("Invalid type for %s", snd_config_get_id(conf));
|
||||
return err;
|
||||
}
|
||||
err = snd_config_searchv(snd_config, &type_conf, "seqtype", str, 0);
|
||||
if (err < 0) {
|
||||
ERR("Unknown SEQ type %s", str);
|
||||
SNDERR("Unknown SEQ type %s", str);
|
||||
return err;
|
||||
}
|
||||
snd_config_for_each(i, next, type_conf) {
|
||||
|
|
@ -85,7 +85,7 @@ int snd_seq_open(snd_seq_t **seqp, const char *name,
|
|||
if (strcmp(id, "lib") == 0) {
|
||||
err = snd_config_get_string(n, &lib);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
|
|
@ -93,29 +93,29 @@ int snd_seq_open(snd_seq_t **seqp, const char *name,
|
|||
if (strcmp(id, "open") == 0) {
|
||||
err = snd_config_get_string(n, &open);
|
||||
if (err < 0) {
|
||||
ERR("Invalid type for %s", id);
|
||||
SNDERR("Invalid type for %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
continue;
|
||||
ERR("Unknown field %s", id);
|
||||
SNDERR("Unknown field %s", id);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
if (!open) {
|
||||
ERR("open is not defined");
|
||||
SNDERR("open is not defined");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!lib)
|
||||
lib = "libasound.so";
|
||||
h = dlopen(lib, RTLD_NOW);
|
||||
if (!h) {
|
||||
ERR("Cannot open shared library %s", lib);
|
||||
SNDERR("Cannot open shared library %s", lib);
|
||||
return -ENOENT;
|
||||
}
|
||||
open_func = dlsym(h, open);
|
||||
dlclose(h);
|
||||
if (!open_func) {
|
||||
ERR("symbol %s is not defined inside %s", open, lib);
|
||||
SNDERR("symbol %s is not defined inside %s", open, lib);
|
||||
return -ENXIO;
|
||||
}
|
||||
return open_func(seqp, name, seq_conf, streams, mode);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue