作者nosrep (ㄎ)
看板Programming
標題[問題] 開檔問題 errno=9
時間Sun Oct 26 23:28:34 2008
我用 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
推 LPH66:errno=9是EBADF (Bad File Descriptor) 140.112.30.84 10/26 23:48
→ LPH66:你看看你傳的時候有沒有什麼問題吧... 140.112.30.84 10/26 23:48
→ nosrep:我知道BADFD, 但似乎看不出問題...220.128.189.251 10/26 23:57
→ nosrep:重點是那個src用mingw編就可以正常使用.220.128.189.251 10/26 23:58