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

Method readPartial

source/core/StarAudio.cpp:471–496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469
470
471 size_t readPartial(int16_t* buffer, size_t bufferSize) {
472 if (bufferSize != NPos)
473 bufferSize = bufferSize * 2;
474 #ifndef STAR_STREAM_AUDIO
475 return m_memoryFile.read((char*)buffer, bufferSize) / 2;
476 #else
477 // Calculate remaining valid data
478 size_t currentPos = m_device->pos() - m_dataStart;
479 size_t remainingBytes = m_dataSize - currentPos;
480
481 // Limit read to remaining valid data
482 if (bufferSize > remainingBytes)
483 bufferSize = remainingBytes;
484
485 if (bufferSize == 0)
486 return 0;
487
488 size_t bytesRead = m_device->read((char*)buffer, bufferSize);
489
490 // Handle endianness conversion
491 for (size_t i = 0; i < bytesRead / 2; ++i)
492 fromByteOrder(ByteOrder::LittleEndian, ((char*)buffer) + i * 2, 2);
493
494 return bytesRead / 2;
495 #endif
496 }
497
498private:
499 #ifdef STAR_STREAM_AUDIO

Callers

nothing calls this directly

Calls 3

fromByteOrderFunction · 0.85
readMethod · 0.45
posMethod · 0.45

Tested by

no test coverage detected