Qmmp
|
00001 /*************************************************************************** 00002 * Copyright (C) 2017 by Ilya Kotov * 00003 * forkotov02@hotmail.ru * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 00019 ***************************************************************************/ 00020 00021 #ifndef VISUALBUFFER_P_H 00022 #define VISUALBUFFER_P_H 00023 00024 #include <QtGlobal> 00025 #include <QTime> 00026 #include <QMutex> 00027 00028 #define VISUAL_BUFFER_SIZE 128 //number of nodes 00029 00030 class VisualNode 00031 { 00032 public: 00033 float data[2][512]; 00034 bool used; 00035 qint64 ts; 00036 00037 VisualNode() 00038 { 00039 used = false; 00040 ts = 0; 00041 } 00042 }; 00043 00044 class VisualBuffer 00045 { 00046 public: 00047 VisualBuffer(); 00048 00049 void add(float *pcm, int samples, int channels, qint64 ts, qint64 delay); 00050 VisualNode *take(); 00051 void clear(); 00052 QMutex *mutex(); 00053 00054 private: 00055 VisualNode m_buffer[VISUAL_BUFFER_SIZE]; 00056 qint64 m_elapsed; 00057 int m_take_index; 00058 int m_add_index; 00059 QTime m_time; 00060 QMutex m_mutex; 00061 00062 }; 00063 00064 #endif // VISUALBUFFER_P_H