Closed gavv closed 11 months ago
Is this issue dependent on #302 or can be done independently?
Technically we can do them in parallel, but I would postpone this one until #302 is merged. Maybe it will raise some new issues to us.
It's been decided to change the initial design a little bit:
FYI @gavv
Landed!
Problem
Here is how packet::IReader and packet::IWriter interfaces look like currently:
We need two improvements here:
Solution
Convert the above interfaces to the following:
In particular:
On success, read() and write() will return zero. read() will set the passed PacketPtr to the packet read.
On failure, read() and write() will return a negative error code defined in roc_error module (roc_error/error_code.h).
After changing the interfaces, we should also find and fix all packet::IReader and packet::IWriter implementations:
Fix function signature.
Fix invocation of nested audio readers and writers. If nested reader / writer returns a negative value, we should break and return that value to the upper level.
Fix audio::Depacketizer and audio::Packetizer. When #302 will be done, they should forward the error code returned by packet reader / writer to the upper level. Until #302 is done, they can just panic on such error.
Fix unit tests for the modified components and add a few tests for the new behavior (test that error codes are forwarded correctly).
Notes
Since currently read() and write() can not fail, after this change all implementations will actually always report success, and error handling code will never trigger, except unit tests.
However, after finishing this task we will be able to add error reporting to some components. This will be done separately.