mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
cdaudio: fix properties
Fix properties and allow setting the device property.
This commit is contained in:
parent
4c625bd569
commit
6095ea02c4
1 changed files with 42 additions and 22 deletions
|
@ -66,15 +66,22 @@ struct _GstCDAudioClass
|
|||
void (*track_change) (GstElement * element, guint track);
|
||||
};
|
||||
|
||||
#define DEFAULT_DEVICE "/dev/cdrom"
|
||||
#define DEFAULT_VOLUME_FR 255
|
||||
#define DEFAULT_VOLUME_FL 255
|
||||
#define DEFAULT_VOLUME_BR 255
|
||||
#define DEFAULT_VOLUME_BL 255
|
||||
|
||||
/* props */
|
||||
enum
|
||||
{
|
||||
ARG_0,
|
||||
ARG_DEVICE,
|
||||
ARG_VOLUME_FR,
|
||||
ARG_VOLUME_FL,
|
||||
ARG_VOLUME_BR,
|
||||
ARG_VOLUME_BL
|
||||
PROP_0,
|
||||
PROP_DEVICE,
|
||||
PROP_VOLUME_FR,
|
||||
PROP_VOLUME_FL,
|
||||
PROP_VOLUME_BR,
|
||||
PROP_VOLUME_BL,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
/* signals */
|
||||
|
@ -157,19 +164,19 @@ gst_cdaudio_class_init (GstCDAudioClass * klass)
|
|||
gobject_klass->set_property = gst_cdaudio_set_property;
|
||||
gobject_klass->get_property = gst_cdaudio_get_property;
|
||||
|
||||
g_object_class_install_property (gobject_klass, ARG_DEVICE,
|
||||
g_object_class_install_property (gobject_klass, PROP_DEVICE,
|
||||
g_param_spec_string ("device", "Device", "CDROM device",
|
||||
NULL, G_PARAM_READWRITE));
|
||||
g_object_class_install_property (gobject_klass, ARG_VOLUME_FL,
|
||||
g_object_class_install_property (gobject_klass, PROP_VOLUME_FL,
|
||||
g_param_spec_int ("volume_fl", "Volume fl", "Front left volume",
|
||||
0, 255, 255, G_PARAM_READWRITE));
|
||||
g_object_class_install_property (gobject_klass, ARG_VOLUME_FR,
|
||||
g_object_class_install_property (gobject_klass, PROP_VOLUME_FR,
|
||||
g_param_spec_int ("volume_fr", "Volume fr", "Front right volume",
|
||||
0, 255, 255, G_PARAM_READWRITE));
|
||||
g_object_class_install_property (gobject_klass, ARG_VOLUME_BL,
|
||||
g_object_class_install_property (gobject_klass, PROP_VOLUME_BL,
|
||||
g_param_spec_int ("volume_bl", "Volume bl", "Back left volume",
|
||||
0, 255, 255, G_PARAM_READWRITE));
|
||||
g_object_class_install_property (gobject_klass, ARG_VOLUME_BR,
|
||||
g_object_class_install_property (gobject_klass, PROP_VOLUME_BR,
|
||||
g_param_spec_int ("volume_br", "Volume br", "Back right volume",
|
||||
0, 255, 255, G_PARAM_READWRITE));
|
||||
|
||||
|
@ -192,7 +199,12 @@ gst_cdaudio_class_init (GstCDAudioClass * klass)
|
|||
static void
|
||||
gst_cdaudio_init (GstCDAudio * cdaudio, GstCDAudioClass * g_class)
|
||||
{
|
||||
cdaudio->device = g_strdup ("/dev/cdrom");
|
||||
cdaudio->device = g_strdup (DEFAULT_DEVICE);
|
||||
cdaudio->volume.vol_front.right = DEFAULT_VOLUME_FR;
|
||||
cdaudio->volume.vol_front.left = DEFAULT_VOLUME_FL;
|
||||
cdaudio->volume.vol_back.right = DEFAULT_VOLUME_BR;
|
||||
cdaudio->volume.vol_back.left = DEFAULT_VOLUME_BL;
|
||||
|
||||
cdaudio->was_playing = FALSE;
|
||||
cdaudio->timer = g_timer_new ();
|
||||
|
||||
|
@ -219,15 +231,21 @@ gst_cdaudio_set_property (GObject * object, guint prop_id, const GValue * value,
|
|||
cdaudio = GST_CDAUDIO (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case ARG_DEVICE:
|
||||
case PROP_DEVICE:
|
||||
g_free (cdaudio->device);
|
||||
cdaudio->device = g_value_dup_string (value);
|
||||
break;
|
||||
case ARG_VOLUME_FR:
|
||||
case PROP_VOLUME_FR:
|
||||
cdaudio->volume.vol_front.right = g_value_get_int (value);
|
||||
break;
|
||||
case ARG_VOLUME_FL:
|
||||
case PROP_VOLUME_FL:
|
||||
cdaudio->volume.vol_front.left = g_value_get_int (value);
|
||||
break;
|
||||
case ARG_VOLUME_BR:
|
||||
case PROP_VOLUME_BR:
|
||||
cdaudio->volume.vol_back.right = g_value_get_int (value);
|
||||
break;
|
||||
case ARG_VOLUME_BL:
|
||||
case PROP_VOLUME_BL:
|
||||
cdaudio->volume.vol_back.left = g_value_get_int (value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -243,19 +261,19 @@ gst_cdaudio_get_property (GObject * object, guint prop_id, GValue * value,
|
|||
cdaudio = GST_CDAUDIO (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case ARG_DEVICE:
|
||||
case PROP_DEVICE:
|
||||
g_value_set_string (value, cdaudio->device);
|
||||
break;
|
||||
case ARG_VOLUME_FR:
|
||||
case PROP_VOLUME_FR:
|
||||
g_value_set_int (value, cdaudio->volume.vol_front.right);
|
||||
break;
|
||||
case ARG_VOLUME_FL:
|
||||
case PROP_VOLUME_FL:
|
||||
g_value_set_int (value, cdaudio->volume.vol_front.left);
|
||||
break;
|
||||
case ARG_VOLUME_BR:
|
||||
case PROP_VOLUME_BR:
|
||||
g_value_set_int (value, cdaudio->volume.vol_back.right);
|
||||
break;
|
||||
case ARG_VOLUME_BL:
|
||||
case PROP_VOLUME_BL:
|
||||
g_value_set_int (value, cdaudio->volume.vol_back.left);
|
||||
break;
|
||||
default:
|
||||
|
@ -573,6 +591,7 @@ cdaudio_uri_get_type (void)
|
|||
{
|
||||
return GST_URI_SRC;
|
||||
}
|
||||
|
||||
static gchar **
|
||||
cdaudio_uri_get_protocols (void)
|
||||
{
|
||||
|
@ -580,6 +599,7 @@ cdaudio_uri_get_protocols (void)
|
|||
|
||||
return protocols;
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
cdaudio_uri_get_uri (GstURIHandler * handler)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue