Selaa lähdekoodia

Fix memory leaks in AudioPlaySDcardWAV

dds
PaulStoffregen 11 vuotta sitten
vanhempi
commit
bf8cffdf02
1 muutettua tiedostoa jossa 22 lisäystä ja 2 poistoa
  1. +22
    -2
      Audio.cpp

+ 22
- 2
Audio.cpp Näytä tiedosto

{ {
__disable_irq(); __disable_irq();
if (state != STATE_STOP) { if (state != STATE_STOP) {
audio_block_t *b1 = block_left;
block_left = NULL;
audio_block_t *b2 = block_right;
block_right = NULL;
state = STATE_STOP; state = STATE_STOP;
__enable_irq(); __enable_irq();
if (b1) release(b1);
if (b2) release(b2);
wavfile.close(); wavfile.close();
} else { } else {
__enable_irq(); __enable_irq();
} else { } else {
// not good, no audio was transmitted // not good, no audio was transmitted
buffer_remaining = 0; buffer_remaining = 0;
if (block_left) release(block_left);
if (block_right) release(block_right);
if (block_left) {
release(block_left);
block_left = NULL;
}
if (block_right) {
release(block_right);
block_right = NULL;
}
// if we're still playing, well, there's going to // if we're still playing, well, there's going to
// be a gap in output, but we can't keep burning // be a gap in output, but we can't keep burning
// time trying to read more data. Hopefully things // time trying to read more data. Hopefully things
} }
// end of file reached or other reason to stop // end of file reached or other reason to stop
wavfile.close(); wavfile.close();
if (block_left) {
release(block_left);
block_left = NULL;
}
if (block_right) {
release(block_right);
block_right = NULL;
}
state_play = STATE_STOP; state_play = STATE_STOP;
state = STATE_STOP; state = STATE_STOP;
} }

Loading…
Peruuta
Tallenna