mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-11 08:06:41 +02:00
Clean up AsioStream reader code
This commit is contained in:
parent
3cb9902bbe
commit
a47849a571
8 changed files with 35 additions and 137 deletions
|
@ -65,97 +65,3 @@ void PipeStream::disconnect()
|
|||
stream_->close();
|
||||
}
|
||||
|
||||
// void PipeStream::worker()
|
||||
// {
|
||||
// timeval tvChunk;
|
||||
// std::unique_ptr<msg::PcmChunk> chunk(new msg::PcmChunk(sampleFormat_, pcmReadMs_));
|
||||
// string lastException = "";
|
||||
|
||||
// while (active_)
|
||||
// {
|
||||
// if (fd_ != -1)
|
||||
// close(fd_);
|
||||
// fd_ = open(uri_.path.c_str(), O_RDONLY | O_NONBLOCK);
|
||||
// chronos::systemtimeofday(&tvChunk);
|
||||
// tvEncodedChunk_ = tvChunk;
|
||||
// long nextTick = chronos::getTickCount();
|
||||
// int idleBytes = 0;
|
||||
// int maxIdleBytes = sampleFormat_.rate * sampleFormat_.frameSize * dryoutMs_ / 1000;
|
||||
// try
|
||||
// {
|
||||
// if (fd_ == -1)
|
||||
// throw SnapException("failed to open fifo: \"" + uri_.path + "\"");
|
||||
|
||||
// while (active_)
|
||||
// {
|
||||
// chunk->timestamp.sec = tvChunk.tv_sec;
|
||||
// chunk->timestamp.usec = tvChunk.tv_usec;
|
||||
// int toRead = chunk->payloadSize;
|
||||
// int len = 0;
|
||||
// do
|
||||
// {
|
||||
// int count = read(fd_, chunk->payload + len, toRead - len);
|
||||
// if (count < 0 && idleBytes < maxIdleBytes)
|
||||
// {
|
||||
// memset(chunk->payload + len, 0, toRead - len);
|
||||
// idleBytes += toRead - len;
|
||||
// len += toRead - len;
|
||||
// continue;
|
||||
// }
|
||||
// if (count < 0)
|
||||
// {
|
||||
// setState(kIdle);
|
||||
// if (!sleep(100))
|
||||
// break;
|
||||
// }
|
||||
// else if (count == 0)
|
||||
// throw SnapException("end of file");
|
||||
// else
|
||||
// {
|
||||
// len += count;
|
||||
// idleBytes = 0;
|
||||
// }
|
||||
// } while ((len < toRead) && active_);
|
||||
|
||||
// if (!active_)
|
||||
// break;
|
||||
|
||||
// /// TODO: use less raw pointers, make this encoding more transparent
|
||||
// encoder_->encode(chunk.get());
|
||||
|
||||
// if (!active_)
|
||||
// break;
|
||||
|
||||
// nextTick += pcmReadMs_;
|
||||
// chronos::addUs(tvChunk, pcmReadMs_ * 1000);
|
||||
// long currentTick = chronos::getTickCount();
|
||||
|
||||
// if (nextTick >= currentTick)
|
||||
// {
|
||||
// setState(kPlaying);
|
||||
// if (!sleep(nextTick - currentTick))
|
||||
// break;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// chronos::systemtimeofday(&tvChunk);
|
||||
// tvEncodedChunk_ = tvChunk;
|
||||
// pcmListener_->onResync(this, currentTick - nextTick);
|
||||
// nextTick = currentTick;
|
||||
// }
|
||||
|
||||
// lastException = "";
|
||||
// }
|
||||
// }
|
||||
// catch (const std::exception& e)
|
||||
// {
|
||||
// if (lastException != e.what())
|
||||
// {
|
||||
// LOG(ERROR) << "(PipeStream) Exception: " << e.what() << std::endl;
|
||||
// lastException = e.what();
|
||||
// }
|
||||
// if (!sleep(100))
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue