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

AddrType enums in roc_address #325

Closed alexandremgo closed 4 years ago

alexandremgo commented 4 years ago

Discussed in #300 : Moving AddrType enum to roc_address and creation of set_host_port(type, ...) and set_miface(type, ...).

I have some questions: 1) Should we keep set_host_port_ipv4(...), set_host_port_ipv6(...), set_miface_ipv4(...), and set_miface_ipv6(...) ?

2) Should we replace all the occurrences of those 4 methods by set_host_port(type, ...) and set_miface(type, ...) ?

3) Should we change version() to return the AddrType enum ?

gavv commented 4 years ago

Should we keep set_host_port_ipv4(...), set_host_port_ipv6(...), set_miface_ipv4(...), and set_miface_ipv6(...) ?

Let's drop them.

Should we replace all the occurrences of those 4 methods by set_host_port(type, ...) and set_miface(type, ...) ?

I think yes.

Should we change version() to return the AddrType enum ?

Also yes.

gavv commented 4 years ago

Two stylistic notes:

gavv commented 4 years ago

For switch-related compiler warning (currently in travis), we usually use this trick:

    switch ((unsigned)args.color_arg) {
    case color_arg_auto:
        core::Logger::instance().set_colors(
            core::colors_available() ? core::ColorsEnabled : core::ColorsDisabled);
        break;

    case color_arg_always:
        core::Logger::instance().set_colors(core::ColorsMode(core::ColorsEnabled));
        break;

    case color_arg_never:
        core::Logger::instance().set_colors(core::ColorsMode(core::ColorsDisabled));
        break;

    default:
        break;
    }

The cast and default branch are needed to shut up compilers. Otherwise some versions of gcc/clang will produce controversial warnings :/ I don't remember exactly, but probably you'll see those warning on travis.

gavv commented 4 years ago

BTW, another hint (if you didn't know): you can run CI builds locally, it may make the development cycle faster: https://roc-project.github.io/roc/docs/development/continuous_integration.html#run-locally

gavv commented 4 years ago

LGTM! Can we merge this?

gavv commented 4 years ago

I recently pushed roc_peer tests which also use set_host_port:

Could you please rebase and update them too?

alexandremgo commented 4 years ago

I recently pushed roc_peer tests which also use set_host_port:

* https://github.com/roc-project/roc/blob/807ec5fa06a8b630d42d5ce39f970d3741cf6d8a/src/tests/roc_peer/test_receiver.cpp#L45

* https://github.com/roc-project/roc/blob/807ec5fa06a8b630d42d5ce39f970d3741cf6d8a/src/tests/roc_peer/test_sender.cpp#L45

Could you please rebase and update them too?

Yep, done ;)

gavv commented 4 years ago

Thanks!

gavv commented 4 years ago

FYI: 70d3c5044391a75db1b517ced9771b9bf6b19262