avdevice/v4l2: Try to fix build on netbsd/openbsd
[ffmpeg.git] / libavdevice / pulse_audio_dec.c
index 01ff6d1..aa0800b 100644 (file)
 
 #include <pulse/rtclock.h>
 #include <pulse/error.h>
-#include "libavformat/avformat.h"
-#include "libavformat/internal.h"
+
+#include "libavutil/internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/time.h"
+
+#include "libavformat/avformat.h"
+#include "libavformat/internal.h"
 #include "pulse_audio_common.h"
 #include "timefilter.h"
 
@@ -48,6 +51,7 @@ typedef struct PulseData {
 
     TimeFilter *timefilter;
     int last_period;
+    int wallclock;
 } PulseData;
 
 
@@ -57,7 +61,7 @@ typedef struct PulseData {
             rerror = AVERROR_EXTERNAL;                          \
             goto label;                                         \
         }                                                       \
-    } while(0);
+    } while (0)
 
 #define CHECK_DEAD_GOTO(p, rerror, label)                               \
     do {                                                                \
@@ -66,7 +70,7 @@ typedef struct PulseData {
             rerror = AVERROR_EXTERNAL;                                  \
             goto label;                                                 \
         }                                                               \
-    } while(0);
+    } while (0)
 
 static void context_state_cb(pa_context *c, void *userdata) {
     PulseData *p = userdata;
@@ -154,7 +158,7 @@ static av_cold int pulse_read_header(AVFormatContext *s)
 
     attr.fragsize = pd->fragment_size;
 
-    if (strcmp(s->filename, "default"))
+    if (s->filename[0] != '\0' && strcmp(s->filename, "default"))
         device = s->filename;
 
     if (!(pd->mainloop = pa_threaded_mainloop_new())) {
@@ -311,7 +315,8 @@ static int pulse_read_packet(AVFormatContext *s, AVPacket *pkt)
             dts += latency;
         } else
             dts -= latency;
-        pkt->pts = ff_timefilter_update(pd->timefilter, dts, pd->last_period);
+        if (pd->wallclock)
+            pkt->pts = ff_timefilter_update(pd->timefilter, dts, pd->last_period);
 
         pd->last_period = frame_duration;
     } else {
@@ -346,6 +351,7 @@ static const AVOption options[] = {
     { "channels",      "set number of audio channels",                      OFFSET(channels),      AV_OPT_TYPE_INT,    {.i64 = 2},        1, INT_MAX, D },
     { "frame_size",    "set number of bytes per frame",                     OFFSET(frame_size),    AV_OPT_TYPE_INT,    {.i64 = 1024},     1, INT_MAX, D },
     { "fragment_size", "set buffering size, affects latency and cpu usage", OFFSET(fragment_size), AV_OPT_TYPE_INT,    {.i64 = -1},      -1, INT_MAX, D },
+    { "wallclock",     "set the initial pts using the current time",     OFFSET(wallclock),     AV_OPT_TYPE_INT,    {.i64 = 1},       -1, 1, D },
     { NULL },
 };