input: wrap InputStream in std::unique_ptr

This commit is contained in:
Max Kellermann
2016-02-21 08:03:32 +01:00
parent 054e9ecaae
commit cadc67ea40
19 changed files with 107 additions and 103 deletions

View File

@@ -256,7 +256,7 @@ void decoder_seek_error(Decoder & decoder)
decoder_command_finished(decoder);
}
InputStream *
InputStreamPtr
decoder_open_uri(Decoder &decoder, const char *uri, Error &error)
{
assert(decoder.dc.state == DecoderState::START ||
@@ -266,8 +266,8 @@ decoder_open_uri(Decoder &decoder, const char *uri, Error &error)
Mutex &mutex = dc.mutex;
Cond &cond = dc.cond;
InputStream *is = InputStream::Open(uri, mutex, cond, error);
if (is == nullptr)
auto is = InputStream::Open(uri, mutex, cond, error);
if (!is)
return nullptr;
mutex.lock();
@@ -280,7 +280,6 @@ decoder_open_uri(Decoder &decoder, const char *uri, Error &error)
if (dc.command == DecoderCommand::STOP) {
mutex.unlock();
delete is;
return nullptr;
}

View File

@@ -30,6 +30,7 @@
// IWYU pragma: begin_exports
#include "check.h"
#include "input/Ptr.hxx"
#include "DecoderCommand.hxx"
#include "DecoderPlugin.hxx"
#include "ReplayGainInfo.hxx"
@@ -116,7 +117,7 @@ decoder_seek_error(Decoder &decoder);
* cancelled by DecoderCommand::STOP (returns nullptr without setting
* #Error).
*/
InputStream *
InputStreamPtr
decoder_open_uri(Decoder &decoder, const char *uri, Error &error);
/**

View File

@@ -486,13 +486,13 @@ wavpack_open_wvc(Decoder &decoder, const char *uri)
char *wvc_url = xstrcatdup(uri, "c");
InputStream *is_wvc = decoder_open_uri(decoder, uri, IgnoreError());
auto is_wvc = decoder_open_uri(decoder, uri, IgnoreError());
free(wvc_url);
if (is_wvc == nullptr)
return nullptr;
return new WavpackInput(decoder, *is_wvc);
return new WavpackInput(decoder, *is_wvc.release());
}
/*