I am doing an android project and I need to integrate Spotify streaming features. Now I can load dynamic libraries and call functions, but there are some problems.
callbacks.notify_main_thread = callback_notify_main_thread; config.callbacks = &callbacks; error = sp_session_create(&config, &session);
Then in the notify_main_thread callback function it will be:
vm->AttachCurrentThread( &env, NULL ); vm->DetachCurrentThread();
This callback function is still in the native thread created by Spotify with code (see the question "According to the documentation, some callbacks are called from the" internal "session thread. What does this mean?").
So, first I attach the current thread to javaVM and get JNIEnv, then call the java methods and then disconnect it. But when running DetachCurrentThread it will work:
10-23 14:55:21.869: E/dalvikvm(1000): ERROR: detaching thread with interp frames (count=28) 10-23 14:55:21.869: I/dalvikvm(1000): "main" prio=5 tid=1 RUNNABLE 10-23 14:55:21.869: I/dalvikvm(1000): | group="main" sCount=0 dsCount=0 s=N obj=0x40025ad8 self=0xcd80 10-23 14:55:21.869: I/dalvikvm(1000): | sysTid=1000 nice=0 sched=0/0 cgrp=default handle=-1345017808 10-23 14:55:21.869: I/dalvikvm(1000): | schedstat=( 523773188 356262213 1690 ) 10-23 14:55:21.869: I/dalvikvm(1000): at com.Spotify.Session.Initialise(Native Method) ... 10-23 14:55:21.869: E/dalvikvm(1000): VM aborting 10-23 14:55:21.899: D/RegisterService(519): insert plugin size 1 10-23 14:55:21.958: D/RegisterService(519): insert plugin size 1 10-23 14:55:21.979: I/DEBUG(64): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 10-23 14:55:21.979: I/DEBUG(64): Build fingerprint: 'htc_wwe/htc_bravo/bravo/bravo:2.2.2/FRG83G/345208.14:user/release-keys' 10-23 14:55:21.979: I/DEBUG(64): pid: 1000, tid: 1000 >>> <<< 10-23 14:55:21.979: I/DEBUG(64): signal 11 (SIGSEGV), fault addr deadd00d 10-23 14:55:21.979: I/DEBUG(64): r0 00000026 r1 afd14699 r2 afd14699 r3 00000000 10-23 14:55:21.979: I/DEBUG(64): r4 808a3448 r5 808a3448 r6 fffe9544 r7 fffe2054 10-23 14:55:21.979: I/DEBUG(64): r8 80b09f04 r9 00000001 10 002f0980 fp 002f0980 10-23 14:55:21.979: I/DEBUG(64): ip deadd00d sp beffb088 lr afd156e3 pc 80842560 cpsr 20000030 10-23 14:55:21.979: I/DEBUG(64): d0 6472656767756265 d1 617453657669746e 10-23 14:55:21.979: I/DEBUG(64): d2 4965746f67795a67 d3 6874654d2474690a 10-23 14:55:21.979: I/DEBUG(64): d4 80a0a16580a0a179 d5 80a0a14580a0a155 10-23 14:55:21.979: I/DEBUG(64): d6 80a0a12180a0a135 d7 0000000000000000 10-23 14:55:21.979: I/DEBUG(64): d8 40b0000040a00000 d9 0000000000000005 10-23 14:55:21.979: I/DEBUG(64): d10 0000000000000000 d11 0000000000000000 10-23 14:55:21.979: I/DEBUG(64): d12 0000000000000000 d13 0000000000000000 10-23 14:55:21.979: I/DEBUG(64): d14 0000000000000000 d15 0000000000000000 10-23 14:55:21.979: I/DEBUG(64): d16 001512f000000025 d17 bff0000000000000 10-23 14:55:21.979: I/DEBUG(64): d18 3ff0000000000000 d19 0000000000000000 10-23 14:55:21.979: I/DEBUG(64): d20 0000000000000000 d21 0000000000000000 10-23 14:55:21.979: I/DEBUG(64): d22 3ff0000000000000 d23 0000000000000000 10-23 14:55:21.979: I/DEBUG(64): d24 3ff0000000000000 d25 0000000000000000 10-23 14:55:21.979: I/DEBUG(64): d26 0000000000000000 d27 0000000000000000 10-23 14:55:21.979: I/DEBUG(64): d28 001f001f001f001e d29 001e001f001f001f 10-23 14:55:21.979: I/DEBUG(64): d30 001f001f001f001f d31 001f001f001f001f 10-23 14:55:21.979: I/DEBUG(64): scr 60000012 10-23 14:55:21.999: I/DEBUG(64):
and if
then sp_session_create () is called, it will never return an error code.
Literature:
source share