Commit graph

1489 commits

Author SHA1 Message Date
Peter Seiderer
c88e042458 v4l2object: reuse caps framerate if not overwritten by v4l2 device
Enables duration setting in v4l2src.

https://bugzilla.gnome.org/show_bug.cgi?id=740403
2015-01-22 18:52:44 -05:00
Nicolas Dufresne
f3f4bdd676 v4l2videodec: Proxy getcaps
Replace the sink_query with new getcaps() virtual and use the proxy
helper with the probed caps. This allow upstream element taking decision
base on what is supported downstream.
2015-01-13 16:55:43 -05:00
Sebastian Dröge
81e15d22c0 osxvideosink: Disable hack for NSApp iteration with a special #define
The hack causes deadlocks and other interesting problems and it really
can only be fixed properly inside GLib. We will include a patch for
GLib in our builds for now that handles this, and hopefully at some
point GLib will also merge a proper solution.

A proper solution would first require to refactor the polling in
GMainContext to only provide a single fd, e.g. via epoll/kqueue
or a thread like the one added by our patch. Then this single
fd could be retrieved from the GMainContext and directly integrated
into a NSRunLoop.

https://bugzilla.gnome.org/show_bug.cgi?id=741450
https://bugzilla.gnome.org/show_bug.cgi?id=704374
2015-01-10 15:54:22 +01:00
Nicolas Dufresne
5c67ba7f88 v4l2videodec: Prevent renegotiation
Renegotiation isn't supported, simply prevent it the way we do in
v4l2src.
2015-01-09 16:59:53 -05:00
Nicolas Dufresne
c4aaff5c92 v4l2videodec: Don't unlock the stream lock twice 2015-01-09 16:55:55 -05:00
Nicolas Dufresne
f7c682f802 v4l2allocator: Add protection against driver bug
v4l2loopback driver has a this nasty bug that if the queue is larger
then 2 buffers, it returns random index on dqbuf. So far we assumed
that the index was always right, which would lead to memory being
unref twice, and eventually crash.
2015-01-08 23:55:28 -05:00
Nicolas Dufresne
3e876215b7 v4l2: Don't use allocator size to iterate
As the buffer array is fixed size and small, it's safer to simply
use this static size to cleanup the buffers. This is also more
consistent with the rest. The associated method is no longer
required and can be dropped.
2015-01-08 23:55:28 -05:00
Nicolas Dufresne
e47a5708f0 v4l2bufferpool: Don't clean buffer array in dispose
This should already have been done, plus this code is incorrect
and may lead to crash.

https://bugzilla.gnome.org/show_bug.cgi?id=742074
2015-01-08 23:55:28 -05:00
Nicolas Dufresne
bbcfd594e4 v4l2bufferpool: Don't ref queued output buffer
This partly revert to the old 1.2 behavior. Instead of keeping a
reference to the output buffer queued, we simply release them but
don't forward it to GstBufferPool. This way, the buffer pool don't
need to be flushed to be stopped.

https://bugzilla.gnome.org/show_bug.cgi?id=742074
2015-01-08 23:55:28 -05:00
Nicolas Dufresne
a4b961e275 v4l2bufferpool: Never fail on streamoff
Failing streamoff prevents allocator from being disposed hence
lead to device FD leak. There is no known cases where streamoff
may fails for which we'd still be streaming. streamoff is known
to fail when a device is being unplugged (in which case errno
19/ENODEV is set).

https://bugzilla.gnome.org/show_bug.cgi?id=732734
2015-01-08 11:37:23 -05:00
Sebastian Dröge
11d6be2dcb osxaudio: Directly return the ringbuffer's caps if it is acquired 2014-12-22 15:33:51 +01:00
Sebastian Dröge
fc1670b75d osxaudio: Put all audio formats into the template caps
We report the proper caps later from the get_caps() vfunc implementation after
probing the selected device.
2014-12-22 12:56:19 +01:00
Sebastian Dröge
b83cd14a12 osxaudio: Also set the big endian flag for floating point samples 2014-12-22 12:56:05 +01:00
Sebastian Dröge
e7b10a107d osxaudio: Fix deadlock and property change notification in device selection code
After creating the ringbuffer we have to set the device on the ringbuffer as
it defaults to kAudioDeviceUnknown. At this point it can't have changed to
anything else yet and we don't have to notify about changes to the sink/src
"device" property. It's also not a good idea because GstAudioBaseSrc has the
object lock taken while the ringbuffer is created, which might cause a
deadlock if something calls back into the element from "notify::device".

Once the base class is done with the NULL_TO_READY state change, it has opened
the device via the ringbuffer and this might have chosen a different device.
Especially if we initially used kAudioDeviceUnknown. Also notify about this
property change as initially intended by this code.
2014-12-22 10:29:01 +01:00
Nicolas Dufresne
2a1459c88f v4l2pool: Update configuration size
We already update our copy of VideoInfo.size to proper size, now also
the configuration so the size matches on release.

