Hello,
I'm using an AsyncStreams object to write data packets to a file:
Sometimes I noted that a few packets get lost (the number of packets inside outFile is lower than packet_counter).
I don't know how this happens, I suspect this could be due to a sort of buffer overrun inside the AsyncStreams thread (may be the internal queue overruns?).
In any case AStreamWriter_Error() subroutine is never called.
What can I do to avoid this loss of data?
Is there a way to know if asyncFile can't accept further data so to avoid to call asyncFile.Write(data) during this condition?
Any idea on how to fix this issue will be greatly appreciated
I'm using an AsyncStreams object to write data packets to a file:
B4X:
...
Dim asyncFile As AsyncStreams
Dim outFile as OutputStream
outFile = File.OpenOutput(dir, fileName, True)
asyncFile.Initialize(Null,outFile,"AStreamWriter")
...
Sub Packet_Ready(data() As Byte)
packet_counter = packet_counter+1
asyncFile.Write(data)
End Sub
Sometimes I noted that a few packets get lost (the number of packets inside outFile is lower than packet_counter).
I don't know how this happens, I suspect this could be due to a sort of buffer overrun inside the AsyncStreams thread (may be the internal queue overruns?).
In any case AStreamWriter_Error() subroutine is never called.
What can I do to avoid this loss of data?
Is there a way to know if asyncFile can't accept further data so to avoid to call asyncFile.Write(data) during this condition?
Any idea on how to fix this issue will be greatly appreciated