Commit eb27317c authored by Linshizhi's avatar Linshizhi

deal with corner case.

parent e7038fbd
......@@ -141,7 +141,6 @@ BUILTIN(Close) {
return *isolate->factory()->ToBoolean(true);
}
std::remove(enc->getOutputPath().c_str());
enc->close();
enc = nullptr;
inited = false;
......@@ -225,6 +224,12 @@ BUILTIN(Save) {
BUILTIN(AddAudioBuffer) {
HandleScope scope(isolate);
Handle<Object> audioBuffer = args.atOrUndefined(isolate, 1);
if (audioBuffer->IsUndefined() || audioBuffer->IsNull()) {
return ReadOnlyRoots(isolate).undefined_value();
}
Handle<JSTypedArray> array;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, array,
JSTypedArray::Validate(isolate, args.atOrUndefined(isolate, 1), "ENCODER.encode()"));
......@@ -252,7 +257,13 @@ BUILTIN(AddAudioBuffer) {
BUILTIN(MergeMP4) {
HandleScope scope(isolate);
if (!audioPath) {
return *(isolate->factory()->
NewStringFromAsciiChecked(enc->getOutputPath().c_str()));
}
Handle<Object> libpath = args.atOrUndefined(isolate, 1);
// Libav path
std::string libpath_cppstr;
if (libpath->IsUndefined()) {
......@@ -284,6 +295,7 @@ BUILTIN(MergeMP4) {
free(audioPath);
audioPath = nullptr;
std::remove(enc->getOutputPath().c_str());
return *mergepath;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment