]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/audio.c
use AVFrame.pts=AV_NOPTS_VALUE instead of AVFrame.pts=0
[ffmpeg] / libavformat / audio.c
index 05055a17818f1a3391c5f7fda95f7cc312a9c22b..3662e458ffd0fc5e0080cae20108c04fee2e55a9 100644 (file)
@@ -37,7 +37,7 @@ typedef struct {
     int frame_size; /* in bytes ! */
     int codec_id;
     int flip_left : 1;
-    UINT8 buffer[AUDIO_BLOCK_SIZE];
+    uint8_t buffer[AUDIO_BLOCK_SIZE];
     int buffer_ptr;
 } AudioData;
 
@@ -165,7 +165,7 @@ static int audio_write_header(AVFormatContext *s1)
 }
 
 static int audio_write_packet(AVFormatContext *s1, int stream_index,
-                              UINT8 *buf, int size, int force_pts)
+                              const uint8_t *buf, int size, int64_t pts)
 {
     AudioData *s = s1->priv_data;
     int len, ret;
@@ -244,6 +244,18 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
     if (av_new_packet(pkt, s->frame_size) < 0)
         return -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);
         if (ret > 0)
             break;