Skip to content

Commit a88be08

Browse files
committed
Use AXLOG for audio module
1 parent 9e0a592 commit a88be08

File tree

7 files changed

+73
-79
lines changed

7 files changed

+73
-79
lines changed

core/audio/AudioCache.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ AudioCache::AudioCache()
5959
, _isLoadingFinished(false)
6060
, _isSkipReadDataTask(false)
6161
{
62-
ALOGV("AudioCache() {}, id={}", fmt::ptr(this), _id);
62+
AXLOGV("AudioCache() {}, id={}", fmt::ptr(this), _id);
6363
for (int i = 0; i < QUEUEBUFFER_NUM; ++i)
6464
{
6565
_queBuffers[i] = nullptr;
@@ -69,16 +69,16 @@ AudioCache::AudioCache()
6969

7070
AudioCache::~AudioCache()
7171
{
72-
ALOGV("~AudioCache() {}, id={}, begin", fmt::ptr(this), _id);
72+
AXLOGV("~AudioCache() {}, id={}, begin", fmt::ptr(this), _id);
7373
*_isDestroyed = true;
7474
while (!_isLoadingFinished)
7575
{
7676
if (_isSkipReadDataTask)
7777
{
78-
ALOGV("id={}, Skip read data task, don't continue to wait!", _id);
78+
AXLOGV("id={}, Skip read data task, don't continue to wait!", _id);
7979
break;
8080
}
81-
ALOGV("id={}, waiting readData thread to finish ...", _id);
81+
AXLOGV("id={}, waiting readData thread to finish ...", _id);
8282
std::this_thread::sleep_for(std::chrono::milliseconds(5));
8383
}
8484
// wait for the 'readDataTask' task to exit
@@ -88,14 +88,14 @@ AudioCache::~AudioCache()
8888
{
8989
if (_alBufferId != INVALID_AL_BUFFER_ID && alIsBuffer(_alBufferId))
9090
{
91-
ALOGV("~AudioCache(id={}), delete buffer: {}", _id, _alBufferId);
91+
AXLOGV("~AudioCache(id={}), delete buffer: {}", _id, _alBufferId);
9292
alDeleteBuffers(1, &_alBufferId);
9393
_alBufferId = INVALID_AL_BUFFER_ID;
9494
}
9595
}
9696
else
9797
{
98-
ALOGW("AudioCache ({}), id={}, buffer isn't ready, state={}", fmt::ptr(this), _id, (int)_state);
98+
AXLOGW("AudioCache ({}), id={}, buffer isn't ready, state={}", fmt::ptr(this), _id, (int)_state);
9999
}
100100

101101
if (_queBufferFrames > 0)
@@ -105,14 +105,14 @@ AudioCache::~AudioCache()
105105
free(_queBuffers[index]);
106106
}
107107
}
108-
ALOGV("~AudioCache() {}, id={}, end", fmt::ptr(this), _id);
108+
AXLOGV("~AudioCache() {}, id={}, end", fmt::ptr(this), _id);
109109
_readDataTaskMutex.unlock();
110110
}
111111

112112
void AudioCache::readDataTask(unsigned int selfId)
113113
{
114114
// Note: It's in sub thread
115-
ALOGV("readDataTask begin, cache id={}", selfId);
115+
AXLOGV("readDataTask begin, cache id={}", selfId);
116116

117117
_readDataTaskMutex.lock();
118118
_state = State::LOADING;
@@ -178,7 +178,7 @@ void AudioCache::readDataTask(unsigned int selfId)
178178
auto alError = alGetError();
179179
if (alError != AL_NO_ERROR)
180180
{
181-
ALOGE("{}: attaching audio to buffer fail: {:#x}", __FUNCTION__, alError);
181+
AXLOGE("{}: attaching audio to buffer fail: {:#x}", __FUNCTION__, alError);
182182
break;
183183
}
184184

@@ -221,7 +221,7 @@ void AudioCache::readDataTask(unsigned int selfId)
221221
}
222222

