summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/xas/object.h8
-rw-r--r--include/xas/seq.h6
-rw-r--r--src/bank.c19
-rw-r--r--src/object.c8
-rw-r--r--src/seq.c8
-rw-r--r--src/synth.c4
-rw-r--r--src/vox.c16
7 files changed, 45 insertions, 24 deletions
diff --git a/include/xas/object.h b/include/xas/object.h
index 5780c7d..1fd3b8c 100644
--- a/include/xas/object.h
+++ b/include/xas/object.h
@@ -5,9 +5,9 @@
typedef struct _xas_object xas_object;
-typedef int (*xas_object_start_callback)(xas_object *object);
+typedef int (*xas_object_start_callback)(xas_object *object, size_t index);
-typedef int (*xas_object_stop_callback)(xas_object *object);
+typedef int (*xas_object_stop_callback)(xas_object *object, size_t index);
typedef int (*xas_object_set_gain_callback)(xas_object *object, float gain);
@@ -34,9 +34,9 @@ struct _xas_object {
void xas_object_init(xas_object *object);
-int xas_object_start(xas_object *object);
+int xas_object_start(xas_object *object, size_t index);
-int xas_object_stop(xas_object *object);
+int xas_object_stop(xas_object *object, size_t index);
int xas_object_set_gain(xas_object *object, float gain);
diff --git a/include/xas/seq.h b/include/xas/seq.h
index 887276b..05b1919 100644
--- a/include/xas/seq.h
+++ b/include/xas/seq.h
@@ -62,11 +62,13 @@ void xas_seq_destroy(xas_seq *seq);
int xas_seq_add_event_off(xas_seq *seq,
xas_spatial_object *object,
- struct timeval timestamp);
+ struct timeval timestamp,
+ size_t index);
int xas_seq_add_event_on(xas_seq *seq,
xas_spatial_object *object,
- struct timeval timestamp);
+ struct timeval timestamp,
+ size_t index);
int xas_seq_add_set_position(xas_seq *seq,
xas_spatial_object *object,
diff --git a/src/bank.c b/src/bank.c
index a80f9f6..90ad394 100644
--- a/src/bank.c
+++ b/src/bank.c
@@ -126,6 +126,21 @@ error_riff_open_file:
return -1;
}
+static int player_start(xas_bank_player *player, size_t index) {
+ if (xas_bank_player_set_entry(player, index) < 0) {
+ goto error_player_set_entry;
+ }
+
+ return xas_bank_player_start(player);
+
+error_player_set_entry:
+ return -1;
+}
+
+static int player_stop(xas_bank_player *player, ...) {
+ return xas_bank_player_stop(player);
+}
+
static int set_gain(xas_bank_player *player, float gain) {
xas_bank_player_set_gain(player, gain);
@@ -139,10 +154,10 @@ xas_bank_player *xas_bank_player_new(xas_bank *bank) {
goto error_malloc_player;
}
- player->obj.start = (xas_object_start_callback)xas_bank_player_start;
- player->obj.stop = (xas_object_stop_callback)xas_bank_player_stop;
xas_object_init(&player->obj);
+ player->obj.start = (xas_object_start_callback)player_start;
+ player->obj.stop = (xas_object_stop_callback)player_stop;
player->obj.set_gain = (xas_object_set_gain_callback)set_gain;
player->obj.stream_new = (xas_object_stream_new_callback)xas_bank_player_stream_new;
player->obj.destroy = (xas_object_destroy_callback)xas_bank_player_destroy;
diff --git a/src/object.c b/src/object.c
index 3c8c84a..39a1edb 100644
--- a/src/object.c
+++ b/src/object.c
@@ -7,24 +7,24 @@ void xas_object_init(xas_object *object) {
memset(object, '\0', sizeof(xas_object));
}
-int xas_object_start(xas_object *object) {
+int xas_object_start(xas_object *object, size_t index) {
if (object->start == NULL) {
errno = ENOSYS;
return -1;
}
- return object->start(object);
+ return object->start(object, index);
}
-int xas_object_stop(xas_object *object) {
+int xas_object_stop(xas_object *object, size_t index) {
if (object->stop == NULL) {
errno = ENOSYS;
return -1;
}
- return object->stop(object);
+ return object->stop(object, index);
}
int xas_object_set_gain(xas_object *object, float gain) {
diff --git a/src/seq.c b/src/seq.c
index b74dc9a..9f8dc4a 100644
--- a/src/seq.c
+++ b/src/seq.c
@@ -158,7 +158,8 @@ static void event_sort(xas_seq *seq) {
int xas_seq_add_event_off(xas_seq *seq,
xas_spatial_object *object,
- struct timeval timestamp) {
+ struct timeval timestamp,
+ size_t index) {
xas_seq_event *ev;
if ((ev = malloc(sizeof(*ev))) == NULL) {
@@ -168,6 +169,7 @@ int xas_seq_add_event_off(xas_seq *seq,
ev->type = XAS_SEQ_EVENT_OFF;
ev->object = object;
ev->timestamp = timestamp;
+ ev->index = index;
if (event_add(seq, ev) < 0) {
goto error_event_add;
@@ -184,7 +186,8 @@ error_malloc_ev:
int xas_seq_add_event_on(xas_seq *seq,
xas_spatial_object *object,
- struct timeval timestamp) {
+ struct timeval timestamp,
+ size_t index) {
xas_seq_event *ev;
if ((ev = malloc(sizeof(*ev))) == NULL) {
@@ -194,6 +197,7 @@ int xas_seq_add_event_on(xas_seq *seq,
ev->type = XAS_SEQ_EVENT_ON;
ev->object = object;
ev->timestamp = timestamp;
+ ev->index = index;
if (event_add(seq, ev) < 0) {
goto error_event_add;
diff --git a/src/synth.c b/src/synth.c
index 56bbe5b..96956c5 100644
--- a/src/synth.c
+++ b/src/synth.c
@@ -111,13 +111,13 @@ static ssize_t synth_fill(xas_synth *synth,
return count;
}
-static int synth_start(xas_synth *synth) {
+static int synth_start(xas_synth *synth, ...) {
xas_synth_start(synth);
return 0;
}
-static int synth_stop(xas_synth *synth) {
+static int synth_stop(xas_synth *synth, ...) {
xas_synth_stop(synth);
return 0;
diff --git a/src/vox.c b/src/vox.c
index 141f555..136cf47 100644
--- a/src/vox.c
+++ b/src/vox.c
@@ -10,7 +10,7 @@
#include <xas/riff.h>
#include <xas/vox.h>
-static int vox_stop(xas_vox *vox) {
+static int vox_stop(xas_vox *vox, ...) {
if (vox->stdin >= 0) {
(void)close(vox->stdin);
@@ -273,6 +273,10 @@ static int set_gain(xas_vox *vox, float gain) {
return 0;
}
+static int vox_generate(xas_vox *vox, ...) {
+ return xas_vox_generate(vox);
+}
+
xas_vox *xas_vox_new_args(xas_audio_format format,
size_t buffer_size,
const char *text2wave_path,
@@ -284,8 +288,8 @@ xas_vox *xas_vox_new_args(xas_audio_format format,
goto error_malloc_vox;
}
- vox->obj.start = (xas_object_start_callback)xas_vox_generate;
- vox->obj.stop = (xas_object_stop_callback)xas_vox_stop;
+ vox->obj.start = (xas_object_start_callback)vox_generate;
+ vox->obj.stop = (xas_object_stop_callback)vox_stop;
vox->obj.set_gain = (xas_object_set_gain_callback)set_gain;
vox->obj.stream_new = (xas_object_stream_new_callback)xas_vox_stream_new;
vox->obj.destroy = (xas_object_destroy_callback)xas_vox_destroy;
@@ -448,11 +452,7 @@ error_riff_open_fd:
}
int xas_vox_stop(xas_vox *vox) {
- if (vox->state == XAS_VOX_ACTIVE) {
- return vox_stop(vox);
- }
-
- return 0;
+ return vox_stop(vox);
}
int xas_vox_vsayf(xas_vox *vox, const char *format, va_list args) {