Commit eb27317c authored by Linshizhi's avatar Linshizhi

deal with corner case.

parent e7038fbd
...@@ -141,7 +141,6 @@ BUILTIN(Close) { ...@@ -141,7 +141,6 @@ BUILTIN(Close) {
return *isolate->factory()->ToBoolean(true); return *isolate->factory()->ToBoolean(true);
} }
std::remove(enc->getOutputPath().c_str());
enc->close(); enc->close();
enc = nullptr; enc = nullptr;
inited = false; inited = false;
...@@ -225,6 +224,12 @@ BUILTIN(Save) { ...@@ -225,6 +224,12 @@ BUILTIN(Save) {
BUILTIN(AddAudioBuffer) { BUILTIN(AddAudioBuffer) {
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<Object> audioBuffer = args.atOrUndefined(isolate, 1);
if (audioBuffer->IsUndefined() || audioBuffer->IsNull()) {
return ReadOnlyRoots(isolate).undefined_value();
}
Handle<JSTypedArray> array; Handle<JSTypedArray> array;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, array, ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, array,
JSTypedArray::Validate(isolate, args.atOrUndefined(isolate, 1), "ENCODER.encode()")); JSTypedArray::Validate(isolate, args.atOrUndefined(isolate, 1), "ENCODER.encode()"));
...@@ -252,7 +257,13 @@ BUILTIN(AddAudioBuffer) { ...@@ -252,7 +257,13 @@ BUILTIN(AddAudioBuffer) {
BUILTIN(MergeMP4) { BUILTIN(MergeMP4) {
HandleScope scope(isolate); HandleScope scope(isolate);
if (!audioPath) {
return *(isolate->factory()->
NewStringFromAsciiChecked(enc->getOutputPath().c_str()));
}
Handle<Object> libpath = args.atOrUndefined(isolate, 1); Handle<Object> libpath = args.atOrUndefined(isolate, 1);
// Libav path // Libav path
std::string libpath_cppstr; std::string libpath_cppstr;
if (libpath->IsUndefined()) { if (libpath->IsUndefined()) {
...@@ -284,6 +295,7 @@ BUILTIN(MergeMP4) { ...@@ -284,6 +295,7 @@ BUILTIN(MergeMP4) {
free(audioPath); free(audioPath);
audioPath = nullptr; audioPath = nullptr;
std::remove(enc->getOutputPath().c_str());
return *mergepath; 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