mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-14 10:12:59 +02:00
d27b854cb1
- All XXXplayers are now in client/media directory - Reogranized code on one class per file basis - Extracted interfaces from handlers. Handlers now implement corresponding interface. - CCS now only stores pointer to an interface
46 lines
898 B
C++
46 lines
898 B
C++
/*
|
|
* CAudioBase.cpp, part of VCMI engine
|
|
*
|
|
* Authors: listed in file AUTHORS in main folder
|
|
*
|
|
* License: GNU General Public License v2.0 or later
|
|
* Full text of license available in license.txt file, in main folder
|
|
*
|
|
*/
|
|
#include "StdInc.h"
|
|
#include "CAudioBase.h"
|
|
|
|
#include "../CGameInfo.h"
|
|
|
|
#include <SDL_mixer.h>
|
|
|
|
int CAudioBase::initializationCounter = 0;
|
|
bool CAudioBase::initializeSuccess = false;
|
|
|
|
CAudioBase::CAudioBase()
|
|
{
|
|
if(initializationCounter == 0)
|
|
{
|
|
if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) == -1)
|
|
logGlobal->error("Mix_OpenAudio error: %s", Mix_GetError());
|
|
else
|
|
initializeSuccess = true;
|
|
}
|
|
++initializationCounter;
|
|
}
|
|
|
|
bool CAudioBase::isInitialized() const
|
|
{
|
|
return initializeSuccess;
|
|
}
|
|
|
|
CAudioBase::~CAudioBase()
|
|
{
|
|
--initializationCounter;
|
|
|
|
if(initializationCounter == 0 && initializeSuccess)
|
|
Mix_CloseAudio();
|
|
|
|
initializeSuccess = false;
|
|
}
|