2002-02-03 20:04:07 +00:00
|
|
|
/* GStreamer
|
2005-05-10 20:10:43 +00:00
|
|
|
* Copyright (C) <2005> Arwed v. Merkatz <v.merkatz@gmx.net>
|
|
|
|
*
|
|
|
|
* Roughly based on the gstreamer 0.8 esdsink plugin:
|
2001-12-20 23:13:50 +00:00
|
|
|
* Copyright (C) <2001> Richard Boulton <richard-gst@tartarus.org>
|
|
|
|
*
|
2005-05-10 20:10:43 +00:00
|
|
|
* esdsink.c: an EsounD audio sink
|
2001-12-20 23:13:50 +00:00
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2006-04-18 14:15:33 +00:00
|
|
|
|
2001-12-20 23:13:50 +00:00
|
|
|
#include "esdsink.h"
|
|
|
|
#include <esd.h>
|
2003-06-29 19:46:12 +00:00
|
|
|
#include <unistd.h>
|
2003-07-17 08:08:09 +00:00
|
|
|
#include <errno.h>
|
2001-12-20 23:13:50 +00:00
|
|
|
|
2006-04-18 14:15:33 +00:00
|
|
|
#include <gst/gst-i18n-plugin.h>
|
|
|
|
|
2006-04-26 17:37:10 +00:00
|
|
|
/* wtay: from my esd.h (debian unstable libesd0-dev 0.2.36-3) */
|
|
|
|
#ifndef ESD_MAX_WRITE_SIZE
|
|
|
|
#define ESD_MAX_WRITE_SIZE (21 * 4096)
|
|
|
|
#endif
|
|
|
|
|
2004-01-23 15:34:50 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (esd_debug);
|
2004-01-23 15:37:12 +00:00
|
|
|
#define GST_CAT_DEFAULT esd_debug
|
2004-01-23 15:34:50 +00:00
|
|
|
|
2001-12-20 23:13:50 +00:00
|
|
|
/* elementfactory information */
|
Define GstElementDetails as const and also static (when defined as global)
Original commit message from CVS:
* ext/aalib/gstaasink.c:
* ext/annodex/gstcmmldec.c:
* ext/annodex/gstcmmlenc.c:
* ext/cairo/gsttextoverlay.c:
* ext/cairo/gsttimeoverlay.c:
* ext/cdio/gstcdiocddasrc.c:
* ext/dv/gstdvdec.c:
* ext/dv/gstdvdemux.c:
* ext/esd/esdmon.c:
* ext/esd/esdsink.c:
* ext/flac/gstflacenc.c:
* ext/flac/gstflactag.c:
* ext/gconf/gstgconfaudiosink.c: (gst_gconf_audio_sink_base_init):
* ext/gconf/gstgconfaudiosrc.c: (gst_gconf_audio_src_base_init):
* ext/gconf/gstgconfvideosink.c: (gst_gconf_video_sink_base_init):
* ext/gconf/gstgconfvideosrc.c: (gst_gconf_video_src_base_init):
* ext/gdk_pixbuf/pixbufscale.c:
* ext/hal/gsthalaudiosink.c: (gst_hal_audio_sink_base_init):
* ext/hal/gsthalaudiosrc.c: (gst_hal_audio_src_base_init):
* ext/jpeg/gstjpegdec.c:
* ext/jpeg/gstjpegenc.c:
* ext/jpeg/gstsmokedec.c:
* ext/jpeg/gstsmokeenc.c:
* ext/libcaca/gstcacasink.c:
* ext/libmng/gstmngdec.c:
* ext/libmng/gstmngenc.c:
* ext/libpng/gstpngdec.c:
* ext/libpng/gstpngenc.c:
* ext/mikmod/gstmikmod.c:
* ext/raw1394/gstdv1394src.c:
* ext/shout2/gstshout2.c: (gst_shout2send_init):
* ext/shout2/gstshout2.h:
* ext/speex/gstspeexdec.c:
* ext/speex/gstspeexenc.c:
* gst/alpha/gstalpha.c:
* gst/alpha/gstalphacolor.c:
* gst/apetag/gstapedemux.c:
* gst/auparse/gstauparse.c:
* gst/autodetect/gstautoaudiosink.c:
(gst_auto_audio_sink_base_init):
* gst/autodetect/gstautovideosink.c:
(gst_auto_video_sink_base_init):
* gst/avi/gstavidemux.c: (gst_avi_demux_base_init):
* gst/avi/gstavimux.c: (gst_avimux_base_init):
* gst/cutter/gstcutter.c:
* gst/debug/breakmydata.c:
* gst/debug/efence.c:
* gst/debug/gstnavigationtest.c:
* gst/debug/gstnavseek.c:
* gst/debug/negotiation.c:
* gst/debug/progressreport.c:
* gst/debug/testplugin.c:
* gst/effectv/gstaging.c:
* gst/effectv/gstdice.c:
* gst/effectv/gstedge.c:
* gst/effectv/gstquark.c:
* gst/effectv/gstrev.c:
* gst/effectv/gstshagadelic.c:
* gst/effectv/gstvertigo.c:
* gst/effectv/gstwarp.c:
* gst/flx/gstflxdec.c:
* gst/goom/gstgoom.c:
* gst/icydemux/gsticydemux.c:
* gst/id3demux/gstid3demux.c:
* gst/interleave/deinterleave.c:
* gst/interleave/interleave.c:
* gst/law/alaw-decode.c: (gst_alawdec_base_init):
* gst/law/alaw-encode.c: (gst_alawenc_base_init):
* gst/law/mulaw-decode.c: (gst_mulawdec_base_init):
* gst/law/mulaw-encode.c: (gst_mulawenc_base_init):
* gst/level/gstlevel.c:
* gst/matroska/matroska-demux.c: (gst_matroska_demux_base_init):
* gst/matroska/matroska-mux.c: (gst_matroska_mux_base_init):
* gst/median/gstmedian.c:
* gst/monoscope/gstmonoscope.c:
* gst/multipart/multipartdemux.c:
* gst/multipart/multipartmux.c:
* gst/oldcore/gstaggregator.c:
* gst/oldcore/gstfdsink.c:
* gst/oldcore/gstmd5sink.c:
* gst/oldcore/gstmultifilesrc.c:
* gst/oldcore/gstpipefilter.c:
* gst/oldcore/gstshaper.c:
* gst/oldcore/gststatistics.c:
* gst/rtp/gstasteriskh263.c:
* gst/rtp/gstrtpL16depay.c:
* gst/rtp/gstrtpL16pay.c:
* gst/rtp/gstrtpamrdepay.c:
* gst/rtp/gstrtpamrpay.c:
* gst/rtp/gstrtpdepay.c:
* gst/rtp/gstrtpgsmpay.c:
* gst/rtp/gstrtph263pay.c:
* gst/rtp/gstrtph263pdepay.c:
* gst/rtp/gstrtph263ppay.c:
* gst/rtp/gstrtpilbcdepay.c:
* gst/rtp/gstrtpmp4gpay.c:
* gst/rtp/gstrtpmp4vdepay.c:
* gst/rtp/gstrtpmp4vpay.c:
* gst/rtp/gstrtpmpadepay.c:
* gst/rtp/gstrtpmpapay.c:
* gst/rtp/gstrtppcmadepay.c:
* gst/rtp/gstrtppcmapay.c:
* gst/rtp/gstrtppcmudepay.c:
* gst/rtp/gstrtppcmupay.c:
* gst/rtp/gstrtpspeexdepay.c:
* gst/rtp/gstrtpspeexpay.c:
* gst/rtsp/gstrtpdec.c:
* gst/rtsp/gstrtspsrc.c:
* gst/smpte/gstsmpte.c:
* gst/udp/gstdynudpsink.c:
* gst/udp/gstmultiudpsink.c:
* gst/udp/gstudpsink.c:
* gst/udp/gstudpsrc.c:
* gst/videobox/gstvideobox.c:
* gst/videofilter/gstgamma.c: (gst_gamma_base_init):
* gst/videofilter/gstvideobalance.c:
* gst/videofilter/gstvideoflip.c:
* gst/videofilter/gstvideotemplate.c:
(gst_videotemplate_base_init):
* gst/videomixer/videomixer.c:
* gst/wavparse/gstwavparse.c: (gst_wavparse_base_init),
(gst_wavparse_class_init), (gst_wavparse_dispose),
(gst_wavparse_reset), (gst_wavparse_init),
(gst_wavparse_perform_seek), (gst_wavparse_peek_chunk_info),
(gst_wavparse_peek_chunk), (gst_wavparse_stream_headers),
(gst_wavparse_parse_stream_init), (gst_wavparse_send_event),
(gst_wavparse_add_src_pad), (gst_wavparse_stream_data),
(gst_wavparse_chain), (gst_wavparse_srcpad_event),
(gst_wavparse_sink_activate), (gst_wavparse_sink_activate_pull),
(gst_wavparse_change_state):
* gst/wavparse/gstwavparse.h:
* sys/oss/gstossmixerelement.c:
* sys/oss/gstosssink.c:
* sys/oss/gstosssrc.c:
* sys/osxaudio/gstosxaudioelement.c:
* sys/osxaudio/gstosxaudiosink.c:
* sys/osxaudio/gstosxaudiosrc.c:
* sys/sunaudio/gstsunaudiomixer.c:
* sys/sunaudio/gstsunaudiosink.c:
Define GstElementDetails as const and also static (when defined as
global)
2006-04-25 21:39:46 +00:00
|
|
|
static const GstElementDetails esdsink_details =
|
2006-03-30 15:37:05 +00:00
|
|
|
GST_ELEMENT_DETAILS ("Esound audio sink",
|
|
|
|
"Sink/Audio",
|
|
|
|
"Plays audio to an esound server",
|
|
|
|
"Arwed von Merkatz <v.merkatz@gmx.net>");
|
2001-12-20 23:13:50 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2006-03-21 18:12:59 +00:00
|
|
|
PROP_0,
|
|
|
|
PROP_HOST
|
2001-12-20 23:13:50 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("audio/x-raw-int, "
|
2004-03-15 19:32:27 +00:00
|
|
|
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER) ", "
|
|
|
|
"signed = (boolean) TRUE, "
|
|
|
|
"width = (int) 16, "
|
2005-05-10 20:10:43 +00:00
|
|
|
"depth = (int) 16, "
|
|
|
|
"rate = (int) [ 1, MAX ], "
|
|
|
|
"channels = (int) [ 1, 2 ]; "
|
|
|
|
"audio/x-raw-int, "
|
|
|
|
"signed = (boolean) { true, false }, "
|
|
|
|
"width = (int) 8, "
|
|
|
|
"depth = (int) 8, "
|
|
|
|
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static void gst_esdsink_base_init (gpointer g_class);
|
2005-05-10 20:10:43 +00:00
|
|
|
static void gst_esdsink_class_init (GstEsdSinkClass * klass);
|
|
|
|
static void gst_esdsink_init (GstEsdSink * esdsink);
|
2006-03-21 18:12:59 +00:00
|
|
|
static void gst_esdsink_finalize (GObject * object);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
static GstCaps *gst_esdsink_getcaps (GstBaseSink * bsink);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2005-08-08 16:43:47 +00:00
|
|
|
static gboolean gst_esdsink_open (GstAudioSink * asink);
|
2005-05-10 20:10:43 +00:00
|
|
|
static gboolean gst_esdsink_close (GstAudioSink * asink);
|
2005-08-08 16:43:47 +00:00
|
|
|
static gboolean gst_esdsink_prepare (GstAudioSink * asink,
|
|
|
|
GstRingBufferSpec * spec);
|
|
|
|
static gboolean gst_esdsink_unprepare (GstAudioSink * asink);
|
2005-05-10 20:10:43 +00:00
|
|
|
static guint gst_esdsink_write (GstAudioSink * asink, gpointer data,
|
|
|
|
guint length);
|
|
|
|
static guint gst_esdsink_delay (GstAudioSink * asink);
|
|
|
|
static void gst_esdsink_reset (GstAudioSink * asink);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
static void gst_esdsink_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_esdsink_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2001-12-20 23:13:50 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2001-12-20 23:13:50 +00:00
|
|
|
GType
|
|
|
|
gst_esdsink_get_type (void)
|
|
|
|
{
|
|
|
|
static GType esdsink_type = 0;
|
|
|
|
|
|
|
|
if (!esdsink_type) {
|
|
|
|
static const GTypeInfo esdsink_info = {
|
2005-05-10 20:10:43 +00:00
|
|
|
sizeof (GstEsdSinkClass),
|
2003-11-01 15:28:33 +00:00
|
|
|
gst_esdsink_base_init,
|
2001-12-20 23:13:50 +00:00
|
|
|
NULL,
|
2005-05-10 20:10:43 +00:00
|
|
|
(GClassInitFunc) gst_esdsink_class_init,
|
2001-12-20 23:13:50 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2005-05-10 20:10:43 +00:00
|
|
|
sizeof (GstEsdSink),
|
2001-12-20 23:13:50 +00:00
|
|
|
0,
|
2005-05-10 20:10:43 +00:00
|
|
|
(GInstanceInitFunc) gst_esdsink_init,
|
2001-12-20 23:13:50 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
esdsink_type =
|
2005-07-10 12:52:20 +00:00
|
|
|
g_type_register_static (GST_TYPE_AUDIO_SINK, "GstEsdSink",
|
|
|
|
&esdsink_info, 0);
|
2001-12-20 23:13:50 +00:00
|
|
|
}
|
|
|
|
return esdsink_type;
|
|
|
|
}
|
|
|
|
|
2003-11-01 15:28:33 +00:00
|
|
|
static void
|
|
|
|
gst_esdsink_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
2003-12-22 01:47:09 +00:00
|
|
|
gst_static_pad_template_get (&sink_factory));
|
2003-11-01 15:28:33 +00:00
|
|
|
gst_element_class_set_details (element_class, &esdsink_details);
|
|
|
|
}
|
|
|
|
|
2001-12-20 23:13:50 +00:00
|
|
|
static void
|
2005-05-10 20:10:43 +00:00
|
|
|
gst_esdsink_class_init (GstEsdSinkClass * klass)
|
2001-12-20 23:13:50 +00:00
|
|
|
{
|
2005-05-10 20:10:43 +00:00
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstBaseSinkClass *gstbasesink_class;
|
|
|
|
GstBaseAudioSinkClass *gstbaseaudiosink_class;
|
|
|
|
GstAudioSinkClass *gstaudiosink_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstbasesink_class = (GstBaseSinkClass *) klass;
|
|
|
|
gstbaseaudiosink_class = (GstBaseAudioSinkClass *) klass;
|
|
|
|
gstaudiosink_class = (GstAudioSinkClass *) klass;
|
|
|
|
|
2006-04-08 21:21:45 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2005-05-10 20:10:43 +00:00
|
|
|
|
2006-03-21 18:12:59 +00:00
|
|
|
gobject_class->finalize = gst_esdsink_finalize;
|
2005-05-10 20:10:43 +00:00
|
|
|
|
|
|
|
gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_esdsink_getcaps);
|
|
|
|
|
|
|
|
gstaudiosink_class->open = GST_DEBUG_FUNCPTR (gst_esdsink_open);
|
|
|
|
gstaudiosink_class->close = GST_DEBUG_FUNCPTR (gst_esdsink_close);
|
2005-08-08 16:43:47 +00:00
|
|
|
gstaudiosink_class->prepare = GST_DEBUG_FUNCPTR (gst_esdsink_prepare);
|
|
|
|
gstaudiosink_class->unprepare = GST_DEBUG_FUNCPTR (gst_esdsink_unprepare);
|
2005-05-10 20:10:43 +00:00
|
|
|
gstaudiosink_class->write = GST_DEBUG_FUNCPTR (gst_esdsink_write);
|
|
|
|
gstaudiosink_class->delay = GST_DEBUG_FUNCPTR (gst_esdsink_delay);
|
|
|
|
gstaudiosink_class->reset = GST_DEBUG_FUNCPTR (gst_esdsink_reset);
|
2001-12-20 23:13:50 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_esdsink_set_property;
|
|
|
|
gobject_class->get_property = gst_esdsink_get_property;
|
|
|
|
|
2006-03-21 18:12:59 +00:00
|
|
|
/* default value is filled in the _init method */
|
|
|
|
g_object_class_install_property (gobject_class, PROP_HOST,
|
|
|
|
g_param_spec_string ("host", "Host",
|
|
|
|
"The host running the esound daemon", NULL, G_PARAM_READWRITE));
|
2001-12-20 23:13:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-05-10 20:10:43 +00:00
|
|
|
gst_esdsink_init (GstEsdSink * esdsink)
|
2001-12-20 23:13:50 +00:00
|
|
|
{
|
|
|
|
esdsink->fd = -1;
|
2005-05-10 20:10:43 +00:00
|
|
|
esdsink->ctrl_fd = -1;
|
2006-03-21 18:12:59 +00:00
|
|
|
esdsink->host = g_strdup (g_getenv ("ESPEAKER"));
|
2001-12-20 23:13:50 +00:00
|
|
|
}
|
|
|
|
|
Fixes: #151879, #151881, #151882, #151883, #151884, #151886, #151887, #152102, #152247.
Original commit message from CVS:
Fixes: #151879, #151881, #151882, #151883, #151884, #151886,
#151887, #152102, #152247.
* examples/indexing/indexmpeg.c: 64-bit warning fixes.
* examples/seeking/cdparanoia.c: same
* examples/seeking/cdplayer.c: same
* examples/seeking/seek.c: same
* examples/seeking/spider_seek.c: same
* examples/seeking/vorbisfile.c: same
* examples/stats/mp2ogg.c: same
* ext/esd/esdsink.c: (gst_esdsink_class_init),
(gst_esdsink_dispose): Dispose of element properly.
* ext/ivorbis/vorbisfile.c: (gst_ivorbisfile_seek): 64-bit warning
fixes.
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_dispose): Dispose of element correctly.
* gst/wavenc/gstwavenc.c: (gst_wavenc_chain): Fix leak.
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new), (gst_ximagesink_ximage_destroy):
Fix 64-bit warning.
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new), (gst_xvimagesink_xvimage_destroy):
Fix 64-bit warning.
2004-09-12 22:57:26 +00:00
|
|
|
static void
|
2006-03-21 18:12:59 +00:00
|
|
|
gst_esdsink_finalize (GObject * object)
|
Fixes: #151879, #151881, #151882, #151883, #151884, #151886, #151887, #152102, #152247.
Original commit message from CVS:
Fixes: #151879, #151881, #151882, #151883, #151884, #151886,
#151887, #152102, #152247.
* examples/indexing/indexmpeg.c: 64-bit warning fixes.
* examples/seeking/cdparanoia.c: same
* examples/seeking/cdplayer.c: same
* examples/seeking/seek.c: same
* examples/seeking/spider_seek.c: same
* examples/seeking/vorbisfile.c: same
* examples/stats/mp2ogg.c: same
* ext/esd/esdsink.c: (gst_esdsink_class_init),
(gst_esdsink_dispose): Dispose of element properly.
* ext/ivorbis/vorbisfile.c: (gst_ivorbisfile_seek): 64-bit warning
fixes.
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_dispose): Dispose of element correctly.
* gst/wavenc/gstwavenc.c: (gst_wavenc_chain): Fix leak.
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new), (gst_ximagesink_ximage_destroy):
Fix 64-bit warning.
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new), (gst_xvimagesink_xvimage_destroy):
Fix 64-bit warning.
2004-09-12 22:57:26 +00:00
|
|
|
{
|
2005-05-10 20:10:43 +00:00
|
|
|
GstEsdSink *esdsink = GST_ESDSINK (object);
|
Fixes: #151879, #151881, #151882, #151883, #151884, #151886, #151887, #152102, #152247.
Original commit message from CVS:
Fixes: #151879, #151881, #151882, #151883, #151884, #151886,
#151887, #152102, #152247.
* examples/indexing/indexmpeg.c: 64-bit warning fixes.
* examples/seeking/cdparanoia.c: same
* examples/seeking/cdplayer.c: same
* examples/seeking/seek.c: same
* examples/seeking/spider_seek.c: same
* examples/seeking/vorbisfile.c: same
* examples/stats/mp2ogg.c: same
* ext/esd/esdsink.c: (gst_esdsink_class_init),
(gst_esdsink_dispose): Dispose of element properly.
* ext/ivorbis/vorbisfile.c: (gst_ivorbisfile_seek): 64-bit warning
fixes.
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_dispose): Dispose of element correctly.
* gst/wavenc/gstwavenc.c: (gst_wavenc_chain): Fix leak.
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new), (gst_ximagesink_ximage_destroy):
Fix 64-bit warning.
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new), (gst_xvimagesink_xvimage_destroy):
Fix 64-bit warning.
2004-09-12 22:57:26 +00:00
|
|
|
|
|
|
|
g_free (esdsink->host);
|
2004-11-01 11:02:31 +00:00
|
|
|
|
2006-03-21 18:12:59 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
Fixes: #151879, #151881, #151882, #151883, #151884, #151886, #151887, #152102, #152247.
Original commit message from CVS:
Fixes: #151879, #151881, #151882, #151883, #151884, #151886,
#151887, #152102, #152247.
* examples/indexing/indexmpeg.c: 64-bit warning fixes.
* examples/seeking/cdparanoia.c: same
* examples/seeking/cdplayer.c: same
* examples/seeking/seek.c: same
* examples/seeking/spider_seek.c: same
* examples/seeking/vorbisfile.c: same
* examples/stats/mp2ogg.c: same
* ext/esd/esdsink.c: (gst_esdsink_class_init),
(gst_esdsink_dispose): Dispose of element properly.
* ext/ivorbis/vorbisfile.c: (gst_ivorbisfile_seek): 64-bit warning
fixes.
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_dispose): Dispose of element correctly.
* gst/wavenc/gstwavenc.c: (gst_wavenc_chain): Fix leak.
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new), (gst_ximagesink_ximage_destroy):
Fix 64-bit warning.
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new), (gst_xvimagesink_xvimage_destroy):
Fix 64-bit warning.
2004-09-12 22:57:26 +00:00
|
|
|
}
|
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_esdsink_getcaps (GstBaseSink * bsink)
|
|
|
|
{
|
2005-08-08 16:43:47 +00:00
|
|
|
GstEsdSink *esdsink;
|
|
|
|
GstPadTemplate *pad_template;
|
2005-05-10 20:10:43 +00:00
|
|
|
GstCaps *caps = NULL;
|
2005-08-08 17:27:28 +00:00
|
|
|
gint i;
|
2005-08-08 16:43:47 +00:00
|
|
|
esd_server_info_t *server_info;
|
|
|
|
|
|
|
|
esdsink = GST_ESDSINK (bsink);
|
|
|
|
|
2006-03-23 20:12:47 +00:00
|
|
|
GST_DEBUG_OBJECT (esdsink, "getcaps called");
|
|
|
|
|
2005-08-08 16:43:47 +00:00
|
|
|
pad_template = gst_static_pad_template_get (&sink_factory);
|
|
|
|
caps = gst_caps_copy (gst_pad_template_get_caps (pad_template));
|
|
|
|
|
2006-03-21 18:12:59 +00:00
|
|
|
/* no fd, we're done with the template caps */
|
|
|
|
if (esdsink->ctrl_fd < 0)
|
|
|
|
goto done;
|
2005-05-10 20:10:43 +00:00
|
|
|
|
2006-03-21 18:12:59 +00:00
|
|
|
/* get server info */
|
2005-05-10 20:10:43 +00:00
|
|
|
server_info = esd_get_server_info (esdsink->ctrl_fd);
|
2006-03-21 18:12:59 +00:00
|
|
|
if (!server_info)
|
|
|
|
goto no_info;
|
2005-05-10 20:10:43 +00:00
|
|
|
|
2006-03-23 20:12:47 +00:00
|
|
|
GST_DEBUG_OBJECT (esdsink, "got server info rate: %i", server_info->rate);
|
2005-08-08 17:27:28 +00:00
|
|
|
|
2006-03-21 18:12:59 +00:00
|
|
|
for (i = 0; i < caps->structs->len; i++) {
|
|
|
|
GstStructure *s;
|
|
|
|
|
|
|
|
s = gst_caps_get_structure (caps, i);
|
|
|
|
gst_structure_set (s, "rate", G_TYPE_INT, server_info->rate, NULL);
|
|
|
|
}
|
|
|
|
esd_free_server_info (server_info);
|
2005-08-08 17:27:28 +00:00
|
|
|
|
2006-03-21 18:12:59 +00:00
|
|
|
done:
|
|
|
|
return caps;
|
2005-08-08 17:27:28 +00:00
|
|
|
|
2006-03-21 18:12:59 +00:00
|
|
|
/* ERRORS */
|
|
|
|
no_info:
|
|
|
|
{
|
2005-08-08 16:43:47 +00:00
|
|
|
GST_WARNING_OBJECT (esdsink, "couldn't get server info!");
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_esdsink_open (GstAudioSink * asink)
|
|
|
|
{
|
|
|
|
GstEsdSink *esdsink = GST_ESDSINK (asink);
|
|
|
|
|
2006-03-23 20:12:47 +00:00
|
|
|
GST_DEBUG_OBJECT (esdsink, "open");
|
|
|
|
|
2005-08-08 16:43:47 +00:00
|
|
|
esdsink->ctrl_fd = esd_open_sound (esdsink->host);
|
|
|
|
if (esdsink->ctrl_fd < 0)
|
|
|
|
goto couldnt_connect;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
2006-03-21 18:12:59 +00:00
|
|
|
/* ERRORS */
|
2005-08-08 16:43:47 +00:00
|
|
|
couldnt_connect:
|
|
|
|
{
|
2006-04-18 14:15:33 +00:00
|
|
|
GST_ELEMENT_ERROR (esdsink, RESOURCE, OPEN_WRITE,
|
|
|
|
(_("Could not establish connection to sound server")),
|
2005-08-08 16:43:47 +00:00
|
|
|
("can't open connection to esound server"));
|
|
|
|
return FALSE;
|
2005-05-10 20:10:43 +00:00
|
|
|
}
|
2001-12-20 23:13:50 +00:00
|
|
|
}
|
2003-07-17 08:08:09 +00:00
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
static gboolean
|
2005-08-08 16:43:47 +00:00
|
|
|
gst_esdsink_close (GstAudioSink * asink)
|
|
|
|
{
|
|
|
|
GstEsdSink *esdsink = GST_ESDSINK (asink);
|
|
|
|
|
2006-03-23 20:12:47 +00:00
|
|
|
GST_DEBUG_OBJECT (esdsink, "close");
|
|
|
|
|
2005-08-08 16:43:47 +00:00
|
|
|
esd_close (esdsink->ctrl_fd);
|
2006-03-21 18:12:59 +00:00
|
|
|
esdsink->ctrl_fd = -1;
|
2005-08-08 16:43:47 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_esdsink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
|
2003-07-17 08:08:09 +00:00
|
|
|
{
|
2005-05-10 20:10:43 +00:00
|
|
|
GstEsdSink *esdsink = GST_ESDSINK (asink);
|
2006-03-23 20:12:47 +00:00
|
|
|
esd_format_t esdformat;
|
2003-07-17 08:08:09 +00:00
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
/* Name used by esound for this connection. */
|
2005-12-16 21:57:51 +00:00
|
|
|
const char connname[] = "GStreamer";
|
2006-03-23 20:12:47 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (esdsink, "prepare");
|
2003-07-17 08:08:09 +00:00
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
/* Bitmap describing audio format. */
|
2006-03-23 20:12:47 +00:00
|
|
|
esdformat = ESD_STREAM | ESD_PLAY;
|
2003-07-17 08:08:09 +00:00
|
|
|
|
2006-03-23 20:12:47 +00:00
|
|
|
switch (spec->depth) {
|
|
|
|
case 8:
|
|
|
|
esdformat |= ESD_BITS8;
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
esdformat |= ESD_BITS16;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto unsupported_depth;
|
2005-05-10 20:10:43 +00:00
|
|
|
}
|
2003-07-04 07:32:19 +00:00
|
|
|
|
2006-03-23 20:12:47 +00:00
|
|
|
switch (spec->channels) {
|
|
|
|
case 1:
|
|
|
|
esdformat |= ESD_MONO;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
esdformat |= ESD_STEREO;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
goto unsupported_channels;
|
2005-05-10 20:10:43 +00:00
|
|
|
}
|
|
|
|
|
2006-03-23 20:12:47 +00:00
|
|
|
GST_INFO_OBJECT (esdsink,
|
|
|
|
"attempting to open data connection to esound server");
|
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
esdsink->fd =
|
|
|
|
esd_play_stream (esdformat, spec->rate, esdsink->host, connname);
|
|
|
|
|
2006-03-21 18:12:59 +00:00
|
|
|
if ((esdsink->fd < 0) || (esdsink->ctrl_fd < 0))
|
|
|
|
goto cannot_open;
|
|
|
|
|
2006-03-23 20:12:47 +00:00
|
|
|
esdsink->rate = spec->rate;
|
|
|
|
|
2006-04-26 08:55:27 +00:00
|
|
|
spec->segsize = ESD_BUF_SIZE;
|
|
|
|
spec->segtotal = (ESD_MAX_WRITE_SIZE / spec->segsize);
|
2006-03-23 20:12:47 +00:00
|
|
|
spec->silence_sample[0] = 0;
|
|
|
|
spec->silence_sample[1] = 0;
|
|
|
|
spec->silence_sample[2] = 0;
|
|
|
|
spec->silence_sample[3] = 0;
|
|
|
|
|
|
|
|
GST_INFO_OBJECT (esdsink, "successfully opened connection to esound server");
|
2006-03-21 18:12:59 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
2006-03-23 20:12:47 +00:00
|
|
|
unsupported_depth:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (esdsink, STREAM, WRONG_TYPE, (NULL),
|
|
|
|
("can't handle sample depth of %d, only 8 or 16 supported",
|
|
|
|
spec->depth));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
unsupported_channels:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (esdsink, STREAM, WRONG_TYPE, (NULL),
|
|
|
|
("can't handle %d channels, only 1 or 2 supported", spec->channels));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-03-21 18:12:59 +00:00
|
|
|
cannot_open:
|
|
|
|
{
|
2006-04-18 14:15:33 +00:00
|
|
|
GST_ELEMENT_ERROR (esdsink, RESOURCE, OPEN_WRITE,
|
|
|
|
(_("Could not establish connection to sound server")),
|
2005-05-10 20:10:43 +00:00
|
|
|
("can't open connection to esound server"));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-07-04 07:32:19 +00:00
|
|
|
}
|
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
static gboolean
|
2005-08-08 16:43:47 +00:00
|
|
|
gst_esdsink_unprepare (GstAudioSink * asink)
|
2003-07-04 07:32:19 +00:00
|
|
|
{
|
2005-05-10 20:10:43 +00:00
|
|
|
GstEsdSink *esdsink = GST_ESDSINK (asink);
|
2003-07-04 07:32:19 +00:00
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
if ((esdsink->fd < 0) && (esdsink->ctrl_fd < 0))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
close (esdsink->fd);
|
|
|
|
esdsink->fd = -1;
|
2003-07-04 07:32:19 +00:00
|
|
|
|
2006-03-23 20:12:47 +00:00
|
|
|
GST_INFO_OBJECT (esdsink, "closed sound device");
|
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
return TRUE;
|
2003-07-04 07:32:19 +00:00
|
|
|
}
|
|
|
|
|
2001-12-20 23:13:50 +00:00
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
static guint
|
|
|
|
gst_esdsink_write (GstAudioSink * asink, gpointer data, guint length)
|
|
|
|
{
|
|
|
|
GstEsdSink *esdsink = GST_ESDSINK (asink);
|
|
|
|
gint to_write = 0;
|
2001-12-20 23:13:50 +00:00
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
to_write = length;
|
2004-01-29 23:20:45 +00:00
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
while (to_write > 0) {
|
|
|
|
int done;
|
2003-07-04 07:32:19 +00:00
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
done = write (esdsink->fd, data, to_write);
|
2003-07-17 08:08:09 +00:00
|
|
|
|
2006-03-21 18:12:59 +00:00
|
|
|
if (done < 0)
|
|
|
|
goto write_error;
|
2005-05-10 20:10:43 +00:00
|
|
|
|
|
|
|
to_write -= done;
|
|
|
|
data += done;
|
2001-12-20 23:13:50 +00:00
|
|
|
}
|
2005-05-10 20:10:43 +00:00
|
|
|
return length;
|
2006-03-21 18:12:59 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
write_error:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (esdsink, RESOURCE, WRITE,
|
|
|
|
("Failed to write data to the esound daemon"), GST_ERROR_SYSTEM);
|
|
|
|
return 0;
|
|
|
|
}
|
2005-05-10 20:10:43 +00:00
|
|
|
}
|
2003-07-17 08:08:09 +00:00
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
static guint
|
|
|
|
gst_esdsink_delay (GstAudioSink * asink)
|
|
|
|
{
|
|
|
|
GstEsdSink *esdsink = GST_ESDSINK (asink);
|
2006-03-23 20:12:47 +00:00
|
|
|
guint latency;
|
|
|
|
|
|
|
|
latency = esd_get_latency (esdsink->ctrl_fd);
|
|
|
|
|
2006-04-26 08:55:27 +00:00
|
|
|
/* latency is measured in samples at a rate of 44100, this
|
|
|
|
* cannot overflow. */
|
2006-03-23 20:12:47 +00:00
|
|
|
latency = latency * 44100LL / esdsink->rate;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (asink, "got latency: %u", latency);
|
2003-07-17 08:08:09 +00:00
|
|
|
|
2005-05-10 20:10:43 +00:00
|
|
|
return latency;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_esdsink_reset (GstAudioSink * asink)
|
|
|
|
{
|
2006-03-23 20:12:47 +00:00
|
|
|
GST_DEBUG_OBJECT (asink, "reset called");
|
2001-12-20 23:13:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_esdsink_set_property (GObject * object, guint prop_id, const GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-20 23:13:50 +00:00
|
|
|
{
|
2005-05-10 20:10:43 +00:00
|
|
|
GstEsdSink *esdsink = GST_ESDSINK (object);
|
2001-12-20 23:13:50 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2006-03-21 18:12:59 +00:00
|
|
|
case PROP_HOST:
|
2004-03-14 22:34:33 +00:00
|
|
|
g_free (esdsink->host);
|
2006-03-21 18:12:59 +00:00
|
|
|
esdsink->host = g_value_dup_string (value);
|
2001-12-20 23:13:50 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_esdsink_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2001-12-20 23:13:50 +00:00
|
|
|
{
|
2005-05-10 20:10:43 +00:00
|
|
|
GstEsdSink *esdsink = GST_ESDSINK (object);
|
2001-12-20 23:13:50 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2006-03-21 18:12:59 +00:00
|
|
|
case PROP_HOST:
|
2001-12-20 23:13:50 +00:00
|
|
|
g_value_set_string (value, esdsink->host);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-07-15 07:52:10 +00:00
|
|
|
gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_esdsink_factory_init (GstPlugin * plugin)
|
2001-12-20 23:13:50 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!gst_element_register (plugin, "esdsink", GST_RANK_NONE,
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_TYPE_ESDSINK))
|
2003-11-01 15:28:33 +00:00
|
|
|
return FALSE;
|
2001-12-20 23:13:50 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|