2002-07-27 01:33:42 +00:00
|
|
|
/* gstcdplay
|
|
|
|
* Copyright (c) 2002 Charles Schmidt <cbschmid@uiuc.edu>
|
|
|
|
|
|
|
|
* 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:13 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2002-07-27 01:33:42 +00:00
|
|
|
#include "gstcdplayer.h"
|
|
|
|
|
|
|
|
/* props */
|
2003-05-24 10:56:28 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
ARG_0,
|
|
|
|
ARG_DEVICE,
|
|
|
|
ARG_NUM_TRACKS,
|
|
|
|
ARG_START_TRACK,
|
|
|
|
ARG_END_TRACK,
|
|
|
|
ARG_CURRENT_TRACK,
|
2004-05-21 23:53:08 +00:00
|
|
|
ARG_CDDB_DISCID
|
2002-07-27 01:33:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* signals */
|
2003-05-24 10:56:28 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
TRACK_CHANGE,
|
2004-05-21 23:53:08 +00:00
|
|
|
LAST_SIGNAL
|
2002-07-27 01:33:42 +00:00
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void cdplayer_base_init (gpointer g_class);
|
|
|
|
static void cdplayer_class_init (CDPlayerClass * klass);
|
|
|
|
static void cdplayer_init (CDPlayer * cdp);
|
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 cdplayer_finalize (GObject * object);
|
2002-07-27 01:33:42 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void cdplayer_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * spec);
|
|
|
|
static void cdplayer_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * spec);
|
|
|
|
static gboolean cdplayer_iterate (GstBin * bin);
|
2002-07-27 01:33:42 +00:00
|
|
|
|
2005-09-05 17:20:29 +00:00
|
|
|
static GstStateChangeReturn cdplayer_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2002-07-27 01:33:42 +00:00
|
|
|
|
|
|
|
static GstElementClass *parent_class;
|
2003-05-24 10:56:28 +00:00
|
|
|
static guint cdplayer_signals[LAST_SIGNAL] = { 0 };
|
2002-07-27 01:33:42 +00:00
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
GType
|
|
|
|
cdplayer_get_type (void)
|
2002-07-27 01:33:42 +00:00
|
|
|
{
|
2003-05-24 10:56:28 +00:00
|
|
|
static GType cdplayer_type = 0;
|
|
|
|
|
|
|
|
if (!cdplayer_type) {
|
|
|
|
static const GTypeInfo cdplayer_info = {
|
|
|
|
sizeof (CDPlayerClass),
|
2003-11-02 14:47:52 +00:00
|
|
|
cdplayer_base_init,
|
2003-05-24 10:56:28 +00:00
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) cdplayer_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (CDPlayer),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) cdplayer_init,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
cdplayer_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_type_register_static (GST_TYPE_BIN, "CDPlayer", &cdplayer_info, 0);
|
2003-05-24 10:56:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return cdplayer_type;
|
2002-07-27 01:33:42 +00:00
|
|
|
}
|
|
|
|
|
2003-11-02 14:47:52 +00:00
|
|
|
static void
|
|
|
|
cdplayer_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
2012-09-14 15:08:49 +00:00
|
|
|
gst_element_class_set_metadata (element_class, "CD Player",
|
2010-03-18 16:30:26 +00:00
|
|
|
"Generic/Bin",
|
|
|
|
"Play CD audio through the CD Drive",
|
|
|
|
"Charles Schmidt <cbschmid@uiuc.edu>, "
|
|
|
|
"Wim Taymans <wim.taymans@chello.be>");
|
2003-11-02 14:47:52 +00:00
|
|
|
}
|
2010-03-18 16:30:26 +00:00
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
static void
|
|
|
|
cdplayer_class_init (CDPlayerClass * klass)
|
2002-07-27 01:33:42 +00:00
|
|
|
{
|
2003-05-24 10:56:28 +00:00
|
|
|
GObjectClass *gobject_klass;
|
|
|
|
GstElementClass *gstelement_klass;
|
|
|
|
GstBinClass *gstbin_klass;
|
|
|
|
|
|
|
|
gobject_klass = (GObjectClass *) klass;
|
|
|
|
gstelement_klass = (GstElementClass *) klass;
|
|
|
|
gstbin_klass = (GstBinClass *) klass;
|
|
|
|
|
2006-04-08 21:48:01 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2003-05-24 10:56:28 +00:00
|
|
|
|
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_klass->finalize = GST_DEBUG_FUNCPTR (cdplayer_finalize);
|
2003-05-24 10:56:28 +00:00
|
|
|
|
|
|
|
gstelement_klass->change_state = GST_DEBUG_FUNCPTR (cdplayer_change_state);
|
|
|
|
gstbin_klass->iterate = GST_DEBUG_FUNCPTR (cdplayer_iterate);
|
|
|
|
|
|
|
|
gobject_klass->set_property = cdplayer_set_property;
|
|
|
|
gobject_klass->get_property = cdplayer_get_property;
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_klass, ARG_DEVICE,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_string ("device", "device", "CDROM device", NULL,
|
2004-03-15 19:32:27 +00:00
|
|
|
G_PARAM_READWRITE));
|
2003-05-24 10:56:28 +00:00
|
|
|
g_object_class_install_property (gobject_klass, ARG_NUM_TRACKS,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_int ("num_tracks", "num_tracks", "Number of Tracks",
|
2004-03-15 19:32:27 +00:00
|
|
|
G_MININT, G_MAXINT, 0, G_PARAM_READABLE));
|
2003-05-24 10:56:28 +00:00
|
|
|
g_object_class_install_property (gobject_klass, ARG_START_TRACK,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_int ("start_track", "start_track",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Track to start playback on", 1,
|
|
|
|
CDPLAYER_MAX_TRACKS - 1, 1, G_PARAM_READWRITE));
|
2003-05-24 10:56:28 +00:00
|
|
|
g_object_class_install_property (gobject_klass, ARG_END_TRACK,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_int ("end_track", "end_track",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Track to end playback on", 0,
|
|
|
|
CDPLAYER_MAX_TRACKS - 1, 0, G_PARAM_READWRITE));
|
2003-05-24 10:56:28 +00:00
|
|
|
g_object_class_install_property (gobject_klass, ARG_CURRENT_TRACK,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_int ("current_track", "current_track",
|
2004-03-15 19:32:27 +00:00
|
|
|
"Current track playing", 1,
|
|
|
|
CDPLAYER_MAX_TRACKS - 1, 1, G_PARAM_READABLE));
|
2003-05-24 10:56:28 +00:00
|
|
|
g_object_class_install_property (gobject_klass, ARG_CDDB_DISCID,
|
2004-03-14 22:34:33 +00:00
|
|
|
g_param_spec_uint ("cddb_discid", "cddb_discid", "CDDB Disc ID",
|
2004-03-15 19:32:27 +00:00
|
|
|
0, G_MAXUINT, 1, G_PARAM_READABLE));
|
2003-05-24 10:56:28 +00:00
|
|
|
|
|
|
|
cdplayer_signals[TRACK_CHANGE] =
|
2004-03-14 22:34:33 +00:00
|
|
|
g_signal_new ("track-change", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CDPlayerClass, track_change), NULL,
|
|
|
|
NULL, gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
|
2003-05-24 10:56:28 +00:00
|
|
|
|
|
|
|
return;
|
2002-07-27 01:33:42 +00:00
|
|
|
}
|
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
static void
|
|
|
|
cdplayer_init (CDPlayer * cdp)
|
2002-07-27 01:33:42 +00:00
|
|
|
{
|
2003-05-24 10:56:28 +00:00
|
|
|
cdp->device = g_strdup ("/dev/cdrom");
|
|
|
|
cdp->num_tracks = -1;
|
|
|
|
cdp->start_track = 1;
|
|
|
|
cdp->end_track = 0;
|
|
|
|
cdp->current_track = 1;
|
2002-07-27 01:33:42 +00:00
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
cdp->paused = FALSE;
|
2002-07-27 01:33:42 +00:00
|
|
|
|
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 (cdp, GST_BIN_FLAG_MANAGER);
|
2002-07-27 01:33:42 +00:00
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
return;
|
2002-07-27 01:33:42 +00:00
|
|
|
}
|
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
cdplayer_set_property (GObject * object, guint prop_id, const GValue * value,
|
|
|
|
GParamSpec * spec)
|
2002-07-27 01:33:42 +00:00
|
|
|
{
|
2003-05-24 10:56:28 +00:00
|
|
|
CDPlayer *cdp;
|
2002-07-27 01:33:42 +00:00
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
g_return_if_fail (GST_IS_CDPLAYER (object));
|
2002-07-27 01:33:42 +00:00
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
cdp = CDPLAYER (object);
|
2002-07-27 01:33:42 +00:00
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_DEVICE:
|
2002-07-27 01:33:42 +00:00
|
|
|
// FIXME prolly should uhh.. stop it or something
|
2003-05-24 10:56:28 +00:00
|
|
|
if (cdp->device) {
|
2004-03-15 19:32:27 +00:00
|
|
|
g_free (cdp->device);
|
2003-05-24 10:56:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cdp->device = g_strdup (g_value_get_string (value));
|
|
|
|
break;
|
|
|
|
case ARG_START_TRACK:
|
2002-07-27 01:33:42 +00:00
|
|
|
// FIXME prolly should uhh.. restart play, i guess... or something whatever
|
2002-07-28 22:45:45 +00:00
|
|
|
// FIXME we should only set current_track if its not playing...
|
2003-05-24 10:56:28 +00:00
|
|
|
cdp->current_track = cdp->start_track = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case ARG_END_TRACK:
|
2002-07-28 22:45:45 +00:00
|
|
|
// FIXME prolly should restart play, maybe, or try to set it without interrupt..
|
2003-05-24 10:56:28 +00:00
|
|
|
cdp->end_track = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2002-07-27 01:33:42 +00:00
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
return;
|
2002-07-27 01:33:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
cdplayer_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * spec)
|
2002-07-27 01:33:42 +00:00
|
|
|
{
|
2003-05-24 10:56:28 +00:00
|
|
|
CDPlayer *cdp;
|
|
|
|
|
|
|
|
g_return_if_fail (GST_IS_CDPLAYER (object));
|
|
|
|
|
|
|
|
cdp = CDPLAYER (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_DEVICE:
|
|
|
|
g_value_set_string (value, cdp->device);
|
|
|
|
break;
|
|
|
|
case ARG_NUM_TRACKS:
|
|
|
|
g_value_set_int (value, cdp->num_tracks);
|
|
|
|
break;
|
|
|
|
case ARG_START_TRACK:
|
|
|
|
g_value_set_int (value, cdp->start_track);
|
|
|
|
break;
|
|
|
|
case ARG_END_TRACK:
|
|
|
|
g_value_set_int (value, cdp->end_track);
|
|
|
|
case ARG_CURRENT_TRACK:
|
|
|
|
g_value_set_int (value, cdp->current_track);
|
|
|
|
break;
|
|
|
|
case ARG_CDDB_DISCID:
|
|
|
|
g_value_set_uint (value, cdp->cddb_discid);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2002-07-27 01:33:42 +00:00
|
|
|
}
|
|
|
|
|
2003-05-24 10:56:28 +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
|
|
|
cdplayer_finalize (GObject * object)
|
2002-07-27 01:33:42 +00:00
|
|
|
{
|
2003-05-24 10:56:28 +00:00
|
|
|
CDPlayer *cdp;
|
2002-07-27 01:33:42 +00:00
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
g_return_if_fail (GST_IS_CDPLAYER (object));
|
2002-07-27 01:33:42 +00:00
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
cdp = CDPLAYER (object);
|
|
|
|
g_free (cdp->device);
|
2002-07-27 01:33:42 +00:00
|
|
|
|
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
|
|
|
if (G_OBJECT_CLASS (parent_class)->finalize) {
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2003-05-24 10:56:28 +00:00
|
|
|
}
|
2002-07-27 01:33:42 +00:00
|
|
|
}
|
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
static gboolean
|
|
|
|
cdplayer_iterate (GstBin * bin)
|
2002-07-28 22:45:45 +00:00
|
|
|
{
|
2003-05-24 10:56:28 +00:00
|
|
|
CDPlayer *cdp = CDPLAYER (bin);
|
|
|
|
gint current_track;
|
|
|
|
|
|
|
|
switch (cd_status (CDPLAYER_CD (cdp))) {
|
|
|
|
case CD_PLAYING:
|
|
|
|
current_track = cd_current_track (CDPLAYER_CD (cdp));
|
|
|
|
if (current_track > cdp->end_track && cdp->end_track != 0) {
|
2004-03-15 19:32:27 +00:00
|
|
|
return FALSE;
|
2003-05-24 10:56:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (current_track != -1 && current_track != cdp->current_track) {
|
2004-03-15 19:32:27 +00:00
|
|
|
cdp->current_track = current_track;
|
|
|
|
g_signal_emit (G_OBJECT (cdp), cdplayer_signals[TRACK_CHANGE], 0,
|
|
|
|
cdp->current_track);
|
2003-05-24 10:56:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case CD_ERROR:
|
|
|
|
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
case CD_COMPLETED:
|
|
|
|
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
|
|
|
|
gst_element_set_eos (GST_ELEMENT (bin));
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2002-07-28 22:45:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-05 17:20:29 +00:00
|
|
|
static GstStateChangeReturn
|
|
|
|
cdplayer_change_state (GstElement * element, GstStateChange transition)
|
2002-07-27 01:33:42 +00:00
|
|
|
{
|
2003-05-24 10:56:28 +00:00
|
|
|
CDPlayer *cdp;
|
2005-09-05 17:20:29 +00:00
|
|
|
GstState state = GST_STATE (element);
|
|
|
|
GstState pending = GST_STATE_PENDING (element);
|
2003-05-24 10:56:28 +00:00
|
|
|
|
2005-09-05 17:20:29 +00:00
|
|
|
g_return_val_if_fail (GST_IS_CDPLAYER (element), GST_STATE_CHANGE_FAILURE);
|
2003-05-24 10:56:28 +00:00
|
|
|
|
|
|
|
cdp = CDPLAYER (element);
|
|
|
|
|
|
|
|
switch (pending) {
|
|
|
|
case GST_STATE_READY:
|
|
|
|
if (state != GST_STATE_PAUSED) {
|
2004-03-15 19:32:27 +00:00
|
|
|
if (cd_init (CDPLAYER_CD (cdp), cdp->device) == FALSE) {
|
2005-09-05 17:20:29 +00:00
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
2004-03-15 19:32:27 +00:00
|
|
|
}
|
|
|
|
cdp->num_tracks = cdp->cd.num_tracks;
|
|
|
|
cdp->cddb_discid = cd_cddb_discid (CDPLAYER_CD (cdp));
|
2003-05-24 10:56:28 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED:
|
|
|
|
/* ready->paused is not useful */
|
|
|
|
if (state != GST_STATE_READY) {
|
2004-03-15 19:32:27 +00:00
|
|
|
if (cd_pause (CDPLAYER_CD (cdp)) == FALSE) {
|
2005-09-05 17:20:29 +00:00
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
2004-03-15 19:32:27 +00:00
|
|
|
}
|
2003-05-24 10:56:28 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
cdp->paused = TRUE;
|
2003-05-24 10:56:28 +00:00
|
|
|
}
|
2002-07-27 01:33:42 +00:00
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_PLAYING:
|
|
|
|
if (cdp->paused == TRUE) {
|
2004-03-15 19:32:27 +00:00
|
|
|
if (cd_resume (CDPLAYER_CD (cdp)) == FALSE) {
|
2005-09-05 17:20:29 +00:00
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
2004-03-15 19:32:27 +00:00
|
|
|
}
|
2002-07-27 01:33:42 +00:00
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
cdp->paused = FALSE;
|
2003-05-24 10:56:28 +00:00
|
|
|
} else {
|
2004-03-15 19:32:27 +00:00
|
|
|
if (cd_start (CDPLAYER_CD (cdp), cdp->start_track,
|
|
|
|
cdp->end_track) == FALSE) {
|
2005-09-05 17:20:29 +00:00
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
2004-03-15 19:32:27 +00:00
|
|
|
}
|
2003-05-24 10:56:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case GST_STATE_NULL:
|
|
|
|
/* stop & close fd */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (cd_stop (CDPLAYER_CD (cdp)) == FALSE
|
2004-03-15 19:32:27 +00:00
|
|
|
|| cd_close (CDPLAYER_CD (cdp)) == FALSE) {
|
2005-09-05 17:20:29 +00:00
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
2003-05-24 10:56:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state) {
|
2005-09-05 17:20:29 +00:00
|
|
|
GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
2003-05-24 10:56:28 +00:00
|
|
|
}
|
|
|
|
|
2005-09-05 17:20:29 +00:00
|
|
|
return GST_STATE_CHANGE_SUCCESS;
|
2002-07-27 01:33:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-24 10:56:28 +00:00
|
|
|
static gboolean
|
2003-11-02 14:47:52 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2002-07-27 01:33:42 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
return gst_element_register (plugin, "cdplayer", GST_RANK_NONE,
|
|
|
|
GST_TYPE_CDPLAYER);
|
2002-07-27 01:33:42 +00:00
|
|
|
}
|
|
|
|
|
2012-04-05 16:02:56 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, cdplayer, "CD Player", plugin_init, VERSION, GST_LICENSE, /* ? */
|
2006-04-01 10:09:11 +00:00
|
|
|
GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
|