On 10/25/11 11:54 PM, Anton Khirnov wrote:

On Tue, 25 Oct 2011 18:59:10 -0700, Luca Barbato<[email protected]>  wrote:
+static int pulse_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+    PulseData *pd  = s->priv_data;
+    int res;
+    pa_usec_t latency;
+    uint64_t frame_duration =
+        (pd->frame_size*1000000LL)/(pd->sample_rate * pd->channels);
+
+    if (av_new_packet(pkt, pd->frame_size)<  0) {
+        return AVERROR(ENOMEM);
+    }
+
+    if ((pa_simple_read(pd->s, pkt->data, pkt->size,&res))<  0) {
+        av_log(s, AV_LOG_ERROR, "pa_simple_read failed: %s\n",
+               pa_strerror(res));
+        av_free_packet(pkt);
+        return AVERROR(EIO);
+    }
+
+    if ((latency = pa_simple_get_latency(pd->s,&res)) == (pa_usec_t) -1) {
+        av_log(s, AV_LOG_ERROR, "pa_simple_get_latency() failed: %s\n",
+               pa_strerror(res));
+        return AVERROR(EIO);
+    }
+
+    if (pd->pts == AV_NOPTS_VALUE) {
+        pd->pts = -latency;

I find this a bit suspicious. If, as you said on IRC, pulseaudio buffers
the data so it is continuous and nothing is dropped, then pts of the
next frame should be just pts of the previous + frame duration.

so it starts from -latency and then continues by increasing by a the time of a frame.

And I agree with Justin that long lines are more readable here.

Replaced.


_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to