| @@ -30,11 +30,11 @@ namespace juce | |||||
| namespace WindowsMediaCodec | namespace WindowsMediaCodec | ||||
| { | { | ||||
| class JuceIStream : public ComBaseClassHelper <IStream> | |||||
| class JuceIStream : public ComBaseClassHelper<IStream> | |||||
| { | { | ||||
| public: | public: | ||||
| JuceIStream (InputStream& in) noexcept | JuceIStream (InputStream& in) noexcept | ||||
| : ComBaseClassHelper <IStream> (0), source (in) | |||||
| : ComBaseClassHelper<IStream> (0), source (in) | |||||
| { | { | ||||
| } | } | ||||
| @@ -48,7 +48,7 @@ public: | |||||
| JUCE_COMRESULT Read (void* dest, ULONG numBytes, ULONG* bytesRead) | JUCE_COMRESULT Read (void* dest, ULONG numBytes, ULONG* bytesRead) | ||||
| { | { | ||||
| auto numRead = source.read (dest, numBytes); | |||||
| auto numRead = source.read (dest, (size_t) numBytes); | |||||
| if (bytesRead != nullptr) | if (bytesRead != nullptr) | ||||
| *bytesRead = numRead; | *bytesRead = numRead; | ||||
| @@ -33,6 +33,26 @@ int64 InputStream::getNumBytesRemaining() | |||||
| return len; | return len; | ||||
| } | } | ||||
| ssize_t InputStream::read (void* destBuffer, size_t size) | |||||
| { | |||||
| ssize_t totalRead = 0; | |||||
| while (size > 0) | |||||
| { | |||||
| auto numToRead = (int) std::min (size, (size_t) 0x70000000); | |||||
| auto numRead = read (juce::addBytesToPointer (destBuffer, totalRead), numToRead); | |||||
| jassert (numRead <= numToRead); | |||||
| if (numRead < 0) return (ssize_t) numRead; | |||||
| if (numRead == 0) break; | |||||
| size -= (size_t) numRead; | |||||
| totalRead += numRead; | |||||
| } | |||||
| return totalRead; | |||||
| } | |||||
| char InputStream::readByte() | char InputStream::readByte() | ||||
| { | { | ||||
| char temp = 0; | char temp = 0; | ||||
| @@ -77,6 +77,8 @@ public: | |||||
| */ | */ | ||||
| virtual int read (void* destBuffer, int maxBytesToRead) = 0; | virtual int read (void* destBuffer, int maxBytesToRead) = 0; | ||||
| ssize_t read (void* destBuffer, size_t maxBytesToRead); | |||||
| /** Reads a byte from the stream. | /** Reads a byte from the stream. | ||||
| If the stream is exhausted, this will return zero. | If the stream is exhausted, this will return zero. | ||||
| @see OutputStream::writeByte | @see OutputStream::writeByte | ||||