MCPcopy Create free account
hub / github.com/clangen/musikcube / CurlWriteCallback

Method CurlWriteCallback

src/plugins/httpdatastream/HttpDataStream.cpp:534–557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

532}
533
534size_t HttpDataStream::CurlWriteCallback(char *ptr, size_t size, size_t nmemb, void *userdata) {
535 HttpDataStream* stream = static_cast<HttpDataStream*>(userdata);
536
537 const size_t total = size * nmemb;
538 const size_t result = fwrite(ptr, size, nmemb, stream->writeFile);
539 fflush(stream->writeFile); /* normally we wouldn't want to do this, but it ensures
540 data written is available immediately to any simultaneous readers */
541 stream->written += result;
542
543 if (stream->written >= stream->chunkSizeBytes) {
544 stream->reader->Add(stream->written);
545 stream->written = 0;
546 }
547
548 if (stream->totalWritten > -1) {
549 stream->totalWritten += result;
550 if (stream->totalWritten >= stream->precacheSizeBytes) {
551 stream->startedContition.notify_all();
552 stream->totalWritten = -1;
553 }
554 }
555
556 return result;
557}
558
559size_t HttpDataStream::CurlReadHeaderCallback(char *buffer, size_t size, size_t nitems, void *userdata) {
560 HttpDataStream* stream = static_cast<HttpDataStream*>(userdata);

Callers

nothing calls this directly

Calls 1

AddMethod · 0.45

Tested by

no test coverage detected