Index: apps/codecs/wav_enc.c =================================================================== --- apps/codecs/wav_enc.c (revision 14915) +++ apps/codecs/wav_enc.c (working copy) @@ -144,8 +144,10 @@ struct riff_header hdr; uint32_t data_size; + /* always _try_ to write the file header, even on error if (!is_file_data_ok(data)) return false; + */ if (ci->lseek(data->rec_file, 0, SEEK_SET) != 0 || ci->read(data->rec_file, &hdr, sizeof (hdr)) != sizeof (hdr)) @@ -387,7 +389,7 @@ /* reset parameters to initial state */ ci->enc_set_parameters(NULL); - + /* main application waits for this flag during encoder removing */ ci->enc_codec_loaded = 0; Index: firmware/pcm_record.c =================================================================== --- firmware/pcm_record.c (revision 14915) +++ firmware/pcm_record.c (working copy) @@ -1022,7 +1022,10 @@ INC_ENC_INDEX(enc_rd_index); if (errors != 0) + { + pcmrec_end_file(); break; + } if (flush_num == PCMREC_FLUSH_MINI && ++chunks_flushed >= MINI_CHUNKS) @@ -1632,7 +1635,6 @@ if (is_recording) break; pcmrec_close(); - reset_hardware(); /* Be sure other threads are released if waiting */ queue_clear(&pcmrec_queue); flush_interrupts = 0;