Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch Android build to using clang (needs buildbot update) #8651

Merged
merged 7 commits into from
Jul 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions .travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,20 @@

export USE_CCACHE=1
export NDK_CCACHE=ccache
NDK_VER=android-ndk-r10d
NDK_VER=android-ndk-r12b

download_extract() {
aria2c -x 16 $1 -o $2
tar -xf $2
}

# This is used for the Android NDK.
download_extract_xz() {
download_extract_zip() {
aria2c --file-allocation=none --timeout=120 --retry-wait=5 --max-tries=20 -Z -c $1 -o $2
stat -c 'ATTEMPT 1 - %s' $2
md5sum $2
# This resumes the download, in case it failed.
aria2c --file-allocation=none --timeout=120 --retry-wait=5 --max-tries=20 -Z -c $1 -o $2
stat -c 'ATTEMPT 2 - %s' $2
md5sum $2

# Keep some output going during the extract, so the build doesn't timeout.
pv $2 | xz -vd | tar -x
unzip $2 2>&1 | pv > /dev/null
}

travis_before_install() {
Expand Down Expand Up @@ -73,7 +68,7 @@ travis_install() {
if [ "$PPSSPP_BUILD_TYPE" = "Android" ]; then
free -m
sudo apt-get install ant -qq
download_extract_xz http://hdkr.co/${NDK_VER}-x86_64.tar.xz ${NDK_VER}-x86_64.tar.xz
download_extract_zip http://dl.google.com/android/repository/${NDK_VER}-linux-x86_64.zip ${NDK_VER}-linux-x86_64.zip
fi

# Blackberry NDK: 10.3.0.440 + GCC: 4.8.2
Expand Down
1 change: 1 addition & 0 deletions Common/GL/GLInterface/EGLAndroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <android/native_window.h>
#include "Common/Log.h"
#include "Common/GL/GLInterface/EGLAndroid.h"

Expand Down
12 changes: 12 additions & 0 deletions Core/HLE/sceAtrac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,13 @@ struct Atrac {
avcodec_close(codecCtx_);
av_freep(&codecCtx_);
#endif
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_packet_free(&packet_);
#else
av_free_packet(packet_);
delete packet_;
packet_ = nullptr;
#endif
}
#endif // USE_FFMPEG

Expand Down Expand Up @@ -552,7 +556,11 @@ struct Atrac {

int got_frame = 0;
int bytes_read = avcodec_decode_audio4(codecCtx_, frame_, &got_frame, packet_);
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_packet_unref(packet_);
#else
av_free_packet(packet_);
#endif
if (bytes_read == AVERROR_PATCHWELCOME) {
ERROR_LOG(ME, "Unsupported feature in ATRAC audio.");
// Let's try the next packet.
Expand Down Expand Up @@ -1836,10 +1844,14 @@ int __AtracSetContext(Atrac *atrac) {

// alloc audio frame
atrac->frame_ = av_frame_alloc();
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
atrac->packet_ = av_packet_alloc();
#else
atrac->packet_ = new AVPacket;
av_init_packet(atrac->packet_);
atrac->packet_->data = nullptr;
atrac->packet_->size = 0;
#endif
// reinit decodePos, because ffmpeg had changed it.
atrac->decodePos_ = 0;
#endif
Expand Down
14 changes: 14 additions & 0 deletions Core/HLE/sceMpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ static bool pmp_oldStateLoaded = false; // for dostate

extern "C" {
#include "libavformat/avformat.h"
#include "libavutil/imgutils.h"
#include "libswscale/swscale.h"
}
static AVPixelFormat pmp_want_pix_fmt;
Expand Down Expand Up @@ -801,7 +802,11 @@ static bool InitPmp(MpegContext * ctx){
}

// get RGBA picture buffer
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
mediaengine->m_bufSize = av_image_get_buffer_size(pmp_want_pix_fmt, pmp_CodecCtx->width, pmp_CodecCtx->height, 1);
#else
mediaengine->m_bufSize = avpicture_get_size(pmp_want_pix_fmt, pmp_CodecCtx->width, pmp_CodecCtx->height);
#endif
mediaengine->m_buffer = (u8*)av_malloc(mediaengine->m_bufSize);

return true;
Expand Down Expand Up @@ -947,7 +952,12 @@ static bool decodePmpVideo(PSPPointer<SceMpegRingBuffer> ringbuffer, u32 pmpctxA
av_frame_unref(pFrameRGB);

// hook pFrameRGB output to buffer
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_image_fill_arrays(pFrameRGB->data, pFrameRGB->linesize, mediaengine->m_buffer, pmp_want_pix_fmt, pCodecCtx->width, pCodecCtx->height, 1);
#else
avpicture_fill((AVPicture *)pFrameRGB, mediaengine->m_buffer, pmp_want_pix_fmt, pCodecCtx->width, pCodecCtx->height);
#endif


// decode video frame
int len = avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, &packet);
Expand Down Expand Up @@ -992,7 +1002,11 @@ static bool decodePmpVideo(PSPPointer<SceMpegRingBuffer> ringbuffer, u32 pmpctxA
// SaveFrame(pNewFrameRGB, pCodecCtx->width, pCodecCtx->height);
}
// free some pointers
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_packet_unref(&packet);
#else
av_free_packet(&packet);
#endif
pmpframes->~H264Frames();
// must reset pmp_VideoSource address to zero after decoding.
pmp_videoSource = 0;
Expand Down
18 changes: 18 additions & 0 deletions Core/HW/MediaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ extern "C" {

#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
#include "libavutil/imgutils.h"
#include "libswscale/swscale.h"

}
Expand Down Expand Up @@ -449,11 +450,19 @@ bool MediaEngine::setVideoDim(int width, int height)

// Allocate video frame for RGB24
m_pFrameRGB = av_frame_alloc();
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
int numBytes = av_image_get_buffer_size((AVPixelFormat)m_sws_fmt, m_desWidth, m_desHeight, 1);
#else
int numBytes = avpicture_get_size((AVPixelFormat)m_sws_fmt, m_desWidth, m_desHeight);
#endif
m_buffer = (u8*)av_malloc(numBytes * sizeof(uint8_t));

// Assign appropriate parts of buffer to image planes in m_pFrameRGB
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_image_fill_arrays(m_pFrameRGB->data, m_pFrameRGB->linesize, m_buffer, (AVPixelFormat)m_sws_fmt, m_desWidth, m_desHeight, 1);
#else
avpicture_fill((AVPicture *)m_pFrameRGB, m_buffer, (AVPixelFormat)m_sws_fmt, m_desWidth, m_desHeight);
#endif
#endif // USE_FFMPEG
return true;
}
Expand Down Expand Up @@ -522,8 +531,13 @@ bool MediaEngine::stepVideo(int videoPixelMode, bool skipFrame) {
// Still need to decode those, so keep calling avcodec_decode_video2().
if (dataEnd || packet.stream_index == m_videoStream) {
// avcodec_decode_video2() gives us the re-ordered frames with a NULL packet.
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
if (dataEnd)
av_packet_unref(&packet);
#else
if (dataEnd)
av_free_packet(&packet);
#endif

int result = avcodec_decode_video2(m_pCodecCtx, m_pFrame, &frameFinished, &packet);
if (frameFinished) {
Expand All @@ -547,7 +561,11 @@ bool MediaEngine::stepVideo(int videoPixelMode, bool skipFrame) {
break;
}
}
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_packet_unref(&packet);
#else
av_free_packet(&packet);
#endif
}
return bGetFrame;
#else
Expand Down
8 changes: 6 additions & 2 deletions Core/HW/SimpleAudioDec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,16 @@ bool SimpleAudio::Decode(void *inbuf, int inbytes, uint8_t *outbuf, int *outbyte
*outbytes = 0;
srcPos = 0;
int len = avcodec_decode_audio4(codecCtx_, frame_, &got_frame, &packet);
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100)
av_packet_unref(&packet);
#else
av_free_packet(&packet);
#endif

if (len < 0) {
ERROR_LOG(ME, "Error decoding Audio frame (%i bytes): %i (%08x)", inbytes, len, len);
// TODO: cleanup
return false;
}
av_free_packet(&packet);

// get bytes consumed in source
srcPos = len;
Expand Down
2 changes: 1 addition & 1 deletion android/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ APP_STL := gnustl_static
APP_PLATFORM := android-9
APP_ABI := arm64-v8a armeabi-v7a x86 x86_64
APP_GNUSTL_CPP_FEATURES :=
NDK_TOOLCHAIN_VERSION := 4.9
NDK_TOOLCHAIN_VERSION := clang
15 changes: 11 additions & 4 deletions android/jni/Locals.mk
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# These are definitions for LOCAL_ variables for PPSSPP.
# They are shared between ppsspp_jni (lib for Android app) and ppsspp_headless.

LOCAL_CFLAGS := -DUSE_FFMPEG -DUSING_GLES2 -DMOBILE_DEVICE -O3 -fsigned-char -Wall -Wno-multichar -Wno-psabi -Wno-unused-variable -fno-strict-aliasing -D__STDC_CONSTANT_MACROS -Wno-format
LOCAL_CFLAGS := -DUSE_FFMPEG -DUSING_GLES2 -DMOBILE_DEVICE -O3 -fsigned-char -Wall -Wno-multichar -Wno-unused-variable -fno-strict-aliasing -D__STDC_CONSTANT_MACROS -Wno-format
# yes, it's really CPPFLAGS for C++
# literal-suffix is generated by Android default code and causes noise.
LOCAL_CPPFLAGS := -fno-exceptions -std=gnu++11 -fno-rtti -Wno-reorder -Wno-literal-suffix -Wno-format
# deprecated-register is generated by Android default code and causes noise.
LOCAL_CPPFLAGS := -fno-exceptions -std=gnu++11 -fno-rtti -Wno-reorder -Wno-format -Wno-deprecated-register
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../../Common \
$(LOCAL_PATH)/../.. \
Expand All @@ -16,7 +16,14 @@ LOCAL_C_INCLUDES := \
$(LOCAL_PATH)

LOCAL_STATIC_LIBRARIES := native libzip glslang
LOCAL_LDLIBS := -lz -landroid -lGLESv2 -lOpenSLES -lEGL -ldl -llog
LOCAL_LDLIBS := -lz -landroid -lGLESv2 -lOpenSLES -lEGL -ldl -llog -latomic
ifneq ($(NDK_DEBUG),1)
# Prettier stack traces are nice on other platforms.
# Maybe we can switch to storing the pre-stripped builds at some point.
ifeq ($(TARGET_ARCH_ABI),x86_64)
LOCAL_LDFLAGS += -Wl,--gc-sections -Wl,--exclude-libs,ALL
endif
endif

# ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
ifeq ($(findstring armeabi-v7a,$(TARGET_ARCH_ABI)),armeabi-v7a)
Expand Down
2 changes: 2 additions & 0 deletions ext/native/gfx/gl_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ typedef void (EGLAPIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (
#endif
extern PFNGLBLITFRAMEBUFFERNVPROC glBlitFramebufferNV;

#ifdef IOS
extern PFNGLDISCARDFRAMEBUFFEREXTPROC glDiscardFramebufferEXT;
extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOES;
extern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOES;
Expand All @@ -70,6 +71,7 @@ extern PFNGLISVERTEXARRAYOESPROC glIsVertexArrayOES;
#define glBindVertexArray glBindVertexArrayOES
#define glDeleteVertexArrays glDeleteVertexArraysOES
#define glIsVertexArray glIsVertexArrayOES
#endif

#endif

Expand Down
2 changes: 1 addition & 1 deletion ffmpeg
Submodule ffmpeg updated 2846 files