void AudioOutputStreamHandler::SetOutputParameters(String type, String typeDevice, String device, bool isAudioOutputToStream) { this->isAudioOutputToStream = isAudioOutputToStream; if (isAudioOutputToStream) { libvlc_audio_set_callbacks(mediaPlayer, audioPlayCallbackProxy, nullptr, nullptr, nullptr, nullptr, this); } else { auto *node = libvlc_audio_output_list_get(vlc); char *_type = type.CreateUTF8String(); char *_typeDevice = typeDevice.CreateUTF8String(); char *_device = device.CreateUTF8String(); if (_type) { int i = libvlc_audio_output_set(mediaPlayer, _type); if (_device) { libvlc_audio_output_device_set(mediaPlayer, _typeDevice, _device); } } if (_type != nullptr) { Free(_type); } if (_typeDevice != nullptr) { Free(_typeDevice); } if (_device != nullptr) { Free(_device); } } }
jboolean Java_org_videolan_libvlc_MediaPlayer_nativeSetAudioOutputDevice(JNIEnv *env, jobject thiz, jstring jid) { const char* psz_id; int i_ret; vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz); if (!p_obj) return false; if (!jid || !(psz_id = (*env)->GetStringUTFChars(env, jid, 0))) { throw_IllegalArgumentException(env, "aout invalid"); return false; } libvlc_audio_output_device_set(p_obj->u.p_mp, NULL, psz_id); (*env)->ReleaseStringUTFChars(env, jid, psz_id); return true; }