1 #ifndef _audioapi_driver__hpp__included__
2 #define _audioapi_driver__hpp__included__
8 class audioapi_instance
;
10 //All the following need to be implemented by the sound driver itself
11 struct _audioapi_driver
13 //These correspond to various audioapi_driver_* functions.
14 void (*init
)() throw();
15 void (*quit
)() throw();
16 void (*enable
)(bool enable
);
17 bool (*initialized
)();
18 void (*set_device
)(const std::string
& pdev
, const std::string
& rdev
);
19 std::string (*get_device
)(bool rec
);
20 std::map
<std::string
, std::string
> (*get_devices
)(bool rec
);
21 const char* (*name
)();
24 struct audioapi_driver
26 audioapi_driver(struct _audioapi_driver driver
);
31 * Initialize the driver.
33 void audioapi_driver_init() throw();
36 * Deinitialize the driver.
38 void audioapi_driver_quit() throw();
41 * Enable or disable sound.
43 * parameter enable: Enable sounds if true, otherwise disable sounds.
45 void audioapi_driver_enable(bool enable
) throw();
48 * Has the sound system been successfully initialized?
50 * Returns: True if sound system has successfully initialized, false otherwise.
52 bool audioapi_driver_initialized();
55 * Set sound device (playback).
57 * - If new sound device is invalid, the sound device is not changed.
59 * Parameter pdev: The new sound device (playback).
60 * Parameter rdev: The new sound device (recording)
62 void audioapi_driver_set_device(const std::string
& pdev
, const std::string
& rdev
) throw(std::bad_alloc
,
66 * Get current sound device (playback).
68 * Returns: The current sound device.
70 std::string
audioapi_driver_get_device(bool rec
) throw(std::bad_alloc
);
73 * Get available sound devices (playback).
75 * Returns: The map of devices. Keyed by name of the device, values are human-readable names for devices.
77 std::map
<std::string
, std::string
> audioapi_driver_get_devices(bool rec
) throw(std::bad_alloc
);
80 * Identification for sound plugin.
82 const char* audioapi_driver_name() throw();
85 * Add an instance to be mixed.
87 void audioapi_connect_instance(audioapi_instance
& instance
);
90 * Remove an instance from being mixed.
92 void audioapi_disconnect_instance(audioapi_instance
& instance
);
97 void audioapi_send_rate_change(unsigned rrate
, unsigned prate
);
100 * Broadcast voice input to all instances.
102 void audioapi_put_voice(float* samples
, size_t count
);
105 * Get mixed music + voice out from all instances.
107 void audioapi_get_mixed(int16_t* samples
, size_t count
, bool stereo
);