diff options
author | Jean-Francois Mauguit <jfmauguit@mac.com> | 2024-09-24 09:03:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 09:03:25 -0400 |
commit | bab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/Input/in_wmvdrm/AllocLayer.h | |
parent | 4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff) | |
parent | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff) | |
download | winamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz |
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/Plugins/Input/in_wmvdrm/AllocLayer.h')
-rw-r--r-- | Src/Plugins/Input/in_wmvdrm/AllocLayer.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/Src/Plugins/Input/in_wmvdrm/AllocLayer.h b/Src/Plugins/Input/in_wmvdrm/AllocLayer.h new file mode 100644 index 00000000..ed07a3bd --- /dev/null +++ b/Src/Plugins/Input/in_wmvdrm/AllocLayer.h @@ -0,0 +1,80 @@ +#ifndef NULLSOFT_ALLOCLAYERH +#define NULLSOFT_ALLOCLAYERH + +#include "WMHandler.h" +#include "BufferPool.h" +#include <cassert> +class AllocLayer : public WMHandler +{ +public: + AllocLayer(IWMReader *reader) + : readerAdvanced(0), + listenOutput( -1), + maxSize(0) + + { + reader->QueryInterface(&readerAdvanced); + + } + ~AllocLayer() + { + if (readerAdvanced) + { + readerAdvanced->Release(); + readerAdvanced = 0; + } + } + + void Listen(long output) + { + listenOutput = output; + if (output != -1) + { + readerAdvanced->SetAllocateForOutput(listenOutput, TRUE); + readerAdvanced->GetMaxOutputSampleSize(listenOutput, &maxSize); + assert(maxSize>0); + pool.SetAllocSize(maxSize); + } + } + + void Listen(long output, long numBuffers) + { + listenOutput = output; + if (output != -1) + { + readerAdvanced->SetAllocateForOutput(listenOutput, TRUE); + readerAdvanced->GetMaxOutputSampleSize(listenOutput, &maxSize); + assert(maxSize>0); + pool.SetAllocSize(maxSize); + pool.PreAllocate(numBuffers); + pool.limit=numBuffers; + + } + } + + void FreeBuffers() + { + pool.FreeBuffers(); + } + + + BufferPool pool; +private: + + void AllocateOutput(long outputNum, long bufferSize, INSSBuffer *&buffer) + { + if (outputNum == listenOutput) + { + assert(maxSize >= bufferSize); + buffer = pool.GetBuffer(bufferSize); + } + else + WMHandler::AllocateOutput(outputNum, bufferSize, buffer); // let other handlers have a shot at it first. + } + + // WMHandler + long listenOutput; + DWORD maxSize; + IWMReaderAdvanced *readerAdvanced; +}; +#endif |