Commit graph

459 commits

Author SHA1 Message Date
Edward Hervey
c3875a236b alsamidisrc: Don't assume a clock has been set
Can happen in testing scenarios for example
2017-11-30 10:47:12 +01:00
Antonio Ospite
feacb875a4 alsamidisrc: Improve buffer timestamping
Make buffer timestamps more accurate and, more importantly, actually
representative of the MIDI events timing.

Previously, buffers were only sent with timetamps aligned at a 10ms
boundary which was just wrong, now the buffer timestamp represents the
real time of the MIDI event.

Conveniently, the ALSA sequencer API supports scheduling events in the
future so the sequencer infrastructure can be used to have the tick
delivered at the right time, avoiding any custom scheduling mechanism.

The ticks scheduling starts on the first transition to PLAYING, and the
delay is also calculated when the pipeline goes into PLAYING.

https://bugzilla.gnome.org/show_bug.cgi?id=787683
2017-11-29 21:13:38 -05:00
Antonio Ospite
3a64ed723a alsamidisrc: Expand snd_seq_create_simple_port() and use a queue for timestamps
Events are timestamped with a real-time value representing the time
passed since the queue timer was started.

The timestamp is not used just yet.

https://bugzilla.gnome.org/show_bug.cgi?id=787683
2017-11-29 21:13:38 -05:00
Antonio Ospite
132ead36c1 alsamidisrc: Merge prepare_buffer() and push_buffer()
The separation is not very useful since push_buffer() is the only user
of prepare_buffer().

https://bugzilla.gnome.org/show_bug.cgi?id=787683
2017-11-29 21:13:38 -05:00
Antonio Ospite
b5060f16d9 alsamidisrc: Don't set buffer offset and duration
They are not relly needed for a live source.

https://bugzilla.gnome.org/show_bug.cgi?id=787683
2017-11-29 21:13:38 -05:00
Antonio Ospite
3c5aa0a786 alsamidisrc: Fix a memory leak when setting the "ports" property
When setting the "ports" property the value is duplicated but it's not
freed when the elements stops.

Reported by Valgrind (example run with "alsamidisrc ports=128:0"):

  6 bytes in 1 blocks are definitely lost in loss record 30 of 1,911
     at 0x4C2BBEF: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
     by 0x5411528: g_malloc (gmem.c:94)
     by 0x542A9FE: g_strdup (gstrfuncs.c:363)
     by 0x775211E: gst_alsa_midi_src_set_property (gstalsamidisrc.c:284)
     by 0x5184A4D: object_set_property (gobject.c:1439)
     by 0x5184A4D: g_object_setv (gobject.c:2245)
     by 0x51859DD: g_object_set_property (gobject.c:2529)
     by 0x4F0474C: ??? (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.1203.0)
     by 0x4F065C8: ??? (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.1203.0)
     by 0x4F07557: ??? (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.1203.0)
     by 0x4EFE3EE: gst_parse_launch_full (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.1203.0)
     by 0x4EFE673: gst_parse_launchv_full (in /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0.1203.0)

https://bugzilla.gnome.org/show_bug.cgi?id=787683
2017-11-29 21:13:38 -05:00
Antonio Ospite
f671026f11 alsamidisrc: Prevent Valgrind from reporting cached config as memory leaks
See http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=MEMORY-LEAK;hb=HEAD

This allows to have cleaner Valgrind reports about alsamidisrc and make
it easier to spot actual problems.

https://bugzilla.gnome.org/show_bug.cgi?id=787683
2017-11-29 21:13:38 -05:00
Antonio Ospite
8638d81eb3 alsamidisrc: Improve a comment and remove one trailing space
https://bugzilla.gnome.org/show_bug.cgi?id=787683
2017-11-29 21:13:38 -05:00
Ponnam Srinivas
0e8a510eda alsasink: Fix Memory leak in payload not succuss case
https://bugzilla.gnome.org/show_bug.cgi?id=788114
2017-09-26 11:18:09 +03:00
Thibault Saunier
dd1e4f5ebb alsasrc: Handle newly added GstStateChange values
https://bugzilla.gnome.org/show_bug.cgi?id=783798
2017-06-20 09:19:53 -04:00
vijay
f460d7d184 alsa: Add mapping for PCM F32/F64 formats
Fix enables float pcm formats for both the alsasrc and alsasink

https://bugzilla.gnome.org/show_bug.cgi?id=782695
2017-05-17 10:33:52 -04:00
Nicolas Dufresne
e0d793f793 alsasink: Accept MPEG 1 layer 3 version 2.5
https://bugzilla.gnome.org/show_bug.cgi?id=781929
2017-05-16 15:37:16 -04:00
Nicolas Dufresne
8e6c6266d7 Remove plugin specific static build option
Static and dynamic plugins now have the same interface. The standard
--enable-static/--enable-shared toggle are sufficient.
2017-05-16 13:42:07 -04:00
Thibault Saunier
099ac9faf2 docs: Convert gtkdoc comments to markdown
Modernizing the documentation, making it simpler to read an
modify and allowing us to possibly switch to hotdoc in the
future.
2017-03-10 18:19:17 -03:00
Nirbheek Chauhan
5c4f4ac1bd Add support for Meson as alternative/parallel build system
https://github.com/mesonbuild/meson

With contributions from:

Tim-Philipp Müller <tim@centricular.com>
Jussi Pakkanen <jpakkane@gmail.com> (original port)

Highlights of the features provided are:
* Faster builds on Linux (~40-50% faster)
* The ability to build with MSVC on Windows
* Generate Visual Studio project files
* Generate XCode project files
* Much faster builds on Windows (on-par with Linux)
* Seriously fast configure and building on embedded

... and many more. For more details see:

http://blog.nirbheek.in/2016/05/gstreamer-and-meson-new-hope.html
http://blog.nirbheek.in/2016/07/building-and-developing-gstreamer-using.html

Building with Meson should work on both Linux and Windows, but may
need a few more tweaks on other operating systems.
2016-08-20 11:09:51 +01:00
Jan Schmidt
614ddaa739 alsasink: Remove unused hwparam/swparam pointers
The ALSA params structures aren't kept. The pointers
aren't used anywhere, so remove them from the struct.
2016-07-15 22:51:35 +10:00
Guillaume Desmottes
6e7fa6659f alsa: properly convert position-less channels from ALSA
The only way for ALSA to expose a position-less multi channels is to
return an array full of SND_CHMAP_MONO. Converting this to a
GST_AUDIO_CHANNEL_POSITION_MONO array would be invalid as
GST_AUDIO_CHANNEL_POSITION_MONO is meant to be used only with one
channel.

Fix this by using GST_AUDIO_CHANNEL_POSITION_NONE which is meant to be
used for position-less channels.

https://bugzilla.gnome.org/show_bug.cgi?id=763799
2016-04-12 14:48:30 -04:00
Guillaume Desmottes
eef7312169 alsa: add some debugging output to alsa_detect_channels_mapping()
https://bugzilla.gnome.org/show_bug.cgi?id=763985
2016-04-12 14:48:30 -04:00
Guillaume Desmottes
d9268a50f1 alsa: factor out alsa_detect_channels_mapping()
This code was duplicated in alsasrc and alsasink.

https://bugzilla.gnome.org/show_bug.cgi?id=763985
2016-04-12 14:34:13 -04:00
Guillaume Desmottes
592b87a463 alsa: coding style fix
Was using tabs instead of spaces.

https://bugzilla.gnome.org/show_bug.cgi?id=763985
2016-04-12 14:34:13 -04:00
Vineeth TM
44b70ca3a1 base: use new gst_element_class_add_static_pad_template()
https://bugzilla.gnome.org/show_bug.cgi?id=763075
2016-03-24 14:25:41 +02:00
Arun Raghavan
af091928f3 alsa: Trivial doc update
alsasink now does more than just raw audio.
2016-01-25 18:31:17 +05:30
Nicolas Dufresne
e7a59d2e08 Revert "alsasrc: Disable HW timestamp"
This reverts commit 3642e9a391.
2015-12-14 13:59:02 -05:00
Nicolas Dufresne
3642e9a391 alsasrc: Disable HW timestamp
This is a workaround for broken pulse module.
2015-12-14 13:39:02 -05:00
Sebastian Dröge
4fe12c1b09 alsa: Use 8 bit pointer type for byte-based pointer arithmetic
Usually these loops only run once, so there's no problem here. But sometimes
they run twice, and by adding the number of bytes to a 16 bit pointer type we
would advance twice as much as we should.

Also use snd_pcm_frames_to_bytes() in alsasrc to calculate
the number of bytes to skip, same as we do in alsasink.

Thanks to Lucio A. Hernandez <lucio.a.hernandez@gmail.com> for reporting.
2015-10-14 00:33:49 +03:00
Antonio Ospite
2c7ed42292 midi: add an ALSA MIDI sequencer source
The alsamidisrc element allows to get input event from ALSA MIDI
sequencer devices, and possibly convert them to sound using some
downstream element like fluiddec.

Fixes #738687
2015-10-01 21:43:21 +02:00
Carlos Rafael Giani
8f339c0932 alsa: report recoverable device failures to base class
This gives custom slave methods in the base class a chance to
resynchronize themselves

Signed-off-by: Carlos Rafael Giani <dv@pseudoterminal.org>

https://bugzilla.gnome.org/show_bug.cgi?id=708362
2015-06-09 21:51:05 +10:00
Tim-Philipp Müller
ec5c93f169 docs: update element example pipelines
- gst-launch -> gst-launch-1.0
- use autoaudiosink and audiovideosink more often
- review pipeline examples and descriptions
2015-05-10 11:38:19 +01:00
Sebastian Dröge
69e338d7dd alsa: Constify channel position table 2015-01-21 09:42:35 +01:00
Sebastian Dröge
8e6fb92886 alsa: Fix indention 2015-01-21 09:42:35 +01:00
Thomas Roos
485ad66a11 alsa: Allow to use 8 bit samples with ALSA
8 bit samples have no (0) as endianness, not the native endianness.

https://bugzilla.gnome.org/show_bug.cgi?id=739446
2015-01-21 09:42:35 +01:00
Thomas Klausner
a4b94e6c69 alsa: Use EPIPE instead of ESTRPIPE if the latter does not exist
NetBSD does not have ESTRPIPE.

https://bugzilla.gnome.org/show_bug.cgi?id=740952
2014-12-01 09:51:12 +01:00
Sebastian Dröge
90eb93c2ef Don't compare booleans for equality to TRUE and FALSE
TRUE is 1, but every other non-zero value is also considered true. Comparing
for equality with TRUE would only consider 1 but not the others.
2014-12-01 09:51:12 +01:00
Tim-Philipp Müller
b6d49d2a12 alsasrc: debug message fixes
In the same vein as 74e9640a.
2014-11-25 22:01:08 +00:00
Branislav Katreniak
5e8e6276cd alsa: Change the log messages in xrun_recovery() from DEBUG to WARNING
xrun_recovery() runs when there is an error

https://bugzilla.gnome.org/show_bug.cgi?id=740615
2014-11-24 15:30:32 +00:00
Vincent Penquerc'h
b444d8ba97 alsasink: make gst-ident happy 2014-06-03 15:17:20 +01:00
Vincent Penquerc'h
3b2d583373 alsasink: fix occasional crash intersecting invalid values
When a pipeline using alsasink and push mode upstream fails
to preroll, the following state will be the case:
- A loop upstream will be PAUSED, pushing a first buffer
- alsasink will be READY, pending PAUSED, because async

On error, the pipeline will switch to NULL. alsasink is in
READY, so goes to NULL immediately. It zeroes its cached
caps. Meanwhile, the upstream loop can cause a caps query,
conccurent with the state change. This will use those cached
caps. If the zeroing happens between the NULL test and the
dereferencing, GStreamer will critical down in the GstValue
code.

