Implement BufferManager
Also, apply things learned while writing BufferManager to the similar NotePlayHandleManager
This commit is contained in:
55
include/BufferManager.h
Normal file
55
include/BufferManager.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* BufferManager.h - A buffer caching/memory management system
|
||||
*
|
||||
* Copyright (c) 2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
|
||||
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BUFFER_MANAGER_H
|
||||
#define BUFFER_MANAGER_H
|
||||
|
||||
#include "MemoryManager.h"
|
||||
#include "lmms_basics.h"
|
||||
#include "engine.h"
|
||||
#include "Mixer.h"
|
||||
#include <QtCore/QAtomicInt>
|
||||
#include <QtCore/QReadWriteLock>
|
||||
|
||||
|
||||
const int BM_INITIAL_BUFFERS = 256;
|
||||
const int BM_INCREMENT = 16;
|
||||
|
||||
class BufferManager
|
||||
{
|
||||
public:
|
||||
static void init();
|
||||
static sampleFrame * acquire();
|
||||
static void release( sampleFrame * buf );
|
||||
static void extend( int c );
|
||||
|
||||
private:
|
||||
static sampleFrame ** s_available;
|
||||
static QAtomicInt s_availableIndex;
|
||||
static QReadWriteLock s_mutex;
|
||||
static int s_size;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "track.h"
|
||||
#include "MemoryManager.h"
|
||||
#include <QtCore/QAtomicInt>
|
||||
#include <QtCore/QReadWriteLock>
|
||||
|
||||
class InstrumentTrack;
|
||||
class NotePlayHandle;
|
||||
@@ -333,10 +334,10 @@ public:
|
||||
static void extend( int i );
|
||||
|
||||
private:
|
||||
static NotePlayHandleList s_nphCache;
|
||||
static NotePlayHandleList s_available;
|
||||
static QMutex s_mutex;
|
||||
static NotePlayHandle ** s_available;
|
||||
static QReadWriteLock s_mutex;
|
||||
static QAtomicInt s_availableIndex;
|
||||
static int s_size;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user