aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-12-29 18:08:49 +0100
committerMax Kellermann <max@duempel.org>2013-12-29 18:08:49 +0100
commitaeb2baa495776d9fc06e63f91167c40c334303c8 (patch)
tree4bbd926c1f19a64a1f3fc5b580d0d68bd3aabca3 /test
parentea9aff1d3f9f68eb5ae9e5f2bd67d283b8c0f47e (diff)
downloadmpd-aeb2baa495776d9fc06e63f91167c40c334303c8.tar.gz
mpd-aeb2baa495776d9fc06e63f91167c40c334303c8.tar.xz
mpd-aeb2baa495776d9fc06e63f91167c40c334303c8.zip
InputStream: add static method OpenReady()
Merge some duplicate code.
Diffstat (limited to '')
-rw-r--r--test/dump_playlist.cxx4
-rw-r--r--test/dump_text_file.cxx20
-rw-r--r--test/read_tags.cxx17
-rw-r--r--test/run_input.cxx12
4 files changed, 6 insertions, 47 deletions
diff --git a/test/dump_playlist.cxx b/test/dump_playlist.cxx
index f0401249e..2ac855a84 100644
--- a/test/dump_playlist.cxx
+++ b/test/dump_playlist.cxx
@@ -92,7 +92,7 @@ int main(int argc, char **argv)
if (playlist == NULL) {
/* open the stream and wait until it becomes ready */
- is = InputStream::Open(uri, mutex, cond, error);
+ is = InputStream::OpenReady(uri, mutex, cond, error);
if (is == NULL) {
if (error.IsDefined())
LogError(error);
@@ -102,8 +102,6 @@ int main(int argc, char **argv)
return 2;
}
- is->LockWaitReady();
-
/* open the playlist */
playlist = playlist_list_open_stream(*is, uri);
diff --git a/test/dump_text_file.cxx b/test/dump_text_file.cxx
index 3da965f03..764d3f24b 100644
--- a/test/dump_text_file.cxx
+++ b/test/dump_text_file.cxx
@@ -49,23 +49,6 @@ dump_text_file(TextInputStream &is)
static int
dump_input_stream(InputStream &is)
{
- Error error;
-
- is.Lock();
-
- /* wait until the stream becomes ready */
-
- is.WaitReady();
-
- if (!is.Check(error)) {
- LogError(error);
- is.Unlock();
- return EXIT_FAILURE;
- }
-
- /* read data and tags from the stream */
-
- is.Unlock();
{
TextInputStream tis(is);
dump_text_file(tis);
@@ -73,6 +56,7 @@ dump_input_stream(InputStream &is)
is.Lock();
+ Error error;
if (!is.Check(error)) {
LogError(error);
is.Unlock();
@@ -121,7 +105,7 @@ int main(int argc, char **argv)
Mutex mutex;
Cond cond;
- InputStream *is = InputStream::Open(argv[1], mutex, cond, error);
+ InputStream *is = InputStream::OpenReady(argv[1], mutex, cond, error);
if (is != NULL) {
ret = dump_input_stream(*is);
is->Close();
diff --git a/test/read_tags.cxx b/test/read_tags.cxx
index dac9aba00..d2cd162d2 100644
--- a/test/read_tags.cxx
+++ b/test/read_tags.cxx
@@ -113,26 +113,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) {
FormatError(error, "Failed to open %s", path);
return EXIT_FAILURE;
}
- mutex.lock();
-
- is->WaitReady();
-
- if (!is->Check(error)) {
- mutex.unlock();
-
- FormatError(error, "Failed to read %s", path);
- return EXIT_FAILURE;
- }
-
- mutex.unlock();
-
success = plugin->ScanStream(*is, print_handler, nullptr);
is->Close();
}
diff --git a/test/run_input.cxx b/test/run_input.cxx
index fcf4107c4..0c1ba1d36 100644
--- a/test/run_input.cxx
+++ b/test/run_input.cxx
@@ -50,16 +50,6 @@ dump_input_stream(InputStream *is)
is->Lock();
- /* wait until the stream becomes ready */
-
- is->WaitReady();
-
- if (!is->Check(error)) {
- LogError(error);
- is->Unlock();
- return EXIT_FAILURE;
- }
-
/* print meta data */
if (!is->mime.empty())
@@ -139,7 +129,7 @@ int main(int argc, char **argv)
Mutex mutex;
Cond cond;
- is = InputStream::Open(argv[1], mutex, cond, error);
+ is = InputStream::OpenReady(argv[1], mutex, cond, error);
if (is != NULL) {
ret = dump_input_stream(is);
is->Close();