+
+#if defined(GSTREAMER_0_10_SOUND) || defined(GSTREAMER_1_0_SOUND)
+ ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key);
+ if(!glk_data->resource_map && !glk_data->resource_load_callback) {
+ WARNING(_("No resource map has been loaded yet."));
+ return 0;
+ }
+
+ /* We keep an array of sounds to skip if any of them have errors */
+ gboolean *skiparray = g_new0(gboolean, chancount);
+
+ /* Set up all the channels one by one */
+ for(count = 0; count < chancount; count++) {
+ /* Stop the previous sound */
+ clean_up_after_playing_sound(chanarray[count]);
+
+ GInputStream *stream = load_resource_into_giostream(sndarray[count]);
+ if(stream == NULL) {
+ skiparray[count] = TRUE;
+ continue;
+ }
+
+ chanarray[count]->source = gst_element_factory_make("giostreamsrc", NULL);
+ g_object_set(chanarray[count]->source, "stream", stream, NULL);
+ g_object_unref(stream); /* Now owned by GStreamer element */
+ gst_bin_add(GST_BIN(chanarray[count]->pipeline), chanarray[count]->source);
+ if(!gst_element_link(chanarray[count]->source, chanarray[count]->typefind)) {
+ WARNING(_("Could not link GStreamer elements"));
+ clean_up_after_playing_sound(chanarray[count]);
+ }
+
+ chanarray[count]->repeats = 1;
+ chanarray[count]->resource = sndarray[count];
+ chanarray[count]->notify = notify;
+ }
+
+ /* Start all the sounds as close to each other as possible. */
+ /* FIXME: Is there a way to start them exactly at the same time? */
+ glui32 successes = 0;
+ for(count = 0; count < chancount; count++) {
+ if(skiparray[count])
+ continue;
+ /* Play the sound; unless the channel is paused, then pause it instead */
+ if(!gst_element_set_state(chanarray[count]->pipeline, chanarray[count]->paused? GST_STATE_PAUSED : GST_STATE_PLAYING)) {
+ WARNING_S(_("Could not set GstElement state to"), chanarray[count]->paused? "PAUSED" : "PLAYING");
+ skiparray[count] = TRUE;
+ clean_up_after_playing_sound(chanarray[count]);
+ continue;
+ }
+ successes++;
+ }
+ g_free(skiparray);
+ return successes;
+#else