aboutsummaryrefslogtreecommitdiffstats
path: root/test/run_decoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/run_decoder.c')
-rw-r--r--test/run_decoder.c58
1 files changed, 51 insertions, 7 deletions
diff --git a/test/run_decoder.c b/test/run_decoder.c
index 861720cdb..da5b6080c 100644
--- a/test/run_decoder.c
+++ b/test/run_decoder.c
@@ -17,17 +17,38 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include "config.h"
#include "decoder_list.h"
#include "decoder_api.h"
+#include "input_init.h"
#include "input_stream.h"
#include "audio_format.h"
#include "pcm_volume.h"
+#include "idle.h"
#include <glib.h>
#include <assert.h>
#include <unistd.h>
+static void
+my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level,
+ const gchar *message, G_GNUC_UNUSED gpointer user_data)
+{
+ if (log_domain != NULL)
+ g_printerr("%s: %s\n", log_domain, message);
+ else
+ g_printerr("%s\n", message);
+}
+
+/**
+ * No-op dummy.
+ */
+void
+idle_add(G_GNUC_UNUSED unsigned flags)
+{
+}
+
/**
* No-op dummy.
*/
@@ -53,11 +74,13 @@ decoder_initialized(struct decoder *decoder,
G_GNUC_UNUSED bool seekable,
G_GNUC_UNUSED float total_time)
{
+ struct audio_format_string af_string;
+
assert(!decoder->initialized);
assert(audio_format_valid(audio_format));
- g_printerr("audio_format=%u:%u:%u\n", audio_format->sample_rate,
- audio_format->bits, audio_format->channels);
+ g_printerr("audio_format=%s\n",
+ audio_format_to_string(audio_format, &af_string));
decoder->initialized = true;
}
@@ -91,14 +114,20 @@ decoder_read(G_GNUC_UNUSED struct decoder *decoder,
struct input_stream *is,
void *buffer, size_t length)
{
- return input_stream_read(is, buffer, length);
+ return input_stream_read(is, buffer, length, NULL);
+}
+
+void
+decoder_timestamp(G_GNUC_UNUSED struct decoder *decoder,
+ G_GNUC_UNUSED double t)
+{
}
enum decoder_command
decoder_data(G_GNUC_UNUSED struct decoder *decoder,
G_GNUC_UNUSED struct input_stream *is,
const void *data, size_t datalen,
- G_GNUC_UNUSED float data_time, G_GNUC_UNUSED uint16_t bit_rate,
+ G_GNUC_UNUSED uint16_t kbit_rate,
G_GNUC_UNUSED struct replay_gain_info *replay_gain_info)
{
write(1, data, datalen);
@@ -115,6 +144,7 @@ decoder_tag(G_GNUC_UNUSED struct decoder *decoder,
int main(int argc, char **argv)
{
+ GError *error = NULL;
bool ret;
const char *decoder_name;
struct decoder decoder;
@@ -127,7 +157,14 @@ int main(int argc, char **argv)
decoder_name = argv[1];
decoder.uri = argv[2];
- input_stream_global_init();
+ g_log_set_default_handler(my_log_func, NULL);
+
+ if (!input_stream_global_init(&error)) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ return 2;
+ }
+
decoder_plugin_init_all();
decoder.plugin = decoder_plugin_from_name(decoder_name);
@@ -144,9 +181,16 @@ int main(int argc, char **argv)
} else if (decoder.plugin->stream_decode != NULL) {
struct input_stream is;
- ret = input_stream_open(&is, decoder.uri);
- if (!ret)
+ ret = input_stream_open(&is, decoder.uri, &error);
+ if (!ret) {
+ if (error != NULL) {
+ g_warning("%s", error->message);
+ g_error_free(error);
+ } else
+ g_printerr("input_stream_open() failed\n");
+
return 1;
+ }
decoder_plugin_stream_decode(decoder.plugin, &decoder, &is);