case gestalt_GraphicsTransparency:
return 1;
+ /* Capabilities supported if compiled with GStreamer */
case gestalt_Sound:
case gestalt_SoundVolume:
+ case gestalt_SoundNotify:
#ifdef GSTREAMER_SOUND
return 1;
#else
#endif
/* Unsupported capabilities */
- case gestalt_SoundNotify:
case gestalt_SoundMusic:
/* Selector not supported */
default:
#include "gi_dispa.h"
#include "gi_blorb.h"
#include "resource.h"
+#include "event.h"
extern GPrivate *glk_data_key;
}
} else {
clean_up_after_playing_sound(s);
+ /* Sound ended normally, send a notification if requested */
+ if(s->notify)
+ event_throw(s->glk, evtype_SoundNotify, NULL, s->resource, s->notify);
}
break;
default:
glk_data->schannel_list = g_list_prepend(glk_data->schannel_list, s);
s->schannel_list = glk_data->schannel_list;
+ /* Add a pointer to the ChimaraGlk widget, for convenience */
+ s->glk = glk_data->self;
+
/* Create a GStreamer pipeline for the sound channel */
gchar *pipeline_name = g_strdup_printf("pipeline-%p", s);
s->pipeline = gst_pipeline_new(pipeline_name);
}
chan->repeats = repeats;
+ chan->resource = snd;
+ chan->notify = notify;
g_object_set(chan->source, "stream", stream, NULL);
g_object_unref(stream); /* Now owned by GStreamer element */
#include <glib.h>
#include "glk.h"
#include "gi_dispa.h"
+#include "chimara-glk.h"
#ifdef GSTREAMER_SOUND
#include <gst/gst.h>
#endif
/* Pointer to the list node in the global sound channel list that contains
this sound channel */
GList *schannel_list;
+ /* Pointer to the GTK widget this sound channel belongs to, for convenience */
+ ChimaraGlk *glk;
+ /* Resource number and notification ID of last played sound */
+ glui32 resource, notify;
/* How many times to repeat the last sound played (-1 = forever) */
glui32 repeats;
char buffer[1024];
int len;
int finish = 0;
+ int repeat = 1;
event_t ev;
while(!finish) {
glk_select(&ev);
printf("Received event:\n");
printf("Type: %d\n", ev.type);
- printf("Win: %d\n", glk_window_get_rock(ev.win) );
+ printf("Win: ");
+ if(ev.win)
+ printf( "%d\n", glk_window_get_rock(ev.win) );
+ else
+ printf("NULL\n");
printf("Var1: %d\n", ev.val1);
printf("Var2: %d\n", ev.val2);
switch(ev.type) {
finish = 1;
} else if(strcmp(buffer, "play") == 0) {
glk_put_string("Playing sound.\n");
- if(!glk_schannel_play(sc, 3)) {
+ if(!glk_schannel_play_ext(sc, 3, repeat, 1)) {
fprintf(stderr, "Could not start sound channel.\n");
finish = 1;
}
+ } else if(strcmp(buffer, "stop") == 0) {
+ glk_put_string("Stopping sound.\n");
+ glk_schannel_stop(sc);
+ } else if(strcmp(buffer, "repeat") == 0) {
+ glk_put_string("Setting repeat to ");
+ if(repeat == 1) {
+ glk_put_string("TWICE.\n");
+ repeat = 2;
+ } else if(repeat == 2) {
+ glk_put_string("INFINITE.\n");
+ repeat = -1;
+ } else if(repeat == -1) {
+ glk_put_string("DON'T PLAY.\n");
+ repeat = 0;
+ } else if(repeat == 0) {
+ glk_put_string("ONCE.\n");
+ repeat = 1;
+ }
} else if(strcmp(buffer, "help") == 0) {
- glk_put_string("Type PLAY or QUIT.\n");
+ glk_put_string("Type PLAY or REPEAT or STOP or QUIT.\n");
}
break;
case evtype_SoundNotify:
+ glk_cancel_line_event(mainwin, NULL);
glk_put_string("\nGot sound notify event!\n");
break;
default: