mirror of
				https://github.com/android/ndk-samples
				synced 2025-11-04 14:27:06 +08:00 
			
		
		
		
	Compare commits
	
		
			3 Commits
		
	
	
		
			ba7d3c1c66
			...
			1bfbb64c01
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					1bfbb64c01 | ||
| 
						 | 
					38c889d999 | ||
| 
						 | 
					2d36bf2ee3 | 
@@ -1,15 +1,15 @@
 | 
				
			|||||||
cmake_minimum_required(VERSION 3.22.1)
 | 
					cmake_minimum_required(VERSION 3.22.1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -UNDEBUG")
 | 
					include(AppLibrary)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_library(native-codec-jni SHARED
 | 
					add_app_library(native-codec-jni SHARED
 | 
				
			||||||
            looper.cpp
 | 
					    looper.cpp
 | 
				
			||||||
            native-codec-jni.cpp)
 | 
					    native-codec-jni.cpp
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Include libraries needed for native-codec-jni lib
 | 
					 | 
				
			||||||
target_link_libraries(native-codec-jni
 | 
					target_link_libraries(native-codec-jni
 | 
				
			||||||
                      android
 | 
					    android
 | 
				
			||||||
                      log
 | 
					    log
 | 
				
			||||||
                      mediandk
 | 
					    mediandk
 | 
				
			||||||
                      OpenMAXAL)
 | 
					    OpenMAXAL
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -199,7 +199,7 @@ void mylooper::handle(int what, void* obj) {
 | 
				
			|||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
jboolean Java_com_example_nativecodec_NativeCodec_createStreamingMediaPlayer(
 | 
					jboolean Java_com_example_nativecodec_NativeCodec_createStreamingMediaPlayer(
 | 
				
			||||||
    JNIEnv* env, jclass clazz, jobject assetMgr, jstring filename) {
 | 
					    JNIEnv* env, jclass, jobject assetMgr, jstring filename) {
 | 
				
			||||||
  LOGV("@@@ create");
 | 
					  LOGV("@@@ create");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // convert Java string to UTF-8
 | 
					  // convert Java string to UTF-8
 | 
				
			||||||
@@ -269,7 +269,7 @@ jboolean Java_com_example_nativecodec_NativeCodec_createStreamingMediaPlayer(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// set the playing state for the streaming media player
 | 
					// set the playing state for the streaming media player
 | 
				
			||||||
void Java_com_example_nativecodec_NativeCodec_setPlayingStreamingMediaPlayer(
 | 
					void Java_com_example_nativecodec_NativeCodec_setPlayingStreamingMediaPlayer(
 | 
				
			||||||
    JNIEnv* env, jclass clazz, jboolean isPlaying) {
 | 
					    JNIEnv*, jclass, jboolean isPlaying) {
 | 
				
			||||||
  LOGV("@@@ playpause: %d", isPlaying);
 | 
					  LOGV("@@@ playpause: %d", isPlaying);
 | 
				
			||||||
  if (mlooper) {
 | 
					  if (mlooper) {
 | 
				
			||||||
    if (isPlaying) {
 | 
					    if (isPlaying) {
 | 
				
			||||||
@@ -281,8 +281,7 @@ void Java_com_example_nativecodec_NativeCodec_setPlayingStreamingMediaPlayer(
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// shut down the native media system
 | 
					// shut down the native media system
 | 
				
			||||||
void Java_com_example_nativecodec_NativeCodec_shutdown(JNIEnv* env,
 | 
					void Java_com_example_nativecodec_NativeCodec_shutdown(JNIEnv*, jclass) {
 | 
				
			||||||
                                                       jclass clazz) {
 | 
					 | 
				
			||||||
  LOGV("@@@ shutdown");
 | 
					  LOGV("@@@ shutdown");
 | 
				
			||||||
  if (mlooper) {
 | 
					  if (mlooper) {
 | 
				
			||||||
    mlooper->post(kMsgDecodeDone, &data, true /* flush */);
 | 
					    mlooper->post(kMsgDecodeDone, &data, true /* flush */);
 | 
				
			||||||
@@ -297,8 +296,7 @@ void Java_com_example_nativecodec_NativeCodec_shutdown(JNIEnv* env,
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// set the surface
 | 
					// set the surface
 | 
				
			||||||
void Java_com_example_nativecodec_NativeCodec_setSurface(JNIEnv* env,
 | 
					void Java_com_example_nativecodec_NativeCodec_setSurface(JNIEnv* env, jclass,
 | 
				
			||||||
                                                         jclass clazz,
 | 
					 | 
				
			||||||
                                                         jobject surface) {
 | 
					                                                         jobject surface) {
 | 
				
			||||||
  // obtain a native window from a Java surface
 | 
					  // obtain a native window from a Java surface
 | 
				
			||||||
  if (data.window) {
 | 
					  if (data.window) {
 | 
				
			||||||
@@ -311,7 +309,7 @@ void Java_com_example_nativecodec_NativeCodec_setSurface(JNIEnv* env,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// rewind the streaming media player
 | 
					// rewind the streaming media player
 | 
				
			||||||
void Java_com_example_nativecodec_NativeCodec_rewindStreamingMediaPlayer(
 | 
					void Java_com_example_nativecodec_NativeCodec_rewindStreamingMediaPlayer(
 | 
				
			||||||
    JNIEnv* env, jclass clazz) {
 | 
					    JNIEnv*, jclass) {
 | 
				
			||||||
  LOGV("@@@ rewind");
 | 
					  LOGV("@@@ rewind");
 | 
				
			||||||
  if (mlooper) {
 | 
					  if (mlooper) {
 | 
				
			||||||
    mlooper->post(kMsgSeek, &data);
 | 
					    mlooper->post(kMsgSeek, &data);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,10 +1,10 @@
 | 
				
			|||||||
cmake_minimum_required(VERSION 3.22.1)
 | 
					cmake_minimum_required(VERSION 3.22.1)
 | 
				
			||||||
project(native_midi LANGUAGES C CXX)
 | 
					project(native_midi LANGUAGES CXX)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -O0")
 | 
					include(AppLibrary)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_library(${PROJECT_NAME}
 | 
					add_app_library(${PROJECT_NAME}
 | 
				
			||||||
  SHARED
 | 
					    SHARED
 | 
				
			||||||
    AppMidiManager.cpp
 | 
					    AppMidiManager.cpp
 | 
				
			||||||
    MainActivity.cpp
 | 
					    MainActivity.cpp
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user