223223
#if AX_USE_ALSOFT
224-
ALOGV("pcm buffer was loaded successfully, total frames: {}, total read frames: {}, remainingFrames: {}",
224+
AXLOGV("pcm buffer was loaded successfully, total frames: {}, total read frames: {}, remainingFrames: {}",
225225
totalFrames, _framesRead, remainingFrames);
226226
if (sourceFormat == AUDIO_SOURCE_FORMAT::ADPCM || sourceFormat == AUDIO_SOURCE_FORMAT::IMA_ADPCM)
227227
alBufferi(_alBufferId, AL_UNPACK_BLOCK_ALIGNMENT_SOFT, decoder->getSamplesPerBlock());
@@ -252,7 +252,7 @@ void AudioCache::readDataTask(unsigned int selfId)
252252

253253
if (adjustFrames > 0)
254254
{
255-
ALOGV("Orignal total frames: {}, adjust frames: {}, current total frames: {}", totalFrames,
255+
AXLOGV("Orignal total frames: {}, adjust frames: {}, current total frames: {}", totalFrames,
256256
adjustFrames, totalFrames + adjustFrames);
257257
totalFrames += adjustFrames;
258258
_totalFrames = remainingFrames = totalFrames;
@@ -270,7 +270,7 @@ void AudioCache::readDataTask(unsigned int selfId)
270270
dataSize = static_cast<uint32_t>(pcmBuffer.size());
271271
}
272272
# endif /* Adjust frames, may not needed */
273-
ALOGV(
273+
AXLOGV(
274274
"pcm buffer was loaded successfully, total frames: {}, total read frames: {}, adjust frames: {}, "
275275
"remainingFrames: {}",
276276
totalFrames, _framesRead, adjustFrames, remainingFrames);
@@ -280,7 +280,7 @@ void AudioCache::readDataTask(unsigned int selfId)
280280
alError = alGetError();
281281
if (alError != AL_NO_ERROR)
282282
{
283-
ALOGE("{}:alBufferData error code:{:#x}", __FUNCTION__, alError);
283+
AXLOGE("{}:alBufferData error code:{:#x}", __FUNCTION__, alError);
284284
break;
285285
}
286286

@@ -313,7 +313,7 @@ void AudioCache::readDataTask(unsigned int selfId)
313313
_state = State::FAILED;
314314
if (_alBufferId != INVALID_AL_BUFFER_ID && alIsBuffer(_alBufferId))
315315
{
316-
ALOGV("readDataTask failed, delete buffer: {}", _alBufferId);
316+
AXLOGV("readDataTask failed, delete buffer: {}", _alBufferId);
317317
alDeleteBuffers(1, &_alBufferId);
318318
_alBufferId = INVALID_AL_BUFFER_ID;
319319
}
@@ -327,7 +327,7 @@ void AudioCache::readDataTask(unsigned int selfId)
327327
invokingLoadCallbacks();
328328

329329
_readDataTaskMutex.unlock();
330-
ALOGV("readDataTask end, cache id={}", selfId);
330+
AXLOGV("readDataTask end, cache id={}", selfId);
331331
}
332332

333333
void AudioCache::addPlayCallback(const std::function<void()>& callback)
@@ -348,7 +348,7 @@ void AudioCache::addPlayCallback(const std::function<void()>& callback)
348348
break;
349349

350350
default:
351-
ALOGE("Invalid state: {}", (int)_state);
351+
AXLOGE("Invalid state: {}", (int)_state);
352352
break;
353353
}
354354
}
@@ -382,7 +382,7 @@ void AudioCache::addLoadCallback(const std::function<void(bool)>& callback)
382382
break;
383383

