VideoWindow::~VideoWindow() { int32 result; teardownwindow = true; wait_for_thread(fDrawThreadID, &result); _FreeBuffers(); delete fSettings; }
//----------------------------------------------------------------------------// CUDAImpl::~CUDAImpl() { std::string err; if(!_FreeBuffers(&err)) { std::cerr << err << std::endl; } err.clear(); if(!_UnloadModule(&err)) { std::cerr << err << std::endl; } }
//----------------------------------------------------------------------------// double CUDAImpl::Allocate(std::string * err) { _StartTimer(); if (!_FreeBuffers(err)) { return GPUIP_ERROR; } std::map<std::string,Buffer::Ptr>::const_iterator it; for(it = _buffers.begin(); it != _buffers.end(); ++it) { _cudaBuffers[it->second->name] = NULL; cudaError_t c_err = cudaMalloc(&_cudaBuffers[it->second->name], _BufferSize(it->second)); if(_cudaErrorMalloc(c_err, err)) { return GPUIP_ERROR; } } return _StopTimer(); }
/***************************************************************************** * VideoWindow::_AllocateBuffers *****************************************************************************/ status_t VideoWindow::_AllocateBuffers(int width, int height, int* mode) { // clear any old buffers _FreeBuffers(); // set default mode *mode = BITMAP; bitmap_count = 3; BRect bitmapFrame( 0, 0, width, height ); // read from config, if we are supposed to use overlay at all int noOverlay = !config_GetInt( p_vout, "overlay" ); /* Test for overlay capability: for every chroma in colspace, we try to do double-buffered overlay, single-buffered overlay or basic overlay. If nothing worked, we then have to work with a non-overlay BBitmap. */ for( int i = 0; i < COLOR_COUNT; i++ ) { if( noOverlay ) break; bitmap[0] = new BBitmap( bitmapFrame, B_BITMAP_WILL_OVERLAY | B_BITMAP_RESERVE_OVERLAY_CHANNEL, colspace[i].colspace ); if( bitmap[0] && bitmap[0]->InitCheck() == B_OK ) { colspace_index = i; *mode = OVERLAY; rgb_color key; view->SetViewOverlay( bitmap[0], bitmap[0]->Bounds(), view->Bounds(), &key, B_FOLLOW_ALL, B_OVERLAY_FILTER_HORIZONTAL | B_OVERLAY_FILTER_VERTICAL ); view->SetViewColor( key ); SetTitle( "VLC " PACKAGE_VERSION " (Overlay)" ); bitmap[1] = new BBitmap( bitmapFrame, B_BITMAP_WILL_OVERLAY, colspace[colspace_index].colspace); if( bitmap[1] && bitmap[1]->InitCheck() == B_OK ) { bitmap[2] = new BBitmap( bitmapFrame, B_BITMAP_WILL_OVERLAY, colspace[colspace_index].colspace); if( bitmap[2] && bitmap[2]->InitCheck() == B_OK ) { msg_Dbg( p_vout, "using double-buffered overlay" ); } else { msg_Dbg( p_vout, "using single-buffered overlay" ); bitmap_count = 2; delete bitmap[2]; bitmap[2] = NULL; } } else { msg_Dbg( p_vout, "using simple overlay" ); bitmap_count = 1; delete bitmap[1]; bitmap[1] = NULL; } break; } else { delete bitmap[0]; bitmap[0] = NULL; } } if (*mode == BITMAP) { msg_Warn( p_vout, "no possible overlay" ); // fallback to RGB colspace_index = DEFAULT_COL; // B_RGB32 bitmap[0] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace ); bitmap[1] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace ); bitmap[2] = new BBitmap( bitmapFrame, colspace[colspace_index].colspace ); SetTitle( "VLC " PACKAGE_VERSION " (Bitmap)" ); } // see if everything went well status_t status = B_ERROR; for (int32_t i = 0; i < bitmap_count; i++) { if (bitmap[i]) status = bitmap[i]->InitCheck(); if (status < B_OK) break; } if (status >= B_OK) { // clear bitmaps to black for (int32_t i = 0; i < bitmap_count; i++) _BlankBitmap(bitmap[i]); } return status; }