TTKMusicPlayer  3.7.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
recycler_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2010-2024 by Ilya Kotov *
3  * forkotov02@ya.ru *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef RECYCLER_P_H
22 #define RECYCLER_P_H
23 
24 #include <QMutex>
25 #include <QWaitCondition>
26 #include "buffer.h"
27 
33 {
34 public:
38  Recycler() = default;
42  ~Recycler();
43 
49  void configure(quint32 freq, int chan);
53  bool full() const;
57  bool empty() const;
61  int available() const;
65  int used() const;
69  Buffer *next();
73  Buffer *get(); // get next in recycle
77  void add(); // add to queue
81  void done(); // add to recycle
85  void clear(); // clear queue
89  size_t samples() const; // size in samples
93  size_t blockSamples() const; // size in samples
94 
98  QMutex *mutex()
99  {
100  return &m_mtx;
101  }
105  QWaitCondition *cond()
106  {
107  return &m_cnd;
108  }
112  bool blocked();
113 
114 private:
115  unsigned int m_buffer_count = 0, m_add_index = 0, m_done_index = 0, m_current_count = 0;
116  size_t m_block_samples = 0;
117  Buffer **m_buffers = nullptr;
118  QMutex m_mtx;
119  QWaitCondition m_cnd;
120  Buffer *m_blocked = nullptr;
121 
122 };
123 
124 #endif
QWaitCondition m_cnd
Definition: recycler_p.h:119
QMutex * mutex()
Definition: recycler_p.h:98
QMutex m_mtx
Definition: recycler_p.h:118
QWaitCondition * cond()
Definition: recycler_p.h:105
#define QMMP_EXPORT
Definition: qmmp_export.h:29
Audio buffer class.
Definition: buffer.h:33