| 120 | } |
| 121 | |
| 122 | bool 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 | |
| 151 | void TranscodingAudioDataStream::Dispose() { |
| 152 | if (this->pcmBuffer) { |
no test coverage detected