• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C)  2005 Wim Taymans <wim@fluendo.com>
3  *
4  * gstalsasink.h:
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 
23 #ifndef __GST_ALSASINK_H__
24 #define __GST_ALSASINK_H__
25 
26 #include <gst/gst.h>
27 #include <gst/audio/audio.h>
28 #include <alsa/asoundlib.h>
29 
30 G_BEGIN_DECLS
31 
32 #define GST_TYPE_ALSA_SINK            (gst_alsasink_get_type())
33 #define GST_ALSA_SINK(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ALSA_SINK,GstAlsaSink))
34 #define GST_ALSA_SINK_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ALSA_SINK,GstAlsaSinkClass))
35 #define GST_IS_ALSA_SINK(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ALSA_SINK))
36 #define GST_IS_ALSA_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ALSA_SINK))
37 #define GST_ALSA_SINK_CAST(obj)       ((GstAlsaSink *) (obj))
38 
39 typedef struct _GstAlsaSink GstAlsaSink;
40 typedef struct _GstAlsaSinkClass GstAlsaSinkClass;
41 
42 #define GST_ALSA_SINK_GET_LOCK(obj)	(&GST_ALSA_SINK_CAST (obj)->alsa_lock)
43 #define GST_ALSA_SINK_LOCK(obj)	    (g_mutex_lock (GST_ALSA_SINK_GET_LOCK (obj)))
44 #define GST_ALSA_SINK_UNLOCK(obj)   (g_mutex_unlock (GST_ALSA_SINK_GET_LOCK (obj)))
45 
46 #define GST_DELAY_SINK_GET_LOCK(obj)	(&GST_ALSA_SINK_CAST (obj)->delay_lock)
47 #define GST_DELAY_SINK_LOCK(obj)	        (g_mutex_lock (GST_DELAY_SINK_GET_LOCK (obj)))
48 #define GST_DELAY_SINK_UNLOCK(obj)	(g_mutex_unlock (GST_DELAY_SINK_GET_LOCK (obj)))
49 
50 /**
51  * GstAlsaSink:
52  *
53  * Opaque data structure
54  */
55 struct _GstAlsaSink {
56   GstAudioSink    sink;
57 
58   gchar                 *device;
59 
60   snd_pcm_t             *handle;
61 
62   snd_pcm_access_t access;
63   snd_pcm_format_t format;
64   guint rate;
65   guint channels;
66   gint bpf;
67   gboolean iec958;
68   gboolean need_swap;
69 
70   guint buffer_time;
71   guint period_time;
72   snd_pcm_uframes_t buffer_size;
73   snd_pcm_uframes_t period_size;
74 
75   GstCaps *cached_caps;
76 
77   gboolean is_paused;
78   gboolean after_paused;
79   gboolean hw_support_pause;
80   snd_pcm_sframes_t pos_in_buffer;
81 
82   GMutex alsa_lock;
83   GMutex delay_lock;
84 };
85 
86 struct _GstAlsaSinkClass {
87   GstAudioSinkClass parent_class;
88 };
89 
90 GType gst_alsasink_get_type(void);
91 
92 G_END_DECLS
93 
94 #endif /* __GST_ALSASINK_H__ */
95