mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
switch-on-connect: Add blacklisting
Add a new module argument, blacklist, which is a regular expression. If the sink/source name matches the provided blacklist regex, don't automatically switch to it. By default, no devices are blacklisted. Add a new function to check whenever a regex pattern is valid, plus extra NULL asserts in pa_match.
This commit is contained in:
parent
c90894b4d5
commit
ad16d77dfe
3 changed files with 48 additions and 0 deletions
|
|
@ -784,12 +784,16 @@ void pa_reset_priority(void) {
|
|||
#endif
|
||||
}
|
||||
|
||||
/* Check whenever any substring in v matches the provided regex. */
|
||||
int pa_match(const char *expr, const char *v) {
|
||||
#if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H)
|
||||
int k;
|
||||
regex_t re;
|
||||
int r;
|
||||
|
||||
pa_assert(expr);
|
||||
pa_assert(v);
|
||||
|
||||
if (regcomp(&re, expr, REG_NOSUB|REG_EXTENDED) != 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
|
|
@ -814,6 +818,22 @@ int pa_match(const char *expr, const char *v) {
|
|||
#endif
|
||||
}
|
||||
|
||||
/* Check whenever the provided regex pattern is valid. */
|
||||
bool pa_is_regex_valid(const char *expr) {
|
||||
#if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H)
|
||||
regex_t re;
|
||||
|
||||
if (expr == NULL || regcomp(&re, expr, REG_NOSUB|REG_EXTENDED) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
regfree(&re);
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Try to parse a boolean string value.*/
|
||||
int pa_parse_boolean(const char *v) {
|
||||
pa_assert(v);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue