AI automatically translates all comments in the code into English (#3917)

This commit is contained in:
alex
2024-09-19 14:53:50 +08:00
committed by GitHub
parent 046de691cb
commit 4152dcd409
279 changed files with 10602 additions and 3038 deletions

View File

@@ -42,7 +42,8 @@ static struct mov_buffer_t s_io = {
MP4FileIO::Writer MP4FileIO::createWriter(int flags, bool is_fmp4){
Writer writer;
Ptr self = shared_from_this();
//保存自己的强引用,防止提前释放
// 保存自己的强引用,防止提前释放 [AUTO-TRANSLATED:e8e14f60]
// Save a strong reference to itself to prevent premature release
writer.reset(mp4_writer_create(is_fmp4, &s_io,this, flags),[self](mp4_writer_t *ptr){
if(ptr){
mp4_writer_destroy(ptr);
@@ -57,7 +58,8 @@ MP4FileIO::Writer MP4FileIO::createWriter(int flags, bool is_fmp4){
MP4FileIO::Reader MP4FileIO::createReader(){
Reader reader;
Ptr self = shared_from_this();
//保存自己的强引用,防止提前释放
// 保存自己的强引用,防止提前释放 [AUTO-TRANSLATED:e8e14f60]
// Save a strong reference to itself to prevent premature release
reader.reset(mov_reader_create(&s_io,this),[self](mov_reader_t *ptr){
if(ptr){
mov_reader_destroy(ptr);
@@ -80,7 +82,8 @@ MP4FileIO::Reader MP4FileIO::createReader(){
#endif
void MP4FileDisk::openFile(const char *file, const char *mode) {
//创建文件
// 创建文件 [AUTO-TRANSLATED:bd145ed5]
// Create a file
auto fp = File::create_file(file, mode);
if(!fp){
throw std::runtime_error(string("打开文件失败:") + file);
@@ -88,7 +91,8 @@ void MP4FileDisk::openFile(const char *file, const char *mode) {
GET_CONFIG(uint32_t,mp4BufSize,Record::kFileBufSize);
//新建文件io缓存
// 新建文件io缓存 [AUTO-TRANSLATED:fda9ff47]
// Create a new file io cache
std::shared_ptr<char> file_buf(new char[mp4BufSize],[](char *ptr){
if(ptr){
delete [] ptr;
@@ -96,11 +100,13 @@ void MP4FileDisk::openFile(const char *file, const char *mode) {
});
if(file_buf){
//设置文件io缓存
// 设置文件io缓存 [AUTO-TRANSLATED:0ed9c8ad]
// Set the file io cache
setvbuf(fp, file_buf.get(), _IOFBF, mp4BufSize);
}
//创建智能指针
// 创建智能指针 [AUTO-TRANSLATED:e7920ab2]
// Create a smart pointer
_file.reset(fp,[file_buf](FILE *fp) {
fflush(fp);
fclose(fp);
@@ -168,7 +174,8 @@ int MP4FileMemory::onRead(void *data, size_t bytes){
int MP4FileMemory::onWrite(const void *data, size_t bytes){
if (_offset + bytes > _memory.size()) {
//需要扩容
// 需要扩容 [AUTO-TRANSLATED:211c91e3]
// Need to expand
_memory.resize(_offset + bytes);
}
memcpy((uint8_t *) _memory.data() + _offset, data, bytes);