Commit ea3d21d5 authored by Arnaud Ferraris's avatar Arnaud Ferraris
Browse files

tools: add helper command-line tool for easy testing

parent f17258ff
......@@ -57,3 +57,4 @@ config_h = configure_file (
subdir('data')
subdir('libcallaudio')
subdir('src')
subdir('tools')
/*
* Copyright (C) 2019 Purism SPC
* Copyright (C) 2020 Arnaud Ferraris <arnaud.ferraris@gmail.com>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "libcallaudio.h"
#include <glib.h>
int main (int argc, char *argv[0])
{
g_autoptr(GOptionContext) opt_context = NULL;
g_autoptr(GError) err = NULL;
int mode = -1;
int speaker = -1;
int mic = -1;
const GOptionEntry options [] = {
{"select-mode", 'm', 0, G_OPTION_ARG_INT, &mode,
"Select mode", NULL},
{"enable-speaker", 's', 0, G_OPTION_ARG_INT, &speaker,
"Enable speaker", NULL},
{"mute-mic", 'u', 0, G_OPTION_ARG_INT, &mic,
"Mute microphone", NULL},
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
};
opt_context = g_option_context_new("- A helper tool for callaudiod");
g_option_context_add_main_entries(opt_context, options, NULL);
if (!g_option_context_parse(opt_context, &argc, &argv, &err)) {
g_warning("%s", err->message);
return 1;
}
if (!call_audio_init(&err)) {
g_print ("Failed to init libcallaudio: %s\n", err->message);
return 1;
}
if (mode == CALL_AUDIO_MODE_DEFAULT || mode == CALL_AUDIO_MODE_CALL)
call_audio_select_mode(mode);
if (speaker == 0 || speaker == 1)
call_audio_enable_speaker((gboolean)speaker);
if (mic == 0 || mic == 1)
call_audio_mute_mic((gboolean)mic);
call_audio_deinit ();
return 0;
}
callaudiocli_sources = [
'callaudiocli.c',
]
callaudiocli_deps = [
libcallaudio_dep,
dependency('gobject-2.0'),
dependency('gio-unix-2.0'),
]
executable(
'callaudiocli',
callaudiocli_sources,
dependencies: callaudiocli_deps,
install: true,
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment