core: refactor channel count negotiation for cleaner code and saner error messages.