Skip to content

Commit

Permalink
Revert "libdeng2: Added function_cast for casting pointers to functio…
Browse files Browse the repository at this point in the history
…n pointers"

This reverts commit a1f6949.
  • Loading branch information
skyjake committed Jan 14, 2013
1 parent 8574864 commit 441218f
Show file tree
Hide file tree
Showing 88 changed files with 6,604 additions and 16 deletions.
76 changes: 76 additions & 0 deletions doomsday/engine/api/api_audiod.h
@@ -0,0 +1,76 @@
/**
* @file api_audiod.h
* Audio driver interface. @ingroup audio
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program 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. This program 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 this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#ifndef LIBDENG_AUDIO_DRIVER_INTERFACE_H
#define LIBDENG_AUDIO_DRIVER_INTERFACE_H

/**
* @defgroup audio Audio
*/
///@{

typedef enum audiodriverid_e {
AUDIOD_INVALID = -1,
AUDIOD_DUMMY = 0,
AUDIOD_SDL_MIXER,
AUDIOD_OPENAL,
AUDIOD_FMOD,
AUDIOD_FLUIDSYNTH,
AUDIOD_DSOUND, // Win32 only
AUDIOD_WINMM, // Win32 only
AUDIODRIVER_COUNT
} audiodriverid_t;

typedef enum {
AUDIO_INONE,
AUDIO_ISFX,
AUDIO_IMUSIC,
AUDIO_ICD,
AUDIO_IMUSIC_OR_ICD
} audiointerfacetype_t;

#ifdef WIN32
# define VALID_AUDIODRIVER_IDENTIFIER(id) ((id) >= AUDIOD_DUMMY && (id) < AUDIODRIVER_COUNT)
#else
# define VALID_AUDIODRIVER_IDENTIFIER(id) ((id) >= AUDIOD_DUMMY && (id) <= AUDIOD_FLUIDSYNTH)
#endif

// Audio driver properties.
enum {
AUDIOP_SOUNDFONT_FILENAME,
AUDIOP_SFX_INTERFACE ///< audiointerface_sfx_t to play sounds with
};

typedef struct audiodriver_s {
int (*Init) (void);
void (*Shutdown) (void);
void (*Event) (int type);
int (*Set) (int prop, const void* ptr);
} audiodriver_t;

typedef struct audiointerface_base_s {
int (*Init) (void);
} audiointerface_base_t;

///@}

#endif /* LIBDENG_AUDIO_DRIVER_INTERFACE_H */
63 changes: 63 additions & 0 deletions doomsday/engine/api/api_audiod_mus.h
@@ -0,0 +1,63 @@
/**
* @file api_audiod_mus.h
* Music interface for an audio driver. @ingroup audio
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program 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. This program 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 this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#ifndef __DOOMSDAY_AUDIO_DRIVER_MUSIC_H__
#define __DOOMSDAY_AUDIO_DRIVER_MUSIC_H__

/// @addtogroup audio
///@{

/// Music interface properties.
enum {
MUSIP_ID, ///< Only for Get()ing.
MUSIP_PLAYING, ///< Is playback in progress?
MUSIP_VOLUME
};

/// Generic driver interface. All other interfaces are based on this.
typedef struct audiointerface_music_generic_s {
int (*Init) (void);
void (*Shutdown) (void);
void (*Update) (void);
void (*Set) (int prop, float value);
int (*Get) (int prop, void *value);
void (*Pause) (int pause);
void (*Stop) (void);
} audiointerface_music_generic_t;

/// Driver interface for playing music.
typedef struct audiointerface_music_s {
audiointerface_music_generic_t gen;
void* (*SongBuffer) (unsigned int length);
int (*Play) (int looped);
int (*PlayFile) (const char *filename, int looped);
} audiointerface_music_t;

/// Driver interface for playing CD tracks.
typedef struct audiointerface_cd_s {
audiointerface_music_generic_t gen;
int (*Play) (int track, int looped);
} audiointerface_cd_t;

///@}

#endif
132 changes: 132 additions & 0 deletions doomsday/engine/api/api_audiod_sfx.h
@@ -0,0 +1,132 @@
/**
* @file api_audiod_sfx.h
* Sound effects playback interface for an audio driver. @ingroup audio
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2013 Daniel Swanson <danij@dengine.net>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program 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. This program 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 this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/

#ifndef __DOOMSDAY_AUDIO_DRIVER_SFX_H__
#define __DOOMSDAY_AUDIO_DRIVER_SFX_H__

/// @addtogroup audio
///@{

/**
* @defgroup sfxBufferFlags Sfx Buffer Flags
* @ingroup audio apiFlags
*/
///@{
#define SFXBF_PLAYING 0x1 ///< The buffer is playing.
#define SFXBF_3D 0x2 ///< Otherwise playing in 2D mode.
#define SFXBF_REPEAT 0x4 ///< Buffer will repeat until stopped.
#define SFXBF_DONT_STOP 0x8 ///< Never stop until normal finish.
#define SFXBF_STREAM 0x10 ///< Buffer plays in streaming mode (looping).
#define SFXBF_RELOAD 0x10000 ///< Sample must be reloaded before playing.
///@}

