Skip to content

Commit

Permalink
Merge branch 'axmolengine:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Joilnen authored Jun 20, 2024
2 parents 299f89d + 2193b50 commit d10b8ee
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 141 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@

## simdjson
- [![Upstream](https://img.shields.io/github/v/tag/simdjson/simdjson?label=Upstream)](https://github.com/simdjson/simdjson)
- Version: 3.9.3
- Version: 3.9.4
- License: Apache-2.0

## stb (stb_image)
Expand Down
11 changes: 8 additions & 3 deletions 3rdparty/simdjson/simdjson.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* auto-generated on 2024-05-30 10:52:38 -0400. Do not edit! */
/* auto-generated on 2024-06-11 14:08:20 -0400. Do not edit! */
/* including simdjson.cpp: */
/* begin file simdjson.cpp */
#define SIMDJSON_SRC_SIMDJSON_CPP
Expand Down Expand Up @@ -84,6 +84,9 @@
#include <strings.h>
#endif

// We are using size_t without namespace std:: throughout the project
using std::size_t;

#ifdef _MSC_VER
#define SIMDJSON_VISUAL_STUDIO 1
/**
Expand Down Expand Up @@ -527,13 +530,13 @@ SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

// #pragma once // We remove #pragma once here as it generates a warning in some cases. We rely on the include guard.
#pragma once

#ifndef NONSTD_SV_LITE_H_INCLUDED
#define NONSTD_SV_LITE_H_INCLUDED

#define string_view_lite_MAJOR 1
#define string_view_lite_MINOR 7
#define string_view_lite_MINOR 8
#define string_view_lite_PATCH 0

#define string_view_lite_VERSION nssv_STRINGIFY(string_view_lite_MAJOR) "." nssv_STRINGIFY(string_view_lite_MINOR) "." nssv_STRINGIFY(string_view_lite_PATCH)
Expand Down Expand Up @@ -655,6 +658,8 @@ SIMDJSON_PUSH_DISABLE_ALL_WARNINGS

#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS

#include <string>

namespace nonstd {

template< class CharT, class Traits, class Allocator = std::allocator<CharT> >
Expand Down
15 changes: 10 additions & 5 deletions 3rdparty/simdjson/simdjson.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* auto-generated on 2024-05-30 10:52:38 -0400. Do not edit! */
/* auto-generated on 2024-06-11 14:08:20 -0400. Do not edit! */
/* including simdjson.h: */
/* begin file simdjson.h */
#ifndef SIMDJSON_H
Expand Down Expand Up @@ -104,6 +104,9 @@
#include <strings.h>
#endif

// We are using size_t without namespace std:: throughout the project
using std::size_t;

#ifdef _MSC_VER
#define SIMDJSON_VISUAL_STUDIO 1
/**
Expand Down Expand Up @@ -547,13 +550,13 @@ SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

// #pragma once // We remove #pragma once here as it generates a warning in some cases. We rely on the include guard.
#pragma once

#ifndef NONSTD_SV_LITE_H_INCLUDED
#define NONSTD_SV_LITE_H_INCLUDED

#define string_view_lite_MAJOR 1
#define string_view_lite_MINOR 7
#define string_view_lite_MINOR 8
#define string_view_lite_PATCH 0

#define string_view_lite_VERSION nssv_STRINGIFY(string_view_lite_MAJOR) "." nssv_STRINGIFY(string_view_lite_MINOR) "." nssv_STRINGIFY(string_view_lite_PATCH)
Expand Down Expand Up @@ -675,6 +678,8 @@ SIMDJSON_PUSH_DISABLE_ALL_WARNINGS

#if nssv_CONFIG_CONVERSION_STD_STRING_FREE_FUNCTIONS

#include <string>

namespace nonstd {

template< class CharT, class Traits, class Allocator = std::allocator<CharT> >
Expand Down Expand Up @@ -2346,7 +2351,7 @@ namespace std {
#define SIMDJSON_SIMDJSON_VERSION_H

/** The version of simdjson being used (major.minor.revision) */
#define SIMDJSON_VERSION "3.9.3"
#define SIMDJSON_VERSION "3.9.4"

namespace simdjson {
enum {
Expand All @@ -2361,7 +2366,7 @@ enum {
/**
* The revision (major.minor.REVISION) of simdjson being used.
*/
SIMDJSON_VERSION_REVISION = 3
SIMDJSON_VERSION_REVISION = 4
};
} // namespace simdjson

Expand Down
54 changes: 22 additions & 32 deletions core/audio/AudioCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,6 @@
#include "audio/AudioDecoderManager.h"
#include "audio/AudioDecoder.h"

#define VERY_VERY_VERBOSE_LOGGING
#ifdef VERY_VERY_VERBOSE_LOGGING
# define ALOGVV ALOGV
#else
# define ALOGVV(...) \
do \
{ \
} while (false)
#endif

namespace
{
unsigned int __idIndex = 0;
Expand All @@ -69,7 +59,7 @@ AudioCache::AudioCache()
, _isLoadingFinished(false)
, _isSkipReadDataTask(false)
{
ALOGVV("AudioCache() %p, id=%u", this, _id);
AXLOGV("AudioCache() {}, id={}", fmt::ptr(this), _id);
for (int i = 0; i < QUEUEBUFFER_NUM; ++i)
{
_queBuffers[i] = nullptr;
Expand All @@ -79,16 +69,16 @@ AudioCache::AudioCache()

AudioCache::~AudioCache()
{
ALOGVV("~AudioCache() %p, id=%u, begin", this, _id);
AXLOGV("~AudioCache() {}, id={}, begin", fmt::ptr(this), _id);
*_isDestroyed = true;
while (!_isLoadingFinished)
{
if (_isSkipReadDataTask)
{
ALOGV("id=%u, Skip read data task, don't continue to wait!", _id);
AXLOGV("id={}, Skip read data task, don't continue to wait!", _id);
break;
}
ALOGVV("id=%u, waiting readData thread to finish ...", _id);
AXLOGV("id={}, waiting readData thread to finish ...", _id);
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
// wait for the 'readDataTask' task to exit
Expand All @@ -98,14 +88,14 @@ AudioCache::~AudioCache()
{
if (_alBufferId != INVALID_AL_BUFFER_ID && alIsBuffer(_alBufferId))
{
ALOGV("~AudioCache(id=%u), delete buffer: %u", _id, _alBufferId);
AXLOGV("~AudioCache(id={}), delete buffer: {}", _id, _alBufferId);
alDeleteBuffers(1, &_alBufferId);
_alBufferId = INVALID_AL_BUFFER_ID;
}
}
else
{
ALOGW("AudioCache (%p), id=%u, buffer isn't ready, state=%d", this, _id, (int)_state);
AXLOGW("AudioCache ({}), id={}, buffer isn't ready, state={}", fmt::ptr(this), _id, (int)_state);
}

if (_queBufferFrames > 0)
Expand All @@ -115,14 +105,14 @@ AudioCache::~AudioCache()
free(_queBuffers[index]);
}
}
ALOGVV("~AudioCache() %p, id=%u, end", this, _id);
AXLOGV("~AudioCache() {}, id={}, end", fmt::ptr(this), _id);
_readDataTaskMutex.unlock();
}

void AudioCache::readDataTask(unsigned int selfId)
{
// Note: It's in sub thread
ALOGVV("readDataTask begin, cache id=%u", selfId);
AXLOGV("readDataTask begin, cache id={}", selfId);

_readDataTaskMutex.lock();
_state = State::LOADING;
Expand Down Expand Up @@ -188,7 +178,7 @@ void AudioCache::readDataTask(unsigned int selfId)
auto alError = alGetError();
if (alError != AL_NO_ERROR)
{
ALOGE("%s: attaching audio to buffer fail: %x", __FUNCTION__, alError);
AXLOGE("{}: attaching audio to buffer fail: {:#x}", __FUNCTION__, alError);
break;
}

Expand Down Expand Up @@ -231,7 +221,7 @@ void AudioCache::readDataTask(unsigned int selfId)
}

#if AX_USE_ALSOFT
ALOGV("pcm buffer was loaded successfully, total frames: %u, total read frames: %u, remainingFrames: %u",
AXLOGV("pcm buffer was loaded successfully, total frames: {}, total read frames: {}, remainingFrames: {}",
totalFrames, _framesRead, remainingFrames);
if (sourceFormat == AUDIO_SOURCE_FORMAT::ADPCM || sourceFormat == AUDIO_SOURCE_FORMAT::IMA_ADPCM)
alBufferi(_alBufferId, AL_UNPACK_BLOCK_ALIGNMENT_SOFT, decoder->getSamplesPerBlock());
Expand All @@ -241,7 +231,7 @@ void AudioCache::readDataTask(unsigned int selfId)
/// Apple OpenAL framework, try adjust frames
/// May don't need, xcode11 sdk works well
uint32_t adjustFrames = 0;
BREAK_IF_ERR_LOG(!decoder->seek(totalFrames), "AudioDecoder::seek(%u) error", totalFrames);
BREAK_IF_ERR_LOG(!decoder->seek(totalFrames), "AudioDecoder::seek({}) error", totalFrames);

char* tmpBuf = (char*)malloc(decoder->framesToBytes(framesToReadOnce));
std::vector<char> adjustFrameBuf;
Expand All @@ -262,7 +252,7 @@ void AudioCache::readDataTask(unsigned int selfId)

if (adjustFrames > 0)
{
ALOGV("Orignal total frames: %u, adjust frames: %u, current total frames: %u", totalFrames,
AXLOGV("Orignal total frames: {}, adjust frames: {}, current total frames: {}", totalFrames,
adjustFrames, totalFrames + adjustFrames);
totalFrames += adjustFrames;
_totalFrames = remainingFrames = totalFrames;
Expand All @@ -280,17 +270,17 @@ void AudioCache::readDataTask(unsigned int selfId)
dataSize = static_cast<uint32_t>(pcmBuffer.size());
}
# endif /* Adjust frames, may not needed */
ALOGV(
"pcm buffer was loaded successfully, total frames: %u, total read frames: %u, adjust frames: %u, "
"remainingFrames: %u",
AXLOGV(
"pcm buffer was loaded successfully, total frames: {}, total read frames: {}, adjust frames: {}, "
"remainingFrames: {}",
totalFrames, _framesRead, adjustFrames, remainingFrames);
_framesRead += adjustFrames;
alBufferData(_alBufferId, _format, pcmData, (ALsizei)dataSize, (ALsizei)sampleRate);
#endif
alError = alGetError();
if (alError != AL_NO_ERROR)
{
ALOGE("%s:alBufferData error code:%x", __FUNCTION__, alError);
AXLOGE("{}:alBufferData error code:{:#x}", __FUNCTION__, alError);
break;
}

Expand Down Expand Up @@ -323,7 +313,7 @@ void AudioCache::readDataTask(unsigned int selfId)
_state = State::FAILED;
if (_alBufferId != INVALID_AL_BUFFER_ID && alIsBuffer(_alBufferId))
{
ALOGV("readDataTask failed, delete buffer: %u", _alBufferId);
AXLOGV("readDataTask failed, delete buffer: {}", _alBufferId);
alDeleteBuffers(1, &_alBufferId);
_alBufferId = INVALID_AL_BUFFER_ID;
}
Expand All @@ -337,7 +327,7 @@ void AudioCache::readDataTask(unsigned int selfId)
invokingLoadCallbacks();

_readDataTaskMutex.unlock();
ALOGVV("readDataTask end, cache id=%u", selfId);
AXLOGV("readDataTask end, cache id={}", selfId);
}

void AudioCache::addPlayCallback(const std::function<void()>& callback)
Expand All @@ -358,7 +348,7 @@ void AudioCache::addPlayCallback(const std::function<void()>& callback)
break;

default:
ALOGE("Invalid state: %d", (int)_state);
AXLOGE("Invalid state: {}", (int)_state);
break;
}
}
Expand Down Expand Up @@ -392,7 +382,7 @@ void AudioCache::addLoadCallback(const std::function<void(bool)>& callback)
break;

default:
ALOGE("Invalid state: %d", (int)_state);
AXLOGE("Invalid state: {}", (int)_state);
break;
}
}
Expand All @@ -401,7 +391,7 @@ void AudioCache::invokingLoadCallbacks()
{
if (*_isDestroyed)
{
ALOGV("AudioCache (%p) was destroyed, don't invoke preload callback ...", this);
AXLOGV("AudioCache ({}) was destroyed, don't invoke preload callback ...", fmt::ptr(this));
return;
}

Expand All @@ -410,7 +400,7 @@ void AudioCache::invokingLoadCallbacks()
scheduler->runOnAxmolThread([&, isDestroyed]() {
if (*isDestroyed)
{
ALOGV("invokingLoadCallbacks perform in cocos thread, AudioCache (%p) was destroyed!", this);
AXLOGV("invokingLoadCallbacks perform in cocos thread, AudioCache ({}) was destroyed!", fmt::ptr(this));
return;
}

Expand Down
16 changes: 8 additions & 8 deletions core/audio/AudioDecoderMp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ bool AudioDecoderMp3::lazyInit()
}
else
{
ALOGE("Basic setup goes wrong: %s", mpg123_plain_strerror(error));
AXLOGE("Basic setup goes wrong: {}", mpg123_plain_strerror(error));
ret = false;
}
}
Expand Down Expand Up @@ -133,7 +133,7 @@ bool AudioDecoderMp3::open(std::string_view fullPath)
_fileStream = FileUtils::getInstance()->openFileStream(fullPath, IFileStream::Mode::READ);
if (!_fileStream)
{
ALOGE("Trouble with minimp3(1): %s\n", strerror(errno));
AXLOGE("Trouble with minimp3(1): {}\n", strerror(errno));
break;
}

Expand Down Expand Up @@ -180,13 +180,13 @@ bool AudioDecoderMp3::open(std::string_view fullPath)
_handle = mpg123_new(nullptr, &error);
if (nullptr == _handle)
{
ALOGE("Basic setup goes wrong: %s", mpg123_plain_strerror(error));
AXLOGE("Basic setup goes wrong: {}", mpg123_plain_strerror(error));
break;
}

if (!_fileStream.open(fullPath))
{
ALOGE("Trouble with mpg123(1): %s\n", strerror(errno));
AXLOGE("Trouble with mpg123(1): {}\n", strerror(errno));
break;
}

Expand All @@ -195,7 +195,7 @@ bool AudioDecoderMp3::open(std::string_view fullPath)
if (mpg123_open_handle(_handle, _fileStream) != MPG123_OK ||
mpg123_getformat(_handle, &rate, &channel, &mp3Encoding) != MPG123_OK)
{
ALOGE("Trouble with mpg123(2): %s\n", mpg123_strerror(_handle));
AXLOGE("Trouble with mpg123(2): {}\n", mpg123_strerror(_handle));
break;
}

Expand All @@ -214,7 +214,7 @@ bool AudioDecoderMp3::open(std::string_view fullPath)
}
else
{
ALOGE("Bad encoding: 0x%x!\n", mp3Encoding);
AXLOGE("Bad encoding: {0:#x}!\n", mp3Encoding);
break;
}

Expand Down Expand Up @@ -279,7 +279,7 @@ uint32_t AudioDecoderMp3::read(uint32_t framesToRead, char* pcmBuf)
int err = mpg123_read(_handle, (unsigned char*)pcmBuf, bytesToRead, &bytesRead);
if (err == MPG123_ERR)
{
ALOGE("Trouble with mpg123: %s\n", mpg123_strerror(_handle));
AXLOGE("Trouble with mpg123: {}\n", mpg123_strerror(_handle));
return 0;
}

Expand All @@ -293,7 +293,7 @@ bool AudioDecoderMp3::seek(uint32_t frameOffset)
return 0 == mp3dec_ex_seek(&_handle->_dec, frameOffset);
#else
off_t offset = mpg123_seek(_handle, frameOffset, SEEK_SET);
// ALOGD("mpg123_seek return: %d", (int)offset);
// AXLOGD("mpg123_seek return: {}", (int)offset);
return (offset >= 0 && offset == frameOffset);
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion core/audio/AudioDecoderOgg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool AudioDecoderOgg::open(std::string_view fullPath)
auto fs = FileUtils::getInstance()->openFileStream(fullPath, IFileStream::Mode::READ).release();
if (!fs)
{
ALOGE("Trouble with ogg(1): %s\n", strerror(errno));
AXLOGE("Trouble with ogg(1): {}\n", strerror(errno));
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion core/audio/AudioDecoderWav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static bool wav_open(std::string_view fullPath, WAV_FILE* wavf)
}
break;
default:
ALOGW("The wav format %d doesn't supported currently!", (int)fmtInfo.AudioFormat);
AXLOGW("The wav format {} doesn't supported currently!", (int)fmtInfo.AudioFormat);
fileStream.reset();
assert(false);
return false;
Expand Down
Loading

0 comments on commit d10b8ee

Please sign in to comment.