| 1 | // SPDX-FileCopyrightText: 2022-2025 Geoffrey D. Bennett <[email protected]> |
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #include "alsa.h" |
| 7 | |
| 8 | // Configuration file sections |
| 9 | #define CONFIG_SECTION_DEVICE "device" |
| 10 | #define CONFIG_SECTION_CONTROLS "controls" |
| 11 | #define CONFIG_SECTION_UI "ui" |
| 12 | |
| 13 | // Load the optional control state for a device from a specific section |
| 14 | // Returns hash table of key → value (as string) |
| 15 | // Caller must free the hash table with g_hash_table_destroy() |
| 16 | // Returns NULL if card has no serial or file doesn't exist |
| 17 | GHashTable *optional_state_load(struct alsa_card *card, const char *section); |
| 18 | |
| 19 | // Save a single value to the state file in a specific section |
| 20 | // Creates the state file and directory if needed |
| 21 | // Returns 0 on success, -1 on error |
| 22 | int optional_state_save( |
| 23 | struct alsa_card *card, |
| 24 | const char *section, |
| 25 | const char *key, |
| 26 | const char *value |
| 27 | ); |
| 28 | |
| 29 | // Remove the state file for a given serial |
| 30 | // Returns 0 on success, -1 on error |
| 31 | int optional_state_remove(const char *serial); |