IslInterface::~IslInterface() { logger->logMessage("[ISL] session ended", this); flushOutputBuffer(); // As these signals are connected with Qt::QueuedConnection implicitly, // we don't need to worry about them modifying the lists while we're iterating. server->roomsLock.lockForRead(); QMapIterator<int, Server_Room *> roomIterator(server->getRooms()); while (roomIterator.hasNext()) { Server_Room *room = roomIterator.next().value(); room->usersLock.lockForRead(); QMapIterator<QString, ServerInfo_User_Container> roomUsers(room->getExternalUsers()); while (roomUsers.hasNext()) { roomUsers.next(); if (roomUsers.value().getUserInfo()->server_id() == serverId) emit externalRoomUserLeft(room->getId(), roomUsers.key()); } room->usersLock.unlock(); } server->roomsLock.unlock(); server->clientsLock.lockForRead(); QMapIterator<QString, Server_AbstractUserInterface *> extUsers(server->getExternalUsers()); while (extUsers.hasNext()) { extUsers.next(); if (extUsers.value()->getUserInfo()->server_id() == serverId) emit externalUserLeft(extUsers.key()); } server->clientsLock.unlock(); }
void IslInterface::sharedCtor(const QSslCertificate &cert, const QSslKey &privateKey) { socket = new QSslSocket(this); socket->setLocalCertificate(cert); socket->setPrivateKey(privateKey); connect(socket, SIGNAL(readyRead()), this, SLOT(readClient()), Qt::QueuedConnection); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(catchSocketError(QAbstractSocket::SocketError))); connect(this, SIGNAL(outputBufferChanged()), this, SLOT(flushOutputBuffer()), Qt::QueuedConnection); }
int mod_decode(OutputBuffer * cb, DecoderControl * dc, char * path) { mod_Data * data; float time = 0.0; int ret; float secPerByte; if(mod_initMikMod() < 0) return -1; if(!(data = mod_open(path))) { ERROR("failed to open mod: %s\n", path); MikMod_Exit(); return -1; } dc->audioFormat.bits = 16; dc->audioFormat.sampleRate = 44100; dc->audioFormat.channels = 2; getOutputAudioFormat(&(dc->audioFormat),&(cb->audioFormat)); secPerByte = 1.0/((dc->audioFormat.bits*dc->audioFormat.channels/8.0)* (float)dc->audioFormat.sampleRate); dc->state = DECODE_STATE_DECODE; while(1) { if(dc->seek) { dc->seekError = 1; dc->seek = 0; } if(dc->stop) break; if(!Player_Active()) break; ret = VC_WriteBytes(data->audio_buffer, MIKMOD_FRAME_SIZE); time += ret*secPerByte; sendDataToOutputBuffer(cb, NULL, dc, 0, (char *)data->audio_buffer, ret, time, 0, NULL); } flushOutputBuffer(cb); mod_close(data); MikMod_Exit(); if(dc->stop) { dc->state = DECODE_STATE_STOP; dc->stop = 0; } else dc->state = DECODE_STATE_STOP; return 0; }
void Base64Encode::finalize() { if (BIO_flush(m_impl->m_base64) != 1) BOOST_THROW_EXCEPTION(Error(getIndex(), "Failed to flush")); while (!isConverterEmpty()) { fillOutputBuffer(); while (!isOutputBufferEmpty()) { flushOutputBuffer(); } } }
SamStatus::Status ClipOverlap::handleSortedByCoord(SamFile& samIn, SamCoordOutput* outputBufferPtr) { MateMapByCoord mateMap; // Get record & track success/fail SamStatus::Status returnStatus = SamStatus::SUCCESS; OverlapHandler::OverlapInfo overlapInfo = OverlapHandler::UNKNOWN_OVERLAP; SamRecord* matePtr = NULL; // Get the first read. SamRecord* recordPtr = myPool.getRecord(); if(recordPtr == NULL) { // No records in the pool, can't process. std::cerr << "ERROR: No records in the pool, can't process by coordinate.\n"; return(SamStatus::FAIL_MEM); } // Track the original chrom/position of the record being processed // for flushing. int32_t chrom = -1; int32_t position = -1; bool overlap = false; while(returnStatus == SamStatus::SUCCESS) { // Get the next Record. returnStatus = readCoordRecord(samIn, &recordPtr, mateMap, outputBufferPtr); if(returnStatus != SamStatus::SUCCESS) { break; } chrom = recordPtr->getReferenceID(); position = recordPtr->get0BasedPosition(); // Cleanup the mate map based on the newly read record. cleanupMateMap(mateMap, outputBufferPtr, chrom, position); // Check the read for overlaps. overlapInfo = myOverlapHandler->getOverlapInfo(*recordPtr, myIntExcludeFlags); // Handle the types of overlaps. switch(overlapInfo) { case OverlapHandler::OVERLAP: overlap = true; // 1st read, so store it in the mate map. mateMap.add(*recordPtr); // Clear the pointer so a new one is used next time. recordPtr = NULL; break; case OverlapHandler::NO_OVERLAP_WRONG_ORIENT: overlap = true; myOverlapHandler->handleNoOverlapWrongOrientation(*recordPtr); break; case OverlapHandler::SAME_START: overlap = true; // First check the mate map for the mate. matePtr = mateMap.getMate(*recordPtr); if(matePtr != NULL) { // Mate was found, so handle the overlap. myOverlapHandler->handleOverlapPair(*matePtr, *recordPtr); } else { // Mate not found, so store this one. mateMap.add(*recordPtr); // Clear the pointer so a new one is used next time. recordPtr = NULL; } break; case OverlapHandler::UNKNOWN_OVERLAP: matePtr = mateMap.getMate(*recordPtr); if(matePtr != NULL) { // Mate was found, there is an overlap. overlap = true; myOverlapHandler->handleOverlapPair(*matePtr, *recordPtr); } else { // No overlap if mate not found. overlap = false; } break; case OverlapHandler::UNKNOWN_OVERLAP_WRONG_ORIENT: overlap = true; matePtr = mateMap.getMate(*recordPtr); if(matePtr != NULL) { // Mate was found, there is an overlap.. myOverlapHandler->handleOverlapPair(*matePtr, *recordPtr); } else { // Mate not found, so handle wrong orientation. // Don't update stats since this is the 2nd in the pair myOverlapHandler->handleNoOverlapWrongOrientation(*recordPtr, false); } break; case OverlapHandler::NO_OVERLAP: default: // No overlap overlap = false; break; } // Handle writing the record if necessary. if(outputBufferPtr != NULL) { // Writing step. if((matePtr != NULL) && (!myOverlapsOnly || overlap)) { // Add the mate to the output buffer. outputBufferPtr->add(matePtr); matePtr = NULL; } if((recordPtr != NULL) && (!myOverlapsOnly || overlap)) { // Add this record to the output buffer. outputBufferPtr->add(recordPtr); recordPtr = NULL; } // Flush the output buffer if(!flushOutputBuffer(mateMap, *outputBufferPtr, chrom, position)) { std::cerr << "ERROR: Failed to flush the output buffer\n"; returnStatus = SamStatus::FAIL_IO; } } else { // Not writing. // Release the mate if it is set. if(matePtr != NULL) { myPool.releaseRecord(matePtr); } } } // Done with the file, cleanup the mate map. // The calling method will cleanup the output buffer. cleanupMateMap(mateMap, outputBufferPtr); if(returnStatus != SamStatus::NO_MORE_RECS) { // Failure. std::cerr << "ERROR reading file, exiting.\n"; return(returnStatus); } return(SamStatus::SUCCESS); }