From a78778fdc2d38586b5cec5ad75b4bb573ddafc74 Mon Sep 17 00:00:00 2001 From: jarikomppa Date: Sun, 22 Jun 2014 19:36:59 +0300 Subject: [PATCH] Fixing various warnings, including some omissions on the error code change.. --- demos/multimusic/main.cpp | 1 - demos/space/main.cpp | 8 ++++---- include/soloud.h | 6 +++--- include/soloud_error.h | 16 ++++++++-------- src/audiosource/modplug/soloud_modplug.cpp | 2 +- src/audiosource/speech/klatt.cpp | 2 +- src/core/soloud.cpp | 3 +-- src/core/soloud_audiosource.cpp | 2 +- src/core/soloud_core_basicops.cpp | 2 +- src/core/soloud_core_getters.cpp | 4 ++-- 10 files changed, 22 insertions(+), 24 deletions(-) diff --git a/demos/multimusic/main.cpp b/demos/multimusic/main.cpp index 6d7ea142..21e44991 100644 --- a/demos/multimusic/main.cpp +++ b/demos/multimusic/main.cpp @@ -203,7 +203,6 @@ int main(int argc, char *argv[]) cycle++; // Render stuff render(); - int h; // Poll for events, and handle the ones we care about. SDL_Event event; while (SDL_PollEvent(&event)) diff --git a/demos/space/main.cpp b/demos/space/main.cpp index ef954715..d2186eaf 100644 --- a/demos/space/main.cpp +++ b/demos/space/main.cpp @@ -141,7 +141,7 @@ void render() float v = fabs(w[i] + (rand() % 500)/10000.0f); if (v > 1) v = 1; float h = 132 * v / 2; - drawrect(317+i, 231 + 66-h, 1, h*2, 0xff009f00); + drawrect(317+i, 231 + 66-(int)floor(h), 1, (int)floor(h*2), 0xff009f00); } float *f = gMusicBus.calcFFT(); @@ -152,7 +152,7 @@ void render() float v = f[(i & ~7) + 5] / 2; float h = 60 * v; if (h > 60) h = 60; - drawrect(62+i,383+60-h,1,h,0xff007f00); + drawrect(62+i,383+60-(int)floor(h),1,(int)floor(h),0xff007f00); } int loop = gSoloud.getLoopCount(speechhandle); @@ -201,7 +201,7 @@ int main(int argc, char *argv[]) gSpeech.setFilter(0, &gLofi); gSpeech.setFilter(2, &gReso); gLofi.setParams(8000,4); - gFlanger.setParams(0.002,100); + gFlanger.setParams(0.002f,100); // gReso.setParams(SoLoud::BiquadResonantFilter::LOWPASS, 8000, 500, 5); gReso.setParams(SoLoud::BiquadResonantFilter::BANDPASS, 8000, 1000, 0.5); @@ -218,7 +218,7 @@ int main(int argc, char *argv[]) gSpeech.setLooping(1); speechhandle = gSpeechBus.play(gSpeech, 3, -0.25); - gSoloud.setRelativePlaySpeed(speechhandle, 1.2); + gSoloud.setRelativePlaySpeed(speechhandle, 1.2f); gSoloud.oscillateFilterParameter(speechhandle, 0, SoLoud::LofiFilter::SAMPLERATE, 2000, 8000, 4); diff --git a/include/soloud.h b/include/soloud.h index 995d1da6..090acf5c 100644 --- a/include/soloud.h +++ b/include/soloud.h @@ -293,9 +293,9 @@ namespace SoLoud // Global filter instance FilterInstance *mFilterInstance[FILTERS_PER_STREAM]; // Find a free voice, stopping the oldest if no free voice is found. - unsigned int findFreeVoice(); - // Converts handle to voice, if the handle is valid. - unsigned int getVoiceFromHandle(handle aVoiceHandle) const; + int findFreeVoice(); + // Converts handle to voice, if the handle is valid. Returns -1 if not. + int getVoiceFromHandle(handle aVoiceHandle) const; // Converts voice + playindex into handle handle getHandleFromVoice(unsigned int aVoice) const; // Stop voice (not handle). diff --git a/include/soloud_error.h b/include/soloud_error.h index 50cac2d2..1379f8e5 100644 --- a/include/soloud_error.h +++ b/include/soloud_error.h @@ -28,14 +28,14 @@ namespace SoLoud { enum SOLOUD_ERRORS { - SO_NO_ERROR = 0, // No error - INVALID_PARAMETER = -1, // Some parameter is invalid - FILE_NOT_FOUND = -2, // File not found - FILE_LOAD_FAILED = -3, // File found, but could not be loaded - DLL_NOT_FOUND = -4, // DLL not found, or wrong DLL - OUT_OF_MEMORY = -5, // Out of memory - NOT_IMPLEMENTED = -6, // Feature not implemented - UNKNOWN_ERROR = -7 // Other error + SO_NO_ERROR = 0, // No error + INVALID_PARAMETER = 1, // Some parameter is invalid + FILE_NOT_FOUND = 2, // File not found + FILE_LOAD_FAILED = 3, // File found, but could not be loaded + DLL_NOT_FOUND = 4, // DLL not found, or wrong DLL + OUT_OF_MEMORY = 5, // Out of memory + NOT_IMPLEMENTED = 6, // Feature not implemented + UNKNOWN_ERROR = 7 // Other error }; }; #endif \ No newline at end of file diff --git a/src/audiosource/modplug/soloud_modplug.cpp b/src/audiosource/modplug/soloud_modplug.cpp index 7369c49f..710b0e43 100644 --- a/src/audiosource/modplug/soloud_modplug.cpp +++ b/src/audiosource/modplug/soloud_modplug.cpp @@ -105,7 +105,7 @@ namespace SoLoud FILE * f = fopen(aFilename, "rb"); if (!f) { - return -1; + return FILE_NOT_FOUND; } if (mData) diff --git a/src/audiosource/speech/klatt.cpp b/src/audiosource/speech/klatt.cpp index 9ceae257..2553bc75 100644 --- a/src/audiosource/speech/klatt.cpp +++ b/src/audiosource/speech/klatt.cpp @@ -628,7 +628,7 @@ void klatt::parwave(klatt_frame *frame, short int *jwave) float sourc; /* Sound source if all-parallel config used */ float glotout; /* Output of glottal sound source */ float par_glotout; /* Output of parallelglottal sound sourc */ - float voice; /* Current sample of voicing waveform */ + float voice = 0; /* Current sample of voicing waveform */ float frics; /* Frication sound source */ float aspiration; /* Aspiration sound source */ int nrand; /* Varible used by random number generator */ diff --git a/src/core/soloud.cpp b/src/core/soloud.cpp index 83bad073..f42df4c3 100644 --- a/src/core/soloud.cpp +++ b/src/core/soloud.cpp @@ -253,7 +253,7 @@ namespace SoLoud } #endif if (!inited) - return -10; + return UNKNOWN_ERROR; return 0; } @@ -450,7 +450,6 @@ namespace SoLoud unsigned int j; float step = mVoice[i]->mSamplerate / aSamplerate; int step_fixed = (int)floor(step * FIXPOINT_FRAC_MUL); - float samples_per_block = SAMPLE_GRANULARITY / step; unsigned int outofs = 0; if (mVoice[i]->mDelaySamples) diff --git a/src/core/soloud_audiosource.cpp b/src/core/soloud_audiosource.cpp index 5e3bb7b3..796d4919 100644 --- a/src/core/soloud_audiosource.cpp +++ b/src/core/soloud_audiosource.cpp @@ -52,7 +52,7 @@ namespace SoLoud mAudioSourceID = 0; mActiveFader = 0; mChannels = 1; - mBusHandle = -1; + mBusHandle = ~0u; mLoopCount = 0; int i; for (i = 0; i < FILTERS_PER_STREAM; i++) diff --git a/src/core/soloud_core_basicops.cpp b/src/core/soloud_core_basicops.cpp index 618f055e..002ab1a8 100644 --- a/src/core/soloud_core_basicops.cpp +++ b/src/core/soloud_core_basicops.cpp @@ -48,7 +48,7 @@ namespace SoLoud { if (mUnlockMutexFunc) mUnlockMutexFunc(mMutex); delete instance; - return -1; + return UNKNOWN_ERROR; } if (!aSound.mAudioSourceID) { diff --git a/src/core/soloud_core_getters.cpp b/src/core/soloud_core_getters.cpp index 5a3dbbce..780643fe 100644 --- a/src/core/soloud_core_getters.cpp +++ b/src/core/soloud_core_getters.cpp @@ -50,7 +50,7 @@ namespace SoLoud return (aVoice + 1) | (mVoice[aVoice]->mPlayIndex << 12); } - unsigned int Soloud::getVoiceFromHandle(handle aVoiceHandle) const + int Soloud::getVoiceFromHandle(handle aVoiceHandle) const { // If this is a voice group handle, pick the first handle from the group handle *h = voiceGroupHandleToArray(aVoiceHandle); @@ -202,7 +202,7 @@ namespace SoLoud return v != 0; } - unsigned int Soloud::findFreeVoice() + int Soloud::findFreeVoice() { int i; unsigned int lowest_play_index_value = 0xffffffff;