mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-27 21:38:48 +02:00
close ALSA if there is no audio
This commit is contained in:
parent
3d43f51efd
commit
cbdc850be1
3 changed files with 21 additions and 1 deletions
|
@ -198,6 +198,8 @@ void AlsaPlayer::worker()
|
|||
{
|
||||
snd_pcm_sframes_t pcm;
|
||||
snd_pcm_sframes_t framesDelay;
|
||||
long lastChunkTick = 0;
|
||||
|
||||
while (active_)
|
||||
{
|
||||
if (handle_ == NULL)
|
||||
|
@ -220,6 +222,7 @@ void AlsaPlayer::worker()
|
|||
|
||||
if (stream_->getPlayerChunk(buff_, delay, frames_))
|
||||
{
|
||||
lastChunkTick = chronos::getTickCount();
|
||||
adjustVolume(buff_, frames_);
|
||||
if ((pcm = snd_pcm_writei(handle_, buff_, frames_)) == -EPIPE)
|
||||
{
|
||||
|
@ -236,7 +239,15 @@ void AlsaPlayer::worker()
|
|||
{
|
||||
logO << "Failed to get chunk\n";
|
||||
while (active_ && !stream_->waitForChunk(100))
|
||||
{
|
||||
logD << "Waiting for chunk\n";
|
||||
if ((handle_ != NULL) && (chronos::getTickCount() - lastChunkTick > 5000))
|
||||
{
|
||||
logO << "No chunk received for 5000ms. Closing ALSA.\n";
|
||||
uninitAlsa();
|
||||
stream_->clearChunks();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ void Stream::clearChunks()
|
|||
{
|
||||
while (chunks_.size() > 0)
|
||||
chunks_.pop();
|
||||
resetBuffers();
|
||||
}
|
||||
|
||||
|
||||
|
@ -364,7 +365,7 @@ bool Stream::getPlayerChunk(void* outputBuffer, const cs::usec& outputBufferDacT
|
|||
logO << "Chunk: " << age.count()/100 << "\t" << miniBuffer_.median()/100 << "\t" << shortMedian_/100 << "\t" << median_/100 << "\t" << buffer_.size() << "\t" << cs::duration<cs::msec>(outputBufferDacTime) << "\n";
|
||||
// logO << "Chunk: " << age.count()/1000 << "\t" << miniBuffer_.median()/1000 << "\t" << shortMedian_/1000 << "\t" << median_/1000 << "\t" << buffer_.size() << "\t" << cs::duration<cs::msec>(outputBufferDacTime) << "\n";
|
||||
}
|
||||
return true;
|
||||
return (abs(cs::duration<cs::msec>(age)) < 500);
|
||||
}
|
||||
catch(int e)
|
||||
{
|
||||
|
|
|
@ -83,3 +83,11 @@ https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
|
|||
-HiRes Audio
|
||||
-Android auto start
|
||||
-pipe creation mode: `-s pipe:///tmp/snapfifo?mode=[read|create]`
|
||||
|
||||
|
||||
*Dependencies
|
||||
libavahi-client3
|
||||
libflac8
|
||||
libogg0
|
||||
libvorbis0a
|
||||
libvorbisenc2
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue