3 * Copyright (c) 2003 by Jaroslav Kysela <perex@perex.cz>
5 * This library is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as
7 * published by the Free Software Foundation; either version 2.1 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 struct list_head list;
39 static LIST_HEAD(shm_areas);
42 * \brief Create a shm area record
43 * \param shmid IPC SHM ID
44 * \param ptr the shared area pointer
45 * \return The allocated shm area record, NULL if fail
47 * Allocates a shared area record with the given SHM ID and pointer.
48 * The record has a reference counter, which is initialized to 1 by this function.
50 struct snd_shm_area *snd_shm_area_create(int shmid, void *ptr)
52 struct snd_shm_area *area = malloc(sizeof(*area));
57 list_add_tail(&area->list, &shm_areas);
63 * \brief Increase the reference counter of shm area record
64 * \param area shm area record
65 * \return the shm area record (identical with the argument)
67 * Increases the reference counter of the given shared area record.
69 struct snd_shm_area *snd_shm_area_share(struct snd_shm_area *area)
78 * \brief Release the shared area record
79 * \param area the shared are record
80 * \return 0 if successful, or a negative error code
82 * Decreases the reference counter of the given shared area record, and
83 * releases the resources automaticall if it reaches to 0.
85 int snd_shm_area_destroy(struct snd_shm_area *area)
91 list_del(&area->list);
97 void snd_shm_area_destructor(void) __attribute__ ((destructor));
99 void snd_shm_area_destructor(void)
101 struct list_head *pos;
102 struct snd_shm_area *area;
104 list_for_each(pos, &shm_areas) {
105 area = list_entry(pos, struct snd_shm_area, list);