ofSoundPlayer

Is there a way to play an audio file on Android in a similar way to how one does it with ofSoundPlayer?

A while back there used to be a ofxAndroidSoundPlayer in github, but now its gone. :?

have you tried ofSoundPlayer? It should work

I have and the app compiles fine, but when installing it on the device, I get this message:

  
05-02 13:08:19.010: I/OF(9019): java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1290]:   113 cannot locate '_ZN13ofSoundPlayer7setLoopEb'...  
  

I am working on github’s master branch.

try with develop, it’s now updated to be compatible with ndk r7 and this should work without problem

Got sidetracked by another project. I’ve come back to this now.

I am now on github develop. Compiled against ndk r7 and sdk-r18-linux.

If I run androidSoundPlayerExample on the device it runs normally but the moment I tap on the screen the app crashes. Device is an HTC Sensation running Android 4.0.3

Is my ndk / sdk combination ok? It loads the files correctly from the SDcard and it seems to fail when calling play() on the sample.

Here’s the logcat:

  
  
05-24 03:16:26.205: D/MP-Decision(289): DOWN Ns:2.100000 Ts:270 rq:0.300000 seq:317 (Up time:1328)  
05-24 03:16:49.968: W/dalvikvm(5213): JNI WARNING: 0x40da3f70 is not a valid JNI reference  
05-24 03:16:49.968: W/dalvikvm(5213):              in Lcc/openframeworks/OFAndroid;.onTouchDown:(IFFF)V (CallVoidMethodV)  
05-24 03:16:49.968: I/dalvikvm(5213): "main" prio=5 tid=1 RUNNABLE  
05-24 03:16:49.968: I/dalvikvm(5213):   | group="main" sCount=0 dsCount=0 obj=0x40ab9490 self=0x1d0c9d0  
05-24 03:16:49.968: I/dalvikvm(5213):   | sysTid=5213 nice=0 sched=0/0 cgrp=default handle=1074595016  
05-24 03:16:49.968: I/dalvikvm(5213):   | schedstat=( 0 0 0 ) utm=10 stm=11 core=0  
05-24 03:16:49.968: I/dalvikvm(5213):   at cc.openframeworks.OFAndroid.onTouchDown(Native Method)  
05-24 03:16:49.968: I/dalvikvm(5213):   at cc.openframeworks.OFGestureListener$1.onTouch(OFAndroid.java:595)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.View.dispatchTouchEvent(View.java:5574)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1965)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1692)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1965)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1692)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1965)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1692)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1965)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1692)  
05-24 03:16:49.968: I/dalvikvm(5213):   at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1983)  
05-24 03:16:49.968: I/dalvikvm(5213):   at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1442)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.app.Activity.dispatchTouchEvent(Activity.java:2414)  
05-24 03:16:49.968: I/dalvikvm(5213):   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1931)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.View.dispatchPointerEvent(View.java:5759)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2963)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2522)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:862)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2531)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.os.Handler.dispatchMessage(Handler.java:99)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.os.Looper.loop(Looper.java:154)  
05-24 03:16:49.968: I/dalvikvm(5213):   at android.app.ActivityThread.main(ActivityThread.java:4944)  
05-24 03:16:49.968: I/dalvikvm(5213):   at java.lang.reflect.Method.invokeNative(Native Method)  
05-24 03:16:49.968: I/dalvikvm(5213):   at java.lang.reflect.Method.invoke(Method.java:511)  
05-24 03:16:49.968: I/dalvikvm(5213):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)  
05-24 03:16:49.968: I/dalvikvm(5213):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)  
05-24 03:16:49.968: I/dalvikvm(5213):   at dalvik.system.NativeStart.main(Native Method)  
05-24 03:16:49.968: E/dalvikvm(5213): VM aborting  
05-24 03:16:49.968: A/libc(5213): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1)  
05-24 03:16:50.479: I/DEBUG(110): debuggerd: 2012-05-24 03:16:50  
05-24 03:16:50.479: I/DEBUG(110): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***  
05-24 03:16:50.479: I/DEBUG(110): Build fingerprint: 'htc_europe/htc_pyramid/pyramid:4.0.3/IML74K/309896.5:user/release-keys'  
05-24 03:16:50.479: I/DEBUG(110): pid: 5213, tid: 5213  >>> cc.openframeworks.androidSoundPlayerExample <<<  
05-24 03:16:50.479: I/DEBUG(110): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadd00d  
05-24 03:16:50.479: I/DEBUG(110):  r0 00000000  r1 01dd1c20  r2 00000000  r3 00000000  
05-24 03:16:50.479: I/DEBUG(110):  r4 deadd00d  r5 4094ace8  r6 0000020c  r7 40030880  
05-24 03:16:50.479: I/DEBUG(110):  r8 409260f3  r9 4092598f  10 409260ff  fp 409267d2  
05-24 03:16:50.479: I/DEBUG(110):  ip 00000000  sp beb39f40  lr 408e2203  pc 408e2202  cpsr 60000030  
05-24 03:16:50.479: I/DEBUG(110):  d0  0000000000000000  d1  0000000000000000  
05-24 03:16:50.479: I/DEBUG(110):  d2  0000000000000000  d3  0000000000000000  
05-24 03:16:50.479: I/DEBUG(110):  d4  8000000000000000  d5  429800003f800000  
05-24 03:16:50.479: I/DEBUG(110):  d6  000003c042980000  d7  4040000044700000  
05-24 03:16:50.479: I/DEBUG(110):  d8  43a0000043100000  d9  0000000000000000  
05-24 03:16:50.479: I/DEBUG(110):  d10 0000000000000000  d11 0000000000000000  
05-24 03:16:50.479: I/DEBUG(110):  d12 0000000000000000  d13 0000000000000000  
05-24 03:16:50.479: I/DEBUG(110):  d14 0000000000000000  d15 0000000000000000  
05-24 03:16:50.479: I/DEBUG(110):  d16 2065766974614e28  d17 0a29646f6874654d  
05-24 03:16:50.479: I/DEBUG(110):  d18 0000000000000000  d19 0000000000000000  
05-24 03:16:50.479: I/DEBUG(110):  d20 3ff0000000000000  d21 8000000000000000  
05-24 03:16:50.479: I/DEBUG(110):  d22 0000000000000000  d23 0000000000000000  
05-24 03:16:50.479: I/DEBUG(110):  d24 0000000000000000  d25 0000000000000000  
05-24 03:16:50.479: I/DEBUG(110):  d26 0000000000000000  d27 0000000000000000  
05-24 03:16:50.479: I/DEBUG(110):  d28 0100010001000100  d29 3ff0000000000000  
05-24 03:16:50.479: I/DEBUG(110):  d30 0000000000000000  d31 3ff0000000000000  
05-24 03:16:50.479: I/DEBUG(110):  scr 80000012  
05-24 03:16:50.739: I/DEBUG(110):          #00  pc 00051202  /system/lib/libdvm.so (dvmAbort)  
05-24 03:16:50.739: I/DEBUG(110):          #01  pc 00044c66  /system/lib/libdvm.so  
05-24 03:16:50.739: I/DEBUG(110):          #02  pc 000455a8  /system/lib/libdvm.so  
05-24 03:16:50.739: I/DEBUG(110):          #03  pc 0004bf48  /system/lib/libdvm.so  
05-24 03:16:50.739: I/DEBUG(110):          #04  pc 000c1904  /mnt/asec/cc.openframeworks.androidSoundPlayerExample-1/lib/libOFAndroidApp_neon.so (_ZN7_JNIEnv14CallVoidMethodEP8_jobjectP10_jmethodIDz)  
05-24 03:16:50.739: I/DEBUG(110): code around pc:  
05-24 03:16:50.749: I/DEBUG(110): 408e21e0 34bcf8d3 eae4f7cd 26001e73 2f01f813  ...4....s..&.../  
05-24 03:16:50.749: I/DEBUG(110): 408e21f0 42abb152 d0074416 4798e7f8 f7ff4c0a  R..B.D.....G.L..  
05-24 03:16:50.749: I/DEBUG(110): 408e2200 7026ffa7 eafef7cd 2006490c 44794a0c  ..&p.....I. .JyD  
05-24 03:16:50.749: I/DEBUG(110): 408e2210 f7cd447a 2000e990 ea70f7cd 58e54b05  zD..... ..p..K.X  
05-24 03:16:50.749: I/DEBUG(110): 408e2220 2b006c6b e7e9d1e9 deadd00d 00063e5c  kl.+........\>..  
05-24 03:16:50.749: I/DEBUG(110): code around lr:  
05-24 03:16:50.749: I/DEBUG(110): 408e21e0 34bcf8d3 eae4f7cd 26001e73 2f01f813  ...4....s..&.../  
05-24 03:16:50.749: I/DEBUG(110): 408e21f0 42abb152 d0074416 4798e7f8 f7ff4c0a  R..B.D.....G.L..  
05-24 03:16:50.749: I/DEBUG(110): 408e2200 7026ffa7 eafef7cd 2006490c 44794a0c  ..&p.....I. .JyD  
05-24 03:16:50.749: I/DEBUG(110): 408e2210 f7cd447a 2000e990 ea70f7cd 58e54b05  zD..... ..p..K.X  
05-24 03:16:50.749: I/DEBUG(110): 408e2220 2b006c6b e7e9d1e9 deadd00d 00063e5c  kl.+........\>..  
05-24 03:16:50.749: I/DEBUG(110): memory map around addr deadd00d:  
05-24 03:16:50.749: I/DEBUG(110): b0001000-b0009000 /system/bin/linker  
05-24 03:16:50.749: I/DEBUG(110): (no map for address)  
05-24 03:16:50.749: I/DEBUG(110): ffff0000-ffff1000 [vectors]  
[...]  
05-24 03:16:54.513: I/BootReceiver(230): Copying /data/tombstones/tombstone_03 to DropBox (SYSTEM_TOMBSTONE)  
05-24 03:16:54.543: W/AudioFlinger(115): AudioFlinger::NotificationClient::binderDied() died  
05-24 03:16:54.543: D/TimedEventQueue(115): pThread_join:14301816 E  
05-24 03:16:54.543: D/memalloc(112): /dev/pmem: Freeing buffer base:0x44001000 size:921600 offset:31649792 fd:50  
05-24 03:16:54.543: D/memalloc(112): /dev/pmem: Freeing buffer base:0x43807000 size:921600 offset:23285760 fd:59  
05-24 03:16:54.543: I/WindowManager(230): WIN DEATH: Window{4136b3f8 cc.openframeworks.androidSoundPlayerExample/cc.openframeworks.androidSoundPlayerExample.OFActivity paused=false}  
05-24 03:16:54.543: W/WindowManager(230): Force-removing child win Window{413c5d20 SurfaceView paused=false} from container Window{4136b3f8 cc.openframeworks.androidSoundPlayerExample/cc.openframeworks.androidSoundPlayerExample.OFActivity paused=false}  
05-24 03:16:54.543: I/ActivityManager(230): Process cc.openframeworks.androidSoundPlayerExample (pid 5213) has died.  
05-24 03:16:54.543: W/ActivityManager(230): Force removing ActivityRecord{4127f160 cc.openframeworks.androidSoundPlayerExample/.OFActivity}: app died, no saved state  
  

mmh, i discovered a problem yesterday with some other objects where i’m not using global references in the jni code, i’ll take a look at that function it seems to be the same problem

what where you callling on touch down? some ofSoundPlayer method?

Hi I am using ofSoundPlayer and it works fine when you first run the App.

I am calling .play at touchDoubleTap

The problem comes when you lock. When you unlock the sound doesn’t work anymore, the same happens with some 3D textures and gl light. I suppose the data related to both textures and sound (ofObjects like ofImage, ofSoundPlayer, …) have to be recalled because Android doesn’t save them when destroying the App at the Lock.

What i do is reloading everything which is loaded in the setup at the first update after the unlock with a condition to assure it is done only once.

i hope this helps!

by the way, I am using the gitHub version of ofAndroid.