https://bugzilla.gnome.org/show_bug.cgi?id=741420
2014-12-19 12:32:06 -05:00
Nicolas Dufresne
f6259e96c7 v4l2bufferpool: Disable create_buf with libv4l2
Libv4l2 does not work with CREATE_BUFS. Instead of failing on random
error caused by libv4l2, disable CREATE_BUFS when an emulated format is
detected.
2014-12-16 15:00:22 -05:00
Nicolas Dufresne
1fe4a19dc2 v4l2allocator: Add protection against broken libv4l2
It looks like libv4l2 support for CREATE_BUF is incomplete. That
combine with existing bugs may lead to crash in GStreamer. These
check will make it robust by:

- Checking create buf index isn't an already in used index
- Checking that the index out of QUERYBUF matches the requested
  index
2014-12-16 13:42:22 -05:00
Wim Taymans
0b881ab2ce osxvideosink: clear rectangle structures before use 2014-12-16 13:25:01 +01:00
Nicolas Dufresne
3dae65ede8 v4l2object: Always set format
Right now we try to be clever by detecting if device format have
changed or not, and skip setting format in this case. This is valid
behaviour with V4L2, but it's also very error prone. The rational
for not setting these all the time is for speed, though I can't
measure any noticeable gain on any HW I own. Also, until recently,
we where doing get/set on the format for each format we where
probing, making it near to impossible that the format would match.
This also fixes bug where we where skipping frame-rate setting if
format didn't change.

https://bugzilla.gnome.org/show_bug.cgi?id=740636
2014-12-15 18:38:00 -05:00
Arun Raghavan
db91486aa8 osxaudiosink: Prefer filter caps order while getting caps
https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:22:44 +05:30
Arun Raghavan
f573f028d2 osxaudiosink: Add some error handling around channel layout parsing
For now we just spit a warning and ignore the channel layout if we can't
support it.

https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:19:52 +05:30
Arun Raghavan
d18a6b0a2c osxaudio: Take lock around sink/source before accessing the ringbuffer
https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:19:52 +05:30
Arun Raghavan
4a58ebf487 osxaudiosrc: Probe channel layout too
https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:19:52 +05:30
Arun Raghavan
df610a7c18 osxaudiosink: Only fix up channels/layout for PCM caps while probing
It's unlikely that setting a channel layout will do much for AC3/DTS
streams. If we find at some point that it does make sense, we can
perform the structure copying unconditionally (i.e., the current code is
wrong, since AC3/DTS will get two structures now - one with the channel
layout, one without).

https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:19:52 +05:30
Arun Raghavan
bd1502862c osxaudiosrc: Implement caps probing
https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:19:52 +05:30
Arun Raghavan
48872dbc56 osxaudio: Bind audio device to audio unit early
We want to bind the device during open so that subsequent format queries
on the audio unit are as specific as possible from that point onwards.

https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:19:52 +05:30
Arun Raghavan
2d0391c6e1 osxaudiosink: Fix up caps querying a bit
This should make caps queries correct in PAUSED and higher as well.

https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:19:51 +05:30
Arun Raghavan
f967f0742f osxaudio: Move osxaudiosrc-specific code out of the generic path
Avoids one layering violation (GstCoreAudio referring to
GstOsxAudioSrc).

https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:19:51 +05:30
Arun Raghavan
ffcb1577fa osxaudio: Clean up a GstCoreAudio -> GstOsxAudioSrc/Sink reference
Now that device selection has no sink/source-specific bits, we can have
generic device selection for this path. We do need to now track state
changes so we can look up the final device_id once the device is open,
though.

https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:19:51 +05:30
Arun Raghavan
5c2f041286 osxaudiosink: Move device caps probing to get_caps()
This should be preferred to running the probe at device open time.

https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:19:51 +05:30
Arun Raghavan
945aaa0a35 osxaudio: Make some debug code compile conditionally
https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:19:51 +05:30
Arun Raghavan
b06ae28061 osxaudio: Move device selection to ringbuffer->open_device()
This is conceptually the right thing to do, and allows us to correctly
catch errors in device selection as well, which we could not do while
creating the ringbuffer.

https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:19:51 +05:30
Arun Raghavan
199461bb2e osxaudio: Consolidate input and output code paths a bit
https://bugzilla.gnome.org/show_bug.cgi?id=740987
2014-12-15 11:19:51 +05:30
Aurélien Zanelli
62193129c5 v4l2bufferpool: set buffer interlace flags when field is V4L2_FIELD_INTERLACED
If v4l2_buffer.field is V4L2_FIELD_INTERLACED, we set corresponding
GstVideoBuffer flags depending on the video standard.
According to V4L2 specification, M/NTSC transmits the bottom field
first, all other standards the top field first.

https://bugzilla.gnome.org/show_bug.cgi?id=737603
2014-12-09 11:00:28 -05:00
Nicolas Dufresne
eb1dcd841a v4l2: Workaround libv4l2 RW emulation bug
When libv4l2 emulates RW mode on top of MMAP devices, the queues are
only initialized on first read. The problem is that poll() will fail
if called before the queues are initialized and streaming. Workaround
this by doing a zero size read when pool is started in that IO mode.

