2004-01-21 06:57:30 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <2003> Laurent Vivier <Laurent.Vivier@bull.net>
|
|
|
|
* Copyright (C) <2004> Arwed v. Merkatz <v.merkatz@gmx.net>
|
|
|
|
*
|
|
|
|
* Based on esdsink.c:
|
|
|
|
* Copyright (C) <2001> Richard Boulton <richard-gst@tartarus.org>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <audio/audiolib.h>
|
|
|
|
#include <audio/soundlib.h>
|
|
|
|
#include "nassink.h"
|
|
|
|
|
2005-12-06 19:55:58 +00:00
|
|
|
#define NAS_SOUND_PORT_DURATION (2)
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG_CATEGORY (NAS);
|
2004-01-21 06:57:30 +00:00
|
|
|
/* Signals and args */
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2004-01-21 06:57:30 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
enum
|
|
|
|
{
|
2004-01-21 06:57:30 +00:00
|
|
|
ARG_0,
|
|
|
|
ARG_MUTE,
|
|
|
|
ARG_HOST
|
|
|
|
};
|
|
|
|
|
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-11-09 06:08:22 +00:00
|
|
|
"endianness = (int) BYTE_ORDER, "
|
2004-03-15 19:32:27 +00:00
|
|
|
"signed = (boolean) TRUE, "
|
|
|
|
"width = (int) 16, "
|
|
|
|
"depth = (int) 16, "
|
|
|
|
"rate = (int) [ 1000, 96000 ], "
|
|
|
|
"channels = (int) [ 1, 2 ]; "
|
|
|
|
"audio/x-raw-int, "
|
|
|
|
"signed = (boolean) FALSE, "
|
|
|
|
"width = (int) 8, "
|
|
|
|
"depth = (int) 8, "
|
|
|
|
"rate = (int) [ 1000, 96000 ], " "channels = (int) [ 1, 2 ]")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
static void gst_nassink_base_init (gpointer g_class);
|
|
|
|
static void gst_nassink_class_init (GstNassinkClass * klass);
|
|
|
|
static void gst_nassink_init (GstNassink * nassink);
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
static void gst_nassink_finalize (GObject * object);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
static gboolean gst_nassink_open_audio (GstNassink * sink);
|
|
|
|
static void gst_nassink_close_audio (GstNassink * sink);
|
2005-09-05 17:20:29 +00:00
|
|
|
static GstStateChangeReturn gst_nassink_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstCaps *gst_nassink_getcaps (GstPad * pad);
|
|
|
|
static gboolean gst_nassink_sync_parms (GstNassink * nassink);
|
|
|
|
static GstPadLinkReturn gst_nassink_sinkconnect (GstPad * pad,
|
|
|
|
const GstCaps * caps);
|
|
|
|
|
|
|
|
static void gst_nassink_chain (GstPad * pad, GstData * _data);
|
|
|
|
|
|
|
|
static void gst_nassink_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_nassink_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
|
|
|
|
|
|
|
static void NAS_flush (GstNassink * sink);
|
|
|
|
static void NAS_sendData (GstNassink * sink, AuUint32 numBytes);
|
|
|
|
static AuBool NAS_EventHandler (AuServer * aud, AuEvent * ev,
|
|
|
|
AuEventHandlerRec * handler);
|
|
|
|
static AuDeviceID NAS_getDevice (AuServer * aud, int numTracks);
|
|
|
|
static int NAS_allocBuffer (GstNassink * sink);
|
|
|
|
static int NAS_createFlow (GstNassink * sink, unsigned char format,
|
|
|
|
unsigned short rate, int numTracks);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class = NULL;
|
|
|
|
|
|
|
|
GType
|
|
|
|
gst_nassink_get_type (void)
|
|
|
|
{
|
|
|
|
static GType nassink_type = 0;
|
|
|
|
|
|
|
|
if (!nassink_type) {
|
|
|
|
static const GTypeInfo nassink_info = {
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstNassinkClass),
|
2004-01-21 06:57:30 +00:00
|
|
|
gst_nassink_base_init,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GClassInitFunc) gst_nassink_class_init,
|
2004-01-21 06:57:30 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2004-03-14 22:34:33 +00:00
|
|
|
sizeof (GstNassink),
|
2004-01-21 06:57:30 +00:00
|
|
|
0,
|
2004-03-14 22:34:33 +00:00
|
|
|
(GInstanceInitFunc) gst_nassink_init,
|
2004-01-21 06:57:30 +00:00
|
|
|
};
|
2004-03-15 19:32:27 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
nassink_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_ELEMENT, "GstNassink", &nassink_info,
|
|
|
|
0);
|
2004-01-21 06:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nassink_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_nassink_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
static GstElementDetails nassink_details = {
|
|
|
|
"NAS sink",
|
|
|
|
"Sink/Audio",
|
|
|
|
"Plays audio to a Network Audio Server",
|
|
|
|
"Laurent Vivier <Laurent.Vivier@bull.net>, "
|
2004-03-15 19:32:27 +00:00
|
|
|
"Arwed v. Merkatz <v.merkatz@gmx.net>"
|
2004-01-21 06:57:30 +00:00
|
|
|
};
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&sink_factory));
|
|
|
|
gst_element_class_set_details (element_class, &nassink_details);
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (NAS, "NAS", 0, NULL);
|
2004-01-21 06:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_nassink_class_init (GstNassinkClass * klass)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
if (parent_class == NULL)
|
2004-03-14 22:34:33 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = gst_nassink_set_property;
|
|
|
|
gobject_class->get_property = gst_nassink_get_property;
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
gobject_class->finalize = gst_nassink_finalize;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MUTE, g_param_spec_boolean ("mute", "mute", "mute", TRUE, G_PARAM_READWRITE)); /* CHECKME */
|
|
|
|
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HOST, g_param_spec_string ("host", "host", "host", NULL, G_PARAM_READWRITE)); /* CHECKME */
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
gstelement_class->change_state = gst_nassink_change_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_nassink_init (GstNassink * nassink)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_CAT_DEBUG (NAS, "nassink: init");
|
|
|
|
nassink->sinkpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get (&sink_factory),
|
|
|
|
"sink");
|
|
|
|
gst_element_add_pad (GST_ELEMENT (nassink), nassink->sinkpad);
|
|
|
|
gst_pad_set_chain_function (nassink->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_nassink_chain));
|
|
|
|
gst_pad_set_link_function (nassink->sinkpad, gst_nassink_sinkconnect);
|
|
|
|
gst_pad_set_getcaps_function (nassink->sinkpad, gst_nassink_getcaps);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
nassink->mute = FALSE;
|
|
|
|
nassink->depth = 16;
|
|
|
|
nassink->tracks = 2;
|
|
|
|
nassink->rate = 44100;
|
2004-03-14 22:34:33 +00:00
|
|
|
nassink->host = g_strdup (getenv ("AUDIOSERVER"));
|
2004-01-21 06:57:30 +00:00
|
|
|
if (nassink->host == NULL)
|
2004-03-14 22:34:33 +00:00
|
|
|
nassink->host = g_strdup (getenv ("DISPLAY"));
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
nassink->audio = NULL;
|
|
|
|
nassink->flow = AuNone;
|
|
|
|
nassink->size = 0;
|
|
|
|
nassink->pos = 0;
|
|
|
|
nassink->buf = NULL;
|
|
|
|
}
|
|
|
|
|
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
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +00:00
|
|
|
gst_nassink_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
|
|
|
{
|
|
|
|
GstNassink *nassink = GST_NASSINK (object);
|
|
|
|
|
|
|
|
g_free (nassink->host);
|
Fixes a bunch of problems with finalize and dispose functions, either assumptions that dispose is only called once, o...
Original commit message from CVS:
* ext/alsa/gstalsa.c: (gst_alsa_class_init), (gst_alsa_dispose),
(gst_alsa_finalize):
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_class_init),
(gst_cdaudio_finalize):
* ext/cdparanoia/gstcdparanoia.c: (cdparanoia_class_init),
(cdparanoia_finalize):
* ext/divx/gstdivxdec.c: (gst_divxdec_dispose):
* ext/divx/gstdivxenc.c: (gst_divxenc_dispose):
* ext/dvdread/dvdreadsrc.c: (dvdreadsrc_class_init),
(dvdreadsrc_finalize):
* ext/flac/gstflacdec.c: (gst_flacdec_class_init),
(gst_flacdec_finalize):
* ext/flac/gstflacenc.c: (gst_flacenc_class_init),
(gst_flacenc_finalize):
* ext/gnomevfs/gstgnomevfssink.c: (gst_gnomevfssink_class_init),
(gst_gnomevfssink_finalize):
* ext/gnomevfs/gstgnomevfssrc.c: (gst_gnomevfssrc_class_init),
(gst_gnomevfssrc_finalize):
* ext/libfame/gstlibfame.c: (gst_fameenc_class_init),
(gst_fameenc_finalize):
* ext/nas/nassink.c: (gst_nassink_class_init),
(gst_nassink_finalize):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_finalize),
(gst_sdlvideosink_class_init):
* ext/sndfile/gstsf.c: (gst_sf_dispose):
* gst-libs/gst/mixer/mixertrack.c: (gst_mixer_track_dispose):
* gst-libs/gst/tuner/tunerchannel.c: (gst_tuner_channel_dispose):
* gst-libs/gst/tuner/tunernorm.c: (gst_tuner_norm_dispose):
* gst-libs/gst/xwindowlistener/xwindowlistener.c:
(gst_x_window_listener_dispose):
* gst/audioscale/gstaudioscale.c:
* gst/playondemand/gstplayondemand.c: (play_on_demand_class_init),
(play_on_demand_finalize):
* gst/videofilter/gstvideobalance.c: (gst_videobalance_dispose):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
* sys/cdrom/gstcdplayer.c: (cdplayer_class_init),
(cdplayer_finalize):
* sys/glsink/glimagesink.c: (gst_glimagesink_finalize),
(gst_glimagesink_class_init):
* sys/oss/gstosselement.c: (gst_osselement_class_init),
(gst_osselement_finalize):
* sys/oss/gstosssink.c: (gst_osssink_dispose):
* sys/oss/gstosssrc.c: (gst_osssrc_dispose):
* sys/v4l/gstv4lelement.c: (gst_v4lelement_dispose):
Fixes a bunch of problems with finalize and dispose functions,
either assumptions that dispose is only called once, or not calling
the parent class dispose/finalize function
2004-11-01 14:43:38 +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
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_nassink_getcaps (GstPad * pad)
|
2004-03-08 22:24:47 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstNassink *nassink = GST_NASSINK (gst_pad_get_parent (pad));
|
|
|
|
GstCaps *templatecaps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
|
2004-03-08 22:24:47 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
int i;
|
|
|
|
AuServer *server;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
server = AuOpenServer (nassink->host, 0, NULL, 0, NULL, NULL);
|
2004-03-08 22:24:47 +00:00
|
|
|
if (!server)
|
|
|
|
return templatecaps;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-08 22:24:47 +00:00
|
|
|
for (i = 0; i < gst_caps_get_size (templatecaps); i++) {
|
|
|
|
GstStructure *structure = gst_caps_get_structure (templatecaps, i);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE,
|
2004-03-15 19:32:27 +00:00
|
|
|
AuServerMinSampleRate (server), AuServerMaxSampleRate (server), NULL);
|
2004-03-08 22:24:47 +00:00
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
caps = gst_caps_intersect (templatecaps, gst_pad_get_pad_template_caps (pad));
|
|
|
|
gst_caps_free (templatecaps);
|
2004-03-08 22:24:47 +00:00
|
|
|
|
|
|
|
return caps;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-08 22:24:47 +00:00
|
|
|
}
|
|
|
|
|
2004-01-21 06:57:30 +00:00
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_nassink_sync_parms (GstNassink * nassink)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
gint ret;
|
|
|
|
unsigned char format;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-01-21 06:57:30 +00:00
|
|
|
g_return_val_if_fail (nassink != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_NASSINK (nassink), FALSE);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (nassink->audio == NULL)
|
|
|
|
return TRUE;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_CAT_DEBUG (NAS, "depth=%i rate=%i", nassink->depth, nassink->rate);
|
|
|
|
if (nassink->flow != AuNone) {
|
|
|
|
GST_CAT_DEBUG (NAS, "flushing buffer");
|
2004-01-21 06:57:30 +00:00
|
|
|
while (nassink->pos && nassink->buf)
|
2004-03-14 22:34:33 +00:00
|
|
|
NAS_flush (nassink);
|
|
|
|
AuStopFlow (nassink->audio, nassink->flow, NULL);
|
|
|
|
AuReleaseScratchFlow (nassink->audio, nassink->flow, NULL);
|
2004-01-21 06:57:30 +00:00
|
|
|
nassink->flow = AuNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nassink->depth == 16)
|
|
|
|
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
|
|
|
format = AuFormatLinearSigned16MSB;
|
|
|
|
#else
|
|
|
|
format = AuFormatLinearSigned16LSB;
|
|
|
|
#endif
|
|
|
|
else
|
|
|
|
format = AuFormatLinearUnsigned8;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
ret = NAS_createFlow (nassink, format, nassink->rate, nassink->tracks);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
return ret >= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstPadLinkReturn
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_nassink_sinkconnect (GstPad * pad, const GstCaps * caps)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
GstNassink *nassink;
|
|
|
|
GstStructure *structure;
|
|
|
|
|
|
|
|
nassink = GST_NASSINK (gst_pad_get_parent (pad));
|
|
|
|
|
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
|
|
|
|
|
|
|
gst_structure_get_int (structure, "depth", &nassink->depth);
|
|
|
|
gst_structure_get_int (structure, "channels", &nassink->tracks);
|
|
|
|
gst_structure_get_int (structure, "rate", &nassink->rate);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (!gst_nassink_sync_parms (nassink))
|
2004-01-21 06:57:30 +00:00
|
|
|
return GST_PAD_LINK_REFUSED;
|
|
|
|
|
|
|
|
return GST_PAD_LINK_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_nassink_chain (GstPad * pad, GstData * _data)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buf = GST_BUFFER (_data);
|
|
|
|
int pos = 0;
|
|
|
|
int remaining;
|
|
|
|
int available;
|
|
|
|
GstNassink *nassink;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (pad != NULL);
|
|
|
|
g_return_if_fail (GST_IS_PAD (pad));
|
|
|
|
g_return_if_fail (buf != NULL);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
nassink = GST_NASSINK (gst_pad_get_parent (pad));
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (nassink->buf != NULL);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
if (GST_BUFFER_DATA (buf) != NULL) {
|
|
|
|
if (!nassink->mute && nassink->audio != NULL) {
|
|
|
|
|
|
|
|
remaining = GST_BUFFER_SIZE (buf);
|
2004-03-14 22:34:33 +00:00
|
|
|
while ((nassink->flow != AuNone) && (remaining > 0)) {
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
/* number of bytes we can copy to buffer */
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
available = remaining > nassink->size - nassink->pos ?
|
|
|
|
nassink->size - nassink->pos : remaining;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
/* fill the buffer */
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
memcpy (nassink->buf + nassink->pos, GST_BUFFER_DATA (buf) + pos,
|
|
|
|
available);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
nassink->pos += available;
|
|
|
|
pos += available;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
remaining -= available;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
/* if we have more bytes, need to flush the buffer */
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
if (remaining > 0) {
|
|
|
|
while ((nassink->flow != AuNone) && (nassink->pos == nassink->size)) {
|
|
|
|
NAS_flush (nassink);
|
|
|
|
}
|
|
|
|
}
|
2004-01-21 06:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* give some time to event handler */
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
AuSync (nassink->audio, AuFalse);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_nassink_set_property (GObject * object, guint prop_id, const GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
GstNassink *nassink;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_NASSINK (object));
|
|
|
|
nassink = GST_NASSINK (object);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2004-03-14 22:34:33 +00:00
|
|
|
case ARG_MUTE:
|
|
|
|
nassink->mute = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case ARG_HOST:
|
|
|
|
if (nassink->host != NULL)
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (nassink->host);
|
2004-03-14 22:34:33 +00:00
|
|
|
if (g_value_get_string (value) == NULL)
|
2004-03-15 19:32:27 +00:00
|
|
|
nassink->host = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
else
|
2004-03-15 19:32:27 +00:00
|
|
|
nassink->host = g_strdup (g_value_get_string (value));
|
2004-03-14 22:34:33 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2004-01-21 06:57:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_nassink_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
GstNassink *nassink;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_return_if_fail (GST_IS_NASSINK (object));
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
nassink = GST_NASSINK (object);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
switch (prop_id) {
|
2004-03-14 22:34:33 +00:00
|
|
|
case ARG_MUTE:
|
|
|
|
g_value_set_boolean (value, nassink->mute);
|
|
|
|
break;
|
|
|
|
case ARG_HOST:
|
|
|
|
g_value_set_string (value, nassink->host);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2004-01-21 06:57:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
if (!gst_element_register (plugin, "nassink", GST_RANK_NONE,
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_TYPE_NASSINK)) {
|
2004-01-21 06:57:30 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"nassink",
|
|
|
|
"uses NAS for audio output",
|
2006-04-01 10:09:11 +00:00
|
|
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_nassink_open_audio (GstNassink * sink)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
/* Open Server */
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sink->audio = AuOpenServer (sink->host, 0, NULL, 0, NULL, NULL);
|
2004-01-21 06:57:30 +00:00
|
|
|
if (sink->audio == NULL)
|
|
|
|
return FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
sink->device = NAS_getDevice (sink->audio, sink->tracks);
|
2004-03-08 22:24:47 +00:00
|
|
|
if (sink->device == AuNone) {
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_CAT_DEBUG (NAS, "no device with %i tracks found", sink->tracks);
|
2004-03-08 22:24:47 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
sink->flow = AuNone;
|
|
|
|
sink->size = 0;
|
|
|
|
sink->pos = 0;
|
|
|
|
sink->buf = NULL;
|
|
|
|
|
|
|
|
/* Start a flow */
|
|
|
|
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
GST_OBJECT_FLAG_SET (sink, GST_NASSINK_OPEN);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_CAT_DEBUG (NAS, "opened audio device");
|
2004-01-21 06:57:30 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_nassink_close_audio (GstNassink * sink)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
if (sink->audio == NULL)
|
|
|
|
return;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
if (sink->flow != AuNone) {
|
|
|
|
while (sink->pos && sink->buf) {
|
2004-03-14 22:34:33 +00:00
|
|
|
NAS_flush (sink);
|
2004-01-21 06:57:30 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
AuStopFlow (sink->audio, sink->flow, NULL);
|
|
|
|
AuReleaseScratchFlow (sink->audio, sink->flow, NULL);
|
2004-01-21 06:57:30 +00:00
|
|
|
sink->flow = AuNone;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (sink->buf != NULL) {
|
|
|
|
free (sink->buf);
|
2004-01-21 06:57:30 +00:00
|
|
|
sink->buf = NULL;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
AuCloseServer (sink->audio);
|
2004-01-21 06:57:30 +00:00
|
|
|
sink->audio = NULL;
|
|
|
|
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
GST_OBJECT_FLAG_UNSET (sink, GST_NASSINK_OPEN);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_CAT_DEBUG (NAS, "closed audio device");
|
2004-01-21 06:57:30 +00:00
|
|
|
}
|
|
|
|
|
2005-09-05 17:20:29 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_nassink_change_state (GstElement * element, GstStateChange transition)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
GstNassink *nassink;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-01-21 06:57:30 +00:00
|
|
|
g_return_val_if_fail (GST_IS_NASSINK (element), FALSE);
|
|
|
|
|
|
|
|
nassink = GST_NASSINK (element);
|
|
|
|
|
|
|
|
switch (GST_STATE_PENDING (element)) {
|
2004-03-14 22:34:33 +00:00
|
|
|
case GST_STATE_NULL:
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
if (GST_OBJECT_FLAG_IS_SET (element, GST_NASSINK_OPEN))
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_nassink_close_audio (nassink);
|
2004-03-14 22:34:33 +00:00
|
|
|
break;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
case GST_STATE_READY:
|
renamed GST_FLAGS macros to GST_OBJECT_FLAGS moved bitshift from macro to enum definition
Original commit message from CVS:
* examples/indexing/indexmpeg.c: (main):
* ext/artsd/gstartsdsink.c: (gst_artsdsink_open_audio),
(gst_artsdsink_close_audio), (gst_artsdsink_change_state):
* ext/artsd/gstartsdsink.h:
* ext/audiofile/gstafparse.c: (gst_afparse_open_file),
(gst_afparse_close_file):
* ext/audiofile/gstafparse.h:
* ext/audiofile/gstafsink.c: (gst_afsink_open_file),
(gst_afsink_close_file), (gst_afsink_chain),
(gst_afsink_change_state):
* ext/audiofile/gstafsink.h:
* ext/audiofile/gstafsrc.c: (gst_afsrc_open_file),
(gst_afsrc_close_file), (gst_afsrc_change_state):
* ext/audiofile/gstafsrc.h:
* ext/cdaudio/gstcdaudio.c: (gst_cdaudio_init):
* ext/directfb/directfbvideosink.c: (gst_directfbvideosink_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_init):
* ext/jack/gstjack.h:
* ext/jack/gstjackbin.c: (gst_jack_bin_init),
(gst_jack_bin_change_state):
* ext/musepack/gstmusepackdec.c: (gst_musepackdec_init):
* ext/musicbrainz/gsttrm.c: (gst_musicbrainz_init):
* ext/nas/nassink.c: (gst_nassink_open_audio),
(gst_nassink_close_audio), (gst_nassink_change_state):
* ext/nas/nassink.h:
* ext/polyp/polypsink.c: (gst_polypsink_init):
* ext/sdl/sdlvideosink.c: (gst_sdlvideosink_change_state):
* ext/sdl/sdlvideosink.h:
* ext/smoothwave/gstsmoothwave.c: (gst_smoothwave_init):
* ext/sndfile/gstsf.c: (gst_sf_set_property),
(gst_sf_change_state), (gst_sf_release_request_pad),
(gst_sf_open_file), (gst_sf_close_file), (gst_sf_loop):
* ext/sndfile/gstsf.h:
* ext/swfdec/gstswfdec.c: (gst_swfdec_init):
* ext/tarkin/gsttarkindec.c: (gst_tarkindec_init):
* gst/apetag/apedemux.c: (gst_ape_demux_init):
* gst/cdxaparse/gstcdxaparse.c: (gst_cdxaparse_init):
* gst/cdxaparse/gstcdxastrip.c: (gst_cdxastrip_init):
* gst/festival/gstfestival.c: (gst_festival_change_state):
* gst/festival/gstfestival.h:
* gst/mpeg2sub/gstmpeg2subt.c: (gst_mpeg2subt_init):
* gst/multifilesink/gstmultifilesink.c: (gst_multifilesink_init),
(gst_multifilesink_set_location), (gst_multifilesink_open_file),
(gst_multifilesink_close_file), (gst_multifilesink_next_file),
(gst_multifilesink_pad_query), (gst_multifilesink_handle_event),
(gst_multifilesink_chain), (gst_multifilesink_change_state):
* gst/multifilesink/gstmultifilesink.h:
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init):
* sys/cdrom/gstcdplayer.c: (cdplayer_init):
* sys/dxr3/dxr3audiosink.c: (dxr3audiosink_init),
(dxr3audiosink_open), (dxr3audiosink_close),
(dxr3audiosink_chain_pcm), (dxr3audiosink_chain_ac3),
(dxr3audiosink_change_state):
* sys/dxr3/dxr3audiosink.h:
* sys/dxr3/dxr3spusink.c: (dxr3spusink_init), (dxr3spusink_open),
(dxr3spusink_close), (dxr3spusink_chain),
(dxr3spusink_change_state):
* sys/dxr3/dxr3spusink.h:
* sys/dxr3/dxr3videosink.c: (dxr3videosink_init),
(dxr3videosink_open), (dxr3videosink_close),
(dxr3videosink_write_data), (dxr3videosink_change_state):
* sys/dxr3/dxr3videosink.h:
* sys/glsink/glimagesink.c: (gst_glimagesink_init):
* sys/qcam/gstqcamsrc.c: (gst_qcamsrc_change_state),
(gst_qcamsrc_open), (gst_qcamsrc_close):
* sys/qcam/gstqcamsrc.h:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_init):
* sys/vcd/vcdsrc.c: (gst_vcdsrc_set_property), (gst_vcdsrc_get),
(gst_vcdsrc_open_file), (gst_vcdsrc_close_file),
(gst_vcdsrc_change_state), (gst_vcdsrc_recalculate):
* sys/vcd/vcdsrc.h:
renamed GST_FLAGS macros to GST_OBJECT_FLAGS
moved bitshift from macro to enum definition
2005-10-12 14:29:55 +00:00
|
|
|
if (!GST_OBJECT_FLAG_IS_SET (element, GST_NASSINK_OPEN))
|
2004-03-15 19:32:27 +00:00
|
|
|
gst_nassink_open_audio (nassink);
|
2004-03-14 22:34:33 +00:00
|
|
|
break;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
case GST_STATE_PAUSED:
|
|
|
|
while (nassink->pos && nassink->buf)
|
2004-03-15 19:32:27 +00:00
|
|
|
NAS_flush (nassink);
|
2004-03-14 22:34:33 +00:00
|
|
|
break;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
case GST_STATE_PLAYING:
|
|
|
|
break;
|
2004-01-21 06:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
2005-09-05 17:20:29 +00:00
|
|
|
return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2005-09-05 17:20:29 +00:00
|
|
|
return GST_STATE_CHANGE_SUCCESS;
|
2004-01-21 06:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
NAS_flush (GstNassink * sink)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
AuEvent ev;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
AuNextEvent (sink->audio, AuTrue, &ev);
|
|
|
|
AuDispatchEvent (sink->audio, &ev);
|
2004-01-21 06:57:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
NAS_sendData (GstNassink * sink, AuUint32 numBytes)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
if (numBytes < (sink->pos)) {
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
AuWriteElement (sink->audio, sink->flow, 0,
|
2004-03-15 19:32:27 +00:00
|
|
|
numBytes, sink->buf, AuFalse, NULL);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
memmove (sink->buf, sink->buf + numBytes, sink->pos - numBytes);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
sink->pos = sink->pos - numBytes;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
|
|
|
AuWriteElement (sink->audio, sink->flow, 0,
|
2004-03-15 19:32:27 +00:00
|
|
|
sink->pos, sink->buf, (numBytes > sink->pos), NULL);
|
2004-01-21 06:57:30 +00:00
|
|
|
sink->pos = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static AuBool
|
2004-03-14 22:34:33 +00:00
|
|
|
NAS_EventHandler (AuServer * aud, AuEvent * ev, AuEventHandlerRec * handler)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstNassink *sink = (GstNassink *) handler->data;
|
2004-01-21 06:57:30 +00:00
|
|
|
AuElementNotifyEvent *notify;
|
|
|
|
|
|
|
|
switch (ev->type) {
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
case AuEventTypeElementNotify:
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
notify = (AuElementNotifyEvent *) ev;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
switch (notify->kind) {
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case AuElementNotifyKindLowWater:
|
|
|
|
NAS_sendData (sink, notify->num_bytes);
|
|
|
|
break;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case AuElementNotifyKindState:
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
switch (notify->cur_state) {
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case AuStateStop:
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
if (sink->flow != AuNone) {
|
|
|
|
if (notify->reason == AuReasonEOF)
|
|
|
|
AuStopFlow (handler->aud, sink->flow, NULL);
|
|
|
|
AuReleaseScratchFlow (handler->aud, sink->flow, NULL);
|
|
|
|
sink->flow = AuNone;
|
|
|
|
}
|
|
|
|
AuUnregisterEventHandler (handler->aud, handler);
|
|
|
|
break;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case AuStatePause:
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
switch (notify->reason) {
|
|
|
|
case AuReasonUnderrun:
|
|
|
|
case AuReasonOverrun:
|
|
|
|
case AuReasonEOF:
|
|
|
|
case AuReasonWatermark:
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
NAS_sendData (sink, notify->num_bytes);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
break;
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
case AuReasonHardware:
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
if (AuSoundRestartHardwarePauses)
|
|
|
|
AuStartFlow (handler->aud, sink->flow, NULL);
|
|
|
|
else
|
|
|
|
AuStopFlow (handler->aud, sink->flow, NULL);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2004-01-21 06:57:30 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return AuTrue;
|
|
|
|
}
|
|
|
|
|
|
|
|
static AuDeviceID
|
2004-03-14 22:34:33 +00:00
|
|
|
NAS_getDevice (AuServer * aud, int numTracks)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0; i < AuServerNumDevices (aud); i++) {
|
|
|
|
if ((AuDeviceKind (AuServerDevice (aud, i))
|
2004-03-15 19:32:27 +00:00
|
|
|
== AuComponentKindPhysicalOutput) &&
|
|
|
|
(AuDeviceNumTracks (AuServerDevice (aud, i)) == numTracks)) {
|
2004-01-21 06:57:30 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
return AuDeviceIdentifier (AuServerDevice (aud, i));
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return AuNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-03-14 22:34:33 +00:00
|
|
|
NAS_allocBuffer (GstNassink * sink)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
if (sink->buf != NULL) {
|
2004-03-14 22:34:33 +00:00
|
|
|
free (sink->buf);
|
2004-01-21 06:57:30 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sink->buf = (char *) malloc (sink->size);
|
2004-01-21 06:57:30 +00:00
|
|
|
if (sink->buf == NULL) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sink->pos = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-03-14 22:34:33 +00:00
|
|
|
NAS_createFlow (GstNassink * sink, unsigned char format, unsigned short rate,
|
|
|
|
int numTracks)
|
2004-01-21 06:57:30 +00:00
|
|
|
{
|
|
|
|
AuElement elements[2];
|
|
|
|
AuUint32 buf_samples;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sink->flow = AuGetScratchFlow (sink->audio, NULL);
|
2004-01-21 06:57:30 +00:00
|
|
|
if (sink->flow == 0) {
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_CAT_DEBUG (NAS, "couldn't get flow");
|
2004-01-21 06:57:30 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-03-07 11:24:38 +00:00
|
|
|
/* free old Elements and reconnet to server, needed to change samplerate */
|
|
|
|
{
|
|
|
|
AuBool clocked;
|
|
|
|
int num_elements;
|
|
|
|
AuStatus status;
|
|
|
|
AuElement *oldelems;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
oldelems =
|
2004-03-15 19:32:27 +00:00
|
|
|
AuGetElements (sink->audio, sink->flow, &clocked, &num_elements,
|
|
|
|
&status);
|
2004-03-07 11:24:38 +00:00
|
|
|
if (num_elements > 0) {
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_CAT_DEBUG (NAS, "GetElements status: %i", status);
|
2004-03-07 11:24:38 +00:00
|
|
|
if (oldelems)
|
2004-03-15 19:32:27 +00:00
|
|
|
AuFreeElements (sink->audio, num_elements, oldelems);
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_nassink_close_audio (sink);
|
|
|
|
gst_nassink_open_audio (sink);
|
|
|
|
sink->flow = AuGetScratchFlow (sink->audio, NULL);
|
2004-03-07 11:24:38 +00:00
|
|
|
if (sink->flow == 0) {
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_CAT_DEBUG (NAS, "couldn't get flow");
|
|
|
|
return -1;
|
2004-03-07 11:24:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-08 22:24:47 +00:00
|
|
|
/* free old Elements and reconnet to server, needed to change samplerate */
|
|
|
|
{
|
|
|
|
AuBool clocked;
|
|
|
|
int num_elements;
|
|
|
|
AuStatus status;
|
|
|
|
AuElement *oldelems;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
oldelems =
|
2004-03-15 19:32:27 +00:00
|
|
|
AuGetElements (sink->audio, sink->flow, &clocked, &num_elements,
|
|
|
|
&status);
|
2004-03-08 22:24:47 +00:00
|
|
|
if (num_elements > 0) {
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_CAT_DEBUG (NAS, "GetElements status: %i", status);
|
2004-03-08 22:24:47 +00:00
|
|
|
if (oldelems)
|
2004-03-15 19:32:27 +00:00
|
|
|
AuFreeElements (sink->audio, num_elements, oldelems);
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_nassink_close_audio (sink);
|
|
|
|
gst_nassink_open_audio (sink);
|
|
|
|
sink->flow = AuGetScratchFlow (sink->audio, NULL);
|
2004-03-08 22:24:47 +00:00
|
|
|
if (sink->flow == 0) {
|
2004-03-15 19:32:27 +00:00
|
|
|
GST_CAT_DEBUG (NAS, "couldn't get flow");
|
|
|
|
return -1;
|
2004-03-08 22:24:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-21 06:57:30 +00:00
|
|
|
buf_samples = rate * NAS_SOUND_PORT_DURATION;
|
|
|
|
|
2004-03-07 11:24:38 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
AuMakeElementImportClient (&elements[0], /* element */
|
|
|
|
rate, /* rate */
|
|
|
|
format, /* format */
|
|
|
|
numTracks, /* number of tracks */
|
|
|
|
AuTrue, /* discart */
|
|
|
|
buf_samples, /* max samples */
|
2004-03-14 22:34:33 +00:00
|
|
|
(AuUint32) (buf_samples / 100 * AuSoundPortLowWaterMark),
|
|
|
|
/* low water mark */
|
2004-03-15 19:32:27 +00:00
|
|
|
0, /* num actions */
|
2004-03-14 22:34:33 +00:00
|
|
|
NULL);
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
AuMakeElementExportDevice (&elements[1], /* element */
|
|
|
|
0, /* input */
|
|
|
|
sink->device, /* device */
|
|
|
|
rate, /* rate */
|
|
|
|
AuUnlimitedSamples, /* num samples */
|
|
|
|
0, /* num actions */
|
|
|
|
NULL); /* actions */
|
|
|
|
|
|
|
|
AuSetElements (sink->audio, /* server */
|
|
|
|
sink->flow, /* flow ID */
|
|
|
|
AuTrue, /* clocked */
|
|
|
|
2, /* num elements */
|
|
|
|
elements, /* elements */
|
2004-03-14 22:34:33 +00:00
|
|
|
NULL);
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
AuRegisterEventHandler (sink->audio, /* server */
|
|
|
|
AuEventHandlerIDMask, /* value mask */
|
|
|
|
0, /* type */
|
|
|
|
sink->flow, /* flow ID */
|
|
|
|
NAS_EventHandler, /* callback */
|
|
|
|
(AuPointer) sink); /* data */
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
sink->size = buf_samples * numTracks * AuSizeofFormat (format);
|
|
|
|
|
|
|
|
if (NAS_allocBuffer (sink) < 0) {
|
|
|
|
|
|
|
|
AuReleaseScratchFlow (sink->audio, sink->flow, NULL);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
AuStartFlow (sink->audio, sink->flow, NULL);
|
2004-01-21 06:57:30 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|