diff --git a/example_bass/example_bass.cpp b/example_bass/example_bass.cpp index 02f62e4..185fdf4 100644 --- a/example_bass/example_bass.cpp +++ b/example_bass/example_bass.cpp @@ -164,7 +164,6 @@ int main(int argc, char *argv[]) die("out of memory?"); #ifndef SYNC_PLAYER - sync_set_callbacks(rocket, &bass_cb, (void *)stream); if (sync_connect(rocket, "localhost", SYNC_DEFAULT_PORT)) die("failed to connect to host"); #endif @@ -184,7 +183,7 @@ int main(int argc, char *argv[]) while (!done) { double row = bass_get_row(stream); #ifndef SYNC_PLAYER - if (sync_update(rocket, (int)floor(row))) + if (sync_update(rocket, (int)floor(row), &bass_cb, (void *)stream)) sync_connect(rocket, "localhost", SYNC_DEFAULT_PORT); #endif diff --git a/sync/device.c b/sync/device.c index 320c08d..9d6c41f 100644 --- a/sync/device.c +++ b/sync/device.c @@ -88,7 +88,6 @@ struct sync_device *sync_create_device(const char *base) d->data.num_tracks = 0; #ifndef SYNC_PLAYER - d->cb = d->cb_param = NULL; d->row = -1; d->sock = INVALID_SOCKET; #endif @@ -130,12 +129,6 @@ static int load_track_data(struct sync_track *t, const char *path) #else -void sync_set_callbacks(struct sync_device *d, struct sync_cb *cb, void *cb_param) -{ - d->cb = cb; - d->cb_param = cb_param; -} - static int save_track(const struct sync_track *t, const char *path) { int i; @@ -248,7 +241,8 @@ int sync_connect(struct sync_device *d, const char *host, unsigned short port) return purge_and_rerequest(d); } -int sync_update(struct sync_device *d, int row) +int sync_update(struct sync_device *d, int row, struct sync_cb *cb, + void *cb_param) { if (d->sock == INVALID_SOCKET) return 1; @@ -272,14 +266,14 @@ int sync_update(struct sync_device *d, int row) case SET_ROW: if (xrecv(d->sock, (char *)&row, sizeof(row), 0)) goto sockerr; - if (d->cb && d->cb->set_row) - d->cb->set_row(d->cb_param, ntohl(row)); + if (cb && cb->set_row) + cb->set_row(cb_param, ntohl(row)); break; case PAUSE: if (xrecv(d->sock, (char *)&flag, 1, 0)) goto sockerr; - if (d->cb && d->cb->pause) - d->cb->pause(d->cb_param, flag); + if (cb && cb->pause) + cb->pause(cb_param, flag); break; case SAVE_TRACKS: sync_save_tracks(d); @@ -290,7 +284,7 @@ int sync_update(struct sync_device *d, int row) } } - if (d->cb && d->cb->is_playing && d->cb->is_playing(d->cb_param)) { + if (cb && cb->is_playing && cb->is_playing(cb_param)) { if (d->row != row && d->sock != INVALID_SOCKET) { unsigned char cmd = SET_ROW; uint32_t nrow = htonl(row); diff --git a/sync/device.h b/sync/device.h index a02de0b..a2851a8 100644 --- a/sync/device.h +++ b/sync/device.h @@ -13,8 +13,6 @@ struct sync_device { struct sync_data data; #ifndef SYNC_PLAYER - struct sync_cb *cb; - void *cb_param; int row; SOCKET sock; #endif diff --git a/sync/sync.h b/sync/sync.h index 8e09bf9..99e24ac 100644 --- a/sync/sync.h +++ b/sync/sync.h @@ -21,10 +21,9 @@ struct sync_cb { void (*set_row)(void *, int); int (*is_playing)(void *); }; -void sync_set_callbacks(struct sync_device *, struct sync_cb *, void *); #define SYNC_DEFAULT_PORT 1338 int sync_connect(struct sync_device *, const char *, unsigned short); -int sync_update(struct sync_device *, int); +int sync_update(struct sync_device *, int, struct sync_cb *, void *); void sync_save_tracks(const struct sync_device *); #endif /* !defined(SYNC_PLAYER) */