int GSM3MobileClientService::read() { if(flags & GSM3MOBILECLIENTSERVICE_WRITING) endWrite(true); int c=theGSM3MobileClientProvider->readSocket(); return c; }
void GSM3MobileClientService::flush() { if(flags & GSM3MOBILECLIENTSERVICE_WRITING) endWrite(true); theGSM3MobileClientProvider->flushSocket(/*mySocket*/); if(flags & GSM3MOBILECLIENTSERVICE_SYNCH) waitForAnswer(); }
void GSM3MobileClientService::stop() { if(flags & GSM3MOBILECLIENTSERVICE_WRITING) endWrite(true); theGSM3MobileClientProvider->disconnectTCP(flags & GSM3MOBILECLIENTSERVICE_CLIENT, mySocket); theGSM3MobileClientProvider->releaseSocket(mySocket); mySocket = 0; if(flags & GSM3MOBILECLIENTSERVICE_SYNCH) waitForAnswer(); }
std::streambuf::int_type IOBuffer::overflow(std::streambuf::int_type ch) { typedef IOBuffer::traits_type traits_type; if(!_ioDevice) return traits_type::eof(); if(!_obuffer) { _obuffer = new char[_obufferSize]; setp(_obuffer, _obuffer + _obufferSize); } else if(_ioDevice->isWriting()) // beginWrite is unfinished { endWrite(); } else if(traits_type::eq_int_type(ch, traits_type::eof()) || ! _oextend) { // normal blocking overflow case std::size_t avail = pptr() - _obuffer; std::size_t written = _ioDevice->write(_obuffer, avail); std::size_t leftover = avail - written; if(leftover > 0) traits_type::move(_obuffer, _obuffer + written, leftover); setp(_obuffer, _obuffer + _obufferSize); pbump( static_cast<int>(leftover) ); } else { // if the buffer area is extensible and overflow is not called by // sync/flush we copy the output buffer to a larger one std::size_t bufsize = _obufferSize + (_obufferSize / 2); char* buf = new char[ bufsize ]; traits_type::copy(buf, _obuffer, _obufferSize); std::swap(_obuffer, buf); setp(_obuffer, _obuffer + bufsize); pbump( static_cast<int>(_obufferSize) ); _obufferSize = bufsize; delete [] buf; } // if the overflow char is not EOF put it in buffer if(traits_type::eq_int_type(ch, traits_type::eof()) == false) { *pptr() = traits_type::to_char_type(ch); pbump(1); } return traits_type::not_eof(ch); }
/*! Deallocates all the FFMPEG parameters. */ void vpFFMPEG::closeStream() { if (streamWasOpen) { if (buffer != NULL) { free(buffer); buffer = NULL; } if (color_type == vpFFMPEG::COLORED) av_free(pFrameRGB); else if (color_type == vpFFMPEG::GRAY_SCALED) av_free(pFrameGRAY); // Free the YUV frame av_free(pFrame); // Close the codec if (pCodecCtx) avcodec_close(pCodecCtx); // Close the video file #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53,17,0) // libavformat 53.17.0 av_close_input_file(pFormatCtx); #else avformat_close_input(&pFormatCtx); #endif } streamWasOpen = false; if (encoderWasOpened) { if(f!=NULL) endWrite(); if(buffer!=NULL) delete[] buffer; if(outbuf != NULL) delete[] outbuf; if(picture_buf != NULL) delete[] picture_buf; av_free(pFrameRGB); av_free(pFrame); if (pCodecCtx) avcodec_close(pCodecCtx); } encoderWasOpened = false; if(streamWasInitialized || encoderWasOpened){ sws_freeContext (img_convert_ctx); } streamWasInitialized = false; }
int GSM3MobileClientService::available() { int res; // Even if not connected, we are looking for available data if(flags & GSM3MOBILECLIENTSERVICE_WRITING) endWrite(true); res=theGSM3MobileClientProvider->availableSocket(flags & GSM3MOBILECLIENTSERVICE_CLIENT,mySocket); if(flags & GSM3MOBILECLIENTSERVICE_SYNCH) res=waitForAnswer(); return res; }
void SegStreamAllocation::closeImpl() { if (pSegOutputStream) { // state WRITING assert(!pSegInputStream); // do a fake read; this won't really read the pages, it will just // deallocate them endWrite(); } if (pSegInputStream) { // state READING assert(!pSegOutputStream); assert(pSegInputStream->isDeallocating()); // this will deallocate all remaining pages as a side-effect pSegInputStream->close(); pSegInputStream.reset(); } else { // state UNALLOCATED: nothing to do } nPagesWritten = 0; }
std::streambuf::pos_type IOBuffer::seekoff(std::streambuf::off_type off, std::ios::seekdir dir, std::ios::openmode) { typedef IOBuffer::pos_type pos_type; typedef IOBuffer::off_type off_type; pos_type ret = pos_type(off_type(-1)); if( ! _ioDevice || ! _ioDevice->seekable() || off == 0) return ret; if(_ioDevice->isWriting()) endWrite(); if(_ioDevice->isReading()) endRead(); ret = _ioDevice->seek(off, dir); // Eliminate currently buffered sequence discard(); return ret; }
int GSM3MobileClientService::peek() { if(flags & GSM3MOBILECLIENTSERVICE_WRITING) endWrite(true); return theGSM3MobileClientProvider->peekSocket(/*mySocket, false*/); }