From 11788c2afcb64a906a6a489d1ee96fbfbcdb832d Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 10 Jul 2014 21:02:51 +0200 Subject: [PATCH] [DEBUG] correction of the segfault on reading ogg file --- ewolsa/decOgg.cpp | 14 ++++++++------ ewolsa/effects.cpp | 2 +- ewolsa/music.cpp | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ewolsa/decOgg.cpp b/ewolsa/decOgg.cpp index 48c8224..f909103 100644 --- a/ewolsa/decOgg.cpp +++ b/ewolsa/decOgg.cpp @@ -12,6 +12,7 @@ #include #include #include +#include static size_t LocalReadFunc(void *ptr, size_t size, size_t nmemb, void *datasource) { @@ -39,6 +40,7 @@ static int localSeekFunc(void *datasource, ogg_int64_t offset, int whence) { static int localCloseFunc(void *datasource) { etk::FSNode* file = static_cast(datasource); file->fileClose(); + return 0; } static long localTellFunc(void *datasource) { @@ -57,23 +59,23 @@ int16_t* ewolsa::ogg::loadAudioFile(const std::string& _filename, int8_t _nbChan localCloseFunc, localTellFunc }; - etk::FSNode fileAccess(_filename); + std::unique_ptr fileAccess = std::unique_ptr(new etk::FSNode(_filename)); // Start loading the XML : //EWOLSA_DEBUG("open file (OGG) \"" << fileAccess << "\""); - if (false == fileAccess.exist()) { + if (false == fileAccess->exist()) { //EWOLSA_ERROR("File Does not exist : \"" << fileAccess << "\""); return NULL; } - int32_t fileSize = fileAccess.fileSize(); + int32_t fileSize = fileAccess->fileSize(); if (0 == fileSize) { //EWOLSA_ERROR("This file is empty : \"" << fileAccess << "\""); return NULL; } - if (false == fileAccess.fileOpenRead()) { + if (false == fileAccess->fileOpenRead()) { //EWOLSA_ERROR("Can not open the file : \"" << fileAccess << "\""); return NULL; } - if (ov_open_callbacks(&fileAccess, &vf, NULL, 0, tmpCallback) < 0) { + if (ov_open_callbacks(&(*fileAccess), &vf, NULL, 0, tmpCallback) < 0) { //EWOLSA_ERROR("Input does not appear to be an Ogg bitstream."); return NULL; } @@ -138,7 +140,7 @@ int16_t* ewolsa::ogg::loadAudioFile(const std::string& _filename, int8_t _nbChan //EWOLSA_DEBUG("get data : " << ret << " Bytes"); } } - /* cleanup */ + // cleanup ov_clear(&vf); //EWOLSA_DEBUG("Done."); return outputData; diff --git a/ewolsa/effects.cpp b/ewolsa/effects.cpp index 3482377..fa4a66a 100644 --- a/ewolsa/effects.cpp +++ b/ewolsa/effects.cpp @@ -176,7 +176,7 @@ static void uptateEffectVolume() { void ewolsa::effects::volumeSet(float _newVolume) { effectsVolume = _newVolume; - effectsVolume = std::avg(-100, effectsVolume, 20); + effectsVolume = std::avg(-100.0f, effectsVolume, 20.0f); EWOLSA_INFO("Set music Volume at " << _newVolume << "dB == > " << effectsVolume << "dB"); uptateEffectVolume(); } diff --git a/ewolsa/music.cpp b/ewolsa/music.cpp index e82f69d..62eedb9 100644 --- a/ewolsa/music.cpp +++ b/ewolsa/music.cpp @@ -150,7 +150,7 @@ static void uptateMusicVolume() { void ewolsa::music::volumeSet(float _newVolume) { musicVolume = _newVolume; - musicVolume = std::avg(-1000, musicVolume, 40); + musicVolume = std::avg(-1000.0f, musicVolume, 40.0f); EWOLSA_INFO("Set music Volume at " << _newVolume << "dB == > " << musicVolume << "dB"); uptateMusicVolume(); }