| 497 | } |
| 498 | |
| 499 | int Voice::send(DataStreamBuffer& out, size_t budget) { |
| 500 | out.setByteOrder(ByteOrder::LittleEndian); |
| 501 | out.write<uint16_t>(VOICE_VERSION); |
| 502 | |
| 503 | MutexLocker encodeLock(m_encodeMutex); |
| 504 | |
| 505 | if (m_encodedChunks.empty()) |
| 506 | return 0; |
| 507 | |
| 508 | std::vector<ByteArray> encodedChunks = std::move(m_encodedChunks); |
| 509 | m_encodedChunksLength = 0; |
| 510 | |
| 511 | encodeLock.unlock(); |
| 512 | |
| 513 | for (auto& chunk : encodedChunks) { |
| 514 | out.write<uint32_t>(chunk.size()); |
| 515 | out.writeBytes(chunk); |
| 516 | if (budget && (budget -= min<size_t>(budget, chunk.size())) == 0) |
| 517 | break; |
| 518 | } |
| 519 | |
| 520 | m_lastSentTime = Time::monotonicMilliseconds(); |
| 521 | if (m_loopback) |
| 522 | receive(m_clientSpeaker, { out.ptr(), out.size() }); |
| 523 | return 1; |
| 524 | } |
| 525 | |
| 526 | bool Voice::receive(SpeakerPtr speaker, std::string_view view) { |
| 527 | if (!m_enabled || !speaker || view.empty()) |
nothing calls this directly
no test coverage detected