decoder/mpcdec: use AtScopeExit()
This commit is contained in:
parent
a88040e4d5
commit
1a8c96a3f0
|
@ -27,6 +27,7 @@
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "util/Macros.hxx"
|
#include "util/Macros.hxx"
|
||||||
#include "util/Clamp.hxx"
|
#include "util/Clamp.hxx"
|
||||||
|
#include "util/ScopeExit.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <mpc/mpcdec.h>
|
#include <mpc/mpcdec.h>
|
||||||
|
@ -158,6 +159,8 @@ mpcdec_decode(DecoderClient &client, InputStream &is)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AtScopeExit(demux) { mpc_demux_exit(demux); };
|
||||||
|
|
||||||
mpc_streaminfo info;
|
mpc_streaminfo info;
|
||||||
mpc_demux_get_info(demux, &info);
|
mpc_demux_get_info(demux, &info);
|
||||||
|
|
||||||
|
@ -217,8 +220,6 @@ mpcdec_decode(DecoderClient &client, InputStream &is)
|
||||||
chunk, ret * sizeof(chunk[0]),
|
chunk, ret * sizeof(chunk[0]),
|
||||||
bit_rate);
|
bit_rate);
|
||||||
} while (cmd != DecoderCommand::STOP);
|
} while (cmd != DecoderCommand::STOP);
|
||||||
|
|
||||||
mpc_demux_exit(demux);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SignedSongTime
|
static SignedSongTime
|
||||||
|
@ -238,9 +239,10 @@ mpcdec_get_file_duration(InputStream &is)
|
||||||
if (demux == nullptr)
|
if (demux == nullptr)
|
||||||
return SignedSongTime::Negative();
|
return SignedSongTime::Negative();
|
||||||
|
|
||||||
|
AtScopeExit(demux) { mpc_demux_exit(demux); };
|
||||||
|
|
||||||
mpc_streaminfo info;
|
mpc_streaminfo info;
|
||||||
mpc_demux_get_info(demux, &info);
|
mpc_demux_get_info(demux, &info);
|
||||||
mpc_demux_exit(demux);
|
|
||||||
|
|
||||||
return SongTime::FromS(mpc_streaminfo_get_length(&info));
|
return SongTime::FromS(mpc_streaminfo_get_length(&info));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue