mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-21 09:53:47 +00:00
feacb875a4
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
79 lines
2.1 KiB
C
79 lines
2.1 KiB
C
/* GStreamer
|
|
* Copyright (C) 2014 Antonio Ospite <ao2@ao2.it>
|
|
*
|
|
* gstalsamidisrc.h: Source element for ALSA MIDI sequencer events
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifndef __GST_ALSA_MIDI_SRC_H__
|
|
#define __GST_ALSA_MIDI_SRC_H__
|
|
|
|
#include <gst/gst.h>
|
|
#include <gst/base/gstpushsrc.h>
|
|
|
|
#include <alsa/asoundlib.h>
|
|
|
|
G_BEGIN_DECLS
|
|
#define GST_TYPE_ALSA_MIDI_SRC \
|
|
(gst_alsa_midi_src_get_type())
|
|
#define GST_ALSA_MIDI_SRC(obj) \
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_MIDI_SRC,GstAlsaMidiSrc))
|
|
#define GST_ALSA_MIDI_SRC_CLASS(klass) \
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_MIDI_SRC,GstAlsaMidiSrcClass))
|
|
#define GST_IS_ALSA_MIDI_SRC(obj) \
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_MIDI_SRC))
|
|
#define GST_IS_ALSA_MIDI_SRC_CLASS(klass) \
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_MIDI_SRC))
|
|
|
|
typedef struct _GstAlsaMidiSrc GstAlsaMidiSrc;
|
|
typedef struct _GstAlsaMidiSrcClass GstAlsaMidiSrcClass;
|
|
|
|
/**
|
|
* GstAlsaMidiSrc:
|
|
*
|
|
* Opaque #GstAlsaMidiSrc data structure.
|
|
*/
|
|
struct _GstAlsaMidiSrc
|
|
{
|
|
GstPushSrc element;
|
|
|
|
gchar *ports;
|
|
|
|
/*< private > */
|
|
snd_seq_t *seq;
|
|
int queue;
|
|
int port_count;
|
|
snd_seq_addr_t *seq_ports;
|
|
snd_midi_event_t *parser;
|
|
unsigned char *buffer;
|
|
|
|
struct pollfd *pfds;
|
|
int npfds;
|
|
|
|
guint64 tick;
|
|
guint64 delay;
|
|
};
|
|
|
|
struct _GstAlsaMidiSrcClass
|
|
{
|
|
GstPushSrcClass parent_class;
|
|
};
|
|
|
|
G_GNUC_INTERNAL GType gst_alsa_midi_src_get_type (void);
|
|
|
|
G_END_DECLS
|
|
#endif /* __GST_ALSA_MIDI_SRC_H__ */
|