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

Method Close

src/plugins/server/TranscodingAudioDataStream.cpp:122–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122bool TranscodingAudioDataStream::Close() {
123 if (this->eof) {
124 this->Dispose();
125 }
126 else {
127 std::thread([this]() { /* detach and finish. hopefully. */
128 char buffer[8192];
129 int count = 0;
130 int last = 0;
131 while (!Eof() && count < detachTolerance) {
132 last = Read(buffer, sizeof(buffer));
133 count += last;
134 }
135
136 if (last != 0 && this->outFile) {
137 /* incomplete, delete... */
138 fclose(this->outFile);
139 this->outFile = nullptr;
140 std::error_code ec;
141 fs::remove(fs::u8path(this->tempFilename), ec);
142 }
143
144 Dispose();
145 }).detach();
146 }
147
148 return true;
149}
150
151void TranscodingAudioDataStream::Dispose() {
152 if (this->pcmBuffer) {

Callers 1

fileFreeCallbackFunction · 0.45

Calls 3

DisposeMethod · 0.95
ReadFunction · 0.85
detachMethod · 0.45

Tested by

no test coverage detected