make PlaybackBuffer<T>'s power-of-two size computation available to others
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 18 Mar 2019 14:32:56 +0000 (07:32 -0700)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 18 Mar 2019 14:39:23 +0000 (07:39 -0700)
libs/pbd/pbd/playback_buffer.h

index fd79d3bfa73b87ecb5deeb1cc25f46ceacd9d175..e5a6857b1f974954d6a9245d9c1cbcd5c71f1055 100644 (file)
@@ -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];