384384
default:
385-
ALOGE("Invalid state: {}", (int)_state);
385+
AXLOGE("Invalid state: {}", (int)_state);
386386
break;
387387
}
388388
}
@@ -391,7 +391,7 @@ void AudioCache::invokingLoadCallbacks()
391391
{
392392
if (*_isDestroyed)
393393
{
394-
ALOGV("AudioCache ({}) was destroyed, don't invoke preload callback ...", fmt::ptr(this));
394+
AXLOGV("AudioCache ({}) was destroyed, don't invoke preload callback ...", fmt::ptr(this));
395395
return;
396396
}
397397

@@ -400,7 +400,7 @@ void AudioCache::invokingLoadCallbacks()
400400
scheduler->runOnAxmolThread([&, isDestroyed]() {
401401
if (*isDestroyed)
402402
{
403-
ALOGV("invokingLoadCallbacks perform in cocos thread, AudioCache ({}) was destroyed!", fmt::ptr(this));
403+
AXLOGV("invokingLoadCallbacks perform in cocos thread, AudioCache ({}) was destroyed!", fmt::ptr(this));
404404
return;
405405
}
406406

core/audio/AudioDecoderMp3.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ bool AudioDecoderMp3::lazyInit()
9696
}
9797
else
9898
{
99-
ALOGE("Basic setup goes wrong: {}", mpg123_plain_strerror(error));
99+
AXLOGE("Basic setup goes wrong: {}", mpg123_plain_strerror(error));
100100
ret = false;
101101
}
102102
}
@@ -133,7 +133,7 @@ bool AudioDecoderMp3::open(std::string_view fullPath)
133133
_fileStream = FileUtils::getInstance()->openFileStream(fullPath, IFileStream::Mode::READ);
134134
if (!_fileStream)
135135
{
136-
ALOGE("Trouble with minimp3(1): {}\n", strerror(errno));
136+
AXLOGE("Trouble with minimp3(1): {}\n", strerror(errno));
137137
break;
138138
}
139139

@@ -180,13 +180,13 @@ bool AudioDecoderMp3::open(std::string_view fullPath)
180180
_handle = mpg123_new(nullptr, &error);
181181
if (nullptr == _handle)
182182
{
183-
ALOGE("Basic setup goes wrong: {}", mpg123_plain_strerror(error));
183+
AXLOGE("Basic setup goes wrong: {}", mpg123_plain_strerror(error));
184184
break;
185185
}
186186

187187
if (!_fileStream.open(fullPath))
188188
{
189-
ALOGE("Trouble with mpg123(1): {}\n", strerror(errno));
189+
AXLOGE("Trouble with mpg123(1): {}\n", strerror(errno));
190190
break;
191191
}
192192

@@ -195,7 +195,7 @@ bool AudioDecoderMp3::open(std::string_view fullPath)
195195
if (mpg123_open_handle(_handle, _fileStream) != MPG123_OK ||
196196
mpg123_getformat(_handle, &rate, &channel, &mp3Encoding) != MPG123_OK)
197197
{
198-
ALOGE("Trouble with mpg123(2): {}\n", mpg123_strerror(_handle));
198+
AXLOGE("Trouble with mpg123(2): {}\n", mpg123_strerror(_handle));
199199
break;
200200
}
201201

@@ -214,7 +214,7 @@ bool AudioDecoderMp3::open(std::string_view fullPath)
214214
}
215215
else
216216
{
217-
ALOGE("Bad encoding: {0:#x}!\n", mp3Encoding);
217+
AXLOGE("Bad encoding: {0:#x}!\n", mp3Encoding);
218218
break;
219219
}
220220

@@ -279,7 +279,7 @@ uint32_t AudioDecoderMp3::read(uint32_t framesToRead, char* pcmBuf)
279279
int err = mpg123_read(_handle, (unsigned char*)pcmBuf, bytesToRead, &bytesRead);
280280
if (err == MPG123_ERR)
281281
{
282-
ALOGE("Trouble with mpg123: {}\n", mpg123_strerror(_handle));
282+
AXLOGE("Trouble with mpg123: {}\n", mpg123_strerror(_handle));
283283
return 0;
284284
}
285285

@@ -293,7 +293,7 @@ bool AudioDecoderMp3::seek(uint32_t frameOffset)
293293
return 0 == mp3dec_ex_seek(&_handle->_dec, frameOffset);
294294
#else
295295
off_t offset = mpg123_seek(_handle, frameOffset, SEEK_SET);
296-
// ALOGD("mpg123_seek return: {}", (int)offset);
296+
// AXLOGD("mpg123_seek return: {}", (int)offset);
297297
return (offset >= 0 && offset == frameOffset);
298298
#endif
299299
}

core/audio/AudioDecoderOgg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ bool AudioDecoderOgg::open(std::string_view fullPath)
7474
auto fs = FileUtils::getInstance()->openFileStream(fullPath, IFileStream::Mode::READ).release();
7575
if (!fs)
7676
{
77-
ALOGE("Trouble with ogg(1): {}\n", strerror(errno));
77+
AXLOGE("Trouble with ogg(1): {}\n", strerror(errno));
7878
return false;
7979
}
8080

core/audio/AudioDecoderWav.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static bool wav_open(std::string_view fullPath, WAV_FILE* wavf)
154154
}
155155
break;
156156
default:
157-
ALOGW("The wav format {} doesn't supported currently!", (int)fmtInfo.AudioFormat);
157+
AXLOGW("The wav format {} doesn't supported currently!", (int)fmtInfo.AudioFormat);
158158
fileStream.reset();
159159
assert(false);
160160
return false;

0 commit comments

Comments
 (0)