Changeset 722


Ignore:
Timestamp:
Sep 26, 2013, 1:18:31 AM (9 years ago)
Author:
Sam Hocevar
Message:

audio: only activate the "song" class if SDL_mixer is present.

Location:
abuse/branches/lol
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • abuse/branches/lol/data/Makefile.am

    r721 r722  
    22include $(top_srcdir)/build/autotools/common.am
    33
    4 EXTRA_DIST = \
     4EXTRA_DIST += \
    55    $(demos) $(music) $(lisp) $(extra) $(art) $(levels) $(doc) $(sound)
    66
  • abuse/branches/lol/doc/Makefile.am

    r721 r722  
    77asset_DATA = abuse.bmp abuse.png
    88
    9 EXTRA_DIST = $(asset_DATA)
     9EXTRA_DIST += $(asset_DATA)
    1010
  • abuse/branches/lol/src/sdlport/sound.cpp

    r686 r722  
    170170// Play music using SDL_Mixer
    171171
    172 song::song(char const * filename)
     172song::song(String const &filename)
    173173{
    174174    data = NULL;
    175     Name = strdup(filename);
     175    m_name = filename;
    176176    song_id = 0;
    177177
     
    179179    music = NULL;
    180180
    181     char realname[255];
    182     strcpy(realname, get_filename_prefix());
    183     strcat(realname, filename);
     181    String realname = String::Printf("%s%s", get_filename_prefix(), m_name.C());
    184182
    185183    uint32_t data_size;
    186     data = load_hmi(realname, data_size);
     184    data = load_hmi(realname.C(), data_size);
    187185
    188186    if (!data)
    189187    {
    190         printf("Sound: ERROR - could not load %s\n", realname);
     188        printf("Sound: ERROR - could not load %s\n", realname.C());
    191189        return;
    192190    }
     
    198196    {
    199197        printf("Sound: ERROR - %s while loading %s\n",
    200                Mix_GetError(), realname);
     198               Mix_GetError(), realname.C());
    201199        return;
    202200    }
     
    208206        stop();
    209207    free(data);
    210     free(Name);
    211208
    212209    Mix_FreeMusic(music);
  • abuse/branches/lol/src/sdlport/sound.h

    r555 r722  
    1212#define __SOUND_H__
    1313
    14 #if !defined __CELLOS_LV2__
    15 #   include <SDL/SDL_mixer.h>
     14#if defined USE_SDL_MIXER
     15#   if defined HAVE_SDL_SDL_H
     16#      include <SDL/SDL.h>
     17#   else
     18#      include <SDL.h>
     19#   endif
     20#   if defined HAVE_SDL_SDL_MIXER_H
     21#      include <SDL/SDL_mixer.h>
     22#   else
     23#      include <SDL_mixer.h>
     24#   endif
    1625#endif
    1726
     
    3443
    3544private:
    36 #if !defined __CELLOS_LV2__
     45#if defined USE_SDL_MIXER
    3746    Mix_Chunk* m_chunk;
    3847#endif
     
    4251{
    4352public:
    44 #if !defined __CELLOS_LV2__
    45     char const *name() { return Name; }
    46 #endif
    47     song(char const *filename);
     53    String const &name() { return m_name; }
     54    song(String const &filename);
    4855    void play(unsigned char volume=127);
    4956    void stop(long fadeout_time=0); // time in ms
     
    5360
    5461private:
    55 #if !defined __CELLOS_LV2__
    56     char *Name;
    57     unsigned char *data;
     62    String m_name;
     63#if defined USE_SDL_MIXER
     64    uint8_t *data;
    5865    unsigned long song_id;
    5966    Mix_Music* music;
Note: See TracChangeset for help on using the changeset viewer.