Audio drivers: Use weak functions
This commit is contained in:
parent
8770824c15
commit
41ca0a3051
5 changed files with 16 additions and 76 deletions
|
@ -1,6 +1,12 @@
|
|||
#ifndef _audioapi__hpp__included__
|
||||
#define _audioapi__hpp__included__
|
||||
|
||||
#ifdef AUDIO_WEAK
|
||||
#define AUDIOAPI_DRV_ATTRIBUTE __attribute__((weak))
|
||||
#else
|
||||
#define AUDIOAPI_DRV_ATTRIBUTE
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
@ -224,26 +230,26 @@ void audioapi_voice_rate(unsigned rate);
|
|||
/**
|
||||
* Initialize the driver.
|
||||
*/
|
||||
void audioapi_driver_init() throw();
|
||||
void audioapi_driver_init() throw() AUDIOAPI_DRV_ATTRIBUTE ;
|
||||
|
||||
/**
|
||||
* Deinitialize the driver.
|
||||
*/
|
||||
void audioapi_driver_quit() throw();
|
||||
void audioapi_driver_quit() throw() AUDIOAPI_DRV_ATTRIBUTE ;
|
||||
|
||||
/**
|
||||
* Enable or disable sound.
|
||||
*
|
||||
* parameter enable: Enable sounds if true, otherwise disable sounds.
|
||||
*/
|
||||
void audioapi_driver_enable(bool enable) throw();
|
||||
void audioapi_driver_enable(bool enable) throw() AUDIOAPI_DRV_ATTRIBUTE ;
|
||||
|
||||
/**
|
||||
* Has the sound system been successfully initialized?
|
||||
*
|
||||
* Returns: True if sound system has successfully initialized, false otherwise.
|
||||
*/
|
||||
bool audioapi_driver_initialized();
|
||||
bool audioapi_driver_initialized() AUDIOAPI_DRV_ATTRIBUTE ;
|
||||
|
||||
/**
|
||||
* Set sound device.
|
||||
|
@ -252,25 +258,25 @@ bool audioapi_driver_initialized();
|
|||
*
|
||||
* Parameter dev: The new sound device.
|
||||
*/
|
||||
void audioapi_driver_set_device(const std::string& dev) throw(std::bad_alloc, std::runtime_error);
|
||||
void audioapi_driver_set_device(const std::string& dev) throw(std::bad_alloc, std::runtime_error) AUDIOAPI_DRV_ATTRIBUTE ;
|
||||
|
||||
/**
|
||||
* Get current sound device.
|
||||
*
|
||||
* Returns: The current sound device.
|
||||
*/
|
||||
std::string audioapi_driver_get_device() throw(std::bad_alloc);
|
||||
std::string audioapi_driver_get_device() throw(std::bad_alloc) AUDIOAPI_DRV_ATTRIBUTE ;
|
||||
|
||||
/**
|
||||
* Get available sound devices.
|
||||
*
|
||||
* Returns: The map of devices. Keyed by name of the device, values are human-readable names for devices.
|
||||
*/
|
||||
std::map<std::string, std::string> audioapi_driver_get_devices() throw(std::bad_alloc);
|
||||
std::map<std::string, std::string> audioapi_driver_get_devices() throw(std::bad_alloc) AUDIOAPI_DRV_ATTRIBUTE ;
|
||||
|
||||
/**
|
||||
* Identification for sound plugin.
|
||||
*/
|
||||
extern const char* audioapi_driver_name;
|
||||
extern const char* audioapi_driver_name AUDIOAPI_DRV_ATTRIBUTE ;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#define AUDIO_WEAK
|
||||
#include "core/command.hpp"
|
||||
#include "core/audioapi.hpp"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
PLATFORMS=dummy evdev portaudio wxwidgets win32mm libao
|
||||
PLATFORMS=evdev portaudio wxwidgets win32mm libao
|
||||
ALLFILES=__all__.files
|
||||
ALLFLAGS=__all__.ldflags
|
||||
PLATFORMS_FILES=$(patsubst %,%/$(ALLFILES),$(PLATFORMS))
|
||||
|
@ -8,9 +8,6 @@ $(ALLFILES): $(PLATFORMS_FILES) $(OBJECTS)
|
|||
lua ../genfilelist.lua $^ >$@
|
||||
cat $(PLATFORMS_FLAGS) >$(ALLFLAGS)
|
||||
|
||||
dummy/$(ALLFILES): forcelook
|
||||
$(MAKE) -C dummy
|
||||
|
||||
evdev/$(ALLFILES): forcelook
|
||||
$(MAKE) -C evdev
|
||||
|
||||
|
@ -30,7 +27,6 @@ wxwidgets/$(ALLFILES): forcelook
|
|||
.PRECIOUS: %.$(OBJECT_SUFFIX) *.files
|
||||
|
||||
precheck:
|
||||
$(MAKE) -C dummy precheck
|
||||
$(MAKE) -C evdev precheck
|
||||
$(MAKE) -C win32mm precheck
|
||||
$(MAKE) -C portaudio precheck
|
||||
|
@ -39,7 +35,6 @@ precheck:
|
|||
|
||||
clean:
|
||||
rm -f *.$(OBJECT_SUFFIX) __all__.ldflags __all__.files
|
||||
$(MAKE) -C dummy clean
|
||||
$(MAKE) -C evdev clean
|
||||
$(MAKE) -C win32mm clean
|
||||
$(MAKE) -C portaudio clean
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
OBJECTS=
|
||||
ifeq ($(SOUND),DUMMY)
|
||||
OBJECTS += sound.$(OBJECT_SUFFIX)
|
||||
endif
|
||||
|
||||
.PRECIOUS: %.$(OBJECT_SUFFIX) %.files
|
||||
|
||||
__all__.files: $(OBJECTS)
|
||||
lua ../../genfilelist.lua $^ >$@
|
||||
touch __all__.ldflags
|
||||
|
||||
%.$(OBJECT_SUFFIX): %.cpp
|
||||
$(REALCC) -c -o $@ $< -I../../../include $(CFLAGS)
|
||||
|
||||
precheck:
|
||||
@true
|
||||
|
||||
clean:
|
||||
rm -f *.$(OBJECT_SUFFIX) __all__.ldflags __all__.files
|
|
@ -1,43 +0,0 @@
|
|||
#include "core/command.hpp"
|
||||
#include "core/audioapi.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
void audioapi_driver_init() throw()
|
||||
{
|
||||
audioapi_set_dummy_cb(true);
|
||||
}
|
||||
|
||||
void audioapi_driver_quit() throw()
|
||||
{
|
||||
}
|
||||
|
||||
void audioapi_driver_enable(bool enable) throw()
|
||||
{
|
||||
}
|
||||
|
||||
bool audioapi_driver_initialized()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void audioapi_driver_set_device(const std::string& dev) throw(std::bad_alloc, std::runtime_error)
|
||||
{
|
||||
if(dev != "null")
|
||||
throw std::runtime_error("Bad sound device '" + dev + "'");
|
||||
}
|
||||
|
||||
std::string audioapi_driver_get_device() throw(std::bad_alloc)
|
||||
{
|
||||
return "null";
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> audioapi_driver_get_devices() throw(std::bad_alloc)
|
||||
{
|
||||
std::map<std::string, std::string> ret;
|
||||
ret["null"] = "NULL sound output";
|
||||
return ret;
|
||||
}
|
||||
|
||||
const char* audioapi_driver_name = "Dummy sound plugin";
|
Loading…
Add table
Reference in a new issue