decoder/wavpack: wavpack_open_wvc() returns InputStreamPtr
Let std::unique_ptr manage both the InputStream and the WavpackInput.
This commit is contained in:
parent
fe9bafa741
commit
38d587aaeb
|
@ -475,7 +475,7 @@ static WavpackStreamReader mpd_is_reader = {
|
||||||
nullptr /* no need to write edited tags */
|
nullptr /* no need to write edited tags */
|
||||||
};
|
};
|
||||||
|
|
||||||
static WavpackInput *
|
static InputStreamPtr
|
||||||
wavpack_open_wvc(Decoder &decoder, const char *uri)
|
wavpack_open_wvc(Decoder &decoder, const char *uri)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -490,11 +490,7 @@ wavpack_open_wvc(Decoder &decoder, const char *uri)
|
||||||
free(wvc_url);
|
free(wvc_url);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto is_wvc = decoder_open_uri(decoder, uri, IgnoreError());
|
return decoder_open_uri(decoder, uri, IgnoreError());
|
||||||
if (is_wvc == nullptr)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
return new WavpackInput(decoder, *is_wvc.release());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -506,18 +502,14 @@ wavpack_streamdecode(Decoder &decoder, InputStream &is)
|
||||||
int open_flags = OPEN_NORMALIZE;
|
int open_flags = OPEN_NORMALIZE;
|
||||||
bool can_seek = is.IsSeekable();
|
bool can_seek = is.IsSeekable();
|
||||||
|
|
||||||
WavpackInput *wvc = wavpack_open_wvc(decoder, is.GetURI());
|
std::unique_ptr<WavpackInput> wvc;
|
||||||
if (wvc != nullptr) {
|
auto is_wvc = wavpack_open_wvc(decoder, is.GetURI());
|
||||||
|
if (is_wvc) {
|
||||||
open_flags |= OPEN_WVC;
|
open_flags |= OPEN_WVC;
|
||||||
can_seek &= wvc->is.IsSeekable();
|
can_seek &= wvc->is.IsSeekable();
|
||||||
}
|
|
||||||
|
|
||||||
AtScopeExit(wvc) {
|
wvc.reset(new WavpackInput(decoder, *is_wvc));
|
||||||
if (wvc != nullptr) {
|
}
|
||||||
delete &wvc->is;
|
|
||||||
delete wvc;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!can_seek) {
|
if (!can_seek) {
|
||||||
open_flags |= OPEN_STREAMING;
|
open_flags |= OPEN_STREAMING;
|
||||||
|
@ -527,7 +519,7 @@ wavpack_streamdecode(Decoder &decoder, InputStream &is)
|
||||||
|
|
||||||
char error[ERRORLEN];
|
char error[ERRORLEN];
|
||||||
WavpackContext *wpc =
|
WavpackContext *wpc =
|
||||||
WavpackOpenFileInputEx(&mpd_is_reader, &isp, wvc,
|
WavpackOpenFileInputEx(&mpd_is_reader, &isp, wvc.get(),
|
||||||
error, open_flags, 23);
|
error, open_flags, 23);
|
||||||
|
|
||||||
if (wpc == nullptr) {
|
if (wpc == nullptr) {
|
||||||
|
|
Loading…
Reference in New Issue