annotate libcore/core/sound.h @ 147:b386d25832c8

doc: use new nomenclature, closes #2497
author David Demelier <markand@malikania.fr>
date Thu, 15 Oct 2020 09:21:04 +0200
parents 789b23e01f52
children eb0a7ab71023
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
103
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
1 /*
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
2 * sound.h -- sound support
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
3 *
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
4 * Copyright (c) 2020 David Demelier <markand@malikania.fr>
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
5 *
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
6 * Permission to use, copy, modify, and/or distribute this software for any
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
7 * purpose with or without fee is hereby granted, provided that the above
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
8 * copyright notice and this permission notice appear in all copies.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
9 *
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
17 */
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
18
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
19 #ifndef MOLKO_SOUND_H
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
20 #define MOLKO_SOUND_H
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
21
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
22 /**
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
23 * \file sound.h
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
24 * \brief Sound support.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
25 */
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
26
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
27 #include <stdbool.h>
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
28 #include <stddef.h>
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
29
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
30 /**
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
31 * \brief Sound flags.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
32 */
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
33 enum sound_flags {
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
34 SOUND_NONE, /*!< No flags. */
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
35 SOUND_LOOP = (1 << 0) /*!< Loop the music. */
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
36 };
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
37
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
38 /**
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
39 * \brief Sound chunk.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
40 */
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
41 struct sound {
147
b386d25832c8 doc: use new nomenclature, closes #2497
David Demelier <markand@malikania.fr>
parents: 121
diff changeset
42 enum sound_flags flags; /*!< (+) Flags. */
b386d25832c8 doc: use new nomenclature, closes #2497
David Demelier <markand@malikania.fr>
parents: 121
diff changeset
43 void *handle; /*!< (*) Native handle. */
103
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
44 };
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
45
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
46 /**
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
47 * Open a sound audio file.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
48 *
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
49 * \pre snd != NULL
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
50 * \pre path != NULL
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
51 * \param snd the sound object to initialize
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
52 * \param path the path to the audio file
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
53 * \return False on errors.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
54 */
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
55 bool
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
56 sound_open(struct sound *snd, const char *path);
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
57
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
58 /**
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
59 * Open a sound audio from a buffer.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
60 *
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
61 * \pre snd != NULL
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
62 * \pre buffer != NULL
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
63 * \param snd the sound object to initialize
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
64 * \param buffer the buffer
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
65 * \param buffersz the buffer size
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
66 * \return False on errors.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
67 * \warning The buffer must exists until the sound object is closed.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
68 */
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
69 bool
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
70 sound_openmem(struct sound *snd, const void *buffer, size_t buffersz);
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
71
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
72 /**
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
73 * Start playing the sound.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
74 *
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
75 * This function will resume the playback since the beginning.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
76 *
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
77 * \pre snd != NULL
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
78 * \param snd the sound object
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
79 * \return False on errors.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
80 */
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
81 bool
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
82 sound_play(struct sound *snd);
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
83
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
84 /**
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
85 * Pause the sound music.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
86 *
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
87 * \pre snd != NULL
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
88 * \param snd the sound object
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
89 */
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
90 void
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
91 sound_pause(struct sound *snd);
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
92
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
93 /**
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
94 * Resume the sound music.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
95 *
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
96 * \pre snd != NULL
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
97 * \param snd the sound object
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
98 */
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
99 void
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
100 sound_resume(struct sound *snd);
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
101
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
102 /**
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
103 * Stop the sound music.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
104 *
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
105 * \pre snd != NULL
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
106 * \param snd the sound object
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
107 */
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
108 void
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
109 sound_stop(struct sound *snd);
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
110
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
111 /**
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
112 * Close the associated resources.
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
113 *
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
114 * \pre snd != NULL
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
115 * \param snd the sound object
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
116 */
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
117 void
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
118 sound_finish(struct sound *snd);
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
119
68ce8e02061a sound: add basic sound API
David Demelier <markand@malikania.fr>
parents:
diff changeset
120 #endif /* !MOLKO_SOUND_H */