00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "Teddy/TeddyConfig.h"
00026 #include "Teddy/Application/BaseAudioManager.h"
00027 #include "Teddy/Application/BaseRoot.h"
00028 #include "Teddy/SysSupport/Messages.h"
00029 #include "Teddy/SysSupport/StdIO.h"
00030 using namespace Teddy::SysSupport;
00031
00032
00033 #if defined( HAVE_LIB_SDL_MIXER ) && !defined( DISABLE_AUDIO )
00034
00035 # include "SDL_mixer.h"
00036 # if defined( _MSC_VER )
00037 # if defined( _DEBUG )
00038 # pragma comment (lib, "SDL_mixerD.lib")
00039 # else
00040 # pragma comment (lib, "SDL_mixer.lib")
00041 # endif
00042 # endif
00043
00044
00045 #else
00046 # include "Teddy/SysSupport/StdIO.h"
00047 #endif
00048
00049
00050 namespace Teddy {
00051 namespace Application {
00052
00053
00054 const int BaseAudioManager::OPT_MASTER = (1ul<<1ul);
00055 const int BaseAudioManager::OPT_SAMPLES = (1ul<<2ul);
00056 const int BaseAudioManager::OPT_MIDI = (1ul<<3ul);
00057 const int BaseAudioManager::OPT_CD = (1ul<<4ul);
00058
00059
00060 BaseAudioManager::BaseAudioManager( const Options &options )
00061 :
00062 options(options)
00063 {
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 # if defined( HAVE_LIB_SDL_MIXER ) && !defined( DISABLE_AUDIO )
00080
00081
00082
00083
00084 if( Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024) < 0 ){
00085 emsg( M_AUDIO, MSG_HEAD "Couldn't open audio: %s", SDL_GetError() );
00086 return;
00087 }else{
00088
00089
00090
00091
00092
00093
00094
00095 }
00096
00097 # else
00098 dmsg( M_AUDIO, "SDL_mixer was not available when built - Audio disabled" );
00099 # endif
00100 }
00101
00102
00103 void BaseAudioManager::playWav( void *chunk ){
00104 # if defined( HAVE_LIB_SDL_MIXER ) && !defined( DISABLE_AUDIO )
00105 if( options.isEnabled(OPT_SAMPLES) == true ){
00106 Mix_PlayChannel( -1, (Mix_Chunk*)chunk, 0 );
00107 }else{
00108 }
00109 # endif
00110 }
00111
00112
00113 Options &BaseAudioManager::getOptions(){
00114 return options;
00115 }
00116
00117
00118 };
00119 };
00120