void Close() { if (--myRefs == 0) { _Close(); delete this; } else _Close(); }
bool AviFrameGraber::_Open(void){ //thread_handle_ !=NULL means it is already opened if (thread_handle_!=NULL) return false; int res=AVIFileOpen(&avi_file_, file_path_.c_str(), OF_READ, NULL); if (res!=AVIERR_OK){ woodychang0611::diagnostics::SendError(_T("AviFrameGraber Open File Fail")); _Close(); return false; } res=AVIFileGetStream(avi_file_, &stream_, streamtypeVIDEO, 0/*first stream*/); if (res!=AVIERR_OK){ woodychang0611::diagnostics::SendError(_T("AviFrameGraber Get Stream Fail")); _Close(); return false; } if (AVIStreamStart(stream_)==-1 || AVIStreamLength(stream_)==-1){ woodychang0611::diagnostics::SendError(_T("AviFrameGraber Stream Start or Length no correct")); _Close(); return false; } AVIFileInfo(avi_file_, &avi_info_, sizeof(AVIFILEINFO)); BITMAPINFOHEADER bih; bih.biSize = sizeof(BITMAPINFOHEADER); bih.biWidth = avi_info_.dwWidth; bih.biHeight = avi_info_.dwHeight; bih.biPlanes = 1; bih.biBitCount = 24; bih.biCompression = BI_RGB; bih.biSizeImage = 0; bih.biXPelsPerMeter = 0; bih.biYPelsPerMeter = 0; bih.biClrUsed = 0; bih.biClrImportant = 0; frame_=AVIStreamGetFrameOpen(stream_, (LPBITMAPINFOHEADER) &bih); if (frame_ !=NULL){ start_frame_ = AVIStreamStart(stream_); frame_length_ = AVIStreamLength(stream_); current_frame_ = start_frame_; //Set Frame info frame_info_.start_frame_=start_frame_; frame_info_.frame_length_ =frame_length_; frame_info_.frame_per_second_=(FLOAT32)avi_info_.dwRate/avi_info_.dwScale; frame_info_.frame_width_=(UINT16) avi_info_.dwWidth; frame_info_.frame_height_=(UINT16) avi_info_.dwHeight; _status = FRAME_SUBJECT_PAUSE; thread_handle_ =CreateThread(NULL ,0,this->_ThreadFunc,this,0,NULL); return true; }else{ woodychang0611::diagnostics::SendError(_T("AviFrameGraber Get Frame Failed")); } return false; }
void Free() { if (--myRefs == 0) { _Close(); delete this; } }
void Sprite::Close() { _Release(m_pVertexBuffer); _Release(m_pIndexBuffer); _Release(m_pConstantBuffer); _Close(m_pShader); }
int GDocApp<OptionsFmt>::OnCommand(int Cmd, int Event, OsView Window) { switch (Cmd) { case IDM_SAVE: { if (!GetCurFile()) { GMru::OnCommand(IDM_SAVEAS); return 0; } else { _SaveFile(GetCurFile()); return 0; } break; } case IDM_CLOSE: { if (SetDirty(false)) _Close(); break; } case IDM_EXIT: { LgiCloseApp(); break; } } GMru::OnCommand(Cmd); return 0; }
void Close(void) { _Close(); call_no = 0; functions = std::vector<bool>(); structs = std::vector<bool>(); enums = std::vector<bool>(); bitmasks = std::vector<bool>(); }
void CSSLClientAsync::Close() { _SetWaitForClose(TRUE); m_sendqueuemutex.Lock(); if (m_sendqueue.size() == 0) { _Close(); } m_sendqueuemutex.Unlock(); }
LRESULT GameMainDlg::OnGameClose(UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == msg_game_quit) { _Close(); } return TRUE; }
bool BWrepFile::Load(const char* pszFileName, int options, void *rwaheader, int size) { if (pszFileName == NULL) return false; // offset of RWA (if any) #ifdef USE_RWA_CODE m_rwaoffset=0; #endif bool bOk = _Open(pszFileName); if(bOk) { long nRepID; unpack_section(m_pFile, (byte*)&nRepID, sizeof(nRepID)); bOk = (nRepID == kBWREP_ID); if (bOk) { // read header bOk = (unpack_section(m_pFile, (byte*)&m_oHeader, kBWREP_HEADER_SIZE)==0); m_oHeader.checkPlayerNameUnicity(); // read actions #ifdef USE_ACTIONS_CODE if(bOk) bOk = _LoadActions(m_pFile,(options&ADDACTIONS)==0,(options&LOADACTIONS)!=0); // load map #ifdef USE_MAP_CODE if(bOk) { bOk = _LoadMap(m_pFile, (options&LOADMAP)!=0); #ifdef USE_RWA_CODE if(bOk && rwaheader!=0) { // read audio header and return file pointer on audio data memset(rwaheader,0,size); unsigned long *headerSize; headerSize=(unsigned long *)rwaheader; if(fread(rwaheader,1,sizeof(long),m_pFile)==sizeof(long)) { size_t readsize; readsize = min((unsigned long)size,*headerSize)-sizeof(long); fread(((char*)rwaheader)+sizeof(long),1,readsize,m_pFile); if(*headerSize>(unsigned long)size) fseek(m_pFile,(*headerSize)-size,SEEK_CUR); m_rwaoffset = ftell(m_pFile); } } #endif } #endif #endif } _Close(); } return bOk; }
bool SFB::Audio::Output::Close() { LOGGER_DEBUG("org.sbooth.AudioEngine.Output", "Closing output"); if(!_IsOpen()) return true; return _Close(); }
void RasterWeather::Reload(int day_time) { static unsigned last_weather_time; bool found = false; bool now = false; if (_parameter == 0) // will be drawing terrain return; Poco::ScopedRWLock protect(lock, true); if (_weather_time == 0) { // "Now" time, so find time in half hours unsigned half_hours = (TimeLocal(day_time) / 1800) % 48; _weather_time = max(_weather_time, half_hours); now = true; } // limit values, for safety _weather_time = min(MAX_WEATHER_TIMES - 1, _weather_time); if (_weather_time != last_weather_time) reload = true; if (!reload) { // no change, quick exit. if (now) // must return to 0 = Now time on exit _weather_time = 0; return; } reload = false; last_weather_time = _weather_time; // scan forward to next valid time while ((_weather_time < MAX_WEATHER_TIMES) && (!found)) { if (!weather_available[_weather_time]) { _weather_time++; } else { found = true; _Close(); if (!LoadItem(WeatherDescriptors[_parameter].name, _weather_time) && _parameter == 1) LoadItem(_T("wstar_bsratio"), _weather_time); } } // can't find valid time, so reset to zero if (!found || now) _weather_time = 0; }
// get offset in file of audio part (if any, 0 if none) unsigned long BWrepFile::GetAudioOffset(const char* pszFileName, void *header, int size) { unsigned long offset=0; bool bOk = _Open(pszFileName); if(!bOk) return 0; long nRepID; int res = unpack_section(m_pFile, (byte*)&nRepID, sizeof(nRepID)); if(nRepID != kBWREP_ID) goto Exit; if(res!=0) goto Exit; // read header bOk = (unpack_section(m_pFile, (byte*)&m_oHeader, kBWREP_HEADER_SIZE)==0); if(!bOk) goto Exit; // get actions section size int cmdSize; cmdSize=0; res = unpack_section(m_pFile, (byte*)&cmdSize, sizeof(cmdSize)); if(res!=0) goto Exit; // alloc buffer to read it byte *buffer; buffer = (byte *)malloc(cmdSize * sizeof(byte)); if (buffer==0) goto Exit; // unpack cmd section in buffer res = unpack_section(m_pFile, buffer, cmdSize); if(res!=0) goto Exit; free(buffer); // get map section size int mapSize; mapSize=0; res = unpack_section(m_pFile, (byte*)&mapSize, sizeof(mapSize)); if(res!=0) goto Exit; // alloc buffer to read it buffer = (byte *)malloc(mapSize * sizeof(byte)); if (buffer==0) goto Exit; // unpack map section in buffer res = unpack_section(m_pFile, buffer, mapSize); if(res!=0) goto Exit; free(buffer); // read audio header and return file pointer on audio data unsigned long *headerSize; headerSize=(unsigned long *)header; if(fread(header,1,sizeof(long),m_pFile)!=sizeof(long)) goto Exit; size_t readsize; readsize = min((unsigned long)size,*headerSize)-sizeof(long); fread(((char*)header)+sizeof(long),1,readsize,m_pFile); if(*headerSize>(unsigned long)size) fseek(m_pFile,(*headerSize)-size,SEEK_CUR); offset = ftell(m_pFile); Exit: _Close(); return offset; }
int fwt_close (int fd) { if (!current_write_ignored) { int ret = _Close(fd); //imagesavecomplete=1; fwt_bytes_written = 0; return ret; } filewrite_jpeg_complete(); return 0; }
bool SFB::InputSource::Close(CFErrorRef *error) { if(!IsOpen()) { LOGGER_WARNING("org.sbooth.AudioEngine.InputSource", "Close() called on an InputSource that hasn't been opened"); return true; } bool result = _Close(error); if(result) mIsOpen = false; return result; }
void CRzLog::_NewLog(tm* atm) { static char_type sformat[7][24] = {_T("%Y"),_T("%Y%m"),_T("%Y%m%d"),_T("%Y%m%d_%H"), _T("%Y%m%d_%H_%M"),_T("%Y%m%d_%H_%M_%S")}; char_type buffer[24] = {0}; DFn_strftime(buffer,24,sformat[_type],atm); if(DFn_strcmp(buffer,_timename) != 0) { DFn_strcpy_s(_timename,512,buffer); _Close(); _Open(); } }
ConfigFile::~ConfigFile() { /* 功能:关闭输入输出流 参数:无 返回值:无 */ _Close(); #ifndef WIN32 //delete decrypt file if(m_acDecryptedFile[0] != '\0') { remove(m_acDecryptedFile); } #endif }
SInt64 SFB::Audio::MODDecoder::_SeekToFrame(SInt64 frame) { // DUMB cannot seek backwards, so the decoder must be reset if(frame < mCurrentFrame) { if(!_Close(nullptr) || !mInputSource->SeekToOffset(0) || !_Open(nullptr)) { LOGGER_ERR("org.sbooth.AudioEngine.Decoder.MOD", "Error reseting DUMB decoder"); return -1; } mCurrentFrame = 0; } long framesToSkip = frame - mCurrentFrame; duh_sigrenderer_generate_samples(dsr.get(), 1, 65536.0f / DUMB_SAMPLE_RATE, framesToSkip, nullptr); mCurrentFrame += framesToSkip; return mCurrentFrame; }
bool SFB::Audio::Decoder::Close(CFErrorRef *error) { if(!IsOpen()) { LOGGER_INFO("org.sbooth.AudioEngine.Decoder", "Close() called on a Decoder that hasn't been opened"); return true; } // Close the decoder bool result = _Close(error); if(result) mIsOpen = false; // Close the input source if(!GetInputSource().Close(error)) return false; return result; }
/** @fn int32_t CTCPClientAsync::SendBufferAsync() * @brief 将待发送队列中的数据发送出去 * @return */ int32_t CTCPClientAsync::SendBufferAsync() { int32_t nErrorCode = 0; m_sendqueuemutex.Lock(); if (m_sendqueue.size() == 0) { //待发送队列中为空,则删除写事件的注册,改成读事件 m_pio->Remove_WriteEvent(this); m_sendqueuemutex.Unlock(); if (_GetWaitForCloseStatus() == TRUE) { //待发送内容发送完毕,则关闭链接 _Close(); } return nErrorCode; } CSimpleBuffer* pBufferLoop = m_sendqueue.front(); m_sendqueuemutex.Unlock(); int32_t nRet = S_Send(GetSocket(), (void*)pBufferLoop->GetBuffer(), pBufferLoop->GetWriteOffset()); if ( nRet < 0) { #if (defined(_WIN32) || defined(_WIN64)) int32_t nError = ::GetLastError(); if (WSAEWOULDBLOCK == nError) #else int32_t nError = errno; if (EAGAIN == nError) #endif { SOCKET_IO_DEBUG("send tcp data, buffer is blocking.") } else { _ClearSendBuffer(); SOCKET_IO_ERROR("send tcp data error, errno: %d.", nError); DoException(GetSocketID(), SOCKET_IO_TCP_SEND_FAILED); } }
LRESULT GameMainDlg::OnTrayMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == msg_traymessage) { switch (lParam) { case WM_LBUTTONUP: ShowWindow(SW_SHOW); break; case WM_RBUTTONUP: _CreateTrayMenu(); break; default: break; } } if (uMsg == msg_game_quit) { _Close(); } return TRUE; }
bool Config0::_ParseFile(LPWSTR pszFileName, CFGDATA *pCD) { bool r = false; Mem::_zero(pCD, sizeof(CFGDATA)); //Открываем файл. Fs::MEMFILE fl; if(Fs::_fileToMem(pszFileName, &fl, 0)) { if(fl.size <= MAX_CONFIG_SIZE) { LPSTR pCur = (LPSTR)fl.data; LPSTR pEnd = pCur + fl.size; bool error = false; VAR **pTree = NULL; DWORD dwTree = 0; DWORD dwStr = 0; while(!error && pCur < pEnd) { //Ищим конец строки. LPSTR pp = pCur; while(*pp != '\n' && *pp != '\r' && pp < pEnd)pp++; //Получаем аргумены. LPSTR *pArgs = NULL; DWORD dwArgsCount = Str::_getArgumentsA(pCur, (DWORD)(pp - pCur), &pArgs, 0); if(dwArgsCount > 0 && dwArgsCount != (DWORD)-1 && pArgs[0][0] != 0 && pArgs[0][0] != ';') { //Конец перечисления потомков. if(CWA(kernel32, lstrcmpiA)(CONFIG0_NAME_SECTION_END, pArgs[0]) == 0) { if(dwTree == 0)error = true; else dwTree--; Mem::freeArrayOfPointers(pArgs, dwArgsCount); } else { //Создание переменной. VAR *pNewVar = _AddVar(dwTree ? pTree[dwTree - 1] : NULL, pCD, pArgs, (BYTE)dwArgsCount); if(pNewVar == NULL) { Mem::freeArrayOfPointers(pArgs, dwArgsCount); error = true; } //Начало перечисления потомков. else if(CWA(kernel32, lstrcmpiA)(CONFIG0_NAME_SECTION_BEGIN, pArgs[0]) == 0) { if(!Mem::reallocEx(&pTree, sizeof(VAR *) * (dwTree + 1)))error = true; else pTree[dwTree++] = pNewVar; } } } else if(dwArgsCount != (DWORD)-1)Mem::freeArrayOfPointers(pArgs, dwArgsCount); pCur = pp + 1; dwStr++; } Mem::free(pTree); if(error)_Close(pCD); else r = true; } Fs::_closeMemFile(&fl); } return r; }
void CSSLClientAsync::ShutDown() { _SetWaitForClose(TRUE); _Close(); }
BWrepFile::~BWrepFile() { _Close(); }
void RasterWeather::Close() { Poco::ScopedRWLock protect(lock, true); _Close(); }
void _close_unix_socket(int *sockd, const char *server_path) { LOGDEBUG("Closing unix socket %d %s", *sockd, server_path); _Close(sockd); }
void GMTicket::Close() const { _Close(GM_TICKET_STATUS_CLOSE); }
void GMTicket::CloseByClient() const { _Close(GM_TICKET_STATUS_DO_NOTHING); }
void GMTicket::CloseWithSurvey() const { _Close(GM_TICKET_STATUS_SURVEY); }
CStageXMLParse::~CStageXMLParse() { _Close(); }
AviFrameGraber::~AviFrameGraber(){ _Close(); AVIFileExit(); }