~ubuntu-branches/ubuntu/trusty/manaplus/trusty

« back to all changes in this revision

Viewing changes to src/soundmanager.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2013-10-07 10:26:14 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20131007102614-tg2zjdz8vmtl6n7i
Tags: 1.3.9.29-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
    mMusicVolume(60),
57
57
    mCurrentMusicFile(),
58
58
    mMusic(nullptr),
 
59
    mGuiChannel(-1),
59
60
    mPlayBattle(false),
60
61
    mPlayGui(false),
61
62
    mPlayMusic(false),
62
63
    mFadeoutMusic(true),
63
 
    mGuiChannel(-1)
 
64
    mCacheSounds(true)
64
65
{
65
66
    // This set up our callback function used to
66
67
    // handle fade outs endings.
94
95
        setMusicVolume(config.getIntValue("musicVolume"));
95
96
    else if (value == "fadeoutmusic")
96
97
        mFadeoutMusic = config.getIntValue("fadeoutmusic");
 
98
    else if (value == "uselonglivesounds")
 
99
        mCacheSounds = config.getIntValue("uselonglivesounds");
97
100
}
98
101
 
99
102
void SoundManager::init()
110
113
    mFadeoutMusic = config.getBoolValue("fadeoutmusic");
111
114
    mMusicVolume = config.getIntValue("musicVolume");
112
115
    mSfxVolume = config.getIntValue("sfxVolume");
 
116
    mCacheSounds = config.getIntValue("uselonglivesounds");
113
117
 
114
118
    config.addListener("playBattleSound", this);
115
119
    config.addListener("playGuiSound", this);
117
121
    config.addListener("sfxVolume", this);
118
122
    config.addListener("musicVolume", this);
119
123
    config.addListener("fadeoutmusic", this);
 
124
    config.addListener("uselonglivesounds", this);
120
125
 
121
126
    if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1)
122
127
    {
360
365
    else
361
366
        tmpPath = paths.getValue("sfx", "sfx/").append(path);
362
367
    ResourceManager *const resman = ResourceManager::getInstance();
363
 
    const SoundEffect *const sample = resman->getSoundEffect(tmpPath);
 
368
    SoundEffect *const sample = resman->getSoundEffect(tmpPath);
364
369
    if (sample)
365
370
    {
366
371
        logger->log("SoundManager::playSfx() Playing: %s", path.c_str());
380
385
            vol -= dist * 8;
381
386
        }
382
387
        sample->play(0, vol);
 
388
        if (!mCacheSounds)
 
389
            sample->decRef();
383
390
    }
384
391
}
385
392
 
400
407
    else
401
408
        tmpPath = paths.getValue("sfx", "sfx/").append(path);
402
409
    ResourceManager *const resman = ResourceManager::getInstance();
403
 
    const SoundEffect *const sample = resman->getSoundEffect(tmpPath);
 
410
    SoundEffect *const sample = resman->getSoundEffect(tmpPath);
404
411
    if (sample)
405
412
    {
406
413
        logger->log("SoundManager::playGuiSfx() Playing: %s", path.c_str());
407
414
        const int ret = sample->play(0, 120, mGuiChannel);
408
415
        if (ret != -1)
409
416
            mGuiChannel = ret;
 
417
        if (!mCacheSounds)
 
418
            sample->decRef();
410
419
    }
411
420
}
412
421