|
|
@ -250,32 +250,13 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) |
|
|
|
|
|
|
|
|
|
|
|
if (av_new_packet(pkt, s->frame_size) < 0) |
|
|
|
if (av_new_packet(pkt, s->frame_size) < 0) |
|
|
|
return AVERROR(EIO); |
|
|
|
return AVERROR(EIO); |
|
|
|
for(;;) { |
|
|
|
|
|
|
|
struct timeval tv; |
|
|
|
|
|
|
|
fd_set fds; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tv.tv_sec = 0; |
|
|
|
|
|
|
|
tv.tv_usec = 30 * 1000; /* 30 msecs -- a bit shorter than 1 frame at 30fps */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FD_ZERO(&fds); |
|
|
|
|
|
|
|
FD_SET(s->fd, &fds); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This will block until data is available or we get a timeout */ |
|
|
|
|
|
|
|
(void) select(s->fd + 1, &fds, 0, 0, &tv); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ret = read(s->fd, pkt->data, pkt->size); |
|
|
|
ret = read(s->fd, pkt->data, pkt->size); |
|
|
|
if (ret > 0) |
|
|
|
if (ret <= 0){ |
|
|
|
break; |
|
|
|
|
|
|
|
if (ret == -1 && (errno == EAGAIN || errno == EINTR)) { |
|
|
|
|
|
|
|
av_free_packet(pkt); |
|
|
|
av_free_packet(pkt); |
|
|
|
pkt->size = 0; |
|
|
|
pkt->size = 0; |
|
|
|
pkt->pts = av_gettime(); |
|
|
|
if (ret<0) return AVERROR(errno); |
|
|
|
return 0; |
|
|
|
else return AVERROR(EOF); |
|
|
|
} |
|
|
|
|
|
|
|
if (!(ret == 0 || (ret == -1 && (errno == EAGAIN || errno == EINTR)))) { |
|
|
|
|
|
|
|
av_free_packet(pkt); |
|
|
|
|
|
|
|
return AVERROR(EIO); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
pkt->size = ret; |
|
|
|
pkt->size = ret; |
|
|
|
|
|
|
|
|
|
|
|