Mercurial > SDL_sound_CoreAudio
diff decoders/skeleton.c @ 16:3efbcaf36fec
Initial add.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 19 Sep 2001 06:24:58 +0000 |
parents | |
children | d9b9d60cf9a9 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/decoders/skeleton.c Wed Sep 19 06:24:58 2001 +0000 @@ -0,0 +1,119 @@ +/* + * SDL_sound -- An abstract sound format decoding API. + * Copyright (C) 2001 Ryan C. Gordon. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* + * FMT decoder for SDL_sound. + * + * This driver handles FMT audio data. Blahblahblah... The author should + * have done a search and replace on "fmt" and "FMT" and changed this + * comment. This is the default comment in the skeleton decoder file... + * + * Please see the file LICENSE in the source's root directory. + * + * This file written by Ryan C. Gordon. (icculus@clutteredmind.org) + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> +#include "SDL_sound.h" + +#define __SDL_SOUND_INTERNAL__ +#include "SDL_sound_internal.h" + +#if (!defined SOUND_SUPPORTS_FMT) +#error SOUND_SUPPORTS_FMT must be defined. +#endif + + +static int FMT_open(Sound_Sample *sample, const char *ext); +static void FMT_close(Sound_Sample *sample); +static Uint32 FMT_read(Sound_Sample *sample); + +const Sound_DecoderFunctions __Sound_DecoderFunctions_FMT = +{ + { + "FMT", + "FMT audio format description", + "Ryan C. Gordon <icculus@clutteredmind.org>", + "http://www.icculus.org/SDL_sound/" + }, + + FMT_open, /* open() method */ + FMT_close, /* close() method */ + FMT_read /* read() method */ +}; + + +static int FMT_open(Sound_Sample *sample, const char *ext) +{ + if (can NOT accept the data) + { + Sound_SetError("FMT: expected X, got Y."); + return(0); + } /* if */ + + _D(("FMT: Accepting data stream.\n")); + set up sample->actual; + sample->flags = SOUND_SAMPLEFLAG_NONE; + return(1); /* we'll handle this data. */ +} /* FMT_open */ + + +static void FMT_close(Sound_Sample *sample) +{ + Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; + clean up anything you put into internal->decoder_private; +} /* FMT_close */ + + +static Uint32 FMT_read(Sound_Sample *sample) +{ + Uint32 retval; + Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; + + /* + * We don't actually do any decoding, so we read the fmt data + * directly into the internal buffer... + */ + retval = SDL_RWread(internal->rw, internal->buffer, + 1, internal->buffer_size); + + (or whatever. Do some decoding here...) + + /* Make sure the read went smoothly... */ + if (retval == 0) + sample->flags |= SOUND_SAMPLEFLAG_EOF; + + else if (retval == -1) + sample->flags |= SOUND_SAMPLEFLAG_ERROR; + + /* (next call this EAGAIN may turn into an EOF or error.) */ + else if (retval < internal->buffer_size) + sample->flags |= SOUND_SAMPLEFLAG_EAGAIN; + + (or whatever. retval == number of bytes you put in internal->buffer). + + return(retval); +} /* FMT_read */ + + +/* end of fmt.c ... */ +