aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-09-05 00:06:31 +0200
committerMax Kellermann <max@duempel.org>2013-09-05 00:23:14 +0200
commit7d0269d2cec68c7e55df5b6db3d2266741534b17 (patch)
tree613f5d7b03bc9624f15167c76f8f4309603944cc /test
parent52ffdb0a55e43153fa9fc1189316884a630df700 (diff)
downloadmpd-7d0269d2cec68c7e55df5b6db3d2266741534b17.tar.gz
mpd-7d0269d2cec68c7e55df5b6db3d2266741534b17.tar.xz
mpd-7d0269d2cec68c7e55df5b6db3d2266741534b17.zip
InputLegacy: move functions to the input_stream class
Diffstat (limited to 'test')
-rw-r--r--test/dump_playlist.cxx14
-rw-r--r--test/dump_text_file.cxx25
-rw-r--r--test/read_tags.cxx13
-rw-r--r--test/run_decoder.cxx13
-rw-r--r--test/run_input.cxx28
5 files changed, 45 insertions, 48 deletions
diff --git a/test/dump_playlist.cxx b/test/dump_playlist.cxx
index c3cdf638f..10cecf73d 100644
--- a/test/dump_playlist.cxx
+++ b/test/dump_playlist.cxx
@@ -21,7 +21,7 @@
#include "TagSave.hxx"
#include "Song.hxx"
#include "Directory.hxx"
-#include "InputLegacy.hxx"
+#include "InputStream.hxx"
#include "conf.h"
#include "DecoderAPI.hxx"
#include "DecoderList.hxx"
@@ -86,7 +86,7 @@ decoder_read(gcc_unused struct decoder *decoder,
void *buffer, size_t length)
{
Error error;
- return input_stream_lock_read(is, buffer, length, error);
+ return is->LockRead(buffer, length, error);
}
void
@@ -190,22 +190,22 @@ int main(int argc, char **argv)
if (playlist == NULL) {
/* open the stream and wait until it becomes ready */
- is = input_stream_open(uri, mutex, cond, error);
+ is = input_stream::Open(uri, mutex, cond, error);
if (is == NULL) {
if (error.IsDefined())
g_warning("%s", error.GetMessage());
else
- g_printerr("input_stream_open() failed\n");
+ g_printerr("input_stream::Open() failed\n");
return 2;
}
- input_stream_lock_wait_ready(is);
+ is->LockWaitReady();
/* open the playlist */
playlist = playlist_list_open_stream(is, uri);
if (playlist == NULL) {
- input_stream_close(is);
+ is->Close();
g_printerr("Failed to open playlist\n");
return 2;
}
@@ -237,7 +237,7 @@ int main(int argc, char **argv)
playlist_plugin_close(playlist);
if (is != NULL)
- input_stream_close(is);
+ is->Close();
decoder_plugin_deinit_all();
playlist_list_global_finish();
diff --git a/test/dump_text_file.cxx b/test/dump_text_file.cxx
index a9f8c95a2..11ac8b3d0 100644
--- a/test/dump_text_file.cxx
+++ b/test/dump_text_file.cxx
@@ -59,34 +59,35 @@ dump_input_stream(struct input_stream *is)
{
Error error;
- input_stream_lock(is);
+ is->Lock();
/* wait until the stream becomes ready */
- input_stream_wait_ready(is);
+ is->WaitReady();
- if (!input_stream_check(is, error)) {
+ if (!is->Check(error)) {
g_warning("%s", error.GetMessage());
- input_stream_unlock(is);
+ is->Unlock();
return EXIT_FAILURE;
}
/* read data and tags from the stream */
- input_stream_unlock(is);
+ is->Unlock();
{
TextInputStream tis(is);
dump_text_file(tis);
}
- input_stream_lock(is);
- if (!input_stream_check(is, error)) {
+ is->Lock();
+
+ if (!is->Check(error)) {
g_warning("%s", error.GetMessage());
- input_stream_unlock(is);
+ is->Unlock();
return EXIT_FAILURE;
}
- input_stream_unlock(is);
+ is->Unlock();
return 0;
}
@@ -131,15 +132,15 @@ int main(int argc, char **argv)
Mutex mutex;
Cond cond;
- is = input_stream_open(argv[1], mutex, cond, error);
+ is = input_stream::Open(argv[1], mutex, cond, error);
if (is != NULL) {
ret = dump_input_stream(is);
- input_stream_close(is);
+ is->Close();
} else {
if (error.IsDefined())
g_warning("%s", error.GetMessage());
else
- g_printerr("input_stream_open() failed\n");
+ g_printerr("input_stream::Open() failed\n");
ret = 2;
}
diff --git a/test/read_tags.cxx b/test/read_tags.cxx
index 8b8500607..dc7a6df65 100644
--- a/test/read_tags.cxx
+++ b/test/read_tags.cxx
@@ -72,7 +72,7 @@ decoder_read(gcc_unused struct decoder *decoder,
void *buffer, size_t length)
{
Error error;
- return input_stream_lock_read(is, buffer, length, error);
+ return is->LockRead(buffer, length, error);
}
void
@@ -185,9 +185,8 @@ int main(int argc, char **argv)
Mutex mutex;
Cond cond;
- struct input_stream *is =
- input_stream_open(path, mutex, cond, error);
-
+ input_stream *is = input_stream::Open(path, mutex, cond,
+ error);
if (is == NULL) {
g_printerr("Failed to open %s: %s\n",
path, error.GetMessage());
@@ -196,9 +195,9 @@ int main(int argc, char **argv)
mutex.lock();
- input_stream_wait_ready(is);
+ is->WaitReady();
- if (!input_stream_check(is, error)) {
+ if (!is->Check(error)) {
mutex.unlock();
g_printerr("Failed to read %s: %s\n",
@@ -210,7 +209,7 @@ int main(int argc, char **argv)
success = decoder_plugin_scan_stream(plugin, is,
&print_handler, NULL);
- input_stream_close(is);
+ is->Close();
}
decoder_plugin_deinit_all();
diff --git a/test/run_decoder.cxx b/test/run_decoder.cxx
index fb06c637a..ed29c1880 100644
--- a/test/run_decoder.cxx
+++ b/test/run_decoder.cxx
@@ -22,7 +22,7 @@
#include "DecoderList.hxx"
#include "DecoderAPI.hxx"
#include "InputInit.hxx"
-#include "InputLegacy.hxx"
+#include "InputStream.hxx"
#include "AudioFormat.hxx"
#include "util/Error.hxx"
#include "stdbin.h"
@@ -92,8 +92,7 @@ decoder_read(gcc_unused struct decoder *decoder,
struct input_stream *is,
void *buffer, size_t length)
{
- Error error;
- return input_stream_lock_read(is, buffer, length, error);
+ return is->LockRead(buffer, length, IgnoreError());
}
void
@@ -189,20 +188,20 @@ int main(int argc, char **argv)
Mutex mutex;
Cond cond;
- struct input_stream *is =
- input_stream_open(decoder.uri, mutex, cond, error);
+ input_stream *is =
+ input_stream::Open(decoder.uri, mutex, cond, error);
if (is == NULL) {
if (error.IsDefined())
g_warning("%s", error.GetMessage());
else
- g_printerr("input_stream_open() failed\n");
+ g_printerr("input_stream::Open() failed\n");
return 1;
}
decoder_plugin_stream_decode(decoder.plugin, &decoder, is);
- input_stream_close(is);
+ is->Close();
} else {
g_printerr("Decoder plugin is not usable\n");
return 1;
diff --git a/test/run_input.cxx b/test/run_input.cxx
index 3c74ab509..051c3a803 100644
--- a/test/run_input.cxx
+++ b/test/run_input.cxx
@@ -22,7 +22,6 @@
#include "stdbin.h"
#include "Tag.hxx"
#include "conf.h"
-#include "InputLegacy.hxx"
#include "InputStream.hxx"
#include "InputInit.hxx"
#include "IOThread.hxx"
@@ -55,15 +54,15 @@ dump_input_stream(struct input_stream *is)
size_t num_read;
ssize_t num_written;
- input_stream_lock(is);
+ is->Lock();
/* wait until the stream becomes ready */
- input_stream_wait_ready(is);
+ is->WaitReady();
- if (!input_stream_check(is, error)) {
+ if (!is->Check(error)) {
g_warning("%s", error.GetMessage());
- input_stream_unlock(is);
+ is->Unlock();
return EXIT_FAILURE;
}
@@ -74,16 +73,15 @@ dump_input_stream(struct input_stream *is)
/* read data and tags from the stream */
- while (!input_stream_eof(is)) {
- Tag *tag = input_stream_tag(is);
+ while (!is->IsEOF()) {
+ Tag *tag = is->ReadTag();
if (tag != NULL) {
g_printerr("Received a tag:\n");
tag_save(stderr, *tag);
delete tag;
}
- num_read = input_stream_read(is, buffer, sizeof(buffer),
- error);
+ num_read = is->Read(buffer, sizeof(buffer), error);
if (num_read == 0) {
if (error.IsDefined())
g_warning("%s", error.GetMessage());
@@ -96,13 +94,13 @@ dump_input_stream(struct input_stream *is)
break;
}
- if (!input_stream_check(is, error)) {
+ if (!is->Check(error)) {
g_warning("%s", error.GetMessage());
- input_stream_unlock(is);
+ is->Unlock();
return EXIT_FAILURE;
}
- input_stream_unlock(is);
+ is->Unlock();
return 0;
}
@@ -147,15 +145,15 @@ int main(int argc, char **argv)
Mutex mutex;
Cond cond;
- is = input_stream_open(argv[1], mutex, cond, error);
+ is = input_stream::Open(argv[1], mutex, cond, error);
if (is != NULL) {
ret = dump_input_stream(is);
- input_stream_close(is);
+ is->Close();
} else {
if (error.IsDefined())
g_warning("%s", error.GetMessage());
else
- g_printerr("input_stream_open() failed\n");
+ g_printerr("input_stream::Open() failed\n");
ret = 2;
}