summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-09-03 00:02:30 +0200
committerLennart Poettering <lennart@poettering.net>2008-09-03 00:02:30 +0200
commit0c1f6a8612d683fe9ba73749e4f624420bd231d4 (patch)
tree4d69ee63662413f671a799bb45b3e1892ab6143e
parentc62c827a061bc3a2a191802a3f0e7726c88c4468 (diff)
parent6ac713466c207ce8253410d1598f5f37e509acc2 (diff)
Merge commit 'elmarco/upstream-master'
-rw-r--r--src/canberra-gtk-play.c32
-rw-r--r--src/canberra-gtk.c2
-rw-r--r--src/gstreamer.c42
3 files changed, 45 insertions, 31 deletions
diff --git a/src/canberra-gtk-play.c b/src/canberra-gtk-play.c
index 0b68dd9..689a8f6 100644
--- a/src/canberra-gtk-play.c
+++ b/src/canberra-gtk-play.c
@@ -80,14 +80,17 @@ static void callback(ca_context *c, uint32_t id, int error, void *userdata) {
int main (int argc, char *argv[]) {
GOptionContext *oc;
- static gchar *event_id = NULL, *event_description = NULL, *cache_control = NULL;
+ static gchar *event_id = NULL, *filename = NULL, *event_description = NULL, *cache_control = NULL;
int r;
+ static gboolean version = FALSE;
static const GOptionEntry options[] = {
- { "id", 0, 0, G_OPTION_ARG_STRING, &event_id, "Event sound identifier", "STRING" },
- { "description", 0, 0, G_OPTION_ARG_STRING, &event_description, "Event sound description", "STRING" },
- { "cache-control", 0, 0, G_OPTION_ARG_STRING, &cache_control, "Cache control (permanent, volatile, never)", "STRING" },
- { "loop", 0, 0, G_OPTION_ARG_INT, &n_loops, "Loop how many times (detault: 1)", "INTEGER" },
+ { "id", 'i', 0, G_OPTION_ARG_STRING, &event_id, "Event sound identifier", "STRING" },
+ { "file", 'f', 0, G_OPTION_ARG_STRING, &filename, "Play file", "PATH" },
+ { "description", 'd', 0, G_OPTION_ARG_STRING, &event_description, "Event sound description", "STRING" },
+ { "cache-control", 'c', 0, G_OPTION_ARG_STRING, &cache_control, "Cache control (permanent, volatile, never)", "STRING" },
+ { "loop", 'l', 0, G_OPTION_ARG_INT, &n_loops, "Loop how many times (detault: 1)", "INTEGER" },
+ { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Display version number and quit", NULL },
{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
@@ -96,16 +99,20 @@ int main (int argc, char *argv[]) {
g_type_init();
g_thread_init(NULL);
- oc = g_option_context_new("- libcanberra-gtk-play");
+ oc = g_option_context_new("- canberra-gtk-play");
g_option_context_add_main_entries(oc, options, NULL);
+ g_option_context_add_group(oc, gtk_get_option_group(TRUE));
g_option_context_set_help_enabled(oc, TRUE);
g_option_context_parse(oc, &argc, &argv, NULL);
g_option_context_free(oc);
- gtk_init(&argc, &argv);
+ if (version) {
+ g_print("canberra-gtk-play from %s\n", PACKAGE_STRING);
+ return 0;
+ }
- if (!event_id) {
- g_printerr("No event id specified.\n");
+ if (!event_id && !filename) {
+ g_printerr("No event id or file specified.\n");
return 1;
}
@@ -115,7 +122,12 @@ int main (int argc, char *argv[]) {
NULL);
ca_proplist_create(&proplist);
- ca_proplist_sets(proplist, CA_PROP_EVENT_ID, event_id);
+
+ if (event_id)
+ ca_proplist_sets(proplist, CA_PROP_EVENT_ID, event_id);
+
+ if (filename)
+ ca_proplist_sets(proplist, CA_PROP_MEDIA_FILENAME, filename);
if (cache_control)
ca_proplist_sets(proplist, CA_PROP_CANBERRA_CACHE_CONTROL, cache_control);
diff --git a/src/canberra-gtk.c b/src/canberra-gtk.c
index 66a2b9a..d3be082 100644
--- a/src/canberra-gtk.c
+++ b/src/canberra-gtk.c
@@ -101,6 +101,8 @@ ca_context *ca_gtk_context_get(void) {
s = gtk_settings_get_default();
+ ca_return_val_if_fail(s, NULL);
+
if (g_object_class_find_property(G_OBJECT_GET_CLASS(s), "gtk-sound-theme-name")) {
g_signal_connect(G_OBJECT(s), "notify::gtk-sound-theme-name", G_CALLBACK(sound_theme_name_changed), c);
read_sound_theme_name(c, s);
diff --git a/src/gstreamer.c b/src/gstreamer.c
index 59556a1..caa28a6 100644
--- a/src/gstreamer.c
+++ b/src/gstreamer.c
@@ -86,7 +86,7 @@ int driver_open(ca_context *c) {
ca_return_val_if_fail(!PRIVATE(c), CA_ERROR_INVALID);
ca_return_val_if_fail(!c->driver || ca_streq(c->driver, "gstreamer"), CA_ERROR_NODRIVER);
- gst_init_check (NULL, NULL, &error);
+ gst_init_check(NULL, NULL, &error);
if (error != NULL) {
g_warning("gst_init: %s ", error->message);
g_error_free(error);
@@ -173,7 +173,7 @@ int driver_destroy(ca_context *c) {
ca_free(p);
- /* no gst_deinit (), see doc */
+ /* no gst_deinit(), see doc */
return CA_SUCCESS;
}
@@ -292,22 +292,22 @@ static void on_pad_added(GstElement *element, GstPad *pad, gboolean arg1, gpoint
GstPad *vpad;
const char *type;
- sinkelement = (GstElement *)data;
+ sinkelement = GST_ELEMENT(data);
- caps = gst_pad_get_caps (pad);
- if (gst_caps_is_empty (caps) || gst_caps_is_any (caps)) {
- gst_caps_unref (caps);
+ caps = gst_pad_get_caps(pad);
+ if (gst_caps_is_empty(caps) || gst_caps_is_any(caps)) {
+ gst_caps_unref(caps);
return;
}
- structure = gst_caps_get_structure (caps, 0);
- type = gst_structure_get_name (structure);
- if (g_str_has_prefix (type, "audio/x-raw") == TRUE) {
- vpad = gst_element_get_pad (sinkelement, "sink");
- gst_pad_link (pad, vpad);
- gst_object_unref (vpad);
+ structure = gst_caps_get_structure(caps, 0);
+ type = gst_structure_get_name(structure);
+ if (g_str_has_prefix(type, "audio/x-raw") == TRUE) {
+ vpad = gst_element_get_pad(sinkelement, "sink");
+ gst_pad_link(pad, vpad);
+ gst_object_unref(vpad);
}
- gst_caps_unref (caps);
+ gst_caps_unref(caps);
}
int driver_play(ca_context *c, uint32_t id, ca_proplist *proplist, ca_finish_callback_t cb, void *userdata) {
@@ -349,9 +349,9 @@ int driver_play(ca_context *c, uint32_t id, ca_proplist *proplist, ca_finish_cal
goto fail;
}
- bin = gst_bin_new ("audiobin");
+ bin = gst_bin_new("audiobin");
- g_signal_connect (decodebin, "new-decoded-pad", G_CALLBACK (on_pad_added), bin);
+ g_signal_connect(decodebin, "new-decoded-pad", G_CALLBACK (on_pad_added), bin);
bus = gst_pipeline_get_bus(GST_PIPELINE (out->pipeline));
gst_bus_set_sync_handler(bus, bus_cb, out);
@@ -369,15 +369,15 @@ int driver_play(ca_context *c, uint32_t id, ca_proplist *proplist, ca_finish_cal
goto fail;
}
- gst_bin_add_many (GST_BIN (bin), audioconvert, audioresample, sink, NULL);
- gst_element_link_many (audioconvert, audioresample, sink, NULL);
+ gst_bin_add_many(GST_BIN (bin), audioconvert, audioresample, sink, NULL);
+ gst_element_link_many(audioconvert, audioresample, sink, NULL);
- audiopad = gst_element_get_pad (audioconvert, "sink");
- gst_element_add_pad (bin, gst_ghost_pad_new ("sink", audiopad));
+ audiopad = gst_element_get_pad(audioconvert, "sink");
+ gst_element_add_pad(bin, gst_ghost_pad_new("sink", audiopad));
- gst_object_unref (audiopad);
+ gst_object_unref(audiopad);
- gst_bin_add (GST_BIN (out->pipeline), bin);
+ gst_bin_add(GST_BIN (out->pipeline), bin);
decodebin = NULL;
sink = NULL;