static int init_decoder(int32_t fmtp[12]) { alac_file *alac; frame_size = fmtp[1]; // stereo samples sampling_rate = fmtp[11]; int sample_size = fmtp[3]; if (sample_size != 16) die("only 16-bit samples supported!"); alac = alac_create(sample_size, 2); if (!alac) return 1; decoder_info = alac; alac->setinfo_max_samples_per_frame = frame_size; alac->setinfo_7a = fmtp[2]; alac->setinfo_sample_size = sample_size; alac->setinfo_rice_historymult = fmtp[4]; alac->setinfo_rice_initialhistory = fmtp[5]; alac->setinfo_rice_kmodifier = fmtp[6]; alac->setinfo_7f = fmtp[7]; alac->setinfo_80 = fmtp[8]; alac->setinfo_82 = fmtp[9]; alac->setinfo_86 = fmtp[10]; alac->setinfo_8a_rate = fmtp[11]; alac_allocate_buffers(alac); return 0; }
JNIEXPORT void JNICALL Java_com_realtek_cast_util_Alac_createAlac(JNIEnv *env, jclass clazz, jint sampleSize, jint numChannels) { if (s_alac != NULL) { alac_free(s_alac); } s_alac = alac_create(sampleSize, numChannels); }