docs: clean up logging a bit
This commit is contained in:
@@ -22,7 +22,14 @@ in readBuffer2() handle != null: 1
|
|||||||
in readBuffer2() done=2304
|
in readBuffer2() done=2304
|
||||||
copying 1152 samples, k=0
|
copying 1152 samples, k=0
|
||||||
<segfault>
|
<segfault>
|
||||||
|
|
||||||
|
err=-12 done=702
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read samples from the next mp3-frame into the struct MP3File's buffer.
|
||||||
|
* @return number of samples read (uses buffer_size which is much smaller than total length)
|
||||||
|
*/
|
||||||
static inline int readBuffer2(MP3File* mp3)
|
static inline int readBuffer2(MP3File* mp3)
|
||||||
{
|
{
|
||||||
//LOGI("in readBuffer2() on mp3 != null: %d", mp3 != nullptr);
|
//LOGI("in readBuffer2() on mp3 != null: %d", mp3 != nullptr);
|
||||||
@@ -34,7 +41,7 @@ static inline int readBuffer2(MP3File* mp3)
|
|||||||
//LOGI("in readBuffer2() done=%d", done);
|
//LOGI("in readBuffer2() done=%d", done);
|
||||||
mp3->remaining_samples -= done / sizeof(int16_t);
|
mp3->remaining_samples -= done / sizeof(int16_t);
|
||||||
mp3->offset = 0;
|
mp3->offset = 0;
|
||||||
if (err != MPG123_OK) LOGI("err=%d done=%d", err, done); // err=-12
|
if (err != MPG123_OK && err != MPG123_DONE) LOGE("mpg123_read() err=%d done=%d", err, done);
|
||||||
if(err == MPG123_DONE) return done / sizeof(int16_t);
|
if(err == MPG123_DONE) return done / sizeof(int16_t);
|
||||||
return err != MPG123_OK ? 0 : done / sizeof(int16_t);
|
return err != MPG123_OK ? 0 : done / sizeof(int16_t);
|
||||||
}
|
}
|
||||||
@@ -43,16 +50,6 @@ static bool read_mp3(std::string filename, std::vector<float>& samples) {
|
|||||||
// TODO: assumes 48000 Hz sampling rate of the file
|
// TODO: assumes 48000 Hz sampling rate of the file
|
||||||
// note: our resource file is mono (1 channel = 1 samples_per_frame)!
|
// note: our resource file is mono (1 channel = 1 samples_per_frame)!
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
2026-03-05 11:54:44.841 17486-17486 NDK at.lockstep I PlaybackEngine - allocated 2304 bytes buffer
|
|
||||||
2026-03-05 11:54:44.841 17486-17486 NDK at.lockstep I PlaybackEngine - blanking the buffer ...
|
|
||||||
2026-03-05 11:54:44.842 17486-17486 NDK at.lockstep I PlaybackEngine - filling 24543 num_samples
|
|
||||||
|
|
||||||
copying 1152 samples, k=0
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
MP3File *mFile = mp3file_open(filename.c_str(), 0); // MPG123_ENC_FLOAT_32 (but does not seem to work)
|
MP3File *mFile = mp3file_open(filename.c_str(), 0); // MPG123_ENC_FLOAT_32 (but does not seem to work)
|
||||||
//LOGI("allocated %d bytes buffer", mFile->buffer_size);
|
//LOGI("allocated %d bytes buffer", mFile->buffer_size);
|
||||||
//LOGI("blanking the buffer ...");
|
//LOGI("blanking the buffer ...");
|
||||||
@@ -67,7 +64,7 @@ static bool read_mp3(std::string filename, std::vector<float>& samples) {
|
|||||||
while (ok2 && mFile->remaining_samples > 0) {
|
while (ok2 && mFile->remaining_samples > 0) {
|
||||||
//LOGI("readBuffer2() k=%d", k);
|
//LOGI("readBuffer2() k=%d", k);
|
||||||
ok2 = readBuffer2(mFile);
|
ok2 = readBuffer2(mFile);
|
||||||
if (!ok2) break; // TODO: check if trailing bit is decoded correctly
|
if (!ok2) break;
|
||||||
//LOGI("copying %d samples, k=%d", mFile->samples_per_frame, k);
|
//LOGI("copying %d samples, k=%d", mFile->samples_per_frame, k);
|
||||||
for (int j = 0; j < ok2 && i < mFile->num_samples; j++, i++) {
|
for (int j = 0; j < ok2 && i < mFile->num_samples; j++, i++) {
|
||||||
int16_t *src = ((int16_t *) mFile->buffer) + j;
|
int16_t *src = ((int16_t *) mFile->buffer) + j;
|
||||||
@@ -79,16 +76,6 @@ static bool read_mp3(std::string filename, std::vector<float>& samples) {
|
|||||||
if(!ok2) {
|
if(!ok2) {
|
||||||
LOGI("ok2=false at i=%d", i);
|
LOGI("ok2=false at i=%d", i);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if(ok1 && ok2) {
|
|
||||||
// num_frames, num_samples, samples_per_frame
|
|
||||||
LOGI("filling %d num_samples", mFile->num_samples);
|
|
||||||
samples.resize(mFile->num_samples);
|
|
||||||
for(int i = 0; i < mFile->num_samples; i++) {
|
|
||||||
int16_t *src = ((int16_t *) mFile->buffer) + i;
|
|
||||||
samples[i] = (*src) / 32768.0f;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
if(mFile)
|
if(mFile)
|
||||||
mp3file_delete(mFile);
|
mp3file_delete(mFile);
|
||||||
return ok1 && ok2;
|
return ok1 && ok2;
|
||||||
|
|||||||
Reference in New Issue
Block a user