Logo Search packages:      
Sourcecode: rosegarden version File versions


// -*- c-basic-offset: 4 -*-

    A sequencer and musical notation editor.

    This program is Copyright 2000-2006
        Guillaume Laurent   <glaurent@telegraph-road.org>,
        Chris Cannam        <cannam@all-day-breakfast.com>,
        Richard Bown        <bownie@bownie.com>

    The moral right of the authors to claim authorship of this work
    has been asserted.

    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.  See the file
    COPYING included with this distribution for more information.

#ifndef _AUDIO_CACHE_H_
#define _AUDIO_CACHE_H_

#include <map>

namespace Rosegarden

 * A simple cache for smallish bits of audio data, indexed by some
 * opaque pointer type.  (The PlayableAudioFile uses this with an
 * AudioFile* index type, for example.)  With reference counting.

00036 class AudioCache
    AudioCache() { }
    virtual ~AudioCache();

     * Look some audio data up in the cache and report whether it
     * exists.
    bool has(void *index);

     * Look some audio data up in the cache and return it if it
     * exists, returning the number of channels in channels, the frame
     * count in frames, and one pointer per channel to samples in the
     * return value.  Return 0 if the data is not in cache.  Does not
     * affect the reference count.  Ownership of the returned data
     * remains with the cache object.  You should not call this unless
     * you have already called incrementReference (or addData) to
     * register your interest.
    float **getData(void *index, size_t &channels, size_t &frames);

     * Add a piece of data to the cache, and increment the reference
     * count for that data (to 1).  Ownership of the data is passed
     * to the cache, which will delete it with delete[] when done.
    void addData(void *index, size_t channels, size_t nframes, float **data);

     * Increment the reference count for a given piece of data.
    void incrementReference(void *index);

     * Decrement the reference count for a given piece of data,
     * and delete the data from the cache if the reference count has
     * reached zero.
    void decrementReference(void *index);

    void clear();

    struct CacheRec {
      CacheRec() : data(0), channels(0), nframes(0), refCount(0) { }
      CacheRec(float **d, size_t c, size_t n) :
          data(d), channels(c), nframes(n), refCount(1) { }
      float **data;
      size_t channels;
      size_t nframes;
      int refCount;

    std::map<void *, CacheRec *> m_cache;



Generated by  Doxygen 1.6.0   Back to index