mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 20:13:36 +00:00
Don't allow waiting for or caching streams with indeterminate/infinite durations when transcoding.
This commit is contained in:
parent
57fc960f35
commit
960d40f8b2
@ -157,15 +157,28 @@ IDataStream* Transcoder::TranscodeOnDemand(
|
||||
prefs::transcoder_cache_count.c_str(),
|
||||
defaults::transcoder_cache_count);
|
||||
|
||||
TranscodingDataStream* transcoder = nullptr;
|
||||
|
||||
if (cacheCount > 0) {
|
||||
PruneTranscodeCache(context);
|
||||
|
||||
return new TranscodingDataStream(
|
||||
transcoder = new TranscodingDataStream(
|
||||
context, uri, tempFilename, expectedFilename, bitrate, format);
|
||||
|
||||
/* if the stream has an indeterminite length, close it down and
|
||||
re-open it without caching options; we don't want to fill up
|
||||
the storage disk */
|
||||
if (transcoder->Length() < 0) {
|
||||
transcoder->Release();
|
||||
delete transcoder;
|
||||
transcoder = new TranscodingDataStream(context, uri, bitrate, format);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return new TranscodingDataStream(context, uri, bitrate, format);
|
||||
transcoder = new TranscodingDataStream(context, uri, bitrate, format);
|
||||
}
|
||||
|
||||
return transcoder;
|
||||
}
|
||||
|
||||
IDataStream* Transcoder::TranscodeAndWait(
|
||||
@ -187,6 +200,14 @@ IDataStream* Transcoder::TranscodeAndWait(
|
||||
TranscodingDataStream* transcoder = new TranscodingDataStream(
|
||||
context, uri, tempFilename, expectedFilename, bitrate, format);
|
||||
|
||||
/* transcoders with a negative length have an indeterminate duration, so
|
||||
we disallow waiting for them because they may never finish */
|
||||
if (transcoder->Length() < 0) {
|
||||
transcoder->Release();
|
||||
delete transcoder;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char buffer[8192];
|
||||
while (!transcoder->Eof()) {
|
||||
transcoder->Read(buffer, sizeof(buffer));
|
||||
|
Loading…
Reference in New Issue
Block a user