input: wrap InputStream in std::unique_ptr
This commit is contained in:
@@ -72,7 +72,7 @@ decoder_seek_error(gcc_unused Decoder &decoder)
|
||||
{
|
||||
}
|
||||
|
||||
InputStream *
|
||||
InputStreamPtr
|
||||
decoder_open_uri(Decoder &decoder, const char *uri, Error &error)
|
||||
{
|
||||
return InputStream::OpenReady(uri, decoder.mutex, decoder.cond, error);
|
||||
|
@@ -50,7 +50,6 @@ tag_save(FILE *file, const Tag &tag)
|
||||
int main(int argc, char **argv)
|
||||
try {
|
||||
const char *uri;
|
||||
InputStream *is = NULL;
|
||||
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "Usage: dump_playlist CONFIG URI\n");
|
||||
@@ -82,12 +81,13 @@ try {
|
||||
Mutex mutex;
|
||||
Cond cond;
|
||||
|
||||
InputStreamPtr is;
|
||||
auto playlist = playlist_list_open_uri(uri, mutex, cond);
|
||||
if (playlist == NULL) {
|
||||
/* open the stream and wait until it becomes ready */
|
||||
|
||||
is = InputStream::OpenReady(uri, mutex, cond, error);
|
||||
if (is == NULL) {
|
||||
if (!is) {
|
||||
if (error.IsDefined())
|
||||
LogError(error);
|
||||
else
|
||||
@@ -100,7 +100,6 @@ try {
|
||||
|
||||
playlist = playlist_list_open_stream(*is, uri);
|
||||
if (playlist == NULL) {
|
||||
delete is;
|
||||
fprintf(stderr, "Failed to open playlist\n");
|
||||
return 2;
|
||||
}
|
||||
@@ -132,7 +131,7 @@ try {
|
||||
/* deinitialize everything */
|
||||
|
||||
delete playlist;
|
||||
delete is;
|
||||
is.reset();
|
||||
|
||||
decoder_plugin_deinit_all();
|
||||
playlist_list_global_finish();
|
||||
|
@@ -92,19 +92,20 @@ int main(int argc, char **argv)
|
||||
|
||||
/* open the stream and dump it */
|
||||
|
||||
Mutex mutex;
|
||||
Cond cond;
|
||||
{
|
||||
Mutex mutex;
|
||||
Cond cond;
|
||||
|
||||
InputStream *is = InputStream::OpenReady(argv[1], mutex, cond, error);
|
||||
if (is != NULL) {
|
||||
ret = dump_input_stream(*is);
|
||||
delete is;
|
||||
} else {
|
||||
if (error.IsDefined())
|
||||
LogError(error);
|
||||
else
|
||||
fprintf(stderr, "input_stream::Open() failed\n");
|
||||
ret = EXIT_FAILURE;
|
||||
auto is = InputStream::OpenReady(argv[1], mutex, cond, error);
|
||||
if (is) {
|
||||
ret = dump_input_stream(*is);
|
||||
} else {
|
||||
if (error.IsDefined())
|
||||
LogError(error);
|
||||
else
|
||||
fprintf(stderr, "input_stream::Open() failed\n");
|
||||
ret = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* deinitialize everything */
|
||||
|
@@ -107,16 +107,15 @@ int main(int argc, char **argv)
|
||||
Mutex mutex;
|
||||
Cond cond;
|
||||
|
||||
InputStream *is = InputStream::OpenReady(path.c_str(),
|
||||
mutex, cond,
|
||||
error);
|
||||
if (is == NULL) {
|
||||
auto is = InputStream::OpenReady(path.c_str(),
|
||||
mutex, cond,
|
||||
error);
|
||||
if (!is) {
|
||||
FormatError(error, "Failed to open %s", path.c_str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
success = plugin->ScanStream(*is, print_handler, nullptr);
|
||||
delete is;
|
||||
}
|
||||
|
||||
decoder_plugin_deinit_all();
|
||||
|
@@ -64,10 +64,9 @@ int main(int argc, char **argv)
|
||||
if (plugin->file_decode != nullptr) {
|
||||
plugin->FileDecode(decoder, Path::FromFS(uri));
|
||||
} else if (plugin->stream_decode != nullptr) {
|
||||
InputStream *is =
|
||||
InputStream::OpenReady(uri, decoder.mutex,
|
||||
decoder.cond, error);
|
||||
if (is == NULL) {
|
||||
auto is = InputStream::OpenReady(uri, decoder.mutex,
|
||||
decoder.cond, error);
|
||||
if (!is) {
|
||||
if (error.IsDefined())
|
||||
LogError(error);
|
||||
else
|
||||
@@ -77,8 +76,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
plugin->StreamDecode(decoder, *is);
|
||||
|
||||
delete is;
|
||||
} else {
|
||||
fprintf(stderr, "Decoder plugin is not usable\n");
|
||||
return EXIT_FAILURE;
|
||||
|
@@ -118,20 +118,20 @@ int main(int argc, char **argv)
|
||||
|
||||
/* open the stream and dump it */
|
||||
|
||||
Mutex mutex;
|
||||
Cond cond;
|
||||
|
||||
InputStream *is = InputStream::OpenReady(argv[1], mutex, cond, error);
|
||||
int ret;
|
||||
if (is != NULL) {
|
||||
ret = dump_input_stream(is);
|
||||
delete is;
|
||||
} else {
|
||||
if (error.IsDefined())
|
||||
LogError(error);
|
||||
else
|
||||
fprintf(stderr, "input_stream::Open() failed\n");
|
||||
ret = EXIT_FAILURE;
|
||||
{
|
||||
Mutex mutex;
|
||||
Cond cond;
|
||||
auto is = InputStream::OpenReady(argv[1], mutex, cond, error);
|
||||
if (is) {
|
||||
ret = dump_input_stream(is.get());
|
||||
} else {
|
||||
if (error.IsDefined())
|
||||
LogError(error);
|
||||
else
|
||||
fprintf(stderr, "input_stream::Open() failed\n");
|
||||
ret = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* deinitialize everything */
|
||||
|
Reference in New Issue
Block a user