decoder/modplug: move code to LoadModPlugFile()
This commit is contained in:
parent
86f08862e4
commit
10196496f3
@ -106,22 +106,27 @@ mod_loadfile(struct decoder *decoder, struct input_stream *is)
|
|||||||
return bdatas;
|
return bdatas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ModPlugFile *
|
||||||
|
LoadModPlugFile(struct decoder *decoder, struct input_stream *is)
|
||||||
|
{
|
||||||
|
const auto bdatas = mod_loadfile(decoder, is);
|
||||||
|
if (!bdatas) {
|
||||||
|
LogWarning(modplug_domain, "could not load stream");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ModPlugFile *f = ModPlug_Load(bdatas->data, bdatas->len);
|
||||||
|
g_byte_array_free(bdatas, TRUE);
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mod_decode(struct decoder *decoder, struct input_stream *is)
|
mod_decode(struct decoder *decoder, struct input_stream *is)
|
||||||
{
|
{
|
||||||
ModPlugFile *f;
|
|
||||||
ModPlug_Settings settings;
|
ModPlug_Settings settings;
|
||||||
GByteArray *bdatas;
|
|
||||||
int ret;
|
int ret;
|
||||||
char audio_buffer[MODPLUG_FRAME_SIZE];
|
char audio_buffer[MODPLUG_FRAME_SIZE];
|
||||||
|
|
||||||
bdatas = mod_loadfile(decoder, is);
|
|
||||||
|
|
||||||
if (!bdatas) {
|
|
||||||
LogWarning(modplug_domain, "could not load stream");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ModPlug_GetSettings(&settings);
|
ModPlug_GetSettings(&settings);
|
||||||
/* alter setting */
|
/* alter setting */
|
||||||
settings.mResamplingMode = MODPLUG_RESAMPLE_FIR; /* RESAMP */
|
settings.mResamplingMode = MODPLUG_RESAMPLE_FIR; /* RESAMP */
|
||||||
@ -132,9 +137,8 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
|
|||||||
/* insert more setting changes here */
|
/* insert more setting changes here */
|
||||||
ModPlug_SetSettings(&settings);
|
ModPlug_SetSettings(&settings);
|
||||||
|
|
||||||
f = ModPlug_Load(bdatas->data, bdatas->len);
|
ModPlugFile *f = LoadModPlugFile(decoder, is);
|
||||||
g_byte_array_free(bdatas, TRUE);
|
if (f == nullptr) {
|
||||||
if (!f) {
|
|
||||||
LogWarning(modplug_domain, "could not decode stream");
|
LogWarning(modplug_domain, "could not decode stream");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -173,15 +177,7 @@ static bool
|
|||||||
modplug_scan_stream(struct input_stream *is,
|
modplug_scan_stream(struct input_stream *is,
|
||||||
const struct tag_handler *handler, void *handler_ctx)
|
const struct tag_handler *handler, void *handler_ctx)
|
||||||
{
|
{
|
||||||
ModPlugFile *f;
|
ModPlugFile *f = LoadModPlugFile(nullptr, is);
|
||||||
GByteArray *bdatas;
|
|
||||||
|
|
||||||
bdatas = mod_loadfile(nullptr, is);
|
|
||||||
if (!bdatas)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
f = ModPlug_Load(bdatas->data, bdatas->len);
|
|
||||||
g_byte_array_free(bdatas, TRUE);
|
|
||||||
if (f == nullptr)
|
if (f == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user