Files

103 lines
3.1 KiB
C
Raw Permalink Normal View History

2005-04-16 15:20:36 -07:00
/*
* ALSA sequencer Memory Manager
* Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
*
*
* 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; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __SND_SEQ_MEMORYMGR_H
#define __SND_SEQ_MEMORYMGR_H
#include <sound/seq_kernel.h>
#include <linux/poll.h>
2011-02-14 11:00:47 +01:00
struct snd_info_buffer;
2005-04-16 15:20:36 -07:00
/* container for sequencer event (internal use) */
2005-11-17 14:04:02 +01:00
struct snd_seq_event_cell {
struct snd_seq_event event;
struct snd_seq_pool *pool; /* used pool */
struct snd_seq_event_cell *next; /* next cell */
};
2005-04-16 15:20:36 -07:00
2006-06-26 18:35:02 +02:00
/* design note: the pool is a contiguous block of memory, if we dynamicly
2005-04-16 15:20:36 -07:00
want to add additional cells to the pool be better store this in another
pool as we need to know the base address of the pool when releasing
memory. */
2005-11-17 14:04:02 +01:00
struct snd_seq_pool {
struct snd_seq_event_cell *ptr; /* pointer to first event chunk */
struct snd_seq_event_cell *free; /* pointer to the head of the free list */
2005-04-16 15:20:36 -07:00
int total_elements; /* pool size actually allocated */
atomic_t counter; /* cells free */
int size; /* pool size to be allocated */
int room; /* watermark for sleep/wakeup */
int closing;
/* statistics */
int max_used;
int event_alloc_nopool;
int event_alloc_failures;
int event_alloc_success;
/* Write locking */
wait_queue_head_t output_sleep;
/* Pool lock */
spinlock_t lock;
};
2005-11-17 14:04:02 +01:00
void snd_seq_cell_free(struct snd_seq_event_cell *cell);
2005-04-16 15:20:36 -07:00
2005-11-17 14:04:02 +01:00
int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event,
struct snd_seq_event_cell **cellp, int nonblock,
struct file *file, struct mutex *mutexp);
2005-04-16 15:20:36 -07:00
/* return number of unused (free) cells */
2005-11-17 14:04:02 +01:00
static inline int snd_seq_unused_cells(struct snd_seq_pool *pool)
2005-04-16 15:20:36 -07:00
{
return pool ? pool->total_elements - atomic_read(&pool->counter) : 0;
}
/* return total number of allocated cells */
2005-11-17 14:04:02 +01:00
static inline int snd_seq_total_cells(struct snd_seq_pool *pool)
2005-04-16 15:20:36 -07:00
{
return pool ? pool->total_elements : 0;
}
/* init pool - allocate events */
2005-11-17 14:04:02 +01:00
int snd_seq_pool_init(struct snd_seq_pool *pool);
2005-04-16 15:20:36 -07:00
/* done pool - free events */
void snd_seq_pool_mark_closing(struct snd_seq_pool *pool);
2005-11-17 14:04:02 +01:00
int snd_seq_pool_done(struct snd_seq_pool *pool);
2005-04-16 15:20:36 -07:00
/* create pool */
2005-11-17 14:04:02 +01:00
struct snd_seq_pool *snd_seq_pool_new(int poolsize);
2005-04-16 15:20:36 -07:00
/* remove pool */
2005-11-17 14:04:02 +01:00
int snd_seq_pool_delete(struct snd_seq_pool **pool);
2005-04-16 15:20:36 -07:00
/* polling */
2005-11-17 14:04:02 +01:00
int snd_seq_pool_poll_wait(struct snd_seq_pool *pool, struct file *file, poll_table *wait);
2005-04-16 15:20:36 -07:00
2011-02-14 11:00:47 +01:00
void snd_seq_info_pool(struct snd_info_buffer *buffer,
struct snd_seq_pool *pool, char *space);
2005-04-16 15:20:36 -07:00
#endif