bool AudioOutputPortAudio::close() { DPTR_D(AudioOutputPortAudio); QMutexLocker lock(&d.mutex); Q_UNUSED(lock); resetStatus(); bool available_old = d.available; d.available = false; PaError err = paNoError; if (!d.stream) { return true; } err = Pa_StopStream(d.stream); //may be already stopped: paStreamIsStopped if (err != paNoError) { d.available = available_old; qWarning("Stop portaudio stream error: %s", Pa_GetErrorText(err)); //return err == paStreamIsStopped; } err = Pa_CloseStream(d.stream); if (err != paNoError) { d.available = available_old; qWarning("Close portaudio stream error: %s", Pa_GetErrorText(err)); return false; } d.stream = NULL; return true; }
void Q3Socket::close() { if ( !isOpen() || d->state == Idle ) // already closed return; if ( d->state == Closing ) return; if ( !d->rsn || !d->wsn ) return; #if defined(Q3SOCKET_DEBUG) qDebug( "Q3Socket (%s): close socket", name() ); #endif if ( d->socket && d->wsize ) { // there's data to be written d->state = Closing; if ( d->rsn ) d->rsn->setEnabled( false ); if ( d->wsn ) d->wsn->setEnabled( true ); d->rba.clear(); // clear incoming data return; } resetStatus(); setOpenMode(NotOpen); d->close(); d->state = Idle; }
bool Character::afflictStatus(const std::string& status, int duration) { auto it = getStatusEffectIterator(status); if (it == m_status.end()) { // Dead status removes all other statuses. if (status == "Dead") { resetStatus(); } if (hasStatus("Normal")) { m_status.clear(); } m_status.push_back(get_status_effect(status)); if (duration > 0) { m_statusDurations[get_status_effect(status)] = duration; } return true; } return false; }
void Q3Socket::setSocketIntern( int socket ) { if ( state() != Idle ) { clearPendingData(); close(); } Q_ULONG oldBufferSize = d ? d->readBufferSize : 0; delete d; d = new Q3SocketPrivate; if (oldBufferSize) d->readBufferSize = oldBufferSize; if ( socket >= 0 ) { Q3SocketDevice *sd = new Q3SocketDevice( socket, Q3SocketDevice::Stream ); sd->setBlocking( false ); sd->setAddressReusable( true ); d->setSocketDevice( this, sd ); } d->state = Idle; // Initialize the IO device flags resetStatus(); open( IO_ReadWrite ); // hm... this is not very nice. d->host.clear(); d->port = 0; #ifndef QT_NO_DNS delete d->dns4; d->dns4 = 0; delete d->dns6; d->dns6 = 0; #endif }
bool ExpandableBlockStreamExchangeEpoll::close() { logging_->log("[%ld] Close: nexhausted lowers=%d, nlower=%d", state.exchange_id_, nexhausted_lowers, nlowers); CancelReceiverThread(); CloseTheSocket(); /* free the temporary resource/ */ for (unsigned i = 0; i < nlowers; i++) { delete block_for_socket_[i]; ; } delete received_block_stream_; delete buffer; delete[] block_for_socket_; /* rest the status of this iterator instance, such that the following calling of open() and next() can * act correctly. */ resetStatus(); Environment::getInstance()->getExchangeTracker()->LogoutExchange(ExchangeID(state.exchange_id_, partition_offset)); logging_->log("[%ld] ExchangeUpper is closed!", state.exchange_id_); return true; }
bool AudioOutputDSound::close() { DPTR_D(AudioOutputDSound); resetStatus(); d.destroy(); return true; }
bool AudioOutputOpenSL::close() { DPTR_D(AudioOutputOpenSL); d.available = false; resetStatus(); if (d.m_playItf) (*d.m_playItf)->SetPlayState(d.m_playItf, SL_PLAYSTATE_STOPPED); if (d.m_bufferQueueItf && SL_RESULT_SUCCESS != (*d.m_bufferQueueItf)->Clear(d.m_bufferQueueItf)) qWarning("Unable to clear buffer"); if (d.m_playerObject) { (*d.m_playerObject)->Destroy(d.m_playerObject); d.m_playerObject = NULL; } if (d.m_outputMixObject) { (*d.m_outputMixObject)->Destroy(d.m_outputMixObject); d.m_outputMixObject = NULL; } d.m_playItf = NULL; d.m_volumeItf = NULL; d.m_bufferQueueItf = NULL; return true; }
void SeahubNotificationsMonitor::refresh() { if (in_refresh_) { return; } const Account& account = seafApplet->accountManager()->currentAccount(); if (!account.isValid()) { resetStatus(); return; } in_refresh_ = true; if (check_messages_req_) { delete check_messages_req_; } check_messages_req_ = new GetUnseenSeahubNotificationsRequest(account); connect(check_messages_req_, SIGNAL(success(int)), this, SLOT(onRequestSuccess(int))); connect(check_messages_req_, SIGNAL(failed(const ApiError&)), this, SLOT(onRequestFailed(const ApiError&))); check_messages_req_->send(); }
void QSocket::close() { if ( !isOpen() || d->state == Idle ) // already closed return; if ( d->state == Closing ) return; if ( !d->rsn || !d->wsn ) return; #if defined(QSOCKET_DEBUG) qDebug( "QSocket (%s): close socket", name() ); #endif if ( d->socket && d->wsize ) { // there's data to be written d->state = Closing; if ( d->rsn ) d->rsn->setEnabled( FALSE ); if ( d->wsn ) d->wsn->setEnabled( TRUE ); d->rba.clear(); // clear incoming data return; } setFlags( IO_Sequential ); resetStatus(); setState( 0 ); d->close(); d->state = Idle; }
QString LongStream::detach() { QString detachedName = fileName(); delete ts; tmpFile->setAutoRemove(false); tmpFile->close(); delete tmpFile; QString tmpName( LongStream::tempDir() + QLatin1String( "/qtopiamail" ) ); tmpFile = new QTemporaryFile( tmpName + QLatin1String( ".XXXXXX" )); tmpFile->open(); tmpFile->setPermissions(QFile::ReadOwner | QFile::WriteOwner); ts = new QDataStream( tmpFile ); len = 0; appendedBytes = minCheck; c = QChar::Null; resetStatus(); return detachedName; }
QSocket::QSocket( QObject *parent, const char *name ) : QObject( parent, name ) { d = new QSocketPrivate; setSocketDevice( 0 ); setFlags( IO_Direct ); resetStatus(); }
Q3Socket::Q3Socket( QObject *parent, const char *name ) : QIODevice( parent ) { setObjectName(QLatin1String(name)); d = new Q3SocketPrivate; setSocketDevice( 0 ); resetStatus(); }
void SeahubNotificationsMonitor::refresh(bool force) { if (force) { resetStatus(); in_refresh_ = false; } refresh(); }
void ImageProcessSystem::cancelOperation() { srcImage=images.top(); currentDisplayImageImproper=false; BasisOperation::qimage2Mat(srcImage,srcMat.get()); images.pop(); resetStatus(); updateToolBar(); updateDisplayImage(); }
bool AudioOutputDSound::open() { DPTR_D(AudioOutputDSound); resetStatus(); if (!d.init()) return false; if (!d.createDSoundBuffers()) return false; return true; }
void SeahubNotificationsMonitor::start() { resetStatus(); refresh_timer_->start(kRefreshSeahubMessagesInterval); connect(seafApplet->accountManager(), SIGNAL(accountsChanged()), this, SLOT(onAccountChanged())); refresh(); }
int list_delete(list_t * self, int index) { resetStatus(self); if(!isEmpty(self) && index - 1 <= self->size - 1) { shift_left(self, index); (self->size)--; } else self->status = LIST_EMPTY; }
void SeahubNotificationsMonitor::openNotificationsPageInBrowser() { const Account& account = seafApplet->accountManager()->currentAccount(); if (!account.isValid()) { return; } QDesktopServices::openUrl(account.getAbsoluteUrl(kNotificationsUrl)); resetStatus(); }
void SeahubNotificationsMonitor::openNotificationsPageInBrowser() { const Account& account = seafApplet->accountManager()->currentAccount(); if (!account.isValid()) { return; } AutoLoginService::instance()->startAutoLogin(kNotificationsUrl); resetStatus(); }
void ImageProcessSystem::listWidgetClicked(QListWidgetItem *item) { int r=ui.listWidget->row(item); fileName=fileNames[r]; resetStatus(); interactiveHasProduceResult=false; loadImage(); updateToolBar(); initMat(); initImageLabel(); }
void ImageProcessSystem::openFile() { fileName=QFileDialog::getOpenFileName(this,"Open File",QDir::currentPath(),"Images (*.bmp *.gif *.jpg *.jpeg *.png *.tiff)"); if(!loadImage()) return ; resetStatus(); interactiveHasProduceResult=false; updateToolBar(); initMat(); delete ImageLabel; ImageLabel=new OriginalImageLabel(ui.centralWidget); initImageLabel(); }
bool QFile::open( int m, FILE *f ) { if ( isOpen() ) { #if defined(QT_CHECK_RANGE) qWarning( "QFile::open: File already open" ); #endif return FALSE; } init(); setMode( m &~IO_Raw ); setState( IO_Open ); fh = f; ext_f = TRUE; struct stat st; ::fstat( fileno(fh), &st ); #if defined(QT_LARGEFILE_SUPPORT) #if !defined(QT_ABI_QT4) off_t tmp = ftello( fh ); ioIndex = tmp > UINT_MAX ? UINT_MAX : (Offset)tmp; #else ioIndex = (Offset)ftello( fh ); #endif #else ioIndex = (Offset)ftell( fh ); #endif if ( (st.st_mode & S_IFMT) != S_IFREG || f == stdin ) { //stdin is non seekable // non-seekable setType( IO_Sequential ); length = INT_MAX; ioIndex = 0; } else { #if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_QT4) length = st.st_size > UINT_MAX ? UINT_MAX : (Offset)st.st_size; #else length = (Offset)st.st_size; #endif if ( !(flags()&IO_Truncate) && length == 0 && isReadable() ) { // try if you can read from it (if you can, it's a sequential // device; e.g. a file in the /proc filesystem) int c = getch(); if ( c != -1 ) { ungetch(c); setType( IO_Sequential ); length = INT_MAX; ioIndex = 0; } resetStatus(); } } return TRUE; }
bool AudioOutputOpenSL::open() { DPTR_D(AudioOutputOpenSL); d.available = false; resetStatus(); SLDataLocator_BufferQueue bufferQueueLocator = { SL_DATALOCATOR_BUFFERQUEUE, (SLuint32)d.nb_buffers }; SLDataFormat_PCM pcmFormat = audioFormatToSL(audioFormat()); SLDataSource audioSrc = { &bufferQueueLocator, &pcmFormat }; // OutputMix SL_RUN_CHECK_FALSE((*d.engine)->CreateOutputMix(d.engine, &d.m_outputMixObject, 0, NULL, NULL)); SL_RUN_CHECK_FALSE((*d.m_outputMixObject)->Realize(d.m_outputMixObject, SL_BOOLEAN_FALSE)); SLDataLocator_OutputMix outputMixLocator = { SL_DATALOCATOR_OUTPUTMIX, d.m_outputMixObject }; SLDataSink audioSink = { &outputMixLocator, NULL }; const SLInterfaceID ids[] = { SL_IID_BUFFERQUEUE};//, SL_IID_VOLUME }; const SLboolean req[] = { SL_BOOLEAN_TRUE};//, SL_BOOLEAN_TRUE }; // AudioPlayer SL_RUN_CHECK_FALSE((*d.engine)->CreateAudioPlayer(d.engine, &d.m_playerObject, &audioSrc, &audioSink, sizeof(ids)/sizeof(ids[0]), ids, req)); SL_RUN_CHECK_FALSE((*d.m_playerObject)->Realize(d.m_playerObject, SL_BOOLEAN_FALSE)); // Buffer interface SL_RUN_CHECK_FALSE((*d.m_playerObject)->GetInterface(d.m_playerObject, SL_IID_BUFFERQUEUE, &d.m_bufferQueueItf)); SL_RUN_CHECK_FALSE((*d.m_bufferQueueItf)->RegisterCallback(d.m_bufferQueueItf, AudioOutputOpenSLPrivate::bufferQueueCallback, &d)); // Play interface SL_RUN_CHECK_FALSE((*d.m_playerObject)->GetInterface(d.m_playerObject, SL_IID_PLAY, &d.m_playItf)); // call when SL_PLAYSTATE_STOPPED SL_RUN_CHECK_FALSE((*d.m_playItf)->RegisterCallback(d.m_playItf, AudioOutputOpenSLPrivate::playCallback, this)); #if 0 SLuint32 mask = SL_PLAYEVENT_HEADATEND; // TODO: what does this do? SL_RUN_CHECK_FALSE((*d.m_playItf)->SetPositionUpdatePeriod(d.m_playItf, 100)); SL_RUN_CHECK_FALSE((*d.m_playItf)->SetCallbackEventsMask(d.m_playItf, mask)); #endif // Volume interface //SL_RUN_CHECK_FALSE((*d.m_playerObject)->GetInterface(d.m_playerObject, SL_IID_VOLUME, &d.m_volumeItf)); const int kBufferSize = 1024*4; static char init_data[kBufferSize]; memset(init_data, 0, sizeof(init_data)); for (quint32 i = 0; i < d.nb_buffers; ++i) { SL_RUN_CHECK_FALSE((*d.m_bufferQueueItf)->Enqueue(d.m_bufferQueueItf, init_data, sizeof(init_data))); d.nextEnqueueInfo().data_size = sizeof(init_data); d.nextEnqueueInfo().timestamp = 0; d.bufferAdded(); d.buffers_queued++; } SL_RUN_CHECK_FALSE((*d.m_playItf)->SetPlayState(d.m_playItf, SL_PLAYSTATE_PLAYING)); d.available = true; return true; }
void Q3SocketDevice::close() { if ( fd == -1 || !isOpen() ) // already closed return; resetStatus(); setOpenMode(NotOpen); ::close( fd ); #if defined(QSOCKETDEVICE_DEBUG) qDebug( "Q3SocketDevice::close: Closed socket %x", fd ); #endif fd = -1; fetchConnectionParameters(); QIODevice::close(); }
int RpcEngine::serveClient() { DWORD status; DWORD nCount; SignalingQueue<callNS::Call>* outgoingQueue = APP_CONTEXT.getRpcOutgoingQueue(); HANDLE queueHandle = outgoingQueue->getSignalHandle(); HANDLE events[3]; nCount = 0; events[nCount++] = mhStopEvent; events[nCount++] = mhClientPipe; events[nCount++] = queueHandle; int retValue = 0; while (1) { status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE); if (WaitForSingleObject(mhStopEvent, 0) == WAIT_OBJECT_0) { retValue = CLIENT_ERROR; break; } if (WaitForSingleObject(mhClientPipe, 0) == WAIT_OBJECT_0) { retValue = read(); if (retValue) { break; } // process the data if (mPayloadRead == mPacktLength) { processData(); resetStatus(); } } if (WaitForSingleObject(queueHandle, 0) == WAIT_OBJECT_0) { outgoingQueue->resetEventAndLockQueue(); callNS::Call * currentCall = outgoingQueue->getElementLockFree(); while (currentCall != NULL) { processOutgoingCall(currentCall); currentCall = outgoingQueue->getElementLockFree(); } outgoingQueue->unlockQueue(); } } return retValue; }
void LongStream::reset() { delete ts; tmpFile->resize( 0 ); tmpFile->close(); tmpFile->open(); ts = new QDataStream( tmpFile ); len = 0; appendedBytes = minCheck; c = QChar::Null; resetStatus(); }
/*! Sets the socket device to operate on the existing socket \a socket. The \a type argument must match the actual socket type; use \c Q3SocketDevice::Stream for a reliable, connection-oriented TCP socket, or Q3SocketDevice::Datagram for an unreliable, connectionless UDP socket. Any existing socket is closed. \sa isValid(), close() */ void Q3SocketDevice::setSocket( int socket, Type type ) { if ( fd != -1 ) // close any open socket close(); #if defined(Q3SOCKETDEVICE_DEBUG) qDebug( "Q3SocketDevice::setSocket: socket %x, type %d", socket, type ); #endif t = type; fd = socket; d->protocol = Unknown; e = NoError; resetStatus(); open( ReadWrite ); fetchConnectionParameters(); }
KviHttpRequest::KviHttpRequest() : QObject() { m_p = new KviHttpRequestPrivate(); m_p->pSocket = NULL; m_p->bIsSSL = false; m_p->pConnectTimeoutTimer = NULL; m_p->pBuffer = new KviDataBuffer(); m_p->pFile = NULL; m_pPrivateData = 0; m_bHeaderProcessed = false; m_uConnectionTimeout = 60; resetStatus(); resetData(); }
void list_add(list_t * self, int value, int index) { resetStatus(self); if(isFull(self)) { self->status = LIST_FULL; return; } if(index - 1 >= MAX_LIST_SIZE || index - 1 >= self->size - 1){ self->arr[(self->size)++] = value; return; } if(index - 1 < self->size - 1) shift_right(self, index); self->arr[index - 1] = value; (self->size)++; }
//TODO: call open after audio format changed? bool AudioOutputPortAudio::open() { DPTR_D(AudioOutputPortAudio); QMutexLocker lock(&d.mutex); Q_UNUSED(lock); resetStatus(); d.outputParameters->sampleFormat = toPaSampleFormat(audioFormat().sampleFormat()); d.outputParameters->channelCount = audioFormat().channels(); PaError err = Pa_OpenStream(&d.stream, NULL, d.outputParameters, audioFormat().sampleRate(), 0, paNoFlag, NULL, NULL); if (err == paNoError) { d.outputLatency = Pa_GetStreamInfo(d.stream)->outputLatency; d.available = true; } else { qWarning("Open portaudio stream error: %s", Pa_GetErrorText(err)); d.available = false; } return err == paNoError; }