std::shared_ptr<Streamer> MusicPlayer::streamFile(const string &fileName) {
	dontPlay = true;
	silentFrames = 0;

	{
		LOCK_GUARD(infoMutex);
		playingInfo = SongInfo();
	}

	string name = fileName;

	LOCK_GUARD(playerMutex);
	player = nullptr;
	player = fromStream(fileName);

	dontPlay = false;
	playEnded = false;

	if(player) {

		fifo.clear();
		fadeOutPos = 0;
		pause(false);
		pos = 0;
		// updatePlayingInfo();
		currentTune = playingInfo.starttune;
		return make_shared<Streamer>(playerMutex, player);
	}
	return nullptr;
}
void KWidgetStreamer::propertyFromStream( QDataStream& stream, QObject* to )
{
  // Only handle widgets. Alternatives to widgets are layouts, validators, timers, etc.
  if ( ! to->inherits("QWidget") )
    return;

  // Stream in all the children (if any)
  const QObjectList* children = to->children();
  unsigned int count;

  stream >> count;
  if ( children ) {
    Q_ASSERT( count == children->count() );
    for ( QObjectListIt it = QObjectListIt(*children); *it; ++it )
      fromStream( stream, *it );
  }
  else {
    Q_ASSERT( count == 0 );
  }

  // Now stream in properties
  for ( PropertyMapIt mapIt = _map.begin(); mapIt != _map.end(); mapIt++ ) {
    QString tp = mapIt.key();
    PropertyList list = mapIt.data();
    if ( to->inherits( tp.latin1() ) ) {
      for ( PropertyListIt it = list.begin(); it != list.end(); ++it ) {
         QVariant value;
        stream >> value;
        to->setProperty((*it).latin1(), value);
      }
    }
  }
}
Beispiel #3
0
bool ParallelMcmcmc::restore(void){
	if(stream.is_open())
		stream.close();

	stream.open((filename+".stream").c_str(), std::fstream::in);

	size_t pos = stream.tellg();
	size_t lastsample = pos;

	while(!stream.eof()){
		fromStream(stream,false);

		lastsample = pos;
		pos = stream.tellg();
	}

	if(numSteppingStones > 0)
	{
	    int index = 0;
	    for ( size_t i = 0; i < numSteppingStones; i++)
	    {
	        stream.clear();
	        stream.seekg(lastsample);

	        stream >> currentGeneration;

	        if(numChains > 1){
	            stream >> index;
	        }

	        chains[i]->fromStream(stream);
	        chains[i]->setChainActive(i == 0);
	        chains[i]->setChainHeat(computeBeta(delta,sigma,i));
	        chainIdxByHeat[i] = i;
	    }
Beispiel #4
0
TEST(RingZZmod32003, fromStream)
{
  std::istringstream i("+1234 +345 -235*a");
  Z_mod* R = Z_mod::create(32003);
  ring_elem a;
  while (fromStream(i, *R, a))
    {
      buffer o;
      R->elem_text_out(o, a);
      std::cout << o.str() << " peek: "
                << "." << static_cast<char>(i.peek()) << "." << std::endl;
    }
}
Beispiel #5
0
TEST(ARingZZp, fromStream)
{
  std::istringstream i("+1234 +345 -235*a");
  M2::ARingZZp R(32003);
  M2::ARingZZp::ElementType a;
  R.init(a);
  while (true)
    {
      while (isspace(i.peek())) i.get();

      if (!isdigit(i.peek()) && i.peek() != '+' && i.peek() != '-') break;

      fromStream(i, R, a);

      buffer o;
      R.elem_text_out(o, a);
      std::cout << o.str() << " peek: " << i.peek() << std::endl;
    }
  R.clear(a);
}
Beispiel #6
0
bool AddTool::_addOneFile(QString templateName, QString targetName,
                          const QList<QPair<QRegExp, QString> > &mapping)
{
    qDebug() << "Adding file:" << targetName << "from" << templateName;

    { //block to make sure file processing is done when we get out of it
        QFile templateFile(templateName);
        QFile targetFile(targetName);

        if(!targetFile.open(QIODevice::WriteOnly | QIODevice::Text))
        {
            toolError(QString("Could not open file: ") + targetName + " for write.");
            return false;
        }

        if(!templateFile.open(QIODevice::ReadOnly | QIODevice::Text))
        {
            toolError(QString("Could not open file: ") + templateName + " for read.");
            return false;
        }

        QTextStream fromStream(&templateFile);
        QTextStream toStream(&targetFile);

        transformStream(fromStream, toStream, mapping);
    }

    //Now add it to mercurial
    QProcess process;
    process.setWorkingDirectory(QFileInfo(targetName).absolutePath());
    process.start(QString("hg add ") + QFileInfo(targetName).fileName());
    if(!process.waitForFinished(3000)) //3 seconds delay
    {
        toolError(QString("Couldn't hg add the file: ") + targetName);
        return false;
    }

    FormatTool::formatFile(targetName);

    return true;
}
Beispiel #7
0
bool LLDate::fromString(const std::string& iso8601_date)
{
	std::istringstream stream(iso8601_date);
	return fromStream(stream);
}
Beispiel #8
0
void Map::fromString(const char* input_str) {
	std::stringstream stream(input_str);
	fromStream(stream);
}
Beispiel #9
0
void Map::fromFile(const char* filename) {
	std::ifstream stream;
	stream.open(filename);
	fromStream(stream);
	stream.close();
}
Beispiel #10
0
	MemoryTriplet::MemoryTriplet(std::istream & is) {
		fromStream(is);
	}
Beispiel #11
0
Curve::Curve(std::istream& isInputStream)
{
	fromStream(isInputStream);
}
Beispiel #12
0
vector<Highscores::Score> Highscores::fromString(const string& s) {
  stringstream in(s);
  return fromStream(in);
}