Audio_in::Stream: add 'queued()' function

Fixes #4374
This commit is contained in:
Christian Prochaska 2022-01-11 22:18:53 +01:00 committed by Christian Helmuth
parent 7b40ccea85
commit 7f8a94bb70

View File

@ -14,7 +14,7 @@
*/ */
/* /*
* Copyright (C) 2015-2017 Genode Labs GmbH * Copyright (C) 2015-2022 Genode Labs GmbH
* *
* This file is part of the Genode OS framework, which is distributed * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3. * under the terms of the GNU Affero General Public License version 3.
@ -162,6 +162,21 @@ class Audio_in::Stream
*/ */
unsigned tail() const { return _tail; } unsigned tail() const { return _tail; }
/**
* Number of packets between record and allocation position
*
* \return number
*/
unsigned queued() const
{
if (_tail > _pos)
return _tail - _pos;
else if (_pos > _tail)
return QUEUE_SIZE - (_pos - _tail);
else
return 0;
}
/** /**
* Retrieve next packet for given packet * Retrieve next packet for given packet
* *