https://bugzilla.gnome.org/show_bug.cgi?id=740633
2014-12-07 17:43:01 -05:00
Nicolas Dufresne
0e05faf91a v4l2: Fix RW io mode
In RW, allocator can be null, max_buffers can be zero, and we need not
to wait while the queue is empty since there is no queue.

https://bugzilla.gnome.org/show_bug.cgi?id=740633
2014-12-07 17:42:48 -05:00
Nicolas Dufresne
d328eea5f2 v4l2bufferpool: Cleanup uneeded check and cases
There is nothing in between the break and the "done:" anymore, plus
USERPTR and DMABUF_IMPORT case is exactly the same.
2014-12-04 17:00:25 -05:00
Nicolas Dufresne
319efc3e20 v4l2pool: Fix CREATE_BUFS support for capture
This patch fixes CREATE_BUFS support for capture devices. Initially we
would only try and allocate more buffers when the copy threshold
is reached. When the threshold was not set (needed) it would never
happen. Another problem is that on capture side, acquire returns
filled buffer, hence need to pool. We need to set a special flag to
force allocation to happen.

https://bugzilla.gnome.org/show_bug.cgi?id=741134
2014-12-04 17:00:25 -05:00
Nicolas Dufresne
b80edd2ee2 v4l2allocator: Fix CREATE_BUF probing
Current for every memory type we where probing MMAP CREATE_BUFS ioct.

https://bugzilla.gnome.org/show_bug.cgi?id=741134
2014-12-04 17:00:25 -05:00
Aurélien Zanelli
114b84c1a3 v4l2allocator: fix gst_v4l2_allocator_stop prototype
gst_v4l2_allocator_stop returns a GstV4l2Return, not a gboolean.

https://bugzilla.gnome.org/show_bug.cgi?id=739792
2014-12-01 10:08:54 -05:00
Aurélien Zanelli
74eb903727 v4l2bufferpool: unref pool when v4l2_allocator_new() fails
https://bugzilla.gnome.org/show_bug.cgi?id=739791
2014-12-01 10:08:40 -05:00
Nicolas Dufresne
cfa5a9d938 v4l2: Remove last include to linux/videodev2.h
We now use and update our internal copy so we no longer have to ifdef
the entire code for features and defines that where added over the
years.

https://bugzilla.gnome.org/show_bug.cgi?id=740905
2014-11-30 17:55:19 -05:00
Nicolas Dufresne
ea4d9745e4 Revert "v4l2allocator: Remove unused variable"
This reverts commit ad4480d534.
2014-11-24 10:36:54 -05:00
Nicolas Dufresne
43d5a523f1 Revert "v4l2: move vb_queue probing from allocator to v4l2object"
This reverts commit ec6b8b84af.
2014-11-24 10:36:30 -05:00
Nicolas Dufresne
3591a91067 Revert "v4l2object: allow to automatic selection of dmabuf"
This reverts commit e6c2ad5571.
2014-11-24 10:33:29 -05:00
Nicolas Dufresne
ad4480d534 v4l2allocator: Remove unused variable
this was introduced by commit ec6b8b

https://bugzilla.gnome.org/show_bug.cgi?id=699382
2014-11-21 11:44:24 -05:00
Nicolas Dufresne
b9992e4347 v4l2: Handle corrupted buffer with empty payload
This allow skipping buffer flagged with ERROR that has no payload.
This is typical behaviour when a recovererable error occured during
capture in the driver, but that no valid data was ever written into that
buffer. This patch also translate V4L2_BUF_FLAG_ERROR into
GST_BUFFER_FLAG_CORRUPTED. Hence decoding error produce
by decoder due to missing frames will now be correctly marked. Finally,
this fixes a buffer leak when EOS is reached.

https://bugzilla.gnome.org/show_bug.cgi?id=740040
2014-11-21 11:29:19 -05:00
Benjamin Gaignard
e6c2ad5571 v4l2object: allow to automatic selection of dmabuf
If the v4l2 queue support dmabuf select this buffer pool mode
and update the query with allocator.
This patch only concern exporting dmabuf and not importing dmabuf
fd from downstream element.

https://bugzilla.gnome.org/show_bug.cgi?id=699382
2014-11-21 11:29:04 -05:00
Benjamin Gaignard
ec6b8b84af v4l2: move vb_queue probing from allocator to v4l2object
The goal is to make those information available in v4l2_object
to be able later to select the best allocation method for the pool

https://bugzilla.gnome.org/show_bug.cgi?id=699382
2014-11-21 11:28:18 -05:00
Aurélien Zanelli
36532f5070 v4l2allocator: fix error message if allocator is already active
https://bugzilla.gnome.org/show_bug.cgi?id=739789
2014-11-07 10:42:40 -05:00