| 1 |
/* |
| 2 |
* BlueALSA - cli.h |
| 3 |
* Copyright (c) 2016-2024 Arkadiusz Bokowy |
| 4 |
* |
| 5 |
* This file is a part of bluez-alsa. |
| 6 |
* |
| 7 |
* This project is licensed under the terms of the MIT license. |
| 8 |
* |
| 9 |
*/ |
| 10 |
|
| 11 |
#pragma once |
| 12 |
#ifndef BLUEALSA_CLI_CLI_H_ |
| 13 |
#define BLUEALSA_CLI_CLI_H_ |
| 14 |
|
| 15 |
#include <stdbool.h> |
| 16 |
|
| 17 |
#include <dbus/dbus.h> |
| 18 |
|
| 19 |
#include "shared/dbus-client.h" |
| 20 |
#include "shared/dbus-client-pcm.h" |
| 21 |
#include "shared/log.h" |
| 22 |
|
| 23 |
struct cli_config { |
| 24 |
|
| 25 |
/* initialized BlueALSA D-Bus context */ |
| 26 |
struct ba_dbus_ctx dbus; |
| 27 |
|
| 28 |
bool quiet; |
| 29 |
unsigned int verbose; |
| 30 |
|
| 31 |
}; |
| 32 |
|
| 33 |
struct cli_command { |
| 34 |
const char *name; |
| 35 |
const char *description; |
| 36 |
int (*func)(int argc, char *argv[]); |
| 37 |
}; |
| 38 |
|
| 39 |
typedef bool (*cli_get_ba_services_cb)(const char *name, void *data); |
| 40 |
|
| 41 |
void cli_get_ba_services(cli_get_ba_services_cb func, void *data, DBusError *err); |
| 42 |
bool cli_get_ba_pcm(const char *path, struct ba_pcm *pcm, DBusError *err); |
| 43 |
|
| 44 |
bool cli_parse_common_options(int opt); |
| 45 |
bool cli_parse_value_on_off(const char *value, bool *out); |
| 46 |
|
| 47 |
void cli_print_adapters(const struct ba_service_props *props); |
| 48 |
void cli_print_profiles_and_codecs(const struct ba_service_props *props); |
| 49 |
void cli_print_pcm_available_codecs(const struct ba_pcm *pcm, DBusError *err); |
| 50 |
void cli_print_pcm_selected_codec(const struct ba_pcm *pcm); |
| 51 |
void cli_print_pcm_soft_volume(const struct ba_pcm *pcm); |
| 52 |
void cli_print_pcm_volume(const struct ba_pcm *pcm); |
| 53 |
void cli_print_pcm_mute(const struct ba_pcm *pcm); |
| 54 |
void cli_print_pcm_properties(const struct ba_pcm *pcm, DBusError *err); |
| 55 |
void cli_print_usage(const char *format, ...); |
| 56 |
|
| 57 |
#define cli_print_error(M, ...) \ |
| 58 |
if (!config.quiet) { error(M, ##__VA_ARGS__); } |
| 59 |
#define cmd_print_error(M, ...) \ |
| 60 |
if (!config.quiet) { error("CMD \"%s\": " M, argv[0], ##__VA_ARGS__); } |
| 61 |
|
| 62 |
/** |
| 63 |
* Global configuration. */ |
| 64 |
extern struct cli_config config; |
| 65 |
|
| 66 |
#endif |