[問題] 開檔問題 errno=9
我用 ffmpeg, 然後用 mingw 去編譯出 library,
接下來用 VC 去編譯 test ap, 發先一直有錯, 找到後來發現 read 資料出問題...
執行結果:
open D:\abc.avi and fd = 3
read fail due to errno=9 (fd=3)
read -1
實在不懂為何會出錯ㄝ....有人有經驗嘛? VC 的讀檔問題?
以下是源碼 (libavformat/file.c)
/* standard file protocol */
static int file_open(URLContext *h, const char *filename, int flags)
{
int access;
int fd;
av_strstart(filename, "file:", &filename);
if (flags & URL_RDWR) {
access = O_CREAT | O_TRUNC | O_RDWR;
} else if (flags & URL_WRONLY) {
access = O_CREAT | O_TRUNC | O_WRONLY;
} else {
access = O_RDONLY;
}
#ifdef O_BINARY
access |= O_BINARY;
#endif
fd = open(filename, access, 0666);
fprintf(stdout, "%d: open %s and fd = %d\n", __LINE__, filename, fd);
if (fd < 0)
return AVERROR(ENOENT);
h->priv_data = (void *)(size_t)fd;
return 0;
}
static int file_read(URLContext *h, unsigned char *buf, int size)
{
//av_log(NULL, AV_LOG_INFO,"%d\n",__LINE__);
int fd = (size_t)h->priv_data;
int r = read(fd, buf, size);
//av_log(NULL, AV_LOG_INFO,"%d: read %d\n",__LINE__, r);
if( r < 0 )
fprintf(stdout, "%d: read fail due to errno=%d (fd=%d)\n", __LINE__, errno,
fd);
fprintf(stdout, "%d: read %d\n", __LINE__, r);
return r;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.128.189.251
推
10/26 23:48, , 1F
10/26 23:48, 1F
→
10/26 23:48, , 2F
10/26 23:48, 2F
→
10/26 23:57, , 3F
10/26 23:57, 3F
→
10/26 23:58, , 4F
10/26 23:58, 4F