gstalsasink.h 2.77 KB
Newer Older
1 2 3
/* GStreamer
 * Copyright (C)  2005 Wim Taymans <wim@fluendo.com>
 *
Axel Mårtensson's avatar
Axel Mårtensson committed
4
 * gstalsasink.h:
5 6 7 8 9 10 11 12
 *
 * 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
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 15 16
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
17
 * License along with this library; if not, write to the
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
18 19
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
20 21 22
 */


23 24 25 26
#ifndef __GST_ALSASINK_H__
#define __GST_ALSASINK_H__

#include <gst/gst.h>
27
#include <gst/audio/audio.h>
28
#include <alsa/asoundlib.h>
29

30
G_BEGIN_DECLS
Johan Dahlin's avatar
Johan Dahlin committed
31

32 33 34 35 36 37
#define GST_TYPE_ALSA_SINK            (gst_alsasink_get_type())
#define GST_ALSA_SINK(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_SINK,GstAlsaSink))
#define GST_ALSA_SINK_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_SINK,GstAlsaSinkClass))
#define GST_IS_ALSA_SINK(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_SINK))
#define GST_IS_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_SINK))
#define GST_ALSA_SINK_CAST(obj)       ((GstAlsaSink *) (obj))
Johan Dahlin's avatar
Johan Dahlin committed
38

39 40 41
typedef struct _GstAlsaSink GstAlsaSink;
typedef struct _GstAlsaSinkClass GstAlsaSinkClass;

42 43 44
#define GST_ALSA_SINK_GET_LOCK(obj)	(&GST_ALSA_SINK_CAST (obj)->alsa_lock)
#define GST_ALSA_SINK_LOCK(obj)	    (g_mutex_lock (GST_ALSA_SINK_GET_LOCK (obj)))
#define GST_ALSA_SINK_UNLOCK(obj)   (g_mutex_unlock (GST_ALSA_SINK_GET_LOCK (obj)))
45

yanghuolin's avatar
yanghuolin committed
46 47 48 49
#define GST_DELAY_SINK_GET_LOCK(obj)	(&GST_ALSA_SINK_CAST (obj)->delay_lock)
#define GST_DELAY_SINK_LOCK(obj)	        (g_mutex_lock (GST_DELAY_SINK_GET_LOCK (obj)))
#define GST_DELAY_SINK_UNLOCK(obj)	(g_mutex_unlock (GST_DELAY_SINK_GET_LOCK (obj)))

Wim Taymans's avatar
Wim Taymans committed
50 51 52 53 54
/**
 * GstAlsaSink:
 *
 * Opaque data structure
 */
Johan Dahlin's avatar
Johan Dahlin committed
55
struct _GstAlsaSink {
56 57
  GstAudioSink    sink;

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
58
  gchar                 *device;
59

Thomas Vander Stichele's avatar
Thomas Vander Stichele committed
60
  snd_pcm_t             *handle;
61 62 63 64 65

  snd_pcm_access_t access;
  snd_pcm_format_t format;
  guint rate;
  guint channels;
Wim Taymans's avatar
Wim Taymans committed
66
  gint bpf;
67 68
  gboolean iec958;
  gboolean need_swap;
69 70 71

  guint buffer_time;
  guint period_time;
72 73
  snd_pcm_uframes_t buffer_size;
  snd_pcm_uframes_t period_size;
74

75 76
  GstCaps *cached_caps;

Axel Mårtensson's avatar
Axel Mårtensson committed
77 78 79 80 81
  gboolean is_paused;
  gboolean after_paused;
  gboolean hw_support_pause;
  snd_pcm_sframes_t pos_in_buffer;

82
  GMutex alsa_lock;
yanghuolin's avatar
yanghuolin committed
83
  GMutex delay_lock;
84 85
};

Johan Dahlin's avatar
Johan Dahlin committed
86
struct _GstAlsaSinkClass {
87
  GstAudioSinkClass parent_class;
88 89
};

90
GType gst_alsasink_get_type(void);
91 92

G_END_DECLS
Johan Dahlin's avatar
Johan Dahlin committed
93

94
#endif /* __GST_ALSASINK_H__ */