Since it appears that such a gap between states (PAUSED
and pushing upstream, and NULL downstream) is expected, we
need to protect the read/write access to the cached caps.

This fixes the critical.

See https://bugzilla.gnome.org/show_bug.cgi?id=731121
2014-06-03 15:17:20 +01:00
Vincent Penquerc'h
74e9640a22 alsasink: pass correct error to g_strerror
The error we get is a negated errno.

While there, fix a couple typos in messages.
2014-05-19 13:57:41 +01:00
Tim-Philipp Müller
bcb8068e27 docs: remove outdated and pointless 'Last reviewed' lines from docs
They are very confusing for people, and more often than not
also just not very accurate. Seeing 'last reviewed: 2005' in
your docs is not very confidence-inspiring. Let's just remove
those comments.
2014-04-26 23:28:57 +01:00
Sebastian Dröge
d3e0381d3d alsa: Make clang happy with our g_strdup_vprintf() wrapper 2014-02-08 17:01:38 +01:00
Takashi Iwai
76d807893c alsa: Add channel map API support
The initial support for the new ALSA chmap API.
Just translate the current chmap to GstAudioChannelPosition during the
setup.  No function to specify the channel map manually yet, so still
impossible to assign any non-standard positions or to configure in a
different order even if the hardware allows.

https://bugzilla.gnome.org/show_bug.cgi?id=709755
2013-10-09 19:05:53 +02:00
Sebastian Dröge
4180581ce9 alsasrc: Dump some more debug output about the device configuration 2013-05-29 16:41:14 +02:00
Sebastian Dröge
639e2d4346 alsasink: Update internal buffer/period times with the values that were configured on the device 2013-05-29 16:41:06 +02:00
Alexander Schrab
a049b102da alsasrc: Make using driver timestamps possible
https://bugzilla.gnome.org/show_bug.cgi?id=699744
2013-05-20 11:25:17 +02:00
Sebastian Dröge
0bc25f0325 alsa: Dump min/max period time and buffer time in alsasrc too 2013-05-20 11:23:06 +02:00
Sebastian Dröge
948a4a3632 gst: Add better support for static plugins 2013-04-15 15:52:58 +02:00
yanghuolin
67a7b5a993 alsasink: don't use 100% CPU
The root cause is that alsa-lib is not thread safe for the same handle.
There are two threads in the gstreamer accessing alsa-lib not serilized.
The race condition happens when one thread holds the old framebuffer app_ptr
position in the kernel, another thread advances the framebuffer app_ptr.
when the former thread is scheduled to run again, it overwrites the app_ptr
to old value by copying from kernel.Thus,the app_ptr in the upper
alsa-lib(pcm_rate) become one period size more advanced than the lower
alsa-lib(pcm_hw & kernel).

gstreamer uses noblock and poll method to communicate with the alsa-lib.
The app_ptr unsync situation as described above makes the poll return immediately because
it concludes there is enough space for the ring-buffer via the low-level alsa-lib.
The write function returns immediately because it concludes there is not enough
space for the ring-buffer from the upper-level alsa-lib. Then the loop of poll
and write runs again and again until another period size is available for
ring-buffer.This leads to the cpu 100 problem.

delay_lock  is used to avoid the race condition.

Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=690937
2013-01-24 15:08:31 +01:00
Tim-Philipp Müller
df6031f7c6 alsasrc: return negative value on read error
Otherwise baseaudiosrc won't go into the error code path.

https://bugzilla.gnome.org/show_bug.cgi?id=690197
2012-12-17 20:50:33 +00:00
Tim-Philipp Müller
3d5a78e67a alsa: post error message when audio device disappears
Don't loop forever if an USB audio device gets disconnected
while in use. Post an error message instead. This is not
enough yet though, we still need to make the base class
and/or the ring buffer bail out.

https://bugzilla.gnome.org/show_bug.cgi?id=690197
2012-12-16 01:00:43 +00:00
Sebastian Dröge
d9b25afe71 ext: Fix some compilation errors caused by circular header includes 2012-12-12 17:22:31 +00:00