return bytes written on success return -1 on error
| 255 | // return bytes written on success |
| 256 | // return -1 on error |
| 257 | static inline int encode_audio(bool encrypted, const audio::buffer_t &plaintext, uint8_t *destination, crypto::aes_t &iv, crypto::cipher::cbc_t &cbc) { |
| 258 | // If encryption isn't enabled |
| 259 | if (!encrypted) { |
| 260 | std::copy(std::begin(plaintext), std::end(plaintext), destination); |
| 261 | return plaintext.size(); |
| 262 | } |
| 263 | |
| 264 | return cbc.encrypt(std::string_view {(char *) std::begin(plaintext), plaintext.size()}, destination, &iv); |
| 265 | } |
| 266 | |
| 267 | static inline void while_starting_do_nothing(std::atomic<session::state_e> &state) { |
| 268 | while (state.load(std::memory_order_acquire) == session::state_e::STARTING) { |
no test coverage detected