make PlaybackBuffer<T>'s power-of-two size computation available to others
This commit is contained in:
parent
4706201425
commit
b53d80a7d4
@ -32,16 +32,18 @@ template<class T>
|
|||||||
class /*LIBPBD_API*/ PlaybackBuffer
|
class /*LIBPBD_API*/ PlaybackBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static guint power_of_two_size (guint sz) {
|
||||||
|
int32_t power_of_two;
|
||||||
|
for (power_of_two = 1; 1U << power_of_two < sz; ++power_of_two);
|
||||||
|
return 1U << power_of_two;
|
||||||
|
}
|
||||||
|
|
||||||
PlaybackBuffer (guint sz, guint res = 8191)
|
PlaybackBuffer (guint sz, guint res = 8191)
|
||||||
: reservation (res)
|
: reservation (res)
|
||||||
, _reservation_lock ()
|
, _reservation_lock ()
|
||||||
{
|
{
|
||||||
sz += reservation;
|
sz += reservation;
|
||||||
|
size = power_of_two_size (sz);
|
||||||
int32_t power_of_two;
|
|
||||||
for (power_of_two = 1; 1U << power_of_two < sz; ++power_of_two);
|
|
||||||
size = 1U << power_of_two;
|
|
||||||
|
|
||||||
size_mask = size - 1;
|
size_mask = size - 1;
|
||||||
buf = new T[size];
|
buf = new T[size];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user