In Erel's example you have no influence on the amout of bytes that arrived in this moment, when streamer_RecordBuffer is called.
I think you will need a second buffer, where you copy the bytes of streamer_RecordBuffer instead of writing them directly to the file.
Also it it necessary to convert them into SHORTs to be able to check if the sample value is smaller then the threshold. As the AudioStreamer sends Bytes, two bytes together build the samples value: 256*Byte(1)+Byte(0). Therefore you need the ByteConverter library with the LittleEndian-Flag set to TRUE.
In the new SHORT-Buffer you first collect a lot of streamer_RecordBuffer Bytes, then check the buffer if you find any value higher than the threshold. Here starts your saving Now check the buffer if you find 110.250 Values (5*22050) below the threshold. Remember the beginning of this part. Then save the buffer from start to this beginning. Now check again for finding any value higher than the threshold to start the procedure again.
For saving the samples, you need to convert them back to BYTES with ByteConverter with the LittleEndian-Flag set to TRUE.
You could work with two SHORT-buffers. One for the receiving of the recordings, the other for checking an saving. Then switch the buffers.
Or you can use more elegant a ring buffer for continuously writing and reading in the same buffer. You will find my tutorial about audio ring buffers here in the forum. It is only a example for AUDIO OUTPUT RING BUFFER, but it shows the way and can be used also for develope a recording ring buffer.