pavucontrol

This commit is contained in:
ChaotiCryptidz 2022-02-13 13:57:39 +00:00
parent 91a99a631c
commit 26190df018
13 changed files with 30 additions and 250 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
networking.nix networking.nix
result result
*.qcow2

View file

@ -1,232 +0,0 @@
diff --git a/src/control/control.c b/src/control/control.c
index d66ed75..42cecad 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -838,6 +838,10 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
#ifndef PIC
extern void *snd_control_open_symbols(void);
#endif
+
+ snd_config_t *libs = NULL;
+ const char *libs_lib = NULL;
+
if (snd_config_get_type(ctl_conf) != SND_CONFIG_TYPE_COMPOUND) {
if (name)
SNDERR("Invalid type for CTL %s definition", name);
@@ -879,6 +883,19 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
SNDERR("Invalid type for %s", id);
goto _err;
}
+
+ continue;
+ }
+ // Handle an array of extra libs.
+ if (strcmp(id, "libs") == 0) {
+ if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+ SNDERR("Invalid type for libs definition in CTL %s definition",
+ str);
+ goto _err;
+ }
+
+ libs = n;
+
continue;
}
if (strcmp(id, "open") == 0) {
@@ -903,7 +920,62 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
open_name = buf;
sprintf(buf, "_snd_ctl_%s_open", str);
}
- if (!lib) {
+
+#ifndef PIC
+ snd_control_open_symbols();
+#endif
+
+ // Normal alsa behaviour when there is no libs array.
+ if (!libs) {
+ if (lib) {
+ open_func = snd_dlobj_cache_get(lib, open_name,
+ SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION), 1);
+ }
+ }
+ // Handle libs array.
+ // Suppresses error messages if any function is loaded successfully.
+ else {
+ if (lib) {
+ open_func = snd_dlobj_cache_get(lib, open_name,
+ SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION), 0);
+ }
+
+ if (!open_func) {
+ snd_config_for_each(i, next, libs) {
+ snd_config_t *n = snd_config_iterator_entry(i);
+
+ err = snd_config_get_string(n, &libs_lib);
+ if (err < 0) {
+ SNDERR("Invalid entry in CTL %s libs definition", str);
+ goto _err;
+ }
+
+ if (!open_func) {
+ open_func = snd_dlobj_cache_get(libs_lib, open_name,
+ SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION), 0);
+ }
+ }
+ }
+
+ // Print error messages.
+ if (!open_func) {
+ if (lib) {
+ SNDERR("Either %s cannot be opened or %s was not defined inside",
+ lib, open_name);
+ }
+
+ snd_config_for_each(i, next, libs) {
+ snd_config_t *n = snd_config_iterator_entry(i);
+
+ snd_config_get_string(n, &libs_lib);
+ SNDERR("Either %s cannot be opened or %s was not defined inside",
+ libs_lib, open_name);
+ }
+ }
+ }
+
+ // Look in ALSA_PLUGIN_DIR iff we found nowhere else to look.
+ if (!lib && (!libs || !libs_lib)) {
const char *const *build_in = build_in_ctls;
while (*build_in) {
if (!strcmp(*build_in, str))
@@ -919,12 +991,11 @@ static int snd_ctl_open_conf(snd_ctl_t **ctlp, const char *name,
lib = buf1;
sprintf(buf1, "%s/libasound_module_ctl_%s.so", ALSA_PLUGIN_DIR, str);
}
- }
-#ifndef PIC
- snd_control_open_symbols();
-#endif
- open_func = snd_dlobj_cache_get(lib, open_name,
+
+ open_func = snd_dlobj_cache_get(lib, open_name,
SND_DLSYM_VERSION(SND_CONTROL_DLSYM_VERSION), 1);
+ }
+
if (open_func) {
err = open_func(ctlp, name, ctl_root, ctl_conf, mode);
if (err >= 0) {
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 2e24338..7f489f4 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -2116,6 +2116,10 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
#ifndef PIC
extern void *snd_pcm_open_symbols(void);
#endif
+
+ snd_config_t *libs = NULL;
+ const char *libs_lib = NULL;
+
if (snd_config_get_type(pcm_conf) != SND_CONFIG_TYPE_COMPOUND) {
char *val;
id = NULL;
@@ -2160,6 +2164,19 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
SNDERR("Invalid type for %s", id);
goto _err;
}
+
+ continue;
+ }
+ // Handle an array of extra libs.
+ if (strcmp(id, "libs") == 0) {
+ if (snd_config_get_type(n) != SND_CONFIG_TYPE_COMPOUND) {
+ SNDERR("Invalid type for libs definition in PCM %s definition",
+ str);
+ goto _err;
+ }
+
+ libs = n;
+
continue;
}
if (strcmp(id, "open") == 0) {
@@ -2184,7 +2201,62 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
open_name = buf;
sprintf(buf, "_snd_pcm_%s_open", str);
}
- if (!lib) {
+
+#ifndef PIC
+ snd_pcm_open_symbols(); /* this call is for static linking only */
+#endif
+
+ // Normal alsa behaviour when there is no libs array.
+ if (!libs) {
+ if (lib) {
+ open_func = snd_dlobj_cache_get(lib, open_name,
+ SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION), 1);
+ }
+ }
+ // Handle libs array.
+ // Suppresses error messages if any function is loaded successfully.
+ else {
+ if (lib) {
+ open_func = snd_dlobj_cache_get(lib, open_name,
+ SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION), 0);
+ }
+
+ if (!open_func) {
+ snd_config_for_each(i, next, libs) {
+ snd_config_t *n = snd_config_iterator_entry(i);
+
+ err = snd_config_get_string(n, &libs_lib);
+ if (err < 0) {
+ SNDERR("Invalid entry in PCM %s libs definition", str);
+ goto _err;
+ }
+
+ if (!open_func) {
+ open_func = snd_dlobj_cache_get(libs_lib, open_name,
+ SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION), 0);
+ }
+ }
+ }
+
+ // Print error messages.
+ if (!open_func) {
+ if (lib) {
+ SNDERR("Either %s cannot be opened or %s was not defined inside",
+ lib, open_name);
+ }
+
+ snd_config_for_each(i, next, libs) {
+ snd_config_t *n = snd_config_iterator_entry(i);
+
+ snd_config_get_string(n, &libs_lib);
+ SNDERR("Either %s cannot be opened or %s was not defined inside",
+ libs_lib, open_name);
+ }
+ }
+ }
+
+ // Look in ALSA_PLUGIN_DIR iff we found nowhere else to look.
+ if (!lib && (!libs || !libs_lib)) {
const char *const *build_in = build_in_pcms;
while (*build_in) {
if (!strcmp(*build_in, str))
@@ -2200,12 +2272,11 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
lib = buf1;
sprintf(buf1, "%s/libasound_module_pcm_%s.so", ALSA_PLUGIN_DIR, str);
}
- }
-#ifndef PIC
- snd_pcm_open_symbols(); /* this call is for static linking only */
-#endif
- open_func = snd_dlobj_cache_get(lib, open_name,
+
+ open_func = snd_dlobj_cache_get(lib, open_name,
SND_DLSYM_VERSION(SND_PCM_DLSYM_VERSION), 1);
+ }
+
if (open_func) {
err = open_func(pcmp, name, pcm_root, pcm_conf, stream, mode);
if (err >= 0) {

View file

@ -83,11 +83,11 @@
"utils": "utils_2" "utils": "utils_2"
}, },
"locked": { "locked": {
"lastModified": 1644329428, "lastModified": 1644497097,
"narHash": "sha256-psoRS7PQe4hMO72BBvSKy2PJWzNZkJp2zV0LKXGZfSM=", "narHash": "sha256-VPay/qY7epqr2oMXcjTSYXqupRCulx6JZdHlUJfM2WA=",
"owner": "ChaotiCryptidz", "owner": "ChaotiCryptidz",
"repo": "musicutil", "repo": "musicutil",
"rev": "86f4865ac74572d43026b19551420f8d0de2b5bb", "rev": "0f66213dfd4ebaa7eac327e12c791766e434f53d",
"type": "gitlab" "type": "gitlab"
}, },
"original": { "original": {
@ -98,11 +98,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1644359234, "lastModified": 1644420267,
"narHash": "sha256-u/sBnRgrFrn9W8gZMS6vN3ZnJsoTvbws968TpqwlDJQ=", "narHash": "sha256-rFJuctggkjM412OC6OGPdXogFp7czGDW05ueWqpJbj8=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "c5051e2b5fe9fab43a64f0e0d06b62c81a890b90", "rev": "98bb5b77c8c6666824a4c13d23befa1e07210ef1",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -0,0 +1 @@
{ pkgs, ... }: { home.packages = with pkgs; [ pavucontrol ]; }

View file

@ -1,5 +1,5 @@
{ config, pkgs, ... }: { { config, pkgs, ... }: {
home.packages = with pkgs; [ exa ripgrep vault ]; home.packages = with pkgs; [ exa bat ripgrep vault ];
programs.zsh = { programs.zsh = {
enable = true; enable = true;
@ -24,6 +24,9 @@
dmesg = "dmesg -HP"; dmesg = "dmesg -HP";
hg = "history 0 | rg"; hg = "history 0 | rg";
}; };
envExtra = ''
export VAULT_ADDR="https://vault.owo.monster"
'';
}; };
programs.direnv = { programs.direnv = {
enable = true; enable = true;

View file

@ -1,3 +1,3 @@
{ pkgs, inputs, ... }: { { pkgs, inputs, ... }: {
home.packages = with pkgs; [ inputs.deploy-rs.defaultPackage.${pkgs.system} ]; home.packages = with pkgs.deploy-rs; [ deploy-rs ];
} }

View file

@ -4,7 +4,7 @@ _: {
if [ "$(tty)" = "/dev/tty1" ]; then if [ "$(tty)" = "/dev/tty1" ]; then
systemctl --user unset-environment \ systemctl --user unset-environment \
SWAYSOCK \ SWAYSOCK \
I3SOCK \ I3SOCK \q
WAYLAND_DISPLAY \ WAYLAND_DISPLAY \
DISPLAY \ DISPLAY \
IN_NIX_SHELL \ IN_NIX_SHELL \

View file

@ -14,7 +14,13 @@ in {
lappy = nixpkgs.lib.nixosSystem { lappy = nixpkgs.lib.nixosSystem {
specialArgs = defaultSpecialArgs; specialArgs = defaultSpecialArgs;
system = "x86_64-linux"; system = "x86_64-linux";
modules = defaultModules ++ [ ./lappy/lappy.nix ]; modules = defaultModules ++ [ ./lappy/lappy.nix ./lappy/hardware.nix ];
};
lappy-vm = nixpkgs.lib.nixosSystem {
specialArgs = defaultSpecialArgs;
system = "x86_64-linux";
modules = defaultModules ++ [ ./lappy/lappy.nix ./lappy/vm.nix ];
}; };
rescue-x86_64 = nixpkgs.lib.nixosSystem { rescue-x86_64 = nixpkgs.lib.nixosSystem {

View file

@ -13,7 +13,6 @@
hosts.hetzner-vm.services.nginx hosts.hetzner-vm.services.nginx
hosts.hetzner-vm.services.invidious hosts.hetzner-vm.services.invidious
hosts.hetzner-vm.services.vault hosts.hetzner-vm.services.vault
hosts.hetzner-vm.services.netdata
hosts.hetzner-vm.services.quassel hosts.hetzner-vm.services.quassel
hosts.hetzner-vm.services.mpd hosts.hetzner-vm.services.mpd
hosts.hetzner-vm.services.storage-sftp hosts.hetzner-vm.services.storage-sftp

View file

@ -18,9 +18,8 @@
samplerate_converter "0" samplerate_converter "0"
metadata_to_use "title,artist" metadata_to_use "title,artist"
auto_update "yes" auto_update "yes"
volume_normalization "yes"
audio_buffer_size "4096" audio_buffer_size "4096"
replaygain "track" #replaygain "track"
audio_output_format "44100:16:2" audio_output_format "44100:16:2"
audio_output { audio_output {
type "httpd" type "httpd"
@ -31,6 +30,8 @@
format "44100:16:2" format "44100:16:2"
always_on "yes" always_on "yes"
tags "yes" tags "yes"
signal "music"
packet_loss "5"
} }
audio_output { audio_output {
type "httpd" type "httpd"
@ -46,7 +47,6 @@
''; '';
}; };
systemd.services.mpd.serviceConfig.After = [ "pulseaudio.service" ];
systemd.services.mpd.serviceConfig.StateDirectory = [ "/mpd" ]; systemd.services.mpd.serviceConfig.StateDirectory = [ "/mpd" ];
services.nginx.virtualHosts."stream.owo.monster" = { services.nginx.virtualHosts."stream.owo.monster" = {
@ -71,4 +71,4 @@
}; };
networking.firewall.allowedTCPPorts = [ 6600 ]; networking.firewall.allowedTCPPorts = [ 6600 ];
} }

View file

@ -1 +0,0 @@
{ lib, ... }: { services.netdata = { enable = true; }; }

View file

@ -2,8 +2,6 @@
{ {
imports = with tree; [ imports = with tree; [
./hardware.nix
users.root users.root
users.chaos users.chaos
profiles.tailscale profiles.tailscale
@ -63,6 +61,7 @@
home.apps.nautilus home.apps.nautilus
home.apps.nicotine-plus home.apps.nicotine-plus
home.apps.musicutil home.apps.musicutil
home.apps.pavucontrol
home.programming home.programming
home.programming.languages.go home.programming.languages.go

4
hosts/lappy/vm.nix Normal file
View file

@ -0,0 +1,4 @@
_: {
users.users.root.password = "password";
users.users.chaos.password = "password";
}