Skip to content

Commit

Permalink
Audio|Refactor: Allow loading multiple audio plugins
Browse files Browse the repository at this point in the history
Refactored the audio plugin loader to allow loading more than one
plugin at a time. The loading and initialization of the audio
plugins was moved to the new AudioDriver module.

The loading was also made platform-independent through the use
of the Library class (which presently lacks a Windows implementation).

The AudioDriver module chooses which SFX, Music, and CD interface
to use from which loaded plugin.
  • Loading branch information
skyjake committed Mar 1, 2012
1 parent 2851583 commit b01a171
Show file tree
Hide file tree
Showing 14 changed files with 532 additions and 704 deletions.
10 changes: 7 additions & 3 deletions doomsday/engine/api/sys_audiod.h
Expand Up @@ -20,8 +20,8 @@
* 02110-1301 USA</small>
*/

#ifndef LIBDENG_AUDIO_DRIVER_H
#define LIBDENG_AUDIO_DRIVER_H
#ifndef LIBDENG_AUDIO_DRIVER_INTERFACE_H
#define LIBDENG_AUDIO_DRIVER_INTERFACE_H

/**
* @defgroup audio Audio
Expand Down Expand Up @@ -52,6 +52,10 @@ typedef struct audiodriver_s {
int (*Set) (int prop, const void* ptr);
} audiodriver_t;

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

///@}

#endif /* LIBDENG_AUDIO_DRIVER_H */
#endif /* LIBDENG_AUDIO_DRIVER_INTERFACE_H */
5 changes: 2 additions & 3 deletions doomsday/engine/engine.pro
Expand Up @@ -112,6 +112,7 @@ DENG_API_HEADERS = \
DENG_HEADERS = \
portable/include/abstractfile.h \
portable/include/abstractresource.h \
portable/include/audiodriver.h \
portable/include/bitmapfont.h \
portable/include/blockset.h \
portable/include/bsp_edge.h \
Expand Down Expand Up @@ -284,7 +285,6 @@ DENG_HEADERS = \
portable/include/svg.h \
portable/include/sys_audio.h \
portable/include/sys_audiod_dummy.h \
portable/include/sys_audiod_loader.h \
portable/include/sys_console.h \
portable/include/sys_direc.h \
portable/include/sys_findfile.h \
Expand Down Expand Up @@ -360,22 +360,21 @@ HEADERS += \
DENG_UNIX_SOURCES += \
portable/src/sys_sdl_window.c \
unix/src/dd_uinit.c \
unix/src/sys_audiod_loader.c \
unix/src/sys_console.c \
unix/src/sys_findfile.c \
unix/src/sys_input.c \
unix/src/sys_path.c

DENG_WIN32_SOURCES += \
win32/src/dd_winit.c \
win32/src/sys_audiod_loader.c \
win32/src/sys_console.c \
win32/src/sys_findfile.c \
win32/src/sys_input.c \
win32/src/sys_window.c

SOURCES += \
portable/src/abstractfile.c \
portable/src/audiodriver.c \
portable/src/animator.c \
portable/src/bitmapfont.c \
portable/src/blockset.c \
Expand Down
56 changes: 56 additions & 0 deletions doomsday/engine/portable/include/audiodriver.h
@@ -0,0 +1,56 @@
/**
* @file audiodriver.h
* Audio driver loading and interface management. @ingroup audio
*
* @authors Copyright © 2012 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2012 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_H
#define LIBDENG_AUDIO_DRIVER_H

#include "sys_audiod.h"
#include "sys_audiod_sfx.h"
#include "sys_audiod_mus.h"

boolean AudioDriver_Init(void);
void AudioDriver_Shutdown(void);

/**
* Retrieves the main interface of the audio driver to which @a sfxMusicOrCd belongs to.
*/
audiodriver_t* AudioDriver_Interface(void* sfxMusicOrCd);

/**
* Returns the current active SFX interface. @c NULL is returned is no SFX
* playback is available.
*/
audiointerface_sfx_generic_t* AudioDriver_SFX(void);

/**
* Returns the currently active Music interface. @c NULL is returned if no music
* playback is available.
*/
audiointerface_music_t* AudioDriver_Music(void);

/**
* Returns the currently active CD playback interface. @c NULL is returned if
* CD playback is not available.
*/
audiointerface_cd_t* AudioDriver_CD(void);

#endif // LIBDENG_AUDIO_DRIVER_H
1 change: 1 addition & 0 deletions doomsday/engine/portable/include/de_audio.h
Expand Up @@ -29,6 +29,7 @@
#ifndef __DOOMSDAY_AUDIO__
#define __DOOMSDAY_AUDIO__

#include "audiodriver.h"
#include "s_main.h"
#include "s_environ.h"
#include "s_sfx.h"
Expand Down
2 changes: 0 additions & 2 deletions doomsday/engine/portable/include/s_main.h
Expand Up @@ -44,8 +44,6 @@ extern int showSoundInfo;
extern int soundMinDist, soundMaxDist;
extern int sfxVolume, musVolume;

extern audiodriver_t* audioDriver;

void S_Register(void);
boolean S_Init(void);
void S_Shutdown(void);
Expand Down
2 changes: 0 additions & 2 deletions doomsday/engine/portable/include/sys_audio.h
Expand Up @@ -36,8 +36,6 @@
#include "sys_audiod.h"
#include "sys_audiod_sfx.h"
#include "sys_audiod_mus.h"

#include "sys_audiod_loader.h"
#include "sys_audiod_dummy.h"

#ifndef DENG_DISABLE_SDLMIXER
Expand Down
44 changes: 0 additions & 44 deletions doomsday/engine/portable/include/sys_audiod_loader.h

This file was deleted.

0 comments on commit b01a171

Please sign in to comment.