2 * Copyright (C) 2008 Rov Juvano <rovjuvano@users.sourceforge.net>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "demo-player.h"
25 static guint demo_player_signals
[LAST_SIGNAL
] = { 0 };
34 typedef struct _DemoPlayerPrivate
39 #define DEMO_PLAYER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEMO_TYPE_PLAYER, DemoPlayerPrivate))
42 /* method implementations */
43 static void demo_player_play_uri_func (DemoPlayer
*player
,
46 g_print ("Now Playing: %s\n", uri
);
51 void demo_player_play_uri (DemoPlayer
*player
,
54 DEMO_PLAYER_GET_CLASS (player
)->play_uri(player
, uri
);
58 /* GObject overrides */
60 demo_player_get_property (GObject
*object
,
65 DemoPlayer
*player
= DEMO_PLAYER (object
);
66 switch (property_id
) {
68 g_value_set_double (value
, player
->rate
);
71 g_value_set_string (value
, player
->filter
);
74 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, property_id
, pspec
);
80 demo_player_set_property (GObject
*object
,
85 DemoPlayer
*player
= DEMO_PLAYER (object
);
86 switch (property_id
) {
88 player
->filter
= g_value_dup_string (value
);
91 G_OBJECT_WARN_INVALID_PROPERTY_ID (object
, property_id
, pspec
);
97 /* GTypeInfo functions */
99 demo_player_init (GTypeInstance
*instance
,
102 DemoPlayer
*player
= (DemoPlayer
*)instance
;
104 player
->filter
= "identity";
108 demo_player_class_init (gpointer g_class
,
111 g_type_class_add_private (g_class
, sizeof (DemoPlayerPrivate
));
114 DemoPlayerClass
*player_class
= (DemoPlayerClass
*)g_class
;
115 player_class
->play_uri
= demo_player_play_uri_func
;
118 GObjectClass
*as_object_class
= G_OBJECT_CLASS (g_class
);
119 as_object_class
->get_property
= demo_player_get_property
;
120 as_object_class
->set_property
= demo_player_set_property
;
122 g_object_class_install_property (as_object_class
, PROP_RATE
,
123 g_param_spec_double ("rate", "Rate", "Current playback rate",
124 -128, 128, 1.0, G_PARAM_READABLE
));
126 g_object_class_install_property (as_object_class
, PROP_FILTER
,
127 g_param_spec_string ("filter", "Filter", "Filter to handle rate change",
128 "identity", G_PARAM_READWRITE
));
130 demo_player_signals
[SIGNAL_RATE_CHANGE
] =
131 g_signal_new ("rate-changed", G_TYPE_FROM_CLASS (g_class
), G_SIGNAL_RUN_FIRST
,
133 g_cclosure_marshal_VOID__DOUBLE
, G_TYPE_NONE
, 1, G_TYPE_DOUBLE
);
137 demo_player_get_type (void)
139 static GType type
= 0;
140 if (G_UNLIKELY (type
== 0)) {
141 static const GTypeInfo info
= {
142 sizeof (DemoPlayerClass
),
143 NULL
, /* base_init */
144 NULL
, /* base_finalize */
145 demo_player_class_init
, /* class_init */
146 NULL
, /* class_finalize */
147 NULL
, /* class_data */
150 demo_player_init
, /* instance_init */
151 NULL
/* value_table */
153 type
= g_type_register_static (G_TYPE_OBJECT
,