return video_caps;
}
+
+bool gst_dshow_configure_latency (IPin *pCapturePin, guint bufSizeMS)
+{
+ HRESULT hr;
+ ALLOCATOR_PROPERTIES alloc_prop;
+ IAMBufferNegotiation * pNeg = NULL;
+ hr = pCapturePin->QueryInterface(IID_IAMBufferNegotiation, (void **)&pNeg);
+
+ if(!SUCCEEDED (hr))
+ return FALSE;
+
+ alloc_prop.cbAlign = -1; // -1 means no preference.
+ alloc_prop.cbBuffer = bufSizeMS;
+ alloc_prop.cbPrefix = -1;
+ alloc_prop.cBuffers = -1;
+ hr = pNeg->SuggestAllocatorProperties (&alloc_prop);
+ return SUCCEEDED (hr);
+}
GstCaps *gst_dshow_new_video_caps (GstVideoFormat video_format,
const gchar * name, GstCapturePinMediaType * pin_mediatype);
+/* configure the latency of the capture source */
+bool gst_dshow_configure_latency (IPin *pCapturePin, guint bufSizeMS);
+
#endif /* _GSTDSHOW_ */
goto error;
}
+ spec->segsize = (gint) (spec->bytes_per_sample * spec->rate * spec->latency_time /
+ GST_MSECOND);
+ spec->segtotal = (gint) ((gfloat) spec->buffer_time /
+ (gfloat) spec->latency_time + 0.5);
+ if (!gst_dshow_configure_latency (pin_mediatype->capture_pin,
+ spec->segsize))
+ {
+ GST_WARNING ("Could not change capture latency");
+ spec->segsize = spec->rate * spec->channels;
+ spec->segtotal = 2;
+ };
+ GST_INFO ("Configuring with segsize:%d segtotal:%d", spec->segsize, spec->segtotal);
hres = src->filter_graph->ConnectDirect (pin_mediatype->capture_pin,
input_pin, NULL);
input_pin->Release ();
goto error;
}
- spec->segsize = spec->rate * spec->channels;
- spec->segtotal = 1;
}
}
}
g_mutex_unlock (src->gbarray_lock);
} else {
if (src->is_running) {
- Sleep (100);
+ Sleep (GST_BASE_AUDIO_SRC(src)->ringbuffer->spec.latency_time /
+ GST_MSECOND / 10);
goto test;
}
}