mirror of
https://github.com/android/ndk-samples
synced 2025-11-06 23:55:35 +08:00
clang-format the world.
This used to be done by CI but we ripped that out since there wasn't any good way to ensure that CI and and local workflows were using the same clang-format. Back when it was in CI, the pointer alignment was configured incorrectly (we used the Google style presets, but those are alignment preserving rather than actually style enforcing). Reformat everything since the .clang-format file has changed since then so I stop including so many unrelated edits in my commits.
This commit is contained in:
@@ -35,7 +35,8 @@
|
||||
#define LOG_TAG "native-activity"
|
||||
|
||||
#define _LOG(priority, fmt, ...) \
|
||||
((void)__android_log_print((priority), (LOG_TAG), (fmt)__VA_OPT__(, ) __VA_ARGS__))
|
||||
((void)__android_log_print((priority), (LOG_TAG), \
|
||||
(fmt)__VA_OPT__(, ) __VA_ARGS__))
|
||||
|
||||
#define LOGE(fmt, ...) _LOG(ANDROID_LOG_ERROR, (fmt)__VA_OPT__(, ) __VA_ARGS__)
|
||||
#define LOGW(fmt, ...) _LOG(ANDROID_LOG_WARN, (fmt)__VA_OPT__(, ) __VA_ARGS__)
|
||||
@@ -305,8 +306,7 @@ static void engine_term_display(Engine* engine) {
|
||||
/**
|
||||
* Process the next input event.
|
||||
*/
|
||||
static int32_t engine_handle_input(android_app* app,
|
||||
AInputEvent* event) {
|
||||
static int32_t engine_handle_input(android_app* app, AInputEvent* event) {
|
||||
auto* engine = (Engine*)app->userData;
|
||||
if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) {
|
||||
engine->state.x = AMotionEvent_getX(event, 0);
|
||||
|
||||
@@ -192,9 +192,9 @@ static XAresult AndroidBufferQueueCallback(
|
||||
// EOS message has no parameters, so the total size of the message is the
|
||||
// size of the key
|
||||
// plus the size if itemSize, both XAuint32
|
||||
res = (*caller)->Enqueue(
|
||||
caller, (void *)&kEosBufferCntxt /*pBufferContext*/, NULL /*pData*/,
|
||||
0 /*dataLength*/, msgEos /*pMsg*/, sizeof(XAuint32) * 2 /*msgLength*/);
|
||||
res = (*caller)->Enqueue(caller, (void*)&kEosBufferCntxt /*pBufferContext*/,
|
||||
NULL /*pData*/, 0 /*dataLength*/, msgEos /*pMsg*/,
|
||||
sizeof(XAuint32) * 2 /*msgLength*/);
|
||||
assert(XA_RESULT_SUCCESS == res);
|
||||
reachedEof = JNI_TRUE;
|
||||
}
|
||||
|
||||
@@ -207,7 +207,8 @@ void Java_com_example_nativemidi_AppMidiManager_startWritingMidi(
|
||||
void Java_com_example_nativemidi_AppMidiManager_stopWritingMidi(JNIEnv*,
|
||||
jobject) {
|
||||
if (sMidiInputPort != nullptr) {
|
||||
AMidiInputPort_close(sMidiInputPort); //Close InputPort to make switching MidiDevices work!
|
||||
AMidiInputPort_close(
|
||||
sMidiInputPort); // Close InputPort to make switching MidiDevices work!
|
||||
sMidiInputPort = nullptr;
|
||||
}
|
||||
/*media_status_t status =*/AMidiDevice_release(sNativeSendDevice);
|
||||
|
||||
@@ -522,9 +522,9 @@ bool SimpleModel::Compute(float inputValue1, float inputValue2, float *result) {
|
||||
|
||||
// Validate the results.
|
||||
const float goldenRef = (inputValue1 + 0.5f) * (inputValue2 + 0.5f);
|
||||
float *outputTensorPtr = reinterpret_cast<float *>(
|
||||
mmap(nullptr, tensorSize_ * sizeof(float), PROT_READ, MAP_SHARED,
|
||||
outputTensorFd_, 0));
|
||||
float* outputTensorPtr =
|
||||
reinterpret_cast<float*>(mmap(nullptr, tensorSize_ * sizeof(float),
|
||||
PROT_READ, MAP_SHARED, outputTensorFd_, 0));
|
||||
for (int32_t idx = 0; idx < tensorSize_; idx++) {
|
||||
float delta = outputTensorPtr[idx] - goldenRef;
|
||||
delta = (delta < 0.0f) ? (-delta) : delta;
|
||||
|
||||
@@ -593,8 +593,8 @@ void android_main(android_app* state) {
|
||||
// If animating, we loop until all events are read, then continue
|
||||
// to draw the next frame of animation.
|
||||
android_poll_source* source = nullptr;
|
||||
auto result = ALooper_pollOnce(g_engine.IsReady() ? 0 : -1, nullptr, nullptr,
|
||||
(void**)&source);
|
||||
auto result = ALooper_pollOnce(g_engine.IsReady() ? 0 : -1, nullptr,
|
||||
nullptr, (void**)&source);
|
||||
if (result == ALOOPER_POLL_ERROR) {
|
||||
LOGE("ALooper_pollOnce returned an error");
|
||||
abort();
|
||||
|
||||
@@ -409,8 +409,8 @@ void android_main(android_app* state) {
|
||||
// If animating, we loop until all events are read, then continue
|
||||
// to draw the next frame of animation.
|
||||
android_poll_source* source = nullptr;
|
||||
auto result = ALooper_pollOnce(g_engine.IsReady() ? 0 : -1, nullptr, nullptr,
|
||||
(void**)&source);
|
||||
auto result = ALooper_pollOnce(g_engine.IsReady() ? 0 : -1, nullptr,
|
||||
nullptr, (void**)&source);
|
||||
if (result == ALOOPER_POLL_ERROR) {
|
||||
LOGE("ALooper_pollOnce returned an error");
|
||||
std::abort();
|
||||
|
||||
@@ -409,8 +409,8 @@ void android_main(android_app* state) {
|
||||
// If animating, we loop until all events are read, then continue
|
||||
// to draw the next frame of animation.
|
||||
android_poll_source* source = nullptr;
|
||||
auto result = ALooper_pollOnce(g_engine.IsReady() ? 0 : -1, nullptr, nullptr,
|
||||
(void**)&source);
|
||||
auto result = ALooper_pollOnce(g_engine.IsReady() ? 0 : -1, nullptr,
|
||||
nullptr, (void**)&source);
|
||||
|
||||
if (result == ALOOPER_POLL_ERROR) {
|
||||
LOGE("ALooper_pollOnce returned an error");
|
||||
|
||||
@@ -421,8 +421,8 @@ void android_main(android_app* state) {
|
||||
// If animating, we loop until all events are read, then continue
|
||||
// to draw the next frame of animation.
|
||||
android_poll_source* source = nullptr;
|
||||
auto result = ALooper_pollOnce(g_engine.IsReady() ? 0 : -1, nullptr, nullptr,
|
||||
(void**)&source);
|
||||
auto result = ALooper_pollOnce(g_engine.IsReady() ? 0 : -1, nullptr,
|
||||
nullptr, (void**)&source);
|
||||
if (result == ALOOPER_POLL_ERROR) {
|
||||
LOGE("ALooper_pollOnce returned an error");
|
||||
std::abort();
|
||||
|
||||
@@ -409,8 +409,8 @@ void android_main(android_app* state) {
|
||||
// If animating, we loop until all events are read, then continue
|
||||
// to draw the next frame of animation.
|
||||
android_poll_source* source = nullptr;
|
||||
auto result = ALooper_pollOnce(g_engine.IsReady() ? 0 : -1, nullptr, nullptr,
|
||||
(void**)&source);
|
||||
auto result = ALooper_pollOnce(g_engine.IsReady() ? 0 : -1, nullptr,
|
||||
nullptr, (void**)&source);
|
||||
if (result == ALOOPER_POLL_ERROR) {
|
||||
LOGE("ALooper_pollOnce returned an error");
|
||||
std::abort();
|
||||
|
||||
@@ -54,8 +54,8 @@ Texture::Texture(std::vector<std::string>& asset_paths,
|
||||
fileBits.clear();
|
||||
AssetReadFile(asset_manager, asset_paths[i], fileBits);
|
||||
|
||||
// tga/bmp asset_paths are saved as vertical mirror images ( at least more than
|
||||
// half ).
|
||||
// tga/bmp asset_paths are saved as vertical mirror images ( at least more
|
||||
// than half ).
|
||||
stbi_set_flip_vertically_on_load(1);
|
||||
|
||||
uint8_t* imageBits =
|
||||
|
||||
Reference in New Issue
Block a user