test/*: use fprintf(stderr,...) and Log() instead of g_printerr()
Avoid GLib.
This commit is contained in:
parent
8064bbbc3f
commit
1ad52f131c
@ -1397,6 +1397,7 @@ endif
|
|||||||
|
|
||||||
test_software_volume_SOURCES = test/software_volume.cxx \
|
test_software_volume_SOURCES = test/software_volume.cxx \
|
||||||
test/stdbin.h \
|
test/stdbin.h \
|
||||||
|
src/Log.cxx src/LogBackend.cxx \
|
||||||
src/AudioFormat.cxx src/CheckAudioFormat.cxx \
|
src/AudioFormat.cxx src/CheckAudioFormat.cxx \
|
||||||
src/AudioParser.cxx
|
src/AudioParser.cxx
|
||||||
test_software_volume_LDADD = \
|
test_software_volume_LDADD = \
|
||||||
|
@ -129,13 +129,13 @@ decoder_replay_gain(gcc_unused Decoder &decoder,
|
|||||||
{
|
{
|
||||||
const ReplayGainTuple *tuple = &rgi->tuples[REPLAY_GAIN_ALBUM];
|
const ReplayGainTuple *tuple = &rgi->tuples[REPLAY_GAIN_ALBUM];
|
||||||
if (tuple->IsDefined())
|
if (tuple->IsDefined())
|
||||||
g_printerr("replay_gain[album]: gain=%f peak=%f\n",
|
fprintf(stderr, "replay_gain[album]: gain=%f peak=%f\n",
|
||||||
tuple->gain, tuple->peak);
|
tuple->gain, tuple->peak);
|
||||||
|
|
||||||
tuple = &rgi->tuples[REPLAY_GAIN_TRACK];
|
tuple = &rgi->tuples[REPLAY_GAIN_TRACK];
|
||||||
if (tuple->IsDefined())
|
if (tuple->IsDefined())
|
||||||
g_printerr("replay_gain[track]: gain=%f peak=%f\n",
|
fprintf(stderr, "replay_gain[track]: gain=%f peak=%f\n",
|
||||||
tuple->gain, tuple->peak);
|
tuple->gain, tuple->peak);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -49,8 +49,8 @@ int main(int argc, char **argv)
|
|||||||
Song *song;
|
Song *song;
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
g_printerr("Usage: dump_playlist CONFIG URI\n");
|
fprintf(stderr, "Usage: dump_playlist CONFIG URI\n");
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Path config_path = Path::FromFS(argv[1]);
|
const Path config_path = Path::FromFS(argv[1]);
|
||||||
@ -68,8 +68,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
if (!ReadConfigFile(config_path, error)) {
|
if (!ReadConfigFile(config_path, error)) {
|
||||||
g_printerr("%s\n", error.GetMessage());
|
LogError(error);
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
io_thread_init();
|
io_thread_init();
|
||||||
@ -77,7 +77,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (!input_stream_global_init(error)) {
|
if (!input_stream_global_init(error)) {
|
||||||
LogError(error);
|
LogError(error);
|
||||||
return 2;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
playlist_list_global_init();
|
playlist_list_global_init();
|
||||||
@ -97,7 +97,8 @@ int main(int argc, char **argv)
|
|||||||
if (error.IsDefined())
|
if (error.IsDefined())
|
||||||
LogError(error);
|
LogError(error);
|
||||||
else
|
else
|
||||||
g_printerr("InputStream::Open() failed\n");
|
fprintf(stderr,
|
||||||
|
"InputStream::Open() failed\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +109,7 @@ int main(int argc, char **argv)
|
|||||||
playlist = playlist_list_open_stream(*is, uri);
|
playlist = playlist_list_open_stream(*is, uri);
|
||||||
if (playlist == NULL) {
|
if (playlist == NULL) {
|
||||||
is->Close();
|
is->Close();
|
||||||
g_printerr("Failed to open playlist\n");
|
fprintf(stderr, "Failed to open playlist\n");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,18 +117,18 @@ int main(int argc, char **argv)
|
|||||||
/* dump the playlist */
|
/* dump the playlist */
|
||||||
|
|
||||||
while ((song = playlist->NextSong()) != NULL) {
|
while ((song = playlist->NextSong()) != NULL) {
|
||||||
g_print("%s\n", song->uri);
|
printf("%s\n", song->uri);
|
||||||
|
|
||||||
if (song->end_ms > 0)
|
if (song->end_ms > 0)
|
||||||
g_print("range: %u:%02u..%u:%02u\n",
|
printf("range: %u:%02u..%u:%02u\n",
|
||||||
song->start_ms / 60000,
|
song->start_ms / 60000,
|
||||||
(song->start_ms / 1000) % 60,
|
(song->start_ms / 1000) % 60,
|
||||||
song->end_ms / 60000,
|
song->end_ms / 60000,
|
||||||
(song->end_ms / 1000) % 60);
|
(song->end_ms / 1000) % 60);
|
||||||
else if (song->start_ms > 0)
|
else if (song->start_ms > 0)
|
||||||
g_print("range: %u:%02u..\n",
|
printf("range: %u:%02u..\n",
|
||||||
song->start_ms / 60000,
|
song->start_ms / 60000,
|
||||||
(song->start_ms / 1000) % 60);
|
(song->start_ms / 1000) % 60);
|
||||||
|
|
||||||
if (song->tag != NULL)
|
if (song->tag != NULL)
|
||||||
tag_save(stdout, *song->tag);
|
tag_save(stdout, *song->tag);
|
||||||
|
@ -24,11 +24,10 @@
|
|||||||
#include "ConfigGlobal.hxx"
|
#include "ConfigGlobal.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <id3tag.h>
|
#include <id3tag.h>
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_LOCALE_H
|
#ifdef HAVE_LOCALE_H
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
@ -50,8 +49,8 @@ int main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
g_printerr("Usage: read_rva2 FILE\n");
|
fprintf(stderr, "Usage: read_rva2 FILE\n");
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *path = argv[1];
|
const char *path = argv[1];
|
||||||
@ -60,9 +59,9 @@ int main(int argc, char **argv)
|
|||||||
struct id3_tag *tag = tag_id3_load(Path::FromFS(path), error);
|
struct id3_tag *tag = tag_id3_load(Path::FromFS(path), error);
|
||||||
if (tag == NULL) {
|
if (tag == NULL) {
|
||||||
if (error.IsDefined())
|
if (error.IsDefined())
|
||||||
g_printerr("%s\n", error.GetMessage());
|
LogError(error);
|
||||||
else
|
else
|
||||||
g_printerr("No ID3 tag found\n");
|
fprintf(stderr, "No ID3 tag found\n");
|
||||||
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
@ -74,19 +73,19 @@ int main(int argc, char **argv)
|
|||||||
id3_tag_delete(tag);
|
id3_tag_delete(tag);
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
g_printerr("No RVA2 tag found\n");
|
fprintf(stderr, "No RVA2 tag found\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReplayGainTuple *tuple = &replay_gain.tuples[REPLAY_GAIN_ALBUM];
|
const ReplayGainTuple *tuple = &replay_gain.tuples[REPLAY_GAIN_ALBUM];
|
||||||
if (tuple->IsDefined())
|
if (tuple->IsDefined())
|
||||||
g_printerr("replay_gain[album]: gain=%f peak=%f\n",
|
fprintf(stderr, "replay_gain[album]: gain=%f peak=%f\n",
|
||||||
tuple->gain, tuple->peak);
|
tuple->gain, tuple->peak);
|
||||||
|
|
||||||
tuple = &replay_gain.tuples[REPLAY_GAIN_TRACK];
|
tuple = &replay_gain.tuples[REPLAY_GAIN_TRACK];
|
||||||
if (tuple->IsDefined())
|
if (tuple->IsDefined())
|
||||||
g_printerr("replay_gain[track]: gain=%f peak=%f\n",
|
fprintf(stderr, "replay_gain[track]: gain=%f peak=%f\n",
|
||||||
tuple->gain, tuple->peak);
|
tuple->gain, tuple->peak);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -89,8 +89,8 @@ int main(int argc, char **argv)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
g_printerr("Usage: run_input URI\n");
|
fprintf(stderr, "Usage: run_input URI\n");
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* initialize GLib */
|
/* initialize GLib */
|
||||||
@ -129,8 +129,8 @@ int main(int argc, char **argv)
|
|||||||
if (error.IsDefined())
|
if (error.IsDefined())
|
||||||
LogError(error);
|
LogError(error);
|
||||||
else
|
else
|
||||||
g_printerr("input_stream::Open() failed\n");
|
fprintf(stderr, "input_stream::Open() failed\n");
|
||||||
ret = 2;
|
ret = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* deinitialize everything */
|
/* deinitialize everything */
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "event/Loop.hxx"
|
#include "event/Loop.hxx"
|
||||||
#include "ConfigData.hxx"
|
#include "ConfigData.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
@ -106,8 +107,8 @@ int main(int argc, gcc_unused char **argv)
|
|||||||
int volume;
|
int volume;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
g_printerr("Usage: read_mixer PLUGIN\n");
|
fprintf(stderr, "Usage: read_mixer PLUGIN\n");
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !GLIB_CHECK_VERSION(2,32,0)
|
#if !GLIB_CHECK_VERSION(2,32,0)
|
||||||
@ -120,14 +121,14 @@ int main(int argc, gcc_unused char **argv)
|
|||||||
Mixer *mixer = mixer_new(&alsa_mixer_plugin, nullptr,
|
Mixer *mixer = mixer_new(&alsa_mixer_plugin, nullptr,
|
||||||
config_param(), error);
|
config_param(), error);
|
||||||
if (mixer == NULL) {
|
if (mixer == NULL) {
|
||||||
g_printerr("mixer_new() failed: %s\n", error.GetMessage());
|
LogError(error, "mixer_new() failed");
|
||||||
return 2;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mixer_open(mixer, error)) {
|
if (!mixer_open(mixer, error)) {
|
||||||
mixer_free(mixer);
|
mixer_free(mixer);
|
||||||
g_printerr("failed to open the mixer: %s\n", error.GetMessage());
|
LogError(error, "failed to open the mixer");
|
||||||
return 2;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
volume = mixer_get_volume(mixer, error);
|
volume = mixer_get_volume(mixer, error);
|
||||||
@ -140,13 +141,12 @@ int main(int argc, gcc_unused char **argv)
|
|||||||
|
|
||||||
if (volume < 0) {
|
if (volume < 0) {
|
||||||
if (error.IsDefined()) {
|
if (error.IsDefined()) {
|
||||||
g_printerr("failed to read volume: %s\n",
|
LogError(error, "failed to read volume");
|
||||||
error.GetMessage());
|
|
||||||
} else
|
} else
|
||||||
g_printerr("failed to read volume\n");
|
fprintf(stderr, "failed to read volume\n");
|
||||||
return 2;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_print("%d\n", volume);
|
printf("%d\n", volume);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -47,20 +47,20 @@ static bool empty = true;
|
|||||||
static void
|
static void
|
||||||
print_duration(unsigned seconds, gcc_unused void *ctx)
|
print_duration(unsigned seconds, gcc_unused void *ctx)
|
||||||
{
|
{
|
||||||
g_print("duration=%d\n", seconds);
|
printf("duration=%d\n", seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_tag(TagType type, const char *value, gcc_unused void *ctx)
|
print_tag(TagType type, const char *value, gcc_unused void *ctx)
|
||||||
{
|
{
|
||||||
g_print("[%s]=%s\n", tag_item_names[type], value);
|
printf("[%s]=%s\n", tag_item_names[type], value);
|
||||||
empty = false;
|
empty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_pair(const char *name, const char *value, gcc_unused void *ctx)
|
print_pair(const char *name, const char *value, gcc_unused void *ctx)
|
||||||
{
|
{
|
||||||
g_print("\"%s\"=%s\n", name, value);
|
printf("\"%s\"=%s\n", name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct tag_handler print_handler = {
|
static const struct tag_handler print_handler = {
|
||||||
@ -80,8 +80,8 @@ int main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
g_printerr("Usage: read_tags DECODER FILE\n");
|
fprintf(stderr, "Usage: read_tags DECODER FILE\n");
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
decoder_name = argv[1];
|
decoder_name = argv[1];
|
||||||
@ -104,8 +104,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
plugin = decoder_plugin_from_name(decoder_name);
|
plugin = decoder_plugin_from_name(decoder_name);
|
||||||
if (plugin == NULL) {
|
if (plugin == NULL) {
|
||||||
g_printerr("No such decoder: %s\n", decoder_name);
|
fprintf(stderr, "No such decoder: %s\n", decoder_name);
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success = plugin->ScanFile(path, print_handler, nullptr);
|
bool success = plugin->ScanFile(path, print_handler, nullptr);
|
||||||
@ -116,9 +116,8 @@ int main(int argc, char **argv)
|
|||||||
InputStream *is = InputStream::Open(path, mutex, cond,
|
InputStream *is = InputStream::Open(path, mutex, cond,
|
||||||
error);
|
error);
|
||||||
if (is == NULL) {
|
if (is == NULL) {
|
||||||
g_printerr("Failed to open %s: %s\n",
|
FormatError(error, "Failed to open %s", path);
|
||||||
path, error.GetMessage());
|
return EXIT_FAILURE;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
@ -128,8 +127,7 @@ int main(int argc, char **argv)
|
|||||||
if (!is->Check(error)) {
|
if (!is->Check(error)) {
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
||||||
g_printerr("Failed to read %s: %s\n",
|
FormatError(error, "Failed to read %s", path);
|
||||||
path, error.GetMessage());
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,8 +142,8 @@ int main(int argc, char **argv)
|
|||||||
io_thread_deinit();
|
io_thread_deinit();
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
g_printerr("Failed to read tags\n");
|
fprintf(stderr, "Failed to read tags\n");
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty) {
|
if (empty) {
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "stdbin.h"
|
#include "stdbin.h"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "system/FatalError.hxx"
|
#include "system/FatalError.hxx"
|
||||||
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
@ -66,14 +67,14 @@ load_filter(const char *name)
|
|||||||
|
|
||||||
param = find_named_config_block(CONF_AUDIO_FILTER, name);
|
param = find_named_config_block(CONF_AUDIO_FILTER, name);
|
||||||
if (param == NULL) {
|
if (param == NULL) {
|
||||||
g_printerr("No such configured filter: %s\n", name);
|
fprintf(stderr, "No such configured filter: %s\n", name);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
Filter *filter = filter_configured_new(*param, error);
|
Filter *filter = filter_configured_new(*param, error);
|
||||||
if (filter == NULL) {
|
if (filter == NULL) {
|
||||||
g_printerr("Failed to load filter: %s\n", error.GetMessage());
|
LogError(error, "Failed to load filter");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,8 +88,8 @@ int main(int argc, char **argv)
|
|||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
|
|
||||||
if (argc < 3 || argc > 4) {
|
if (argc < 3 || argc > 4) {
|
||||||
g_printerr("Usage: run_filter CONFIG NAME [FORMAT] <IN\n");
|
fprintf(stderr, "Usage: run_filter CONFIG NAME [FORMAT] <IN\n");
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Path config_path = Path::FromFS(argv[1]);
|
const Path config_path = Path::FromFS(argv[1]);
|
||||||
@ -112,9 +113,8 @@ int main(int argc, char **argv)
|
|||||||
if (argc > 3) {
|
if (argc > 3) {
|
||||||
Error error;
|
Error error;
|
||||||
if (!audio_format_parse(audio_format, argv[3], false, error)) {
|
if (!audio_format_parse(audio_format, argv[3], false, error)) {
|
||||||
g_printerr("Failed to parse audio format: %s\n",
|
LogError(error, "Failed to parse audio format");
|
||||||
error.GetMessage());
|
return EXIT_FAILURE;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,20 +122,20 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
Filter *filter = load_filter(argv[2]);
|
Filter *filter = load_filter(argv[2]);
|
||||||
if (filter == NULL)
|
if (filter == NULL)
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
/* open the filter */
|
/* open the filter */
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
const AudioFormat out_audio_format = filter->Open(audio_format, error);
|
const AudioFormat out_audio_format = filter->Open(audio_format, error);
|
||||||
if (!out_audio_format.IsDefined()) {
|
if (!out_audio_format.IsDefined()) {
|
||||||
g_printerr("Failed to open filter: %s\n", error.GetMessage());
|
LogError(error, "Failed to open filter");
|
||||||
delete filter;
|
delete filter;
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_printerr("audio_format=%s\n",
|
fprintf(stderr, "audio_format=%s\n",
|
||||||
audio_format_to_string(out_audio_format, &af_string));
|
audio_format_to_string(out_audio_format, &af_string));
|
||||||
|
|
||||||
/* play */
|
/* play */
|
||||||
|
|
||||||
@ -151,15 +151,16 @@ int main(int argc, char **argv)
|
|||||||
dest = filter->FilterPCM(buffer, (size_t)nbytes,
|
dest = filter->FilterPCM(buffer, (size_t)nbytes,
|
||||||
&length, error);
|
&length, error);
|
||||||
if (dest == NULL) {
|
if (dest == NULL) {
|
||||||
g_printerr("Filter failed: %s\n", error.GetMessage());
|
LogError(error, "Filter failed");
|
||||||
filter->Close();
|
filter->Close();
|
||||||
delete filter;
|
delete filter;
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nbytes = write(1, dest, length);
|
nbytes = write(1, dest, length);
|
||||||
if (nbytes < 0) {
|
if (nbytes < 0) {
|
||||||
g_printerr("Failed to write: %s\n", g_strerror(errno));
|
fprintf(stderr, "Failed to write: %s\n",
|
||||||
|
strerror(errno));
|
||||||
filter->Close();
|
filter->Close();
|
||||||
delete filter;
|
delete filter;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include <sys/inotify.h>
|
#include <sys/inotify.h>
|
||||||
|
|
||||||
static constexpr unsigned IN_MASK =
|
static constexpr unsigned IN_MASK =
|
||||||
@ -39,7 +37,7 @@ static void
|
|||||||
my_inotify_callback(gcc_unused int wd, unsigned mask,
|
my_inotify_callback(gcc_unused int wd, unsigned mask,
|
||||||
const char *name, gcc_unused void *ctx)
|
const char *name, gcc_unused void *ctx)
|
||||||
{
|
{
|
||||||
g_print("mask=0x%x name='%s'\n", mask, name);
|
printf("mask=0x%x name='%s'\n", mask, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
@ -47,8 +45,8 @@ int main(int argc, char **argv)
|
|||||||
const char *path;
|
const char *path;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
g_printerr("Usage: run_inotify PATH\n");
|
fprintf(stderr, "Usage: run_inotify PATH\n");
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = argv[1];
|
path = argv[1];
|
||||||
@ -62,17 +60,18 @@ int main(int argc, char **argv)
|
|||||||
nullptr, error);
|
nullptr, error);
|
||||||
if (source == NULL) {
|
if (source == NULL) {
|
||||||
LogError(error);
|
LogError(error);
|
||||||
return 2;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int descriptor = source->Add(path, IN_MASK, error);
|
int descriptor = source->Add(path, IN_MASK, error);
|
||||||
if (descriptor < 0) {
|
if (descriptor < 0) {
|
||||||
delete source;
|
delete source;
|
||||||
LogError(error);
|
LogError(error);
|
||||||
return 2;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
event_loop.Run();
|
event_loop.Run();
|
||||||
|
|
||||||
delete source;
|
delete source;
|
||||||
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "PlayerControl.hxx"
|
#include "PlayerControl.hxx"
|
||||||
#include "stdbin.h"
|
#include "stdbin.h"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ load_audio_output(const char *name)
|
|||||||
|
|
||||||
param = find_named_config_block(CONF_AUDIO_OUTPUT, name);
|
param = find_named_config_block(CONF_AUDIO_OUTPUT, name);
|
||||||
if (param == NULL) {
|
if (param == NULL) {
|
||||||
g_printerr("No such configured audio output: %s\n", name);
|
fprintf(stderr, "No such configured audio output: %s\n", name);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ load_audio_output(const char *name)
|
|||||||
struct audio_output *ao =
|
struct audio_output *ao =
|
||||||
audio_output_new(*param, dummy_player_control, error);
|
audio_output_new(*param, dummy_player_control, error);
|
||||||
if (ao == nullptr)
|
if (ao == nullptr)
|
||||||
g_printerr("%s\n", error.GetMessage());
|
LogError(error);
|
||||||
|
|
||||||
return ao;
|
return ao;
|
||||||
}
|
}
|
||||||
@ -105,21 +106,19 @@ run_output(struct audio_output *ao, AudioFormat audio_format)
|
|||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
if (!ao_plugin_enable(ao, error)) {
|
if (!ao_plugin_enable(ao, error)) {
|
||||||
g_printerr("Failed to enable audio output: %s\n",
|
LogError(error, "Failed to enable audio output");
|
||||||
error.GetMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ao_plugin_open(ao, audio_format, error)) {
|
if (!ao_plugin_open(ao, audio_format, error)) {
|
||||||
ao_plugin_disable(ao);
|
ao_plugin_disable(ao);
|
||||||
g_printerr("Failed to open audio output: %s\n",
|
LogError(error, "Failed to open audio output");
|
||||||
error.GetMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct audio_format_string af_string;
|
struct audio_format_string af_string;
|
||||||
g_printerr("audio_format=%s\n",
|
fprintf(stderr, "audio_format=%s\n",
|
||||||
audio_format_to_string(audio_format, &af_string));
|
audio_format_to_string(audio_format, &af_string));
|
||||||
|
|
||||||
size_t frame_size = audio_format.GetFrameSize();
|
size_t frame_size = audio_format.GetFrameSize();
|
||||||
|
|
||||||
@ -145,8 +144,7 @@ run_output(struct audio_output *ao, AudioFormat audio_format)
|
|||||||
if (consumed == 0) {
|
if (consumed == 0) {
|
||||||
ao_plugin_close(ao);
|
ao_plugin_close(ao);
|
||||||
ao_plugin_disable(ao);
|
ao_plugin_disable(ao);
|
||||||
g_printerr("Failed to play: %s\n",
|
LogError(error, "Failed to play");
|
||||||
error.GetMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,8 +166,8 @@ int main(int argc, char **argv)
|
|||||||
Error error;
|
Error error;
|
||||||
|
|
||||||
if (argc < 3 || argc > 4) {
|
if (argc < 3 || argc > 4) {
|
||||||
g_printerr("Usage: run_output CONFIG NAME [FORMAT] <IN\n");
|
fprintf(stderr, "Usage: run_output CONFIG NAME [FORMAT] <IN\n");
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Path config_path = Path::FromFS(argv[1]);
|
const Path config_path = Path::FromFS(argv[1]);
|
||||||
@ -184,8 +182,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
config_global_init();
|
config_global_init();
|
||||||
if (!ReadConfigFile(config_path, error)) {
|
if (!ReadConfigFile(config_path, error)) {
|
||||||
g_printerr("%s\n", error.GetMessage());
|
LogError(error);
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
main_loop = new EventLoop(EventLoop::Default());
|
main_loop = new EventLoop(EventLoop::Default());
|
||||||
@ -203,9 +201,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (argc > 3) {
|
if (argc > 3) {
|
||||||
if (!audio_format_parse(audio_format, argv[3], false, error)) {
|
if (!audio_format_parse(audio_format, argv[3], false, error)) {
|
||||||
g_printerr("Failed to parse audio format: %s\n",
|
LogError(error, "Failed to parse audio format");
|
||||||
error.GetMessage());
|
return EXIT_FAILURE;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#include <winsock.h>
|
#include <winsock.h>
|
||||||
@ -37,7 +35,7 @@
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
g_printerr("Usage: run_resolver HOST\n");
|
fprintf(stderr, "Usage: run_resolver HOST\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +50,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
for (const struct addrinfo *i = ai; i != NULL; i = i->ai_next) {
|
for (const struct addrinfo *i = ai; i != NULL; i = i->ai_next) {
|
||||||
const auto s = sockaddr_to_string(i->ai_addr, i->ai_addrlen);
|
const auto s = sockaddr_to_string(i->ai_addr, i->ai_addrlen);
|
||||||
g_print("%s\n", s.c_str());
|
printf("%s\n", s.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
freeaddrinfo(ai);
|
freeaddrinfo(ai);
|
||||||
|
@ -30,8 +30,7 @@
|
|||||||
#include "util/ConstBuffer.hxx"
|
#include "util/ConstBuffer.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "stdbin.h"
|
#include "stdbin.h"
|
||||||
|
#include "Log.hxx"
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -43,17 +42,16 @@ int main(int argc, char **argv)
|
|||||||
ssize_t nbytes;
|
ssize_t nbytes;
|
||||||
|
|
||||||
if (argc > 2) {
|
if (argc > 2) {
|
||||||
g_printerr("Usage: software_volume [FORMAT] <IN >OUT\n");
|
fprintf(stderr, "Usage: software_volume [FORMAT] <IN >OUT\n");
|
||||||
return 1;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error error;
|
Error error;
|
||||||
AudioFormat audio_format(48000, SampleFormat::S16, 2);
|
AudioFormat audio_format(48000, SampleFormat::S16, 2);
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
if (!audio_format_parse(audio_format, argv[1], false, error)) {
|
if (!audio_format_parse(audio_format, argv[1], false, error)) {
|
||||||
g_printerr("Failed to parse audio format: %s\n",
|
LogError(error, "Failed to parse audio format");
|
||||||
error.GetMessage());
|
return EXIT_FAILURE;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user