| { | { | ||||
| __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; | ||||
| } | } |