diff options
| author | vovanec <vovanec@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-02-07 13:36:34 +0000 |
|---|---|---|
| committer | vovanec <vovanec@90c681e8-e032-0410-971d-27865f9a5e38> | 2008-02-07 13:36:34 +0000 |
| commit | 06d1877811fa6aa97dddc0e03bcde4e766928c87 (patch) | |
| tree | c25462d0e58c3d58c728664440412bf4f16a49ec /lib/recycler.cpp | |
| parent | 3f6b60f23c44a8ba8dd97ca6f41a16e2af7ef2f7 (diff) | |
| download | qmmp-06d1877811fa6aa97dddc0e03bcde4e766928c87.tar.gz qmmp-06d1877811fa6aa97dddc0e03bcde4e766928c87.tar.bz2 qmmp-06d1877811fa6aa97dddc0e03bcde4e766928c87.zip | |
new directory structure
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@232 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'lib/recycler.cpp')
| -rw-r--r-- | lib/recycler.cpp | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/lib/recycler.cpp b/lib/recycler.cpp deleted file mode 100644 index 15d2234a6..000000000 --- a/lib/recycler.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) 2000-2001 Brad Hughes <bhughes@trolltech.com> -// -// Use, modification and distribution is allowed without limitation, -// warranty, or liability of any kind. -// - -#include "recycler.h" -#include "constants.h" -#include "buffer.h" - - -Recycler::Recycler ( unsigned int sz ) - : add_index ( 0 ), done_index ( 0 ), current_count ( 0 ) -{ - buffer_count = ( sz / Buffer::size() ); - if ( buffer_count < 1 ) - { - buffer_count = 1; - } - - buffers = new Buffer*[buffer_count]; - - for ( unsigned int i = 0; i < buffer_count; i ++ ) - { - buffers[i] = new Buffer; - } -} - - -Recycler::~Recycler() -{ - for ( unsigned int i = 0; i < buffer_count; i++ ) - { - delete buffers[i]; - buffers[i] = 0; - } - - delete [] buffers; -} - - -bool Recycler::full() const -{ - return current_count == buffer_count; -} - - -bool Recycler::empty() const -{ - return current_count == 0; -} - - -int Recycler::available() const -{ - return buffer_count - current_count; -} - -int Recycler::used() const -{ - return current_count; -} - - -Buffer *Recycler::get(unsigned long size) -{ - if (full()) - return 0; - if(size > Buffer::size() + buffers[add_index]->exceeding) - { - delete buffers[add_index]->data; - buffers[add_index]->data = new unsigned char[size]; - buffers[add_index]->exceeding = size - Buffer::size(); - //qDebug("new size = %d, index = %d", size, add_index); - } - - return buffers[add_index]; -} - - -void Recycler::add() -{ - add_index = ++add_index % buffer_count; - current_count++; -} - - -Buffer *Recycler::next() -{ - return buffers[done_index]; -} - - -void Recycler::done() -{ - done_index = ++done_index % buffer_count; - current_count--; -} - - -void Recycler::clear() -{ - add_index = done_index = current_count = 0; - /*for ( unsigned int i = 0; i < buffer_count; i ++ ) - { - if(buffers[i]->exceeding > 0) - { - delete buffers[i]->data; - buffers[i]->data = new unsigned char[Buffer::size()]; - buffers[i]->exceeding = 0; - buffers[i]->nbytes = 0; - } - }*/ -} - - -unsigned int Recycler::size() const -{ - return buffer_count * Buffer::size(); -} |
