infra: Clean up project setup
[jog] / ausys-fake.c
... / ...
CommitLineData
1/* -*-c-*-
2 *
3 * $Id: ausys-fake.c,v 1.1 2002/02/02 19:16:28 mdw Exp $
4 *
5 * Fake not-audio-at-all audio driver
6 *
7 * (c) 2002 Mark Wooding
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of Jog: Programming for a jogging machine.
13 *
14 * Jog is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * Jog is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with Jog; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 */
28
29/*----- Header files ------------------------------------------------------*/
30
31#ifdef HAVE_CONFIG_H
32# include "config.h"
33#endif
34
35#include <stdio.h>
36#include <string.h>
37
38#include <mLib/alloc.h>
39#include <mLib/sub.h>
40#include <mLib/trace.h>
41
42#include "au.h"
43#include "ausys.h"
44#include "jog.h"
45
46/*----- Global variables --------------------------------------------------*/
47
48const char *const ausys_suffix = "txt";
49
50/*----- Main code ---------------------------------------------------------*/
51
52/* --- @ausys_init@ --- *
53 *
54 * Arguments: ---
55 *
56 * Returns: ---
57 *
58 * Use: Does any initialization required by the system-specific audio
59 * handler.
60 */
61
62void ausys_init(void)
63{
64 T( trace(T_AUSYS, "ausys: initalized ok"); )
65}
66
67/* --- @ausys_shutdown@ --- *
68 *
69 * Arguments: ---
70 *
71 * Returns: ---
72 *
73 * Use: Does any tidying up required.
74 */
75
76void ausys_shutdown(void)
77{
78 T( trace(T_AUSYS, "ausys: shut down ok"); )
79}
80
81/* --- @ausys_lock@, @ausys_unlock@ --- *
82 *
83 * Arguments: ---
84 *
85 * Returns: ---
86 *
87 * Use: Locks or unlocks the audio subsystem. This protects the
88 * audio queue from becoming corrupted during all the tedious
89 * asynchronous stuff.
90 */
91
92void ausys_lock(void) { T( trace(T_AUSYS, "ausys: acquired lock"); ) ; }
93void ausys_unlock(void) { T( trace(T_AUSYS, "ausys: released lock"); ) ; }
94
95/* --- @ausys_decode@ --- *
96 *
97 * Arguments: @au_sample *s@ = pointer to sample block
98 * @const void *p@ = pointer to sample file contents
99 * @size_t sz@ = size of sample file contents
100 *
101 * Returns: Pointer to a sample data structure.
102 *
103 * Use: Decodes a WAV file into something the system-specific layer
104 * actually wants to deal with.
105 */
106
107au_data *ausys_decode(au_sample *s, const void *p, size_t sz)
108{
109 au_data *a = CREATE(au_data);
110 const octet *pp = p;
111 const octet *qq = memchr(pp, '\n', sz);
112
113 if (qq)
114 sz = qq - pp;
115 else
116 sz++;
117 a->p = xmalloc(sz);
118 a->sz = sz;
119 memcpy(a->p, p, sz);
120 a->p[sz] = 0;
121 T( trace(T_AUSYS, "ausys: decoded `%s' ok", SYM_NAME(s)); )
122 return (a);
123}
124
125/* --- @ausys_queue@ --- *
126 *
127 * Arguments: @au_data *a@ = an audio thingy to play
128 *
129 * Returns: ---
130 *
131 * Use: Queues an audio sample to be played. The sample should be
132 * freed (with @au_free@) when it's no longer wanted.
133 */
134
135void ausys_queue(au_data *a)
136{
137 T( trace(T_AUSYS, "ausys: queuing `%s'", SYM_NAME(a->s)); )
138 printf("[%s]\n", a->p);
139 au_free(a);
140}
141
142/* --- @ausys_free@ --- *
143 *
144 * Arguments: @au_data *a@ = an audio thingy to free
145 *
146 * Returns: ---
147 *
148 * Use: Frees a decoded audio sample.
149 */
150
151void ausys_free(au_data *a)
152{
153 T( trace(T_AUSYS, "ausys: freeing data for `%s' ok", SYM_NAME(a->s)); )
154 xfree(a->p);
155 DESTROY(a);
156}
157
158/*----- That's all, folks -------------------------------------------------*/