5 #include <BlueVelvet4.h>
\r
6 #include "../../frame/frame_format.h"
\r
7 #include "exception.h"
\r
9 namespace caspar { namespace bluefish {
\r
11 static const size_t MAX_HANC_BUFFER_SIZE = 256*1024;
\r
12 static const size_t MAX_VBI_BUFFER_SIZE = 36*1920*4;
\r
14 struct page_locked_buffer
\r
17 page_locked_buffer(size_t size) : size_(size), data_(static_cast<unsigned char*>(::VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE)))
\r
20 BOOST_THROW_EXCEPTION(bluefish_exception() << msg_info("Failed to allocate memory for paged locked buffer."));
\r
21 if(::VirtualLock(data_.get(), size_) == 0)
\r
22 BOOST_THROW_EXCEPTION(bluefish_exception() << msg_info("Failed to lock memory for paged locked buffer."));
\r
25 static void reserve_working_size(size_t size)
\r
27 SIZE_T workingSetMinSize = 0, workingSetMaxSize = 0;
\r
28 if(::GetProcessWorkingSetSize(::GetCurrentProcess(), &workingSetMinSize, &workingSetMaxSize))
\r
30 CASPAR_LOG(debug) << TEXT("WorkingSet size: min = ") << workingSetMinSize << TEXT(", max = ") << workingSetMaxSize;
\r
32 workingSetMinSize += size;
\r
33 workingSetMaxSize += size;
\r
35 if(!::SetProcessWorkingSetSize(::GetCurrentProcess(), workingSetMinSize, workingSetMaxSize))
\r
36 BOOST_THROW_EXCEPTION(bluefish_exception() << msg_info("Failed set workingset."));
\r
40 PBYTE data() const { return data_.get(); }
\r
41 size_t size() const { return size_; }
\r
46 void operator()(LPVOID lpAddress)
\r
48 if(lpAddress != nullptr)
\r
49 try{::VirtualFree(lpAddress, 0, MEM_RELEASE);}catch(...){}
\r
54 std::unique_ptr<BYTE, virtual_free> data_;
\r
56 typedef std::shared_ptr<page_locked_buffer> page_locked_buffer_ptr;
\r