2 * ALSA sequencer Memory Manager
3 * Copyright (c) 1998 by Frank van de Pol <fvdpol@coil.demon.nl>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef __SND_SEQ_MEMORYMGR_H
22 #define __SND_SEQ_MEMORYMGR_H
24 #include <sound/seq_kernel.h>
25 #include <linux/poll.h>
27 typedef struct pool pool_t
;
29 /* container for sequencer event (internal use) */
30 typedef struct snd_seq_event_cell_t
{
31 snd_seq_event_t event
;
32 pool_t
*pool
; /* used pool */
33 struct snd_seq_event_cell_t
*next
; /* next cell */
34 } snd_seq_event_cell_t
;
36 /* design note: the pool is a contigious block of memory, if we dynamicly
37 want to add additional cells to the pool be better store this in another
38 pool as we need to know the base address of the pool when releasing
42 snd_seq_event_cell_t
*ptr
; /* pointer to first event chunk */
43 snd_seq_event_cell_t
*free
; /* pointer to the head of the free list */
45 int total_elements
; /* pool size actually allocated */
46 atomic_t counter
; /* cells free */
48 int size
; /* pool size to be allocated */
49 int room
; /* watermark for sleep/wakeup */
55 int event_alloc_nopool
;
56 int event_alloc_failures
;
57 int event_alloc_success
;
60 wait_queue_head_t output_sleep
;
66 extern void snd_seq_cell_free(snd_seq_event_cell_t
* cell
);
68 int snd_seq_event_dup(pool_t
*pool
, snd_seq_event_t
*event
, snd_seq_event_cell_t
**cellp
, int nonblock
, struct file
*file
);
70 /* return number of unused (free) cells */
71 static inline int snd_seq_unused_cells(pool_t
*pool
)
73 return pool
? pool
->total_elements
- atomic_read(&pool
->counter
) : 0;
76 /* return total number of allocated cells */
77 static inline int snd_seq_total_cells(pool_t
*pool
)
79 return pool
? pool
->total_elements
: 0;
82 /* init pool - allocate events */
83 int snd_seq_pool_init(pool_t
*pool
);
85 /* done pool - free events */
86 int snd_seq_pool_done(pool_t
*pool
);
89 pool_t
*snd_seq_pool_new(int poolsize
);
92 int snd_seq_pool_delete(pool_t
**pool
);
95 int snd_sequencer_memory_init(void);
97 /* release event memory */
98 void snd_sequencer_memory_done(void);
101 int snd_seq_pool_poll_wait(pool_t
*pool
, struct file
*file
, poll_table
*wait
);