[DEBUG] correction of the segfault on reading ogg file
This commit is contained in:
parent
730685f470
commit
11788c2afc
@ -12,6 +12,7 @@
|
|||||||
#include <ewolsa/decOgg.h>
|
#include <ewolsa/decOgg.h>
|
||||||
#include <tremor/ivorbiscodec.h>
|
#include <tremor/ivorbiscodec.h>
|
||||||
#include <tremor/ivorbisfile.h>
|
#include <tremor/ivorbisfile.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
static size_t LocalReadFunc(void *ptr, size_t size, size_t nmemb, void *datasource) {
|
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) {
|
static int localCloseFunc(void *datasource) {
|
||||||
etk::FSNode* file = static_cast<etk::FSNode*>(datasource);
|
etk::FSNode* file = static_cast<etk::FSNode*>(datasource);
|
||||||
file->fileClose();
|
file->fileClose();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static long localTellFunc(void *datasource) {
|
static long localTellFunc(void *datasource) {
|
||||||
@ -57,23 +59,23 @@ int16_t* ewolsa::ogg::loadAudioFile(const std::string& _filename, int8_t _nbChan
|
|||||||
localCloseFunc,
|
localCloseFunc,
|
||||||
localTellFunc
|
localTellFunc
|
||||||
};
|
};
|
||||||
etk::FSNode fileAccess(_filename);
|
std::unique_ptr<etk::FSNode> fileAccess = std::unique_ptr<etk::FSNode>(new etk::FSNode(_filename));
|
||||||
// Start loading the XML :
|
// Start loading the XML :
|
||||||
//EWOLSA_DEBUG("open file (OGG) \"" << fileAccess << "\"");
|
//EWOLSA_DEBUG("open file (OGG) \"" << fileAccess << "\"");
|
||||||
if (false == fileAccess.exist()) {
|
if (false == fileAccess->exist()) {
|
||||||
//EWOLSA_ERROR("File Does not exist : \"" << fileAccess << "\"");
|
//EWOLSA_ERROR("File Does not exist : \"" << fileAccess << "\"");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
int32_t fileSize = fileAccess.fileSize();
|
int32_t fileSize = fileAccess->fileSize();
|
||||||
if (0 == fileSize) {
|
if (0 == fileSize) {
|
||||||
//EWOLSA_ERROR("This file is empty : \"" << fileAccess << "\"");
|
//EWOLSA_ERROR("This file is empty : \"" << fileAccess << "\"");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (false == fileAccess.fileOpenRead()) {
|
if (false == fileAccess->fileOpenRead()) {
|
||||||
//EWOLSA_ERROR("Can not open the file : \"" << fileAccess << "\"");
|
//EWOLSA_ERROR("Can not open the file : \"" << fileAccess << "\"");
|
||||||
return NULL;
|
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.");
|
//EWOLSA_ERROR("Input does not appear to be an Ogg bitstream.");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -138,7 +140,7 @@ int16_t* ewolsa::ogg::loadAudioFile(const std::string& _filename, int8_t _nbChan
|
|||||||
//EWOLSA_DEBUG("get data : " << ret << " Bytes");
|
//EWOLSA_DEBUG("get data : " << ret << " Bytes");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* cleanup */
|
// cleanup
|
||||||
ov_clear(&vf);
|
ov_clear(&vf);
|
||||||
//EWOLSA_DEBUG("Done.");
|
//EWOLSA_DEBUG("Done.");
|
||||||
return outputData;
|
return outputData;
|
||||||
|
@ -176,7 +176,7 @@ static void uptateEffectVolume() {
|
|||||||
|
|
||||||
void ewolsa::effects::volumeSet(float _newVolume) {
|
void ewolsa::effects::volumeSet(float _newVolume) {
|
||||||
effectsVolume = _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");
|
EWOLSA_INFO("Set music Volume at " << _newVolume << "dB == > " << effectsVolume << "dB");
|
||||||
uptateEffectVolume();
|
uptateEffectVolume();
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ static void uptateMusicVolume() {
|
|||||||
|
|
||||||
void ewolsa::music::volumeSet(float _newVolume) {
|
void ewolsa::music::volumeSet(float _newVolume) {
|
||||||
musicVolume = _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");
|
EWOLSA_INFO("Set music Volume at " << _newVolume << "dB == > " << musicVolume << "dB");
|
||||||
uptateMusicVolume();
|
uptateMusicVolume();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user