private native void nativeDestroy(long handle);
private native boolean nativeStart(long handle);
private native boolean nativeStop(long handle);
+ private native boolean nativeFlush(long handle, boolean start);
private native int nativeGetState(long handle);
private native boolean nativeInputData(long handle, String name, TensorsData data);
private native String[] nativeGetSwitchPads(long handle, String name);
}
/**
+ * Clears all data and resets the pipeline.
+ * During the flush operation, the pipeline is stopped and after the operation is done,
+ * the pipeline is resumed and ready to start the data flow.
+ *
+ * @param start The flag to start the pipeline after the flush operation is done
+ *
+ * @throws IllegalStateException if failed to flush the pipeline
+ */
+ public void flush(boolean start) {
+ checkPipelineHandle();
+
+ if (!nativeFlush(mHandle, start)) {
+ throw new IllegalStateException("Failed to flush the pipeline");
+ }
+ }
+
+ /**
* Gets the state of pipeline.
*
* @return The state of pipeline
/**
* @brief Native method for pipeline API.
*/
+static jboolean
+nns_native_pipe_flush (JNIEnv * env, jobject thiz, jlong handle, jboolean start)
+{
+ pipeline_info_s *pipe_info = NULL;
+ ml_pipeline_h pipe;
+ int status;
+
+ pipe_info = CAST_TO_TYPE (handle, pipeline_info_s *);
+ pipe = pipe_info->pipeline_handle;
+
+ status = ml_pipeline_flush (pipe, (start == JNI_TRUE));
+ if (status != ML_ERROR_NONE) {
+ nns_loge ("Failed to flush the pipeline.");
+ return JNI_FALSE;
+ }
+
+ return JNI_TRUE;
+}
+
+/**
+ * @brief Native method for pipeline API.
+ */
static jint
nns_native_pipe_get_state (JNIEnv * env, jobject thiz, jlong handle)
{
{"nativeDestroy", "(J)V", (void *) nns_native_pipe_destroy},
{"nativeStart", "(J)Z", (void *) nns_native_pipe_start},
{"nativeStop", "(J)Z", (void *) nns_native_pipe_stop},
+ {"nativeFlush", "(JZ)Z", (void *) nns_native_pipe_flush},
{"nativeGetState", "(J)I", (void *) nns_native_pipe_get_state},
{"nativeInputData", "(JLjava/lang/String;L" NNS_CLS_TDATA ";)Z",
(void *) nns_native_pipe_input_data},