X-Git-Url: https://git.distorted.org.uk/~mdw/jog/blobdiff_plain/b1ffb19d137241e62b4eea0e6db834bd624bdda2..e9060e7e4c0de71ef6d4b7d7b05c3167790073e3:/ausys-fake.c diff --git a/ausys-fake.c b/ausys-fake.c new file mode 100644 index 0000000..121cb79 --- /dev/null +++ b/ausys-fake.c @@ -0,0 +1,166 @@ +/* -*-c-*- + * + * $Id: ausys-fake.c,v 1.1 2002/02/02 19:16:28 mdw Exp $ + * + * Fake not-audio-at-all audio driver + * + * (c) 2002 Mark Wooding + */ + +/*----- Licensing notice --------------------------------------------------* + * + * This file is part of Jog: Programming for a jogging machine. + * + * Jog is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Jog is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jog; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/*----- Revision history --------------------------------------------------* + * + * $Log: ausys-fake.c,v $ + * Revision 1.1 2002/02/02 19:16:28 mdw + * New audio subsystem. + * + */ + +/*----- Header files ------------------------------------------------------*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include +#include +#include + +#include "au.h" +#include "ausys.h" +#include "jog.h" + +/*----- Global variables --------------------------------------------------*/ + +const char *const ausys_suffix = "txt"; + +/*----- Main code ---------------------------------------------------------*/ + +/* --- @ausys_init@ --- * + * + * Arguments: --- + * + * Returns: --- + * + * Use: Does any initialization required by the system-specific audio + * handler. + */ + +void ausys_init(void) +{ + T( trace(T_AUSYS, "ausys: initalized ok"); ) +} + +/* --- @ausys_shutdown@ --- * + * + * Arguments: --- + * + * Returns: --- + * + * Use: Does any tidying up required. + */ + +void ausys_shutdown(void) +{ + T( trace(T_AUSYS, "ausys: shut down ok"); ) +} + +/* --- @ausys_lock@, @ausys_unlock@ --- * + * + * Arguments: --- + * + * Returns: --- + * + * Use: Locks or unlocks the audio subsystem. This protects the + * audio queue from becoming corrupted during all the tedious + * asynchronous stuff. + */ + +void ausys_lock(void) { T( trace(T_AUSYS, "ausys: acquired lock"); ) ; } +void ausys_unlock(void) { T( trace(T_AUSYS, "ausys: released lock"); ) ; } + +/* --- @ausys_decode@ --- * + * + * Arguments: @au_sample *s@ = pointer to sample block + * @const void *p@ = pointer to sample file contents + * @size_t sz@ = size of sample file contents + * + * Returns: Pointer to a sample data structure. + * + * Use: Decodes a WAV file into something the system-specific layer + * actually wants to deal with. + */ + +au_data *ausys_decode(au_sample *s, const void *p, size_t sz) +{ + au_data *a = CREATE(au_data); + const octet *pp = p; + const octet *qq = memchr(pp, '\n', sz); + + if (qq) + sz = qq - pp; + else + sz++; + a->p = xmalloc(sz); + a->sz = sz; + memcpy(a->p, p, sz); + a->p[sz] = 0; + T( trace(T_AUSYS, "ausys: decoded `%s' ok", SYM_NAME(s)); ) + return (a); +} + +/* --- @ausys_queue@ --- * + * + * Arguments: @au_data *a@ = an audio thingy to play + * + * Returns: --- + * + * Use: Queues an audio sample to be played. The sample should be + * freed (with @au_free@) when it's no longer wanted. + */ + +void ausys_queue(au_data *a) +{ + T( trace(T_AUSYS, "ausys: queuing `%s'", SYM_NAME(a->s)); ) + printf("[%s]\n", a->p); + au_free(a); +} + +/* --- @ausys_free@ --- * + * + * Arguments: @au_data *a@ = an audio thingy to free + * + * Returns: --- + * + * Use: Frees a decoded audio sample. + */ + +void ausys_free(au_data *a) +{ + T( trace(T_AUSYS, "ausys: freeing data for `%s' ok", SYM_NAME(a->s)); ) + xfree(a->p); + DESTROY(a); +} + +/*----- That's all, folks -------------------------------------------------*/