diff options
author | Charles Schmidt <cbschmid@users.sourceforge.net> | 2002-07-28 22:45:45 +0000 |
---|---|---|
committer | Charles Schmidt <cbschmid@users.sourceforge.net> | 2002-07-28 22:45:45 +0000 |
commit | 0327f33923e0861e59dbaba696f86d87149eb885 (patch) | |
tree | 62c25141c8d0e8543dd5f00626f9e95deb48d898 /sys/cdrom/gstcdplayer.c | |
parent | 186ba5c337e42e8c87f1851615e1d0dd7c717904 (diff) | |
download | gst-plugins-bad-0327f33923e0861e59dbaba696f86d87149eb885.tar.gz gst-plugins-bad-0327f33923e0861e59dbaba696f86d87149eb885.tar.bz2 gst-plugins-bad-0327f33923e0861e59dbaba696f86d87149eb885.zip |
Added *BSD (and Darwin) ioctl cdaudio playing. Couple bugfixes. 'end-track','current-track' and 'cddb-discid' propert...
Original commit message from CVS:
Added *BSD (and Darwin) ioctl cdaudio playing. Couple bugfixes. 'end-track','current-track' and 'cddb-discid' properties and 'track-change' signal for the element.
Diffstat (limited to 'sys/cdrom/gstcdplayer.c')
-rw-r--r-- | sys/cdrom/gstcdplayer.c | 85 |
1 files changed, 71 insertions, 14 deletions
diff --git a/sys/cdrom/gstcdplayer.c b/sys/cdrom/gstcdplayer.c index 2bbbddb2..7852276f 100644 --- a/sys/cdrom/gstcdplayer.c +++ b/sys/cdrom/gstcdplayer.c @@ -17,8 +17,9 @@ * Boston, MA 02111-1307, USA. */ +/* #define GST_DEBUG_ENABLED */ + #include "gstcdplayer.h" -#include "gstcdplayer_ioctl.h" /* props */ enum { @@ -26,10 +27,14 @@ enum { ARG_DEVICE, ARG_NUM_TRACKS, ARG_START_TRACK, + ARG_END_TRACK, + ARG_CURRENT_TRACK, + ARG_CDDB_DISCID, }; /* signals */ enum { + TRACK_CHANGE, LAST_SIGNAL, }; @@ -38,6 +43,7 @@ static void cdplayer_init(CDPlayer *cdp); 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 void cdplayer_dispose(GObject *object); +static gboolean cdplayer_iterate(GstBin *bin); static GstElementStateReturn cdplayer_change_state(GstElement *element); static gboolean plugin_init(GModule *module,GstPlugin *plugin); @@ -45,7 +51,7 @@ static gboolean plugin_init(GModule *module,GstPlugin *plugin); static GstElementClass *parent_class; -/* static guint cdplayer_signals[LAST_SIGNAL] = {0}; */ + static guint cdplayer_signals[LAST_SIGNAL] = {0}; static GstElementDetails cdplayer_details = { @@ -87,19 +93,27 @@ static void cdplayer_class_init(CDPlayerClass *klass) { GObjectClass *gobject_klass; GstElementClass *gstelement_klass; + GstBinClass *gstbin_klass; gobject_klass = (GObjectClass *)klass; gstelement_klass = (GstElementClass *)klass; + gstbin_klass = (GstBinClass *)klass; parent_class = g_type_class_ref(gst_bin_get_type()); gobject_klass->dispose = GST_DEBUG_FUNCPTR(cdplayer_dispose); gstelement_klass->change_state = GST_DEBUG_FUNCPTR(cdplayer_change_state); + gstbin_klass->iterate = GST_DEBUG_FUNCPTR(cdplayer_iterate); g_object_class_install_property(gobject_klass,ARG_DEVICE,g_param_spec_string("device","device","CDROM device",NULL,G_PARAM_READWRITE)); g_object_class_install_property(gobject_klass,ARG_NUM_TRACKS,g_param_spec_int("num_tracks","num_tracks","Number of Tracks",G_MININT,G_MAXINT,0,G_PARAM_READABLE)); - g_object_class_install_property(gobject_klass,ARG_START_TRACK,g_param_spec_int("start_track","start_track","Track to start playback on",1,CDPLAYER_MAX_TRACKS-1,1,G_PARAM_READABLE)); + g_object_class_install_property(gobject_klass,ARG_START_TRACK,g_param_spec_int("start_track","start_track","Track to start playback on",1,CDPLAYER_MAX_TRACKS-1,1,G_PARAM_READWRITE)); + g_object_class_install_property(gobject_klass,ARG_END_TRACK,g_param_spec_int("end_track","end_track","Track to end playback on",0,CDPLAYER_MAX_TRACKS-1,0,G_PARAM_READWRITE)); + g_object_class_install_property(gobject_klass,ARG_CURRENT_TRACK,g_param_spec_int("current_track","current_track","Current track playing",1,CDPLAYER_MAX_TRACKS-1,1,G_PARAM_READABLE)); + g_object_class_install_property(gobject_klass,ARG_CDDB_DISCID,g_param_spec_uint("cddb_discid","cddb_discid","CDDB Disc ID",0,G_MAXUINT,1,G_PARAM_READABLE)); + + cdplayer_signals[TRACK_CHANGE] = 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); gobject_klass->set_property = cdplayer_set_property; gobject_klass->get_property = cdplayer_get_property; @@ -112,11 +126,12 @@ static void cdplayer_init(CDPlayer *cdp) cdp->device = g_strdup("/dev/cdrom"); cdp->num_tracks = -1; cdp->start_track = 1; + cdp->end_track = 0; + cdp->current_track = 1; cdp->paused = FALSE; - GST_FLAG_SET(cdp,GST_BIN_FLAG_MANAGER); - GST_FLAG_SET(cdp,GST_BIN_SELF_SCHEDULABLE); +// GST_FLAG_SET(cdp,GST_BIN_FLAG_MANAGER); return; } @@ -140,7 +155,12 @@ static void cdplayer_set_property(GObject *object,guint prop_id,const GValue *va break; case ARG_START_TRACK: // FIXME prolly should uhh.. restart play, i guess... or something whatever - cdp->start_track = g_value_get_int(value); +// FIXME we should only set current_track if its not playing... + cdp->current_track = cdp->start_track = g_value_get_int(value); + break; + case ARG_END_TRACK: +// FIXME prolly should restart play, maybe, or try to set it without interrupt.. + cdp->end_track = g_value_get_int(value); break; default: break; @@ -168,6 +188,13 @@ static void cdplayer_get_property(GObject *object,guint prop_id,GValue *value,GP 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; } @@ -182,20 +209,49 @@ static void cdplayer_dispose(GObject *object) g_return_if_fail(GST_IS_CDPLAYER(object)); cdp = CDPLAYER(object); - - G_OBJECT_CLASS(parent_class)->dispose(object); - g_free(cdp->device); - if (GST_ELEMENT_SCHED(cdp)) { - gst_scheduler_reset(GST_ELEMENT_SCHED(cdp)); - gst_object_unref(GST_OBJECT(GST_ELEMENT_SCHED(cdp))); - GST_ELEMENT_SCHED(cdp) = NULL; + if (G_OBJECT_CLASS(parent_class)->dispose) { + G_OBJECT_CLASS(parent_class)->dispose(object); } return; } +static gboolean cdplayer_iterate(GstBin *bin) +{ + 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) { + return FALSE; + } + + if (current_track != -1 && current_track != cdp->current_track) { + cdp->current_track = current_track; + g_signal_emit(G_OBJECT(cdp),cdplayer_signals[TRACK_CHANGE],0,cdp->current_track); + } + + 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; +} + + static GstElementStateReturn cdplayer_change_state(GstElement *element) { CDPlayer *cdp; @@ -213,6 +269,7 @@ static GstElementStateReturn cdplayer_change_state(GstElement *element) return GST_STATE_FAILURE; } cdp->num_tracks = cdp->cd.num_tracks; + cdp->cddb_discid = cd_cddb_discid(CDPLAYER_CD(cdp)); } break; case GST_STATE_PAUSED: @@ -234,7 +291,7 @@ static GstElementStateReturn cdplayer_change_state(GstElement *element) cdp->paused = FALSE; } else { - if (cd_start(CDPLAYER_CD(cdp),cdp->start_track) == FALSE) { + if (cd_start(CDPLAYER_CD(cdp),cdp->start_track,cdp->end_track) == FALSE) { return GST_STATE_FAILURE; } } |