Skip to content

Commit 42d08cc

Browse files
committed
FLACDecoderFoxen: releaseOnEnd = false
1 parent 1d72090 commit 42d08cc

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/AudioTools/AudioCodecs/CodecFLACFoxen.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ class FLACDecoderFoxen : public AudioDecoder {
2222

2323
/// Default Constructor
2424
FLACDecoderFoxen(int maxBlockSize, int maxChannels,
25-
bool convertTo16Bits = true) {
25+
bool convertTo16Bits = true, bool releaseOnEnd = false) {
2626
is_convert_to_16 = convertTo16Bits;
2727
max_block_size = maxBlockSize;
2828
max_channels = maxChannels;
29+
is_release_memory_on_end = releaseOnEnd;
2930
};
3031

3132
/// Destructor - calls end();
@@ -36,10 +37,7 @@ class FLACDecoderFoxen : public AudioDecoder {
3637
is_active = false;
3738
size_t foxen_size = fx_flac_size(max_block_size, max_channels);
3839
foxen_data.resize(foxen_size);
39-
40-
if (foxen_data.data() != nullptr) {
41-
flac = fx_flac_init(foxen_data.data(), max_block_size, max_channels);
42-
}
40+
flac = fx_flac_init(foxen_data.data(), max_block_size, max_channels);
4341

4442
if (flac != nullptr) {
4543
is_active = true;
@@ -55,13 +53,12 @@ class FLACDecoderFoxen : public AudioDecoder {
5553

5654
void end() {
5755
TRACEI();
58-
if (flac != nullptr) {
59-
flush();
56+
flush();
57+
if (flac != nullptr && is_release_memory_on_end) {
6058
foxen_data.resize(0);
61-
flac = nullptr;
59+
write_buffer.resize(0);
60+
out.resize(0);
6261
}
63-
write_buffer.resize(0);
64-
out.resize(0);
6562
is_active = false;
6663
}
6764

@@ -115,6 +112,7 @@ class FLACDecoderFoxen : public AudioDecoder {
115112
bool is_active = false;
116113
bool is_convert_to_16 = true;
117114
bool is_stop_on_error = true;
115+
bool is_release_memory_on_end = false;
118116
int bits_eff = 0;
119117
int max_block_size = 5 * 1024;
120118
int max_channels = 2;

0 commit comments

Comments
 (0)