diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2019-03-18 07:32:56 -0700 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2019-03-18 07:39:23 -0700 |
commit | b53d80a7d48e4bb16c586376371e6a2b72122d78 (patch) | |
tree | 870168074f424226bf2048a5d76fc92c539bfcb2 /libs/pbd | |
parent | 4706201425e9ce7d8f4609cb920f4b28f261ee63 (diff) |
make PlaybackBuffer<T>'s power-of-two size computation available to others
Diffstat (limited to 'libs/pbd')
-rw-r--r-- | libs/pbd/pbd/playback_buffer.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libs/pbd/pbd/playback_buffer.h b/libs/pbd/pbd/playback_buffer.h index fd79d3bfa7..e5a6857b1f 100644 --- a/libs/pbd/pbd/playback_buffer.h +++ b/libs/pbd/pbd/playback_buffer.h @@ -32,16 +32,18 @@ template<class T> class /*LIBPBD_API*/ PlaybackBuffer { 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) : reservation (res) , _reservation_lock () { sz += reservation; - - int32_t power_of_two; - for (power_of_two = 1; 1U << power_of_two < sz; ++power_of_two); - size = 1U << power_of_two; - + size = power_of_two_size (sz); size_mask = size - 1; buf = new T[size]; |