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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 /* These funcs are only used by pcm_mmap when sys/shm.h is available. */
37 struct list_head list;
44 static LIST_HEAD(shm_areas);
47 * \brief Create a shm area record
48 * \param shmid IPC SHM ID
49 * \param ptr the shared area pointer
50 * \return The allocated shm area record, NULL if fail
52 * Allocates a shared area record with the given SHM ID and pointer.
53 * The record has a reference counter, which is initialized to 1 by this function.
55 struct snd_shm_area *snd_shm_area_create(int shmid, void *ptr)
57 struct snd_shm_area *area = malloc(sizeof(*area));
62 list_add_tail(&area->list, &shm_areas);
68 * \brief Increase the reference counter of shm area record
69 * \param area shm area record
70 * \return the shm area record (identical with the argument)
72 * Increases the reference counter of the given shared area record.
74 struct snd_shm_area *snd_shm_area_share(struct snd_shm_area *area)
83 * \brief Release the shared area record
84 * \param area the shared are record
85 * \return 0 if successful, or a negative error code
87 * Decreases the reference counter of the given shared area record, and
88 * releases the resources automaticall if it reaches to 0.
90 int snd_shm_area_destroy(struct snd_shm_area *area)
96 list_del(&area->list);
102 void snd_shm_area_destructor(void) __attribute__ ((destructor));
104 void snd_shm_area_destructor(void)
106 struct list_head *pos;
107 struct snd_shm_area *area;
109 list_for_each(pos, &shm_areas) {
110 area = list_entry(pos, struct snd_shm_area, list);