109 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			109 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /* vim: set filetype=c: */
 | |
| % ClassName
 | |
| GstAudioSink
 | |
| % TYPE_CLASS_NAME
 | |
| GST_TYPE_AUDIO_SINK
 | |
| % pads
 | |
| sinkpad-audio
 | |
| % pkg-config
 | |
| gstreamer-audio-1.0
 | |
| % includes
 | |
| #include <gst/audio/gstaudiosink.h>
 | |
| % prototypes
 | |
| static gboolean gst_replace_open (GstAudioSink * sink);
 | |
| static gboolean gst_replace_prepare (GstAudioSink * sink,
 | |
|     GstAudioRingBufferSpec * spec);
 | |
| static gboolean gst_replace_unprepare (GstAudioSink * sink);
 | |
| static gboolean gst_replace_close (GstAudioSink * sink);
 | |
| static gint gst_replace_write (GstAudioSink * sink, gpointer data,
 | |
|     guint length);
 | |
| static guint gst_replace_delay (GstAudioSink * sink);
 | |
| static void gst_replace_reset (GstAudioSink * sink);
 | |
| % declare-class
 | |
|   GstAudioSinkClass *audio_sink_class = GST_AUDIO_SINK_CLASS (klass);
 | |
| % set-methods
 | |
|   audio_sink_class->open = GST_DEBUG_FUNCPTR (gst_replace_open);
 | |
|   audio_sink_class->prepare = GST_DEBUG_FUNCPTR (gst_replace_prepare);
 | |
|   audio_sink_class->unprepare = GST_DEBUG_FUNCPTR (gst_replace_unprepare);
 | |
|   audio_sink_class->close = GST_DEBUG_FUNCPTR (gst_replace_close);
 | |
|   audio_sink_class->write = GST_DEBUG_FUNCPTR (gst_replace_write);
 | |
|   audio_sink_class->delay = GST_DEBUG_FUNCPTR (gst_replace_delay);
 | |
|   audio_sink_class->reset = GST_DEBUG_FUNCPTR (gst_replace_reset);
 | |
| % methods
 | |
| /* open the device with given specs */
 | |
| static gboolean
 | |
| gst_replace_open (GstAudioSink * sink)
 | |
| {
 | |
|   GstReplace *replace = GST_REPLACE (sink);
 | |
| 
 | |
|   GST_DEBUG_OBJECT (replace, "open");
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| /* prepare resources and state to operate with the given specs */
 | |
| static gboolean
 | |
| gst_replace_prepare (GstAudioSink * sink, GstAudioRingBufferSpec * spec)
 | |
| {
 | |
|   GstReplace *replace = GST_REPLACE (sink);
 | |
| 
 | |
|   GST_DEBUG_OBJECT (replace, "prepare");
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| /* undo anything that was done in prepare() */
 | |
| static gboolean
 | |
| gst_replace_unprepare (GstAudioSink * sink)
 | |
| {
 | |
|   GstReplace *replace = GST_REPLACE (sink);
 | |
| 
 | |
|   GST_DEBUG_OBJECT (replace, "unprepare");
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| /* close the device */
 | |
| static gboolean
 | |
| gst_replace_close (GstAudioSink * sink)
 | |
| {
 | |
|   GstReplace *replace = GST_REPLACE (sink);
 | |
| 
 | |
|   GST_DEBUG_OBJECT (replace, "close");
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| /* write samples to the device */
 | |
| static gint
 | |
| gst_replace_write (GstAudioSink * sink, gpointer data, guint length)
 | |
| {
 | |
|   GstReplace *replace = GST_REPLACE (sink);
 | |
| 
 | |
|   GST_DEBUG_OBJECT (replace, "write");
 | |
| 
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| /* get number of samples queued in the device */
 | |
| static guint
 | |
| gst_replace_delay (GstAudioSink * sink)
 | |
| {
 | |
|   GstReplace *replace = GST_REPLACE (sink);
 | |
| 
 | |
|   GST_DEBUG_OBJECT (replace, "delay");
 | |
| 
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| /* reset the audio device, unblock from a write */
 | |
| static void
 | |
| gst_replace_reset (GstAudioSink * sink)
 | |
| {
 | |
|   GstReplace *replace = GST_REPLACE (sink);
 | |
| 
 | |
|   GST_DEBUG_OBJECT (replace, "reset");
 | |
| 
 | |
| }
 | |
| % end
 |