MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / send

Method send

source/frontend/StarVoice.cpp:499–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497}
498
499int 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
526bool Voice::receive(SpeakerPtr speaker, std::string_view view) {
527 if (!m_enabled || !speaker || view.empty())

Callers

nothing calls this directly

Calls 6

setByteOrderMethod · 0.80
emptyMethod · 0.45
unlockMethod · 0.45
sizeMethod · 0.45
writeBytesMethod · 0.45
ptrMethod · 0.45

Tested by

no test coverage detected