# Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
#
# * https://github.com/vaiorabbit/sdl2-bindings
#
# [NOTICE] This is an automatically generated file.

require 'ffi'

module SDL
  extend FFI::Library
  # Define/Macro

  MIXER_MAJOR_VERSION = 2
  MIXER_MINOR_VERSION = 8
  MIXER_PATCHLEVEL = 0
  MIX_CHANNELS = 8
  MIX_DEFAULT_FREQUENCY = 44100
  MIX_DEFAULT_FORMAT = AUDIO_S16SYS
  MIX_DEFAULT_CHANNELS = 2
  MIX_CHANNEL_POST = -2

  # Enum

  MIX_INIT_FLAC = 1
  MIX_INIT_MOD = 2
  MIX_INIT_MP3 = 8
  MIX_INIT_OGG = 16
  MIX_INIT_MID = 32
  MIX_INIT_OPUS = 64
  MIX_INIT_WAVPACK = 128
  MIX_NO_FADING = 0
  MIX_FADING_OUT = 1
  MIX_FADING_IN = 2
  MUS_NONE = 0
  MUS_CMD = 1
  MUS_WAV = 2
  MUS_MOD = 3
  MUS_MID = 4
  MUS_OGG = 5
  MUS_MP3 = 6
  MUS_MP3_MAD_UNUSED = 7
  MUS_FLAC = 8
  MUS_MODPLUG_UNUSED = 9
  MUS_OPUS = 10
  MUS_WAVPACK = 11
  MUS_GME = 12

  # Typedef

  typedef :int, :MIX_InitFlags
  typedef :int, :Mix_Fading
  typedef :int, :Mix_MusicType
  callback :Mix_EffectFunc_t, [:int, :pointer, :int, :pointer], :void
  callback :Mix_EffectDone_t, [:int, :pointer], :void

  # Struct

  class Mix_Chunk < FFI::Struct
    layout(
      :allocated, :int,
      :abuf, :pointer,
      :alen, :uint,
      :volume, :uchar,
    )
  end


  # Function

  def self.setup_mixer_symbols(output_error = false)
    symbols = [
      :Mix_Linked_Version,
      :Mix_Init,
      :Mix_Quit,
      :Mix_OpenAudio,
      :Mix_OpenAudioDevice,
      :Mix_PauseAudio,
      :Mix_QuerySpec,
      :Mix_AllocateChannels,
      :Mix_LoadWAV_RW,
      :Mix_LoadWAV,
      :Mix_LoadMUS,
      :Mix_LoadMUS_RW,
      :Mix_LoadMUSType_RW,
      :Mix_QuickLoad_WAV,
      :Mix_QuickLoad_RAW,
      :Mix_FreeChunk,
      :Mix_FreeMusic,
      :Mix_GetNumChunkDecoders,
      :Mix_GetChunkDecoder,
      :Mix_HasChunkDecoder,
      :Mix_GetNumMusicDecoders,
      :Mix_GetMusicDecoder,
      :Mix_HasMusicDecoder,
      :Mix_GetMusicType,
      :Mix_GetMusicTitle,
      :Mix_GetMusicTitleTag,
      :Mix_GetMusicArtistTag,
      :Mix_GetMusicAlbumTag,
      :Mix_GetMusicCopyrightTag,
      :Mix_SetPostMix,
      :Mix_HookMusic,
      :Mix_HookMusicFinished,
      :Mix_GetMusicHookData,
      :Mix_ChannelFinished,
      :Mix_RegisterEffect,
      :Mix_UnregisterEffect,
      :Mix_UnregisterAllEffects,
      :Mix_SetPanning,
      :Mix_SetPosition,
      :Mix_SetDistance,
      :Mix_SetReverseStereo,
      :Mix_ReserveChannels,
      :Mix_GroupChannel,
      :Mix_GroupChannels,
      :Mix_GroupAvailable,
      :Mix_GroupCount,
      :Mix_GroupOldest,
      :Mix_GroupNewer,
      :Mix_PlayChannel,
      :Mix_PlayChannelTimed,
      :Mix_PlayMusic,
      :Mix_FadeInMusic,
      :Mix_FadeInMusicPos,
      :Mix_FadeInChannel,
      :Mix_FadeInChannelTimed,
      :Mix_Volume,
      :Mix_VolumeChunk,
      :Mix_VolumeMusic,
      :Mix_GetMusicVolume,
      :Mix_MasterVolume,
      :Mix_HaltChannel,
      :Mix_HaltGroup,
      :Mix_HaltMusic,
      :Mix_ExpireChannel,
      :Mix_FadeOutChannel,
      :Mix_FadeOutGroup,
      :Mix_FadeOutMusic,
      :Mix_FadingMusic,
      :Mix_FadingChannel,
      :Mix_Pause,
      :Mix_Resume,
      :Mix_Paused,
      :Mix_PauseMusic,
      :Mix_ResumeMusic,
      :Mix_RewindMusic,
      :Mix_PausedMusic,
      :Mix_ModMusicJumpToOrder,
      :Mix_StartTrack,
      :Mix_GetNumTracks,
      :Mix_SetMusicPosition,
      :Mix_GetMusicPosition,
      :Mix_MusicDuration,
      :Mix_GetMusicLoopStartTime,
      :Mix_GetMusicLoopEndTime,
      :Mix_GetMusicLoopLengthTime,
      :Mix_Playing,
      :Mix_PlayingMusic,
      :Mix_SetMusicCMD,
      :Mix_SetSynchroValue,
      :Mix_GetSynchroValue,
      :Mix_SetSoundFonts,
      :Mix_GetSoundFonts,
      :Mix_EachSoundFont,
      :Mix_SetTimidityCfg,
      :Mix_GetTimidityCfg,
      :Mix_GetChunk,
      :Mix_CloseAudio,
    ]
    apis = {
      :Mix_Linked_Version => :Mix_Linked_Version,
      :Mix_Init => :Mix_Init,
      :Mix_Quit => :Mix_Quit,
      :Mix_OpenAudio => :Mix_OpenAudio,
      :Mix_OpenAudioDevice => :Mix_OpenAudioDevice,
      :Mix_PauseAudio => :Mix_PauseAudio,
      :Mix_QuerySpec => :Mix_QuerySpec,
      :Mix_AllocateChannels => :Mix_AllocateChannels,
      :Mix_LoadWAV_RW => :Mix_LoadWAV_RW,
      :Mix_LoadWAV => :Mix_LoadWAV,
      :Mix_LoadMUS => :Mix_LoadMUS,
      :Mix_LoadMUS_RW => :Mix_LoadMUS_RW,
      :Mix_LoadMUSType_RW => :Mix_LoadMUSType_RW,
      :Mix_QuickLoad_WAV => :Mix_QuickLoad_WAV,
      :Mix_QuickLoad_RAW => :Mix_QuickLoad_RAW,
      :Mix_FreeChunk => :Mix_FreeChunk,
      :Mix_FreeMusic => :Mix_FreeMusic,
      :Mix_GetNumChunkDecoders => :Mix_GetNumChunkDecoders,
      :Mix_GetChunkDecoder => :Mix_GetChunkDecoder,
      :Mix_HasChunkDecoder => :Mix_HasChunkDecoder,
      :Mix_GetNumMusicDecoders => :Mix_GetNumMusicDecoders,
      :Mix_GetMusicDecoder => :Mix_GetMusicDecoder,
      :Mix_HasMusicDecoder => :Mix_HasMusicDecoder,
      :Mix_GetMusicType => :Mix_GetMusicType,
      :Mix_GetMusicTitle => :Mix_GetMusicTitle,
      :Mix_GetMusicTitleTag => :Mix_GetMusicTitleTag,
      :Mix_GetMusicArtistTag => :Mix_GetMusicArtistTag,
      :Mix_GetMusicAlbumTag => :Mix_GetMusicAlbumTag,
      :Mix_GetMusicCopyrightTag => :Mix_GetMusicCopyrightTag,
      :Mix_SetPostMix => :Mix_SetPostMix,
      :Mix_HookMusic => :Mix_HookMusic,
      :Mix_HookMusicFinished => :Mix_HookMusicFinished,
      :Mix_GetMusicHookData => :Mix_GetMusicHookData,
      :Mix_ChannelFinished => :Mix_ChannelFinished,
      :Mix_RegisterEffect => :Mix_RegisterEffect,
      :Mix_UnregisterEffect => :Mix_UnregisterEffect,
      :Mix_UnregisterAllEffects => :Mix_UnregisterAllEffects,
      :Mix_SetPanning => :Mix_SetPanning,
      :Mix_SetPosition => :Mix_SetPosition,
      :Mix_SetDistance => :Mix_SetDistance,
      :Mix_SetReverseStereo => :Mix_SetReverseStereo,
      :Mix_ReserveChannels => :Mix_ReserveChannels,
      :Mix_GroupChannel => :Mix_GroupChannel,
      :Mix_GroupChannels => :Mix_GroupChannels,
      :Mix_GroupAvailable => :Mix_GroupAvailable,
      :Mix_GroupCount => :Mix_GroupCount,
      :Mix_GroupOldest => :Mix_GroupOldest,
      :Mix_GroupNewer => :Mix_GroupNewer,
      :Mix_PlayChannel => :Mix_PlayChannel,
      :Mix_PlayChannelTimed => :Mix_PlayChannelTimed,
      :Mix_PlayMusic => :Mix_PlayMusic,
      :Mix_FadeInMusic => :Mix_FadeInMusic,
      :Mix_FadeInMusicPos => :Mix_FadeInMusicPos,
      :Mix_FadeInChannel => :Mix_FadeInChannel,
      :Mix_FadeInChannelTimed => :Mix_FadeInChannelTimed,
      :Mix_Volume => :Mix_Volume,
      :Mix_VolumeChunk => :Mix_VolumeChunk,
      :Mix_VolumeMusic => :Mix_VolumeMusic,
      :Mix_GetMusicVolume => :Mix_GetMusicVolume,
      :Mix_MasterVolume => :Mix_MasterVolume,
      :Mix_HaltChannel => :Mix_HaltChannel,
      :Mix_HaltGroup => :Mix_HaltGroup,
      :Mix_HaltMusic => :Mix_HaltMusic,
      :Mix_ExpireChannel => :Mix_ExpireChannel,
      :Mix_FadeOutChannel => :Mix_FadeOutChannel,
      :Mix_FadeOutGroup => :Mix_FadeOutGroup,
      :Mix_FadeOutMusic => :Mix_FadeOutMusic,
      :Mix_FadingMusic => :Mix_FadingMusic,
      :Mix_FadingChannel => :Mix_FadingChannel,
      :Mix_Pause => :Mix_Pause,
      :Mix_Resume => :Mix_Resume,
      :Mix_Paused => :Mix_Paused,
      :Mix_PauseMusic => :Mix_PauseMusic,
      :Mix_ResumeMusic => :Mix_ResumeMusic,
      :Mix_RewindMusic => :Mix_RewindMusic,
      :Mix_PausedMusic => :Mix_PausedMusic,
      :Mix_ModMusicJumpToOrder => :Mix_ModMusicJumpToOrder,
      :Mix_StartTrack => :Mix_StartTrack,
      :Mix_GetNumTracks => :Mix_GetNumTracks,
      :Mix_SetMusicPosition => :Mix_SetMusicPosition,
      :Mix_GetMusicPosition => :Mix_GetMusicPosition,
      :Mix_MusicDuration => :Mix_MusicDuration,
      :Mix_GetMusicLoopStartTime => :Mix_GetMusicLoopStartTime,
      :Mix_GetMusicLoopEndTime => :Mix_GetMusicLoopEndTime,
      :Mix_GetMusicLoopLengthTime => :Mix_GetMusicLoopLengthTime,
      :Mix_Playing => :Mix_Playing,
      :Mix_PlayingMusic => :Mix_PlayingMusic,
      :Mix_SetMusicCMD => :Mix_SetMusicCMD,
      :Mix_SetSynchroValue => :Mix_SetSynchroValue,
      :Mix_GetSynchroValue => :Mix_GetSynchroValue,
      :Mix_SetSoundFonts => :Mix_SetSoundFonts,
      :Mix_GetSoundFonts => :Mix_GetSoundFonts,
      :Mix_EachSoundFont => :Mix_EachSoundFont,
      :Mix_SetTimidityCfg => :Mix_SetTimidityCfg,
      :Mix_GetTimidityCfg => :Mix_GetTimidityCfg,
      :Mix_GetChunk => :Mix_GetChunk,
      :Mix_CloseAudio => :Mix_CloseAudio,
    }
    args = {
      :Mix_Linked_Version => [],
      :Mix_Init => [:int],
      :Mix_Quit => [],
      :Mix_OpenAudio => [:int, :ushort, :int, :int],
      :Mix_OpenAudioDevice => [:int, :ushort, :int, :int, :pointer, :int],
      :Mix_PauseAudio => [:int],
      :Mix_QuerySpec => [:pointer, :pointer, :pointer],
      :Mix_AllocateChannels => [:int],
      :Mix_LoadWAV_RW => [:pointer, :int],
      :Mix_LoadWAV => [:pointer],
      :Mix_LoadMUS => [:pointer],
      :Mix_LoadMUS_RW => [:pointer, :int],
      :Mix_LoadMUSType_RW => [:pointer, :int, :int],
      :Mix_QuickLoad_WAV => [:pointer],
      :Mix_QuickLoad_RAW => [:pointer, :uint],
      :Mix_FreeChunk => [:pointer],
      :Mix_FreeMusic => [:pointer],
      :Mix_GetNumChunkDecoders => [],
      :Mix_GetChunkDecoder => [:int],
      :Mix_HasChunkDecoder => [:pointer],
      :Mix_GetNumMusicDecoders => [],
      :Mix_GetMusicDecoder => [:int],
      :Mix_HasMusicDecoder => [:pointer],
      :Mix_GetMusicType => [:pointer],
      :Mix_GetMusicTitle => [:pointer],
      :Mix_GetMusicTitleTag => [:pointer],
      :Mix_GetMusicArtistTag => [:pointer],
      :Mix_GetMusicAlbumTag => [:pointer],
      :Mix_GetMusicCopyrightTag => [:pointer],
      :Mix_SetPostMix => [:pointer, :pointer],
      :Mix_HookMusic => [:pointer, :pointer],
      :Mix_HookMusicFinished => [:pointer],
      :Mix_GetMusicHookData => [],
      :Mix_ChannelFinished => [:pointer],
      :Mix_RegisterEffect => [:int, :Mix_EffectFunc_t, :Mix_EffectDone_t, :pointer],
      :Mix_UnregisterEffect => [:int, :Mix_EffectFunc_t],
      :Mix_UnregisterAllEffects => [:int],
      :Mix_SetPanning => [:int, :uchar, :uchar],
      :Mix_SetPosition => [:int, :short, :uchar],
      :Mix_SetDistance => [:int, :uchar],
      :Mix_SetReverseStereo => [:int, :int],
      :Mix_ReserveChannels => [:int],
      :Mix_GroupChannel => [:int, :int],
      :Mix_GroupChannels => [:int, :int, :int],
      :Mix_GroupAvailable => [:int],
      :Mix_GroupCount => [:int],
      :Mix_GroupOldest => [:int],
      :Mix_GroupNewer => [:int],
      :Mix_PlayChannel => [:int, :pointer, :int],
      :Mix_PlayChannelTimed => [:int, :pointer, :int, :int],
      :Mix_PlayMusic => [:pointer, :int],
      :Mix_FadeInMusic => [:pointer, :int, :int],
      :Mix_FadeInMusicPos => [:pointer, :int, :int, :double],
      :Mix_FadeInChannel => [:int, :pointer, :int, :int],
      :Mix_FadeInChannelTimed => [:int, :pointer, :int, :int, :int],
      :Mix_Volume => [:int, :int],
      :Mix_VolumeChunk => [:pointer, :int],
      :Mix_VolumeMusic => [:int],
      :Mix_GetMusicVolume => [:pointer],
      :Mix_MasterVolume => [:int],
      :Mix_HaltChannel => [:int],
      :Mix_HaltGroup => [:int],
      :Mix_HaltMusic => [],
      :Mix_ExpireChannel => [:int, :int],
      :Mix_FadeOutChannel => [:int, :int],
      :Mix_FadeOutGroup => [:int, :int],
      :Mix_FadeOutMusic => [:int],
      :Mix_FadingMusic => [],
      :Mix_FadingChannel => [:int],
      :Mix_Pause => [:int],
      :Mix_Resume => [:int],
      :Mix_Paused => [:int],
      :Mix_PauseMusic => [],
      :Mix_ResumeMusic => [],
      :Mix_RewindMusic => [],
      :Mix_PausedMusic => [],
      :Mix_ModMusicJumpToOrder => [:int],
      :Mix_StartTrack => [:pointer, :int],
      :Mix_GetNumTracks => [:pointer],
      :Mix_SetMusicPosition => [:double],
      :Mix_GetMusicPosition => [:pointer],
      :Mix_MusicDuration => [:pointer],
      :Mix_GetMusicLoopStartTime => [:pointer],
      :Mix_GetMusicLoopEndTime => [:pointer],
      :Mix_GetMusicLoopLengthTime => [:pointer],
      :Mix_Playing => [:int],
      :Mix_PlayingMusic => [],
      :Mix_SetMusicCMD => [:pointer],
      :Mix_SetSynchroValue => [:int],
      :Mix_GetSynchroValue => [],
      :Mix_SetSoundFonts => [:pointer],
      :Mix_GetSoundFonts => [],
      :Mix_EachSoundFont => [:pointer, :pointer],
      :Mix_SetTimidityCfg => [:pointer],
      :Mix_GetTimidityCfg => [],
      :Mix_GetChunk => [:int],
      :Mix_CloseAudio => [],
    }
    retvals = {
      :Mix_Linked_Version => :pointer,
      :Mix_Init => :int,
      :Mix_Quit => :void,
      :Mix_OpenAudio => :int,
      :Mix_OpenAudioDevice => :int,
      :Mix_PauseAudio => :void,
      :Mix_QuerySpec => :int,
      :Mix_AllocateChannels => :int,
      :Mix_LoadWAV_RW => :pointer,
      :Mix_LoadWAV => :pointer,
      :Mix_LoadMUS => :pointer,
      :Mix_LoadMUS_RW => :pointer,
      :Mix_LoadMUSType_RW => :pointer,
      :Mix_QuickLoad_WAV => :pointer,
      :Mix_QuickLoad_RAW => :pointer,
      :Mix_FreeChunk => :void,
      :Mix_FreeMusic => :void,
      :Mix_GetNumChunkDecoders => :int,
      :Mix_GetChunkDecoder => :pointer,
      :Mix_HasChunkDecoder => :int,
      :Mix_GetNumMusicDecoders => :int,
      :Mix_GetMusicDecoder => :pointer,
      :Mix_HasMusicDecoder => :int,
      :Mix_GetMusicType => :int,
      :Mix_GetMusicTitle => :pointer,
      :Mix_GetMusicTitleTag => :pointer,
      :Mix_GetMusicArtistTag => :pointer,
      :Mix_GetMusicAlbumTag => :pointer,
      :Mix_GetMusicCopyrightTag => :pointer,
      :Mix_SetPostMix => :void,
      :Mix_HookMusic => :void,
      :Mix_HookMusicFinished => :void,
      :Mix_GetMusicHookData => :pointer,
      :Mix_ChannelFinished => :void,
      :Mix_RegisterEffect => :int,
      :Mix_UnregisterEffect => :int,
      :Mix_UnregisterAllEffects => :int,
      :Mix_SetPanning => :int,
      :Mix_SetPosition => :int,
      :Mix_SetDistance => :int,
      :Mix_SetReverseStereo => :int,
      :Mix_ReserveChannels => :int,
      :Mix_GroupChannel => :int,
      :Mix_GroupChannels => :int,
      :Mix_GroupAvailable => :int,
      :Mix_GroupCount => :int,
      :Mix_GroupOldest => :int,
      :Mix_GroupNewer => :int,
      :Mix_PlayChannel => :int,
      :Mix_PlayChannelTimed => :int,
      :Mix_PlayMusic => :int,
      :Mix_FadeInMusic => :int,
      :Mix_FadeInMusicPos => :int,
      :Mix_FadeInChannel => :int,
      :Mix_FadeInChannelTimed => :int,
      :Mix_Volume => :int,
      :Mix_VolumeChunk => :int,
      :Mix_VolumeMusic => :int,
      :Mix_GetMusicVolume => :int,
      :Mix_MasterVolume => :int,
      :Mix_HaltChannel => :int,
      :Mix_HaltGroup => :int,
      :Mix_HaltMusic => :int,
      :Mix_ExpireChannel => :int,
      :Mix_FadeOutChannel => :int,
      :Mix_FadeOutGroup => :int,
      :Mix_FadeOutMusic => :int,
      :Mix_FadingMusic => :int,
      :Mix_FadingChannel => :int,
      :Mix_Pause => :void,
      :Mix_Resume => :void,
      :Mix_Paused => :int,
      :Mix_PauseMusic => :void,
      :Mix_ResumeMusic => :void,
      :Mix_RewindMusic => :void,
      :Mix_PausedMusic => :int,
      :Mix_ModMusicJumpToOrder => :int,
      :Mix_StartTrack => :int,
      :Mix_GetNumTracks => :int,
      :Mix_SetMusicPosition => :int,
      :Mix_GetMusicPosition => :double,
      :Mix_MusicDuration => :double,
      :Mix_GetMusicLoopStartTime => :double,
      :Mix_GetMusicLoopEndTime => :double,
      :Mix_GetMusicLoopLengthTime => :double,
      :Mix_Playing => :int,
      :Mix_PlayingMusic => :int,
      :Mix_SetMusicCMD => :int,
      :Mix_SetSynchroValue => :int,
      :Mix_GetSynchroValue => :int,
      :Mix_SetSoundFonts => :int,
      :Mix_GetSoundFonts => :pointer,
      :Mix_EachSoundFont => :int,
      :Mix_SetTimidityCfg => :int,
      :Mix_GetTimidityCfg => :pointer,
      :Mix_GetChunk => :pointer,
      :Mix_CloseAudio => :void,
    }
    symbols.each do |sym|
      begin
        attach_function apis[sym], sym, args[sym], retvals[sym]
      rescue FFI::NotFoundError => error
        $stderr.puts("[Warning] Failed to import #{sym} (#{error}).") if output_error
      end
    end
  end

end

