diff --git a/src/kits/media/ChunkCache.cpp b/src/kits/media/ChunkCache.cpp index c88570d542..951a684ee4 100644 --- a/src/kits/media/ChunkCache.cpp +++ b/src/kits/media/ChunkCache.cpp @@ -93,7 +93,7 @@ ChunkCache::PutNextChunk(void *chunkBuffer, int32 chunkSize, const media_header if (err == B_OK) { if (fNextPut->sizeMax < chunkSize) { -// printf("ChunkCache::PutNextChunk: %p resizing from %ld to %ld\n", fNextPut, fNextPut->sizeMax, chunkSize); + printf("ChunkCache::PutNextChunk: %p resizing from %ld to %ld\n", fNextPut, fNextPut->sizeMax, chunkSize); free(fNextPut->buffer); fNextPut->buffer = malloc((chunkSize + 1024) & ~1023); fNextPut->sizeMax = chunkSize; diff --git a/src/kits/media/MediaExtractor.cpp b/src/kits/media/MediaExtractor.cpp index d9caadf737..0300d4f2f3 100644 --- a/src/kits/media/MediaExtractor.cpp +++ b/src/kits/media/MediaExtractor.cpp @@ -7,6 +7,8 @@ #include #include +// should be 0, to disable the chunk cache set it to 1 +#define DISABLE_CHUNK_CACHE 0 MediaExtractor::MediaExtractor(BDataIO *source, int32 flags) { @@ -62,10 +64,12 @@ MediaExtractor::MediaExtractor(BDataIO *source, int32 flags) } } +#if DISABLE_CHUNK_CACHE == 0 // start extractor thread fExtractorWaitSem = create_sem(1, "media extractor thread sem"); fExtractorThread = spawn_thread(extractor_thread, "media extractor thread", 10, this); - resume_thread(fExtractorThread); + resume_thread(fExtractorThread); +#endif } @@ -182,6 +186,12 @@ MediaExtractor::GetNextChunk(int32 stream, void **chunkBuffer, int32 *chunkSize, media_header *mediaHeader) { +#if DISABLE_CHUNK_CACHE > 0 + static BLocker locker; + BAutolock lock(locker); + return fReader->GetNextChunk(fStreamInfo[stream].cookie, chunkBuffer, chunkSize, mediaHeader); +#endif + status_t err; err = fStreamInfo[stream].chunkCache->GetNextChunk(chunkBuffer, chunkSize, mediaHeader); release_sem(fExtractorWaitSem);