diff options
Diffstat (limited to 'src/InputStream.cxx')
-rw-r--r-- | src/InputStream.cxx | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/InputStream.cxx b/src/InputStream.cxx index 28a0aad1a..2321011ef 100644 --- a/src/InputStream.cxx +++ b/src/InputStream.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2013 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 @@ -57,6 +57,28 @@ InputStream::Open(const char *url, return nullptr; } +InputStream * +InputStream::OpenReady(const char *uri, + Mutex &mutex, Cond &cond, + Error &error) +{ + InputStream *is = Open(uri, mutex, cond, error); + if (is == nullptr) + return nullptr; + + mutex.lock(); + is->WaitReady(); + bool success = is->Check(error); + mutex.unlock(); + + if (!success) { + is->Close(); + is = nullptr; + } + + return is; +} + bool InputStream::Check(Error &error) { |