comparison extra_rwops.h @ 8:dca15bb29d35

Initial add.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 18 Sep 2001 10:54:21 +0000
parents
children 47cc2de2ae36
comparison
equal deleted inserted replaced
7:29313c20963d 8:dca15bb29d35
1 /*
2 * SDL_sound -- An abstract sound format decoding API.
3 * Copyright (C) 2001 Ryan C. Gordon.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Lesser General Public License for more details.
14 *
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
18 */
19
20 /*
21 * Some extra RWops that are needed or are just handy to have.
22 *
23 * Please see the file LICENSE in the source's root directory.
24 *
25 * This file written by Ryan C. Gordon. (icculus@clutteredmind.org)
26 */
27
28 #ifndef _INCLUDE_EXTRA_RWOPS_H_
29 #define _INCLUDE_EXTRA_RWOPS_H_
30
31 #include "SDL.h"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 /*
38 * The Reference Counter RWops...
39 *
40 * This wraps another RWops with a reference counter. When you create a
41 * reference counter RWops, it sets a counter to one. Everytime you call
42 * RWops_RWRefCounter_new(), that's RWops's counter increments by one.
43 * Everytime you call that RWops's close() method, the counter decrements
44 * by one. If the counter hits zero, the original RWops's close() method
45 * is called, and the reference counting wrapper deletes itself. The read,
46 * write, and seek methods just pass through to the original.
47 *
48 * This is handy if you have two libraries (in the original case, SDL_sound
49 * and SMPEG), who both want an SDL_RWops, and both want to close it when
50 * they are finished. This resolves that contention. The user creates a
51 * RWops, passes it to SDL_sound, which wraps it in a reference counter and
52 * increments the number of references, and passes the wrapped RWops to
53 * SMPEG. SMPEG "closes" this wrapped RWops when the MP3 has finished
54 * playing, and SDL_sound then closes it, too. This second closing removes
55 * the last reference, and the RWops is smoothly destructed.
56 */
57
58 /* Return a SDL_RWops that is a reference counting wrapper of (rw). */
59 SDL_RWops *RWops_RWRefCounter_new(SDL_RWops *rw);
60
61 /* Increment a reference counting RWops's refcount by one. */
62 void RWops_RWRefCounter_addRef(SDL_RWops *rw);
63
64 #ifdef __cplusplus
65 }
66 #endif
67
68 #endif /* !defined _INCLUDE_EXTRA_RWOPS_H_ */
69
70 /* end of extra_rwops.h ... */
71