2014-01-07 11:47:11 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
2012-07-26 15:30:09 +08:00
|
|
|
#ifndef _OPENSL_ENGINE_H_
|
|
|
|
#define _OPENSL_ENGINE_H_
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <jni.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <map>
|
2012-08-02 14:28:40 +08:00
|
|
|
#include <vector>
|
2012-08-17 09:51:49 +08:00
|
|
|
#include <dlfcn.h>
|
2013-07-16 07:45:31 +08:00
|
|
|
#include <SLES/OpenSLES.h>
|
|
|
|
#include <SLES/OpenSLES_Android.h>
|
2012-07-26 15:30:09 +08:00
|
|
|
#include <sys/types.h>
|
2013-07-16 07:45:31 +08:00
|
|
|
#include <android/asset_manager.h>
|
|
|
|
#include <android/asset_manager_jni.h>
|
2012-07-26 15:30:09 +08:00
|
|
|
#include <android/log.h>
|
|
|
|
#include <jni/JniHelper.h>
|
2012-08-20 12:49:59 +08:00
|
|
|
#include <dlfcn.h>
|
2012-07-26 15:30:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
class OpenSLEngine
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
OpenSLEngine();
|
|
|
|
~OpenSLEngine();
|
|
|
|
|
2012-08-17 09:51:49 +08:00
|
|
|
void createEngine(void * pHandle);
|
2012-07-26 15:30:09 +08:00
|
|
|
|
|
|
|
void closeEngine();
|
|
|
|
|
|
|
|
|
|
|
|
bool preloadBackgroundMusic(const char * filename);
|
|
|
|
|
|
|
|
void setBackgroundMusicState(int state);
|
|
|
|
|
|
|
|
int getBackgroundMusicState();
|
|
|
|
|
|
|
|
void rewindBackgroundMusic();
|
|
|
|
|
|
|
|
void setBackgroundMusicLooping(bool isLooping);
|
|
|
|
|
|
|
|
void setBackgroundVolume(int volume);
|
|
|
|
|
|
|
|
int getBackgroundVolume();
|
|
|
|
|
|
|
|
|
2012-08-02 14:28:40 +08:00
|
|
|
|
|
|
|
bool recreatePlayer(const char* filename);
|
|
|
|
|
2012-07-26 15:30:09 +08:00
|
|
|
unsigned int preloadEffect(const char * filename);
|
|
|
|
|
|
|
|
void unloadEffect(const char * filename);
|
|
|
|
|
2012-08-02 14:28:40 +08:00
|
|
|
int getEffectState(unsigned int effectID);
|
|
|
|
|
|
|
|
void setEffectState(unsigned int effectID, int state, bool isClear = false);
|
2012-07-26 15:30:09 +08:00
|
|
|
|
|
|
|
void setAllEffectState(int state);
|
|
|
|
|
2012-07-27 10:36:05 +08:00
|
|
|
void resumeEffect(unsigned int effectID);
|
|
|
|
|
|
|
|
void resumeAllEffects();
|
|
|
|
|
2013-06-22 04:01:00 +08:00
|
|
|
void setEffectParameters(unsigned int effectID, bool isLooping, float pitch, float pan, float gain);
|
2012-07-26 15:30:09 +08:00
|
|
|
|
2012-08-02 14:28:40 +08:00
|
|
|
void setEffectsVolume(float volume);
|
2012-07-26 15:30:09 +08:00
|
|
|
|
2012-08-02 14:28:40 +08:00
|
|
|
float getEffectsVolume();
|
2012-07-26 15:30:09 +08:00
|
|
|
|
|
|
|
private:
|
2013-06-15 14:03:30 +08:00
|
|
|
SLmillibel _musicVolume;
|
2013-06-22 04:01:00 +08:00
|
|
|
float _effectVolume;
|
2012-07-26 15:30:09 +08:00
|
|
|
};
|
|
|
|
|
2013-06-22 04:01:00 +08:00
|
|
|
#endif
|