@@ -22,10 +22,11 @@ class FLACDecoderFoxen : public AudioDecoder {
22
22
23
23
// / Default Constructor
24
24
FLACDecoderFoxen (int maxBlockSize, int maxChannels,
25
- bool convertTo16Bits = true ) {
25
+ bool convertTo16Bits = true , bool releaseOnEnd = false ) {
26
26
is_convert_to_16 = convertTo16Bits;
27
27
max_block_size = maxBlockSize;
28
28
max_channels = maxChannels;
29
+ is_release_memory_on_end = releaseOnEnd;
29
30
};
30
31
31
32
// / Destructor - calls end();
@@ -36,10 +37,7 @@ class FLACDecoderFoxen : public AudioDecoder {
36
37
is_active = false ;
37
38
size_t foxen_size = fx_flac_size (max_block_size, max_channels);
38
39
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);
43
41
44
42
if (flac != nullptr ) {
45
43
is_active = true ;
@@ -55,13 +53,12 @@ class FLACDecoderFoxen : public AudioDecoder {
55
53
56
54
void end () {
57
55
TRACEI ();
58
- if (flac != nullptr ) {
59
- flush ();
56
+ flush ();
57
+ if (flac != nullptr && is_release_memory_on_end) {
60
58
foxen_data.resize (0 );
61
- flac = nullptr ;
59
+ write_buffer.resize (0 );
60
+ out.resize (0 );
62
61
}
63
- write_buffer.resize (0 );
64
- out.resize (0 );
65
62
is_active = false ;
66
63
}
67
64
@@ -115,6 +112,7 @@ class FLACDecoderFoxen : public AudioDecoder {
115
112
bool is_active = false ;
116
113
bool is_convert_to_16 = true ;
117
114
bool is_stop_on_error = true ;
115
+ bool is_release_memory_on_end = false ;
118
116
int bits_eff = 0 ;
119
117
int max_block_size = 5 * 1024 ;
120
118
int max_channels = 2 ;
0 commit comments