void MainObject::ProcessCommands() { char c; Q3SocketDevice *udp_command=new Q3SocketDevice(Q3SocketDevice::Datagram); char rml[RD_RML_MAX_LENGTH]; unsigned ptr=0; bool active=false; while(!GetNextChar(&c)) { if(active) { if(c=='!') { rml[ptr++]=c; rml[ptr]=0; udp_command->writeBlock(rml,ptr,*dest_addr,dest_port); ptr=0; active=false; } else { rml[ptr++]=c; } if(ptr==RD_RML_MAX_LENGTH) { fprintf(stderr,"rmlsend: rml command too long\n"); CloseStream(); exit(256); } } else { if(isalpha(c)) { rml[ptr++]=c; active=true; } } } }
XnStatus PlayerNode::HandleEndRecord(EndRecord record) { XN_VALIDATE_INPUT_PTR(m_pNodeNotifications); XnStatus nRetVal = record.Decode(); XN_IS_STATUS_OK(nRetVal); DEBUG_LOG_RECORD(record, "End"); if (!m_bDataBegun) { XN_LOG_WARNING_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_OPEN_NI, "File does not contain any data!"); } nRetVal = m_eofReachedEvent.Raise(); XN_IS_STATUS_OK(nRetVal); if (m_bRepeat) { nRetVal = Rewind(); XN_IS_STATUS_OK(nRetVal); } else { m_bEOF = TRUE; CloseStream(); } return XN_STATUS_OK; }
PageCond plRegistryPageNode::IVerify() { // Check the checksum values first, to make sure the files aren't corrupt uint32_t ourChecksum = 0; hsStream* stream = OpenStream(); if (stream) { ourChecksum = stream->GetEOF() - fPageInfo.GetDataStart(); CloseStream(); } if (ourChecksum != fPageInfo.GetChecksum()) return kPageCorrupt; // If major version out-of-date, entire location is screwed if (fPageInfo.GetMajorVersion() > plVersion::GetMajorVersion()) return kPageTooNew; else if (fPageInfo.GetMajorVersion() < plVersion::GetMajorVersion()) return kPageOutOfDate; // Check the minor versions const plPageInfo::ClassVerVec& classVersions = fPageInfo.GetClassVersions(); for (int i = 0; i < classVersions.size(); i++) { const plPageInfo::ClassVersion& cv = classVersions[i]; uint16_t curVersion = plVersion::GetCreatableVersion(cv.Class); if (curVersion > cv.Version) return kPageOutOfDate; else if (curVersion < cv.Version) return kPageTooNew; } return kPageOk; }
void cSoundStream::Release() { CloseStream(); DeleteChunks(); DefaultAllProperties(); m_Format = AL_FORMAT_MONO8; };
//////////////////////////////////////////////////////////////// // ビデオキャプチャ停止 // // 引数: なし // 返値: なし //////////////////////////////////////////////////////////////// void AVI6::StopAVI( void ) { #ifndef NOAVI if(oc){ cCritical::Lock(); isAVI = false; av_write_trailer(oc); CloseStream(oc, &video_st); CloseStream(oc, &audio_st); avio_closep(&oc->pb); avformat_free_context(oc); oc = NULL; cCritical::UnLock(); } #endif }
STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSize) { UInt32 realProcessedSize = 0; while ((_fileIndex < _numFiles || _fileIsOpen) && size > 0) { if (_fileIsOpen) { UInt32 localProcessedSize; RINOK(_inStreamWithHash->Read( ((Byte *)data) + realProcessedSize, size, &localProcessedSize)); if (localProcessedSize == 0) { RINOK(CloseStream()); continue; } realProcessedSize += localProcessedSize; _filePos += localProcessedSize; size -= localProcessedSize; break; } else { RINOK(OpenStream()); } } if (processedSize != 0) *processedSize = realProcessedSize; return S_OK; }
void emAvFileModel::ResetData() { CloseStream(); Video=false; PlayLength=0; InfoText.Empty(); WarningText.Empty(); ErrorText.Empty(); AudioVisus.Empty(true); AudioChannels.Empty(true); SpuChannels.Empty(true); Signal(InfoSignal); PlayState=PS_STOPPED; RemoveFromActiveList(); Signal(PlayStateSignal); PlayPos=0; Signal(PlayPosSignal); AudioVolume=0; AudioMute=false; AudioVisu=0; AudioChannel=0; SpuChannel=0; Signal(AdjustmentSignal); Image.Empty(); Tallness=1.0; Signal(ImageSignal); }
XnStatus PlayerNode::Destroy() { CloseStream(); //Don't verify return value - proceed anyway if (m_pNodeInfoMap != NULL) { for (XnUInt32 i = 0; i < m_nMaxNodes; i++) { RemovePlayerNodeInfo(i); } XN_DELETE_ARR(m_pNodeInfoMap); m_pNodeInfoMap = NULL; } if (m_aSeekTempArray != NULL) { xnOSFree(m_aSeekTempArray); m_aSeekTempArray = NULL; } XN_DELETE_ARR(m_pRecordBuffer); m_pRecordBuffer = NULL; XN_DELETE_ARR(m_pUncompressedData); m_pUncompressedData = NULL; return XN_STATUS_OK; }
STDMETHODIMP CFolderInStream::Read(void *data, UInt32 size, UInt32 *processedSize) { UInt32 realProcessedSize = 0; while ((_curIndex < _refItem.NumItems || _fileIsOpen) && size > 0) { if (_fileIsOpen) { UInt32 localProcessedSize; RINOK(_stream->Read( ((Byte *)data) + realProcessedSize, size, &localProcessedSize)); _crc = CrcUpdate(_crc, ((Byte *)data) + realProcessedSize, localProcessedSize); if (localProcessedSize == 0) { RINOK(CloseStream()); continue; } realProcessedSize += localProcessedSize; size -= localProcessedSize; break; } else { RINOK(OpenStream()); } } if (processedSize != 0) *processedSize = realProcessedSize; return S_OK; }
static void print_stream(const char *fname) { fprintf(OutputFile, "File %s:", fname); if (!OpenStream(fname)) { fprintf(OutputFile, " cannot open\n"); return; } fprintf(OutputFile, " showing token stream:\nnl_cnt, tk_cnt: tokens"); lex_token = EOL; do { if (TOKEN_EQ(lex_token, EOL)) { fprintf(OutputFile, "\n%u,%u:", lex_nl_cnt, lex_tk_cnt ); } else { print_token(OutputFile, lex_token); } } while (NextStreamTokenObtained()); fprintf(OutputFile, "\n"); CloseStream(); }
DWORD MP3decoder::GetTotalTime(char * pcfilename) // 1/1000 sec { int ntmp = 0; if(!OpenStream(pcfilename, &ntmp, &ntmp, &ntmp, NULL, &ntmp)) return 0; CloseStream(); return m_length; }
extern void CloseObj() { /**************************/ if( ObjFile != 0 ) { CloseStream( ObjFile ); ObjFile = 0; } }
extern void ScratchObj() { /****************************/ if( ObjFile != 0 ) { CloseStream( ObjFile ); EraseStream( ObjName ); ObjFile = 0; } }
//------------------------------------------------------------------------------- // Decode this file //------------------------------------------------------------------------------- bool CPlaneIdent::ScanInfoFile(const char *filname) { SStream s; make[0] = 0; icon[0] = 0; if (OpenRStream((char *)filname,s) == 0) return false; item = 0; ReadFrom (this, &s); CloseStream (&s); return true; }
//============================== // ovrFileSysLocal::FileExists bool ovrFileSysLocal::FileExists( char const * uri ) { ovrStream * stream = OpenStream( uri, OVR_STREAM_MODE_READ ); if ( stream == NULL ) { return false; } CloseStream( stream ); return true; }
void CPlayer::CloseVsFile() { if(m_bStreamType) { CloseStream(); } else { HKCloseFile(); } }
//============================== // ovrFileSysLocal::ReadFile bool ovrFileSysLocal::ReadFile( char const * uri, MemBufferT< uint8_t > & outBuffer ) { ovrStream * stream = OpenStream( uri, OVR_STREAM_MODE_READ ); if ( stream == NULL ) { return false; } bool success = stream->ReadFile( uri, outBuffer ); CloseStream( stream ); return success; }
bool CVideoPlayerSubtitle::OpenStream(CDVDStreamInfo &hints, std::string &filename) { CSingleLock lock(m_section); CloseStream(true); m_streaminfo = hints; // okey check if this is a filesubtitle if(filename.size() && filename != "dvd" ) { m_pSubtitleFileParser = CDVDFactorySubtitle::CreateParser(filename); if (!m_pSubtitleFileParser) { CLog::Log(LOGERROR, "%s - Unable to create subtitle parser", __FUNCTION__); CloseStream(true); return false; } if (!m_pSubtitleFileParser->Open(hints)) { CLog::Log(LOGERROR, "%s - Unable to init subtitle parser", __FUNCTION__); CloseStream(true); return false; } m_pSubtitleFileParser->Reset(); return true; } // dvd's use special subtitle decoder if(hints.codec == AV_CODEC_ID_DVD_SUBTITLE && filename == "dvd") return true; m_pOverlayCodec = CDVDFactoryCodec::CreateOverlayCodec(hints); if(m_pOverlayCodec) return true; CLog::Log(LOGERROR, "%s - Unable to init overlay codec", __FUNCTION__); return false; }
int CStreamMuxerImp1::DestroyStreamMuxer(void) { CloseStream(); if(m_pWriter) { m_pWriter->CloseWriter(); } if( NULL != m_hSSFMux ) { SSFMuxDestroy( m_hSSFMux ); m_hSSFMux = NULL; } return 0; }
void emAvFileModel::SetPlayState(PlayStateType playState) { if (GetFileState()!=FS_LOADED) return; if (PlayState==playState) return; PlayState=playState; Signal(PlayStateSignal); if (PlayState==PS_STOPPED) { RemoveFromActiveList(); CloseStream(); PlayPos=0; Signal(PlayPosSignal); Image.Empty(); Signal(ImageSignal); } else { AddToActiveList(); if (GetStreamState()!=STREAM_OPENING && GetStreamState()!=STREAM_OPENED) { if (!WarningText.IsEmpty() || !ErrorText.IsEmpty()) { WarningText.Empty(); ErrorText.Empty(); Signal(InfoSignal); } OpenStream("auto","emAv",GetFilePath()); SetProperty("audio_volume",emString::Format("%d",AudioVolume)); SetProperty("audio_mute",AudioMute?"on":"off"); if (AudioVisu>=0 && AudioVisu<AudioVisus.GetCount()) { SetProperty("audio_visu",AudioVisus[AudioVisu].Get()); } SetProperty("pos",emString::Format("%d",PlayPos)); #if 0 // ??? This did not function. if (AudioChannel>=0 && AudioChannel<AudioChannels.GetCount()) { SetProperty("audio_channel",AudioChannels[AudioChannel].Get()); } if (SpuChannel>=0 && SpuChannel<SpuChannels.GetCount()) { SetProperty("spu_channel",SpuChannels[SpuChannel].Get()); } #endif } SetProperty( "state", PlayState==PS_PAUSED ? "paused" : PlayState==PS_SLOW ? "slow" : PlayState==PS_FAST ? "fast" : "normal" ); } SaveFileState(); }
unsigned long GS_CloseStream(unsigned long nPort) { //关闭编解码器 PSTREAMCONFIG pm = GetStream(nPort); if(pm==NULL) { return S_FALSE; } CloseStream(pm->pContrlConfig); CloseStreamCodec(pm->pCodecConfig); char str[128]; sprintf(str," Close GentekPlatformStream %d\n",nPort); OutputDebugStringA(str); return S_OK; }
MainObject::MainObject(QObject *parent,const char *name) { input_fd=-1; dest_hostname=RMLSEND_DEFAULT_ADDR; dest_port=RMLSEND_DEFAULT_PORT; rml_ptr=0; ReadSwitches(); ResolveName(); InitStream(); ProcessCommands(); CloseStream(); exit(0); }
void debug_stream_test_cb (puObject* obj) { SStream* s = new SStream; strncpy (s->filename, "teststream.txt",(PATH_MAX-1)); strncpy (s->mode, "w",3); OpenStream (s); WriteComment ("Comment...testing testing testing", s); WriteComment ("", s); WriteTag ('bgno', "---- object ----", s); WriteTag ('bgno', "---- nested Object ----", s); WriteTag ('int_', "---- int ----", s); int i = 500; WriteInt (&i, s); WriteTag ('uint', "---- unsigned int ----", s); unsigned int ui = 12345678; WriteUInt (&ui, s); float f = 12345.67f; WriteTag ('flot', "---- float ----", s); WriteFloat (&f, s); double d = 987654.3210; WriteTag ('dubl', "---- double ----", s); WriteDouble (&d, s); WriteTag ('stng', "---- string ----", s); WriteString ("This a string", s); SVector v; v.x = 1.0; v.y = 2.0; v.z = 3.0; WriteTag ('vect', "--- vector ----", s); WriteVector (&v, s); SPosition pos; pos.lat = 1000.0; pos.lon = 2000.0; pos.alt = 3000.0; WriteTag ('posn', "---- position ----", s); WritePosition (&pos, s); SMessage mesg; WriteTag ('mesg', "---- message ----", s); WriteMessage (&mesg, s); WriteTag ('endo', s); WriteTag ('endo', s); CloseStream (s); delete s; }
plRegistryPageNode::plRegistryPageNode(const char* path) : fValid(kPageCorrupt) , fPath(nil) , fDynLoadedTypes(0) , fStaticLoadedTypes(0) , fOpenRequests(0) , fIsNewPage(false) { fPath = hsStrcpy(path); hsStream* stream = OpenStream(); if (stream) { fPageInfo.Read(&fStream); fValid = IVerify(); CloseStream(); } }
void CWAV::CloseNormalizeAudioFile(CUString strFileName, BOOL bAbort, BOOL bReplace) { // Close input stream CloseStream(); // Close temp output stream m_pTmpWav->CloseStream(); delete m_pTmpWav; m_pTmpWav = NULL; if ( bAbort ) { // Delete temp file if ( CDexDeleteFile(strFileName + AUDIO_FILE_NRMFILEEXT ) == 0 ) { } } else { if ( bReplace ) { // Delete un-normalized file name if ( CDexDeleteFile( strFileName + _W( ".wav" ) ) == 0 ) { } // Rename output file if ( CDexMoveFile( strFileName + AUDIO_FILE_NRMFILEEXT, strFileName + _W( ".wav" ) ) ==0 ) { CUString strMsg = GetLastErrorString(); // Display the string. CDexMessageBox( strMsg, MB_OK | MB_ICONINFORMATION); } } } }
bool emAvFileModel::TryContinueLoading() throw(emString) { switch (GetStreamState()) { case STREAM_CLOSED: OpenStream("none","none",GetFilePath()); return false; case STREAM_OPENED: CloseStream(); PlayPos=0; AudioVolume=100; AudioMute=false; LoadAudioVolume(); LoadAudioVisu(); LoadFileState(); return true; case STREAM_ERRORED: throw emString(GetStreamErrorText()); default: emSleepMS(10); return false; } }
void plRegistryPageNode::LoadKeys() { hsAssert(IsValid(), "Trying to load keys for invalid page"); hsAssert(!fIsNewPage, "Trying to read a new page"); if (IsFullyLoaded()) return; hsStream* stream = OpenStream(); if (!stream) { hsAssert(0, plString::Format("plRegistryPageNode::LoadKeysFromSource - bad stream %s,%s", GetPageInfo().GetAge(), GetPageInfo().GetPage()).c_str()); return; } // If we're loading keys in the middle of a read because FindKey() failed, we'd better // make note of our stream position and restore it when we're done. uint32_t oldPos = stream->GetPosition(); stream->SetPosition(GetPageInfo().GetIndexStart()); // Read in the number of key types uint32_t numTypes = stream->ReadLE32(); for (uint32_t i = 0; i < numTypes; i++) { uint16_t classType = stream->ReadLE16(); plRegistryKeyList* keyList = IGetKeyList(classType); if (!keyList) { keyList = new plRegistryKeyList(classType); fKeyLists[classType] = keyList; } keyList->Read(stream); } stream->SetPosition(oldPos); CloseStream(); fStaticLoadedTypes = fKeyLists.size(); }
XnStatus PlayerNode::HandleEndRecord(EndRecord record) { XN_VALIDATE_INPUT_PTR(m_pNodeNotifications); XnStatus nRetVal = record.Decode(); XN_IS_STATUS_OK(nRetVal); DEBUG_LOG_RECORD(record, "End"); nRetVal = m_eofReachedEvent.Raise(); XN_IS_STATUS_OK(nRetVal); if (m_bRepeat) { nRetVal = Rewind(); XN_IS_STATUS_OK(nRetVal); } else { m_bEOF = TRUE; CloseStream(); } return XN_STATUS_OK; }
OMXPlayerAudio::~OMXPlayerAudio() { CloseStream(false); }
/// @brief Destructor /// AudioPlayer::~AudioPlayer() { if (displayTimer) { displayTimer->Stop(); } CloseStream(); }