J'utilise l'objet SOUNDPOOL pour charger 2 fichiers wav comme ceci:Soundpool se bloque lors du chargement de fichier WAV sur Samsung Galaxy Note 8
public RingtoneManager(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
soundPool = createSoundPool();
} else {
soundPool = createLegacySoundPool();
}
RING_OUT = soundPool.load(context, R.raw.groovy, 1);
sounds.put(RING_OUT, -1);
RING_IN = soundPool.load(context, R.raw.ring_ring_wav, 1); // crashes on this line
sounds.put(RING_IN, -1);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
protected SoundPool createSoundPool() {
Logger.log(TAG, "createSoundPool load attributes");
AudioAttributes attributes = new AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION_SIGNALLING)
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.build();
Logger.log(TAG, "build soundpool");
return new SoundPool.Builder()
.setAudioAttributes(attributes)
.build();
}
@SuppressWarnings("deprecation")
protected SoundPool createLegacySoundPool() {
Logger.log(TAG, "createLegacySoundPool");
return new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
}
J'ai eu aucun problème sur un appareil avec ce code jusqu'à récemment Je l'ai testé sur une nouvelle Samsung Galaxy note 8. il se bloque toujours lorsque vous tentez de charger le fichier ring_ring_wav.wav avec la trace de pile suivante:
09-27 20:30:20.033 23644-23644/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
09-27 20:30:20.033 23644-23644/? A/DEBUG: Build fingerprint: 'samsung/greatltexx/greatlte:7.1.1/NMF26X/N950FXXU1AQI1:user/release-keys'
09-27 20:30:20.033 23644-23644/? A/DEBUG: Revision: '9'
09-27 20:30:20.033 23644-23644/? A/DEBUG: ABI: 'arm'
09-27 20:30:20.034 23644-23644/? A/DEBUG: pid: 23526, tid: 23629, name: SoundPoolThread >>> com.wizix.gridme <<<
09-27 20:30:20.034 23644-23644/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
09-27 20:30:20.041 23644-23644/? A/DEBUG: Abort message: 'buffer(0xddf28068) localRefcount 1 != 0, remoteRefcount 0'
09-27 20:30:20.041 23644-23644/? A/DEBUG: r0 00000000 r1 00005c4d r2 00000006 r3 00000008
09-27 20:30:20.041 23644-23644/? A/DEBUG: r4 c59b9978 r5 00000006 r6 c59b9920 r7 0000010c
09-27 20:30:20.041 23644-23644/? A/DEBUG: r8 c6018120 r9 e7ae5ee6 sl e7ae5fb0 fp c9e716b0
09-27 20:30:20.041 23644-23644/? A/DEBUG: ip 00000000 sp c59b92f0 lr e9ff1097 pc e9ff38f4 cpsr 200e0010
09-27 20:30:20.052 23644-23644/? A/DEBUG: backtrace:
09-27 20:30:20.053 23644-23644/? A/DEBUG: #00 pc 0004a8f4 /system/lib/libc.so (tgkill+12)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #01 pc 00048093 /system/lib/libc.so (pthread_kill+34)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #02 pc 0001db6d /system/lib/libc.so (raise+10)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #03 pc 00019271 /system/lib/libc.so (__libc_android_abort+34)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #04 pc 0001718c /system/lib/libc.so (abort+4)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #05 pc 0000c971 /system/lib/libcutils.so (__android_log_assert+112)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #06 pc 00018355 /system/lib/libstagefright_foundation.so (_ZN7android16MediaBufferGroupD1Ev+168)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #07 pc 00018399 /system/lib/libstagefright_foundation.so (_ZN7android16MediaBufferGroupD0Ev+2)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #08 pc 00121eb1 /system/lib/libstagefright.so (_ZN7android9WAVSource4stopEv+20)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #09 pc 00121aeb /system/lib/libstagefright.so (_ZN7android9WAVSourceD2Ev+34)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #10 pc 00121bd7 /system/lib/libstagefright.so (_ZTv0_n12_N7android9WAVSourceD0Ev+18)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #11 pc 0000bd87 /system/lib/libutils.so (_ZNK7android7RefBase9decStrongEPKv+58)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #12 pc 0000520b /system/lib/libsoundextractor.so (_ZN7android20SoundExtractorParserD1Ev+46)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #13 pc 00005343 /system/lib/libsoundextractor.so (_ZN7android23SoundExtractorMp3ParserD0Ev+2)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #14 pc 0000bd87 /system/lib/libutils.so (_ZNK7android7RefBase9decStrongEPKv+58)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #15 pc 00005b31 /system/lib/libsoundextractor.so (_ZN7android19SoundExtractorCodecD1Ev+24)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #16 pc 00005bdb /system/lib/libsoundextractor.so (_ZN7android22SoundExtractorRawCodecD0Ev+2)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #17 pc 0000bd87 /system/lib/libutils.so (_ZNK7android7RefBase9decStrongEPKv+58)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #18 pc 0000513d /system/lib/libsoundextractor.so (_ZN7android14SoundExtractor7releaseEv+12)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #19 pc 00005ecf /system/lib/libsoundpool.so (_ZN7android6Sample6doLoadEv+258)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #20 pc 000069ad /system/lib/libsoundpool.so (_ZN7android15SoundPoolThread12doLoadSampleEi+32)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #21 pc 0000695f /system/lib/libsoundpool.so (_ZN7android15SoundPoolThread3runEv+18)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #22 pc 000068e7 /system/lib/libsoundpool.so (_ZN7android15SoundPoolThread11beginThreadEPv+2)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #23 pc 0006b65d /system/lib/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+80)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #24 pc 00047b63 /system/lib/libc.so (_ZL15__pthread_startPv+22)
09-27 20:30:20.053 23644-23644/? A/DEBUG: #25 pc 00019ee1 /system/lib/libc.so (__start_thread+6)
Si je télécharger le fichier directement sur l'appareil, il joue bien par Chrome. L'autre fichier wav se charge et joue bien dans le groupe de sons.
Comment avez-vous résoudre ce problème ??? une solution à partager? – Allan
Salut, je n'ai rien obtenu avec ça à la fin. Ma solution était de ré-encoder mes fichiers audio en utilisant un format différent. J'ai utilisé m4a au lieu de wav. –