Allow null FILE* to AecDumpFactory::Create
Also add Create method with a FileWrapper argument, extracted from cl https://webrtc-review.googlesource.com/c/src/+/140283 Bug: webrtc:6463 Change-Id: If86f17d5fda964df0b5874bd5a15fcaed899dd4e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/140946 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Alex Loiko <aleloi@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28211}
This commit is contained in:
parent
8169db6df2
commit
646e096e03
@ -17,6 +17,7 @@ rtc_source_set("aec_dump") {
|
|||||||
deps = [
|
deps = [
|
||||||
"../",
|
"../",
|
||||||
"../../../rtc_base:rtc_base_approved",
|
"../../../rtc_base:rtc_base_approved",
|
||||||
|
"../../../rtc_base/system:file_wrapper",
|
||||||
"../../../rtc_base/system:rtc_export",
|
"../../../rtc_base/system:rtc_export",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "modules/audio_processing/include/aec_dump.h"
|
#include "modules/audio_processing/include/aec_dump.h"
|
||||||
#include "rtc_base/platform_file.h"
|
#include "rtc_base/platform_file.h"
|
||||||
|
#include "rtc_base/system/file_wrapper.h"
|
||||||
#include "rtc_base/system/rtc_export.h"
|
#include "rtc_base/system/rtc_export.h"
|
||||||
|
|
||||||
namespace rtc {
|
namespace rtc {
|
||||||
@ -32,6 +33,10 @@ class RTC_EXPORT AecDumpFactory {
|
|||||||
// responsibility for |handle| and closes it in the destructor. A
|
// responsibility for |handle| and closes it in the destructor. A
|
||||||
// non-null return value indicates that the file has been
|
// non-null return value indicates that the file has been
|
||||||
// sucessfully opened.
|
// sucessfully opened.
|
||||||
|
static std::unique_ptr<AecDump> Create(webrtc::FileWrapper&& file,
|
||||||
|
int64_t max_log_size_bytes,
|
||||||
|
rtc::TaskQueue* worker_queue);
|
||||||
|
// TODO(webrtc:6463): Deprecated. Delete, together with the PlatformFile type.
|
||||||
static std::unique_ptr<AecDump> Create(rtc::PlatformFile file,
|
static std::unique_ptr<AecDump> Create(rtc::PlatformFile file,
|
||||||
int64_t max_log_size_bytes,
|
int64_t max_log_size_bytes,
|
||||||
rtc::TaskQueue* worker_queue);
|
rtc::TaskQueue* worker_queue);
|
||||||
|
|||||||
@ -216,36 +216,34 @@ std::unique_ptr<WriteToFileTask> AecDumpImpl::CreateWriteToFileTask() {
|
|||||||
&num_bytes_left_for_log_);
|
&num_bytes_left_for_log_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<AecDump> AecDumpFactory::Create(rtc::PlatformFile file,
|
std::unique_ptr<AecDump> AecDumpFactory::Create(webrtc::FileWrapper&& file,
|
||||||
int64_t max_log_size_bytes,
|
int64_t max_log_size_bytes,
|
||||||
rtc::TaskQueue* worker_queue) {
|
rtc::TaskQueue* worker_queue) {
|
||||||
RTC_DCHECK(worker_queue);
|
RTC_DCHECK(worker_queue);
|
||||||
FILE* handle = rtc::FdopenPlatformFileForWriting(file);
|
if (!file.is_open())
|
||||||
if (!handle) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
return absl::make_unique<AecDumpImpl>(FileWrapper(handle), max_log_size_bytes,
|
return absl::make_unique<AecDumpImpl>(std::move(file), max_log_size_bytes,
|
||||||
worker_queue);
|
worker_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<AecDump> AecDumpFactory::Create(rtc::PlatformFile file,
|
||||||
|
int64_t max_log_size_bytes,
|
||||||
|
rtc::TaskQueue* worker_queue) {
|
||||||
|
return Create(FileWrapper(rtc::FdopenPlatformFileForWriting(file)),
|
||||||
|
max_log_size_bytes, worker_queue);
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<AecDump> AecDumpFactory::Create(std::string file_name,
|
std::unique_ptr<AecDump> AecDumpFactory::Create(std::string file_name,
|
||||||
int64_t max_log_size_bytes,
|
int64_t max_log_size_bytes,
|
||||||
rtc::TaskQueue* worker_queue) {
|
rtc::TaskQueue* worker_queue) {
|
||||||
RTC_DCHECK(worker_queue);
|
return Create(FileWrapper::OpenWriteOnly(file_name.c_str()),
|
||||||
FileWrapper debug_file = FileWrapper::OpenWriteOnly(file_name.c_str());
|
|
||||||
if (!debug_file.is_open()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return absl::make_unique<AecDumpImpl>(std::move(debug_file),
|
|
||||||
max_log_size_bytes, worker_queue);
|
max_log_size_bytes, worker_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<AecDump> AecDumpFactory::Create(FILE* handle,
|
std::unique_ptr<AecDump> AecDumpFactory::Create(FILE* handle,
|
||||||
int64_t max_log_size_bytes,
|
int64_t max_log_size_bytes,
|
||||||
rtc::TaskQueue* worker_queue) {
|
rtc::TaskQueue* worker_queue) {
|
||||||
RTC_DCHECK(worker_queue);
|
return Create(FileWrapper(handle), max_log_size_bytes, worker_queue);
|
||||||
RTC_DCHECK(handle);
|
|
||||||
return absl::make_unique<AecDumpImpl>(FileWrapper(handle), max_log_size_bytes,
|
|
||||||
worker_queue);
|
|
||||||
}
|
}
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -13,6 +13,12 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
std::unique_ptr<AecDump> AecDumpFactory::Create(webrtc::FileWrapper&& file,
|
||||||
|
int64_t max_log_size_bytes,
|
||||||
|
rtc::TaskQueue* worker_queue) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<AecDump> AecDumpFactory::Create(rtc::PlatformFile file,
|
std::unique_ptr<AecDump> AecDumpFactory::Create(rtc::PlatformFile file,
|
||||||
int64_t max_log_size_bytes,
|
int64_t max_log_size_bytes,
|
||||||
rtc::TaskQueue* worker_queue) {
|
rtc::TaskQueue* worker_queue) {
|
||||||
|
|||||||
@ -44,7 +44,8 @@ class FileWrapper final {
|
|||||||
|
|
||||||
FileWrapper() = default;
|
FileWrapper() = default;
|
||||||
|
|
||||||
// Takes over ownership of |file|, closing it on destruction.
|
// Takes over ownership of |file|, closing it on destruction. Calling with
|
||||||
|
// null |file| is allowed, and results in a FileWrapper with is_open() false.
|
||||||
explicit FileWrapper(FILE* file) : file_(file) {}
|
explicit FileWrapper(FILE* file) : file_(file) {}
|
||||||
~FileWrapper() { Close(); }
|
~FileWrapper() { Close(); }
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user