Qmmp
/usr/src/RPM/BUILD/qmmp-0.7-svn/src/qmmp/recycler.h
00001 // Copyright (c) 2000-2001 Brad Hughes <bhughes@trolltech.com>
00002 //
00003 // Use, modification and distribution is allowed without limitation,
00004 // warranty, or liability of any kind.
00005 //
00006 
00007 #ifndef __recycler_h
00008 #define __recycler_h
00009 
00010 #include <QMutex>
00011 #include <QWaitCondition>
00012 #include "qmmp.h"
00013 
00014 class Buffer;
00015 
00019 class Recycler
00020 {
00021 public:
00025     Recycler();
00029     ~Recycler();
00036     void configure(quint32 freq, int chan, Qmmp::AudioFormat format);
00040     bool full() const;
00044     bool empty() const;
00048     int available() const;
00052     int used() const;
00056     Buffer *next();
00060     Buffer *get(); // get next in recycle
00064     void add(); // add to queue
00068     void done(); // add to recycle
00072     void clear(); // clear queue
00076     unsigned long size() const; // size in bytes
00080     QMutex *mutex()
00081     {
00082         return &m_mtx;
00083     }
00087     QWaitCondition *cond()
00088     {
00089         return &m_cnd;
00090     }
00094     bool blocked();
00095 
00096 private:
00097     unsigned int m_buffer_count, m_add_index, m_done_index, m_current_count;
00098     unsigned long m_block_size;
00099     Buffer **m_buffers;
00100     QMutex m_mtx;
00101     QWaitCondition m_cnd;
00102     Buffer *m_blocked;
00103 };
00104 
00105 #endif // __recycler_h
 All Classes Functions Variables Enumerations Enumerator