[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog backend/sound_handler.h
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog backend/sound_handler.h |
Date: |
Wed, 26 Sep 2007 07:25:01 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/09/26 07:25:00
Modified files:
. : ChangeLog
backend : sound_handler.h
Log message:
* backend/sound_handler.h: add more services to the
Buffer class (sounds like reinventing the std::vector class
actually).
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4412&r2=1.4413
http://cvs.savannah.gnu.org/viewcvs/gnash/backend/sound_handler.h?cvsroot=gnash&r1=1.27&r2=1.28
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.4412
retrieving revision 1.4413
diff -u -b -r1.4412 -r1.4413
--- ChangeLog 26 Sep 2007 07:09:01 -0000 1.4412
+++ ChangeLog 26 Sep 2007 07:25:00 -0000 1.4413
@@ -1,5 +1,11 @@
2007-09-26 Sandro Santilli <address@hidden>
+ * backend/sound_handler.h: add more services to the
+ Buffer class (sounds like reinventing the std::vector class
+ actually).
+
+2007-09-26 Sandro Santilli <address@hidden>
+
* backend/sound_handler.h: define a Buffer class
to avoid duplicating code within the different
versions of sound_data and active_sound.
Index: backend/sound_handler.h
===================================================================
RCS file: /sources/gnash/gnash/backend/sound_handler.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- backend/sound_handler.h 26 Sep 2007 07:09:02 -0000 1.27
+++ backend/sound_handler.h 26 Sep 2007 07:25:00 -0000 1.28
@@ -18,7 +18,7 @@
//
//
-/* $Id: sound_handler.h,v 1.27 2007/09/26 07:09:02 strk Exp $ */
+/* $Id: sound_handler.h,v 1.28 2007/09/26 07:25:00 strk Exp $ */
/// \page sound_handler_intro Sound handler introduction
///
@@ -72,20 +72,7 @@
return;
}
- if ( _capacity < _size+size )
- {
- // TODO: find the smallest bigger power of 2 ?
- unsigned long newCapacity = std::max(_capacity*2,
_size+size);
-
- //log_debug("Buffer %p reallocating from %lu to %lu
bytes", (void*)this, _capacity, newCapacity);
-
- _capacity = newCapacity;
-
- uint8_t* tmp = _data;
- _data = new uint8_t[_capacity];
- memcpy(_data, tmp, _size);
- delete [] tmp;
- }
+ reserve(_size+size);
assert(_capacity >= _size+size);
memcpy(_data+_size, newData, size);
@@ -98,6 +85,43 @@
return _data;
}
+ uint8_t* data()
+ {
+ return _data;
+ }
+
+ const uint8_t* data(size_t pos) const
+ {
+ assert(pos < _capacity);
+ return _data+pos;
+ }
+
+ uint8_t* data(size_t pos)
+ {
+ assert(pos < _capacity);
+ return _data+pos;
+ }
+
+ void resize(size_t newSize)
+ {
+ // we won't change capacity here
+ // (should we?)
+ _size = newSize;
+ }
+
+ void reserve(size_t newCapacity)
+ {
+ if ( _capacity > newCapacity ) return;
+
+ // TODO: use smalles power of 2 bigger then newCapacity
+ _capacity = std::max(newCapacity, _capacity*2);
+
+ uint8_t* tmp = _data;
+ _data = new uint8_t[_capacity];
+ memcpy(_data, tmp, _size);
+ delete [] tmp;
+ }
+
size_t size() const
{
return _size;
- [Gnash-commit] gnash ChangeLog backend/sound_handler.h,
Sandro Santilli <=