roc-streaming / roc-toolkit

Real-time audio streaming over the network.
https://roc-streaming.org
Mozilla Public License 2.0
1.06k stars 213 forks source link

Support status codes in packet readers and writers #303

Closed gavv closed 11 months ago

gavv commented 4 years ago

Problem

Here is how packet::IReader and packet::IWriter interfaces look like currently:

class IReader {
public:
    virtual PacketPtr read() = 0;
};

class IWriter {
public:
    virtual void write(const PacketPtr&) = 0;
};

We need two improvements here:

Solution

Convert the above interfaces to the following:

class IReader {
public:
    virtual int read(PacketPtr&) = 0;
};

class IWriter {
public:
    virtual int write(const PacketPtr&) = 0;
};

In particular:

After changing the interfaces, we should also find and fix all packet::IReader and packet::IWriter implementations:

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.

fusuiyi123 commented 4 years ago

Is this issue dependent on #302 or can be done independently?

gavv commented 4 years ago

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.

dshil commented 1 year ago

It's been decided to change the initial design a little bit:

FYI @gavv

gavv commented 11 months ago

Landed!