Skip to content

Commit cc4ed39

Browse files
committed
FLACDecoder begin() check state
1 parent 9ce1898 commit cc4ed39

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/AudioCodecs/CodecFLAC.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class FLACDecoder : public StreamingDecoder {
6060

6161
bool begin() {
6262
TRACEI();
63+
is_active = false;
6364
if (decoder == nullptr) {
6465
if ((decoder = FLAC__stream_decoder_new()) == NULL) {
6566
LOGE("ERROR: allocating decoder");
@@ -70,9 +71,9 @@ class FLACDecoder : public StreamingDecoder {
7071
}
7172

7273
// if it is already active we close it
73-
if (is_active){
74+
auto state = FLAC__stream_decoder_get_state(decoder);
75+
if (state != FLAC__STREAM_DECODER_UNINITIALIZED){
7476
FLAC__stream_decoder_finish(decoder);
75-
is_active = false;
7677
}
7778

7879
// deactivate md5 checking

0 commit comments

Comments
 (0)