13
0

add a single-element ring-buffer write function

This commit is contained in:
Robin Gareus 2016-07-10 15:56:18 +02:00
parent 140258d8ab
commit 7dfd39e708
2 changed files with 10 additions and 0 deletions

View File

@ -303,6 +303,7 @@ LuaBindings::common (lua_State* L)
.addFunction ("reset", &PBD::RingBufferNPT<uint8_t>::reset)
.addFunction ("read", &PBD::RingBufferNPT<uint8_t>::read)
.addFunction ("write", &PBD::RingBufferNPT<uint8_t>::write)
.addFunction ("write_one", &PBD::RingBufferNPT<uint8_t>::write_one)
.addFunction ("write_space", &PBD::RingBufferNPT<uint8_t>::write_space)
.addFunction ("read_space", &PBD::RingBufferNPT<uint8_t>::read_space)
.addFunction ("increment_read_ptr", &PBD::RingBufferNPT<uint8_t>::increment_read_ptr)
@ -314,6 +315,7 @@ LuaBindings::common (lua_State* L)
.addFunction ("reset", &PBD::RingBufferNPT<float>::reset)
.addFunction ("read", &PBD::RingBufferNPT<float>::read)
.addFunction ("write", &PBD::RingBufferNPT<float>::write)
.addFunction ("write_one", &PBD::RingBufferNPT<float>::write_one)
.addFunction ("write_space", &PBD::RingBufferNPT<float>::write_space)
.addFunction ("read_space", &PBD::RingBufferNPT<float>::read_space)
.addFunction ("increment_read_ptr", &PBD::RingBufferNPT<float>::increment_read_ptr)
@ -325,6 +327,7 @@ LuaBindings::common (lua_State* L)
.addFunction ("reset", &PBD::RingBufferNPT<int>::reset)
.addFunction ("read", &PBD::RingBufferNPT<int>::read)
.addFunction ("write", &PBD::RingBufferNPT<int>::write)
.addFunction ("write_one", &PBD::RingBufferNPT<int>::write_one)
.addFunction ("write_space", &PBD::RingBufferNPT<int>::write_space)
.addFunction ("read_space", &PBD::RingBufferNPT<int>::read_space)
.addFunction ("increment_read_ptr", &PBD::RingBufferNPT<int>::increment_read_ptr)

View File

@ -59,6 +59,7 @@ class /*LIBPBD_API*/ RingBufferNPT
size_t read (T *dest, size_t cnt);
size_t write (const T *src, size_t cnt);
size_t write_one (const T src);
struct rw_vector {
T *buf[2];
@ -198,6 +199,12 @@ RingBufferNPT<T>::write (const T *src, size_t cnt)
return to_write;
}
template<class T> /*LIBPBD_API*/ size_t
RingBufferNPT<T>::write_one (const T src)
{
return write (&src, 1);
}
template<class T> /*LIBPBD_API*/ void
RingBufferNPT<T>::get_read_vector (typename RingBufferNPT<T>::rw_vector *vec)
{