1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
#[cfg(feature = "no_std")]
use core::prelude::*;
use libc::{c_int, c_uint, c_void, uint8_t, uint32_t};
use libc::{uint16_t, c_double, c_char};
use super::rwops::SDL_RWops;

// assume LSB
pub type SDL_AudioFormat = uint16_t;
pub const AUDIO_U8 : SDL_AudioFormat =         0x0008;
pub const AUDIO_S8 : SDL_AudioFormat =         0x8008;
pub const AUDIO_U16LSB : SDL_AudioFormat =     0x0010;
pub const AUDIO_S16LSB : SDL_AudioFormat =     0x8010;
pub const AUDIO_U16MSB : SDL_AudioFormat =     0x1010;
pub const AUDIO_S16MSB : SDL_AudioFormat =     0x9010;
pub const AUDIO_U16 : SDL_AudioFormat =        AUDIO_U16LSB;
pub const AUDIO_S16 : SDL_AudioFormat =        AUDIO_S16LSB;
pub const AUDIO_S32LSB : SDL_AudioFormat =     0x8020;
pub const AUDIO_S32MSB : SDL_AudioFormat =     0x9020;
pub const AUDIO_S32 : SDL_AudioFormat =        AUDIO_S32LSB;
pub const AUDIO_F32LSB : SDL_AudioFormat =     0x8120;
pub const AUDIO_F32MSB : SDL_AudioFormat =     0x9120;
pub const AUDIO_F32 : SDL_AudioFormat =        AUDIO_F32LSB;
pub const AUDIO_U16SYS : SDL_AudioFormat =     AUDIO_U16LSB;
pub const AUDIO_S16SYS : SDL_AudioFormat =     AUDIO_S16LSB;
pub const AUDIO_S32SYS : SDL_AudioFormat =     AUDIO_S32LSB;
pub const AUDIO_F32SYS : SDL_AudioFormat =     AUDIO_F32LSB;

pub type SDL_AudioCallback =
    Option<extern "C" fn (arg1: *mut c_void, arg2: *mut uint8_t, arg3: c_int)>;
#[allow(missing_copy_implementations)]
#[repr(C)]
pub struct SDL_AudioSpec {
    pub freq: c_int,
    pub format: SDL_AudioFormat,
    pub channels: uint8_t,
    pub silence: uint8_t,
    pub samples: uint16_t,
    pub padding: uint16_t,
    pub size: uint32_t,
    pub callback: SDL_AudioCallback,
    pub userdata: *mut c_void,
}
pub type SDL_AudioFilter =
    Option<extern "C" fn (arg1: *mut SDL_AudioCVT, arg2: SDL_AudioFormat)>;
#[allow(dead_code, missing_copy_implementations, raw_pointer_derive)]
#[derive(Copy, Clone)]
#[repr(C)]
pub struct SDL_AudioCVT {
    pub needed: c_int,
    pub src_format: SDL_AudioFormat,
    pub dst_format: SDL_AudioFormat,
    pub rate_incr: c_double,
    pub buf: *mut uint8_t,
    pub len: c_int,
    pub len_cvt: c_int,
    pub len_mult: c_int,
    pub len_ratio: c_double,
    filters: [SDL_AudioFilter; 10],
    filter_index: c_int,
}
pub type SDL_AudioDeviceID = uint32_t;
pub type SDL_AudioStatus = c_uint;
pub const SDL_AUDIO_STOPPED: c_uint = 0;
pub const SDL_AUDIO_PLAYING: c_uint = 1;
pub const SDL_AUDIO_PAUSED: c_uint = 2;
extern "C" {
    pub fn SDL_GetNumAudioDrivers() -> c_int;
    pub fn SDL_GetAudioDriver(index: c_int) -> *const c_char;
    pub fn SDL_AudioInit(driver_name: *const c_char) -> c_int;
    pub fn SDL_AudioQuit();
    pub fn SDL_GetCurrentAudioDriver() -> *const c_char;
    pub fn SDL_OpenAudio(desired: *const SDL_AudioSpec,
                         obtained: *mut SDL_AudioSpec) -> c_int;
    pub fn SDL_GetNumAudioDevices(iscapture: c_int) -> c_int;
    pub fn SDL_GetAudioDeviceName(index: c_int, iscapture: c_int) -> *const c_char;
    pub fn SDL_OpenAudioDevice(device: *const c_char, iscapture: c_int,
                               desired: *const SDL_AudioSpec,
                               obtained: *mut SDL_AudioSpec,
                               allowed_changes: c_int) -> SDL_AudioDeviceID;
    pub fn SDL_GetAudioStatus() -> SDL_AudioStatus;
    pub fn SDL_GetAudioDeviceStatus(dev: SDL_AudioDeviceID) ->
        SDL_AudioStatus;
    pub fn SDL_PauseAudio(pause_on: c_int);
    pub fn SDL_PauseAudioDevice(dev: SDL_AudioDeviceID, pause_on: c_int);
    pub fn SDL_LoadWAV_RW(src: *mut SDL_RWops, freesrc: c_int,
                          spec: *mut SDL_AudioSpec,
                          audio_buf: *mut *mut uint8_t, audio_len: *mut uint32_t) -> *mut SDL_AudioSpec;
    pub fn SDL_FreeWAV(audio_buf: *mut uint8_t);
    pub fn SDL_BuildAudioCVT(cvt: *mut SDL_AudioCVT,
                             src_format: SDL_AudioFormat, src_channels: uint8_t,
                             src_rate: c_int, dst_format: SDL_AudioFormat,
                             dst_channels: uint8_t, dst_rate: c_int) -> c_int;
    pub fn SDL_ConvertAudio(cvt: *mut SDL_AudioCVT) -> c_int;
    pub fn SDL_MixAudio(dst: *mut uint8_t, src: *const uint8_t, len: uint32_t,
                        volume: c_int);
    pub fn SDL_MixAudioFormat(dst: *mut uint8_t, src: *const uint8_t,
                              format: SDL_AudioFormat, len: uint32_t,
                              volume: c_int);
    pub fn SDL_LockAudio();
    pub fn SDL_LockAudioDevice(dev: SDL_AudioDeviceID);
    pub fn SDL_UnlockAudio();
    pub fn SDL_UnlockAudioDevice(dev: SDL_AudioDeviceID);
    pub fn SDL_CloseAudio();
    pub fn SDL_CloseAudioDevice(dev: SDL_AudioDeviceID);
}