output/alsa: improve silence generator test in DrainInternal()

There cannot be partial frames in the buffer, so we don't need
GetPeriodPosition(); it's enough to check whether head has been moved
in this period.
This commit is contained in:
Max Kellermann
2019-06-27 21:17:37 +02:00
parent 9fc1668de3
commit 8f6c750064
2 changed files with 9 additions and 6 deletions

View File

@@ -73,6 +73,14 @@ public:
return tail >= capacity;
}
/**
* Has some data already been consumed at the buffer's head in
* this period?
*/
bool WasConsumed() const noexcept {
return head > 0;
}
/**
* Returns the tail of the buffer, i.e. where new data can be
* written. Call GetSpaceBytes() to find out how much may be
@@ -163,10 +171,6 @@ public:
ConsumeBytes(n * frame_size);
}
snd_pcm_uframes_t GetPeriodPosition(size_t frame_size) const noexcept {
return head / frame_size;
}
void Rewind() noexcept {
head = 0;
}