/// Sfx interface properties.
enum {
SFXIP_DISABLE_CHANNEL_REFRESH = 1, ///< The channel refresh thread is not needed.
SFXIP_ANY_SAMPLE_RATE_ACCEPTED = 2 ///< Samples don't all need the same rate.
};

/// Events.
enum {
SFXEV_BEGIN, ///< An update is about to begin.
SFXEV_END ///< The update is done.
};

/// Buffer properties.
enum {
SFXBP_VOLUME, ///< 0..1
SFXBP_FREQUENCY, ///< 1 = normal
SFXBP_PAN, ///< -1..1 (2D only)
SFXBP_MIN_DISTANCE, ///< 3D only
SFXBP_MAX_DISTANCE,
SFXBP_POSITION,
SFXBP_VELOCITY,
SFXBP_RELATIVE_MODE
};

/// Listener properties.
enum {
SFXLP_UPDATE, ///< Not a real value (commit deferred)
SFXLP_PRIMARY_FORMAT, ///< Arguments are bits and rate.
SFXLP_UNITS_PER_METER,
SFXLP_DOPPLER,
SFXLP_POSITION,
SFXLP_VELOCITY,
SFXLP_ORIENTATION,
SFXLP_REVERB ///< Use SRD_* for indices.
};

typedef struct sfxsample_s {
int id; ///< Id number of the sound sample.
void* data; ///< Actual sample data.
unsigned int size; ///< Size in bytes.
int numSamples; ///< Number of samples.
int bytesPer; ///< Bytes per sample (1 or 2).
int rate; ///< Samples per second.
int group; ///< Exclusion group (0, if none).
} sfxsample_t;

typedef struct sfxbuffer_s {
void* ptr; ///< Pointer to driver's own buffer object.
void* ptr3D; ///< Pointer to driver's 3D buffer data.
struct sfxsample_s* sample; ///< Source sample data.
int bytes; ///< Bytes per sample (1 or 2).
int rate; ///< Samples per second.
int flags;
unsigned int length; ///< Length of the buffer (bytes).
unsigned int cursor; ///< Write cursor position (%length).
unsigned int written; ///< Total bytes written.
unsigned int endTime; ///< System time, milliseconds (if !repeating).
unsigned int freq; ///< Played samples per second (real freq).
} sfxbuffer_t;

/**
* When a buffer is using SFXBF_STREAM, a sample's data pointer is interpreted
* as a sfxstreamfunc_t and will be called whenever the sample needs more data
* streamed in.
*/
typedef int (*sfxstreamfunc_t)(sfxbuffer_t* buf, void* data, unsigned int size);

/// Generic driver interface. All other interfaces are based on this.
typedef struct audiointerface_sfx_generic_s {
int (*Init) (void);
sfxbuffer_t* (*Create) (int flags, int bits, int rate);
void (*Destroy) (sfxbuffer_t* buf);
void (*Load) (sfxbuffer_t* buf, struct sfxsample_s* sample);
void (*Reset) (sfxbuffer_t* buf);
void (*Play) (sfxbuffer_t* buf);
void (*Stop) (sfxbuffer_t* buf);
void (*Refresh) (sfxbuffer_t* buf);
void (*Set) (sfxbuffer_t* buf, int prop, float value);
void (*Setv) (sfxbuffer_t* buf, int prop, float* values);
void (*Listener) (int prop, float value);
void (*Listenerv) (int prop, float* values);
int (*Getv) (int prop, void* values);
} audiointerface_sfx_generic_t;

typedef struct audiointerface_sfx_s {
audiointerface_sfx_generic_t gen;
} audiointerface_sfx_t;

///@}

#endif

0 comments on commit 441218f

Please sign in to comment.