*/
schanid_t
glk_schannel_create(glui32 rock)
+{
+ return glk_schannel_create_ext(rock, 0x10000);
+}
+
+/**
+ * glk_schannel_create_ext:
+ * @rock: The rock value to give the new sound channel.
+ * @volume: Integer representing the volume; 0x10000 is 100%.
+ *
+ * [DRAFT SPEC]
+ *
+ * The glk_schannel_create_ext() call lets you create a channel with the volume
+ * already set at a given level.
+ *
+ * Returns: A new sound channel, or %NULL.
+ */
+schanid_t
+glk_schannel_create_ext(glui32 rock, glui32 volume)
{
#ifdef GSTREAMER_SOUND
ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
goto fail;
}
+ /* Set the initial volume */
+ glk_schannel_set_volume(s, volume);
+
/* Put the elements in the pipeline and link as many together as we can
without knowing the type of the audio stream */
gst_bin_add_many(GST_BIN(s->pipeline), s->source, s->typefind, s->convert, s->filter, s->sink, NULL);
g_object_set(chan->source, "stream", stream, NULL);
g_object_unref(stream); /* Now owned by GStreamer element */
- if(!gst_element_set_state(chan->pipeline, GST_STATE_PLAYING)) {
- WARNING_S(_("Could not set GstElement state to"), "PLAYING");
+ /* Play the sound; unless the channel is paused, then pause it instead */
+ if(!gst_element_set_state(chan->pipeline, chan->paused? GST_STATE_PAUSED : GST_STATE_PLAYING)) {
+ WARNING_S(_("Could not set GstElement state to"), chan->paused? "PAUSED" : "PLAYING");
return 0;
}
return 1;
/**
* glk_schannel_play_multi:
- * @chanarray:
- * @chancount:
- * @sndarray:
- * @soundcount:
- * @notify:
+ * @chanarray: Array of #schanid_t structures.
+ * @chancount: Length of @chanarray.
+ * @sndarray: Array of sound resource numbers.
+ * @soundcount: Length of @sndarray, must be equal to @chanarray.
+ * @notify: If nonzero, request a notification when each sound finishes.
*
* [DRAFT SPEC]
*
{
VALID_SCHANNEL(chan, return);
- /* Not implemented */
+ if(chan->paused)
+ return; /* Silently do nothing */
+
+ /* Mark the channel as paused even if there is no sound playing yet */
+ chan->paused = TRUE;
+
+ GstState state;
+ if(gst_element_get_state(chan->pipeline, &state, NULL, GST_CLOCK_TIME_NONE) != GST_STATE_CHANGE_SUCCESS) {
+ WARNING(_("Could not get GstElement state"));
+ return;
+ }
+ if(state != GST_STATE_PLAYING)
+ return; /* Silently do nothing if no sound is playing */
+
+ if(!gst_element_set_state(chan->pipeline, GST_STATE_PAUSED)) {
+ WARNING_S(_("Could not set GstElement state to"), "PAUSED");
+ return;
+ }
}
/**
{
VALID_SCHANNEL(chan, return);
- /* Not implemented */
+ if(!chan->paused)
+ return; /* Silently do nothing */
+
+ /* Mark the channel as not paused in any case */
+ chan->paused = FALSE;
+
+ GstState state;
+ if(gst_element_get_state(chan->pipeline, &state, NULL, GST_CLOCK_TIME_NONE) != GST_STATE_CHANGE_SUCCESS) {
+ WARNING(_("Could not get GstElement state"));
+ return;
+ }
+ if(state != GST_STATE_PAUSED)
+ return; /* Silently do nothing */
+
+ if(!gst_element_set_state(chan->pipeline, GST_STATE_PLAYING)) {
+ WARNING_S(_("Could not set GstElement state to"), "PLAYING");
+ return;
+ }
}
/**
* volume change should be wherever the previous volume change was interrupted
* (rather than the previous change's beginning or ending point).
*
- * Not all libraries support thse functions. You should test the appropriate
+ * Not all libraries support these functions. You should test the appropriate
* gestalt selectors before you rely on them; see "Testing for Sound
* Capabilities".
*/
#ifdef GSTREAMER_SOUND
gdouble volume_gst = (gdouble)vol / 0x10000;
- g_printerr("Volume set to: %f\n", volume_gst);
g_object_set(chan->filter, "volume", CLAMP(volume_gst, 0.0, 10.0), NULL);
#endif