作者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
1F:推 LPH66:errno=9是EBADF (Bad File Descriptor) 140.112.30.84 10/26 23:48
2F:→ LPH66:你看看你传的时候有没有什麽问题吧... 140.112.30.84 10/26 23:48
3F:→ nosrep:我知道BADFD, 但似乎看不出问题...220.128.189.251 10/26 23:57
4F:→ nosrep:重点是那个src用mingw编就可以正常使用.220.128.189.251 10/26 23:58