aboutsummaryrefslogtreecommitdiffstats
path: root/test/read_tags.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'test/read_tags.cxx')
-rw-r--r--test/read_tags.cxx123
1 files changed, 18 insertions, 105 deletions
diff --git a/test/read_tags.cxx b/test/read_tags.cxx
index 90f1424d9..b12aff11a 100644
--- a/test/read_tags.cxx
+++ b/test/read_tags.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2014 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -19,10 +19,10 @@
#include "config.h"
#include "IOThread.hxx"
-#include "DecoderList.hxx"
-#include "DecoderAPI.hxx"
-#include "InputInit.hxx"
-#include "InputStream.hxx"
+#include "decoder/DecoderList.hxx"
+#include "decoder/DecoderPlugin.hxx"
+#include "input/Init.hxx"
+#include "input/InputStream.hxx"
#include "AudioFormat.hxx"
#include "tag/TagHandler.hxx"
#include "tag/TagId3.hxx"
@@ -37,103 +37,31 @@
#include <assert.h>
#include <unistd.h>
#include <stdlib.h>
+#include <stdio.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
-void
-decoder_initialized(gcc_unused Decoder &decoder,
- gcc_unused const AudioFormat audio_format,
- gcc_unused bool seekable,
- gcc_unused float total_time)
-{
-}
-
-DecoderCommand
-decoder_get_command(gcc_unused Decoder &decoder)
-{
- return DecoderCommand::NONE;
-}
-
-void
-decoder_command_finished(gcc_unused Decoder &decoder)
-{
-}
-
-double
-decoder_seek_where(gcc_unused Decoder &decoder)
-{
- return 1.0;
-}
-
-void
-decoder_seek_error(gcc_unused Decoder &decoder)
-{
-}
-
-size_t
-decoder_read(gcc_unused Decoder *decoder,
- InputStream &is,
- void *buffer, size_t length)
-{
- return is.LockRead(buffer, length, IgnoreError());
-}
-
-void
-decoder_timestamp(gcc_unused Decoder &decoder,
- gcc_unused double t)
-{
-}
-
-DecoderCommand
-decoder_data(gcc_unused Decoder &decoder,
- gcc_unused InputStream *is,
- const void *data, size_t datalen,
- gcc_unused uint16_t kbit_rate)
-{
- gcc_unused ssize_t nbytes = write(1, data, datalen);
- return DecoderCommand::NONE;
-}
-
-DecoderCommand
-decoder_tag(gcc_unused Decoder &decoder,
- gcc_unused InputStream *is,
- gcc_unused Tag &&tag)
-{
- return DecoderCommand::NONE;
-}
-
-void
-decoder_replay_gain(gcc_unused Decoder &decoder,
- gcc_unused const ReplayGainInfo *replay_gain_info)
-{
-}
-
-void
-decoder_mixramp(gcc_unused Decoder &decoder, gcc_unused MixRampInfo &&mix_ramp)
-{
-}
-
static bool empty = true;
static void
print_duration(unsigned seconds, gcc_unused void *ctx)
{
- g_print("duration=%d\n", seconds);
+ printf("duration=%d\n", seconds);
}
static void
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;
}
static void
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 = {
@@ -153,8 +81,8 @@ int main(int argc, char **argv)
#endif
if (argc != 3) {
- g_printerr("Usage: read_tags DECODER FILE\n");
- return 1;
+ fprintf(stderr, "Usage: read_tags DECODER FILE\n");
+ return EXIT_FAILURE;
}
decoder_name = argv[1];
@@ -177,8 +105,8 @@ int main(int argc, char **argv)
plugin = decoder_plugin_from_name(decoder_name);
if (plugin == NULL) {
- g_printerr("No such decoder: %s\n", decoder_name);
- return 1;
+ fprintf(stderr, "No such decoder: %s\n", decoder_name);
+ return EXIT_FAILURE;
}
bool success = plugin->ScanFile(path, print_handler, nullptr);
@@ -186,28 +114,13 @@ int main(int argc, char **argv)
Mutex mutex;
Cond cond;
- InputStream *is = InputStream::Open(path, mutex, cond,
- error);
+ InputStream *is = InputStream::OpenReady(path, mutex, cond,
+ error);
if (is == NULL) {
- g_printerr("Failed to open %s: %s\n",
- path, error.GetMessage());
- return 1;
- }
-
- mutex.lock();
-
- is->WaitReady();
-
- if (!is->Check(error)) {
- mutex.unlock();
-
- g_printerr("Failed to read %s: %s\n",
- path, error.GetMessage());
+ FormatError(error, "Failed to open %s", path);
return EXIT_FAILURE;
}
- mutex.unlock();
-
success = plugin->ScanStream(*is, print_handler, nullptr);
is->Close();
}
@@ -217,8 +130,8 @@ int main(int argc, char **argv)
io_thread_deinit();
if (!success) {
- g_printerr("Failed to read tags\n");
- return 1;
+ fprintf(stderr, "Failed to read tags\n");
+ return EXIT_FAILURE;
}
if (empty) {