player: pass row as integer to sync_update

There's no point in passing the row as a double to sync_update, which
only cares about the integer-part.
This commit is contained in:
Erik Faye-Lund 2010-05-01 20:00:53 +02:00
parent 99e2489e89
commit 2a44eff473
3 changed files with 6 additions and 7 deletions

View File

@ -143,7 +143,7 @@ int main(int argc, char *argv[])
bool done = false; bool done = false;
while (!done) { while (!done) {
double row = bass_get_row(stream); double row = bass_get_row(stream);
sync_update(rocket, row); sync_update(rocket, (int)floor(row));
/* draw */ /* draw */

View File

@ -234,7 +234,7 @@ static int purge_and_rerequest(struct sync_device *d)
return 0; return 0;
} }
void sync_update(struct sync_device *d, double row) void sync_update(struct sync_device *d, int row)
{ {
if (d->sock == INVALID_SOCKET) { if (d->sock == INVALID_SOCKET) {
d->sock = server_connect(REMOTE_HOST, REMOTE_PORT); d->sock = server_connect(REMOTE_HOST, REMOTE_PORT);
@ -280,14 +280,13 @@ void sync_update(struct sync_device *d, double row)
} }
if (d->cb && d->cb->is_playing && d->cb->is_playing(d->cb_param)) { if (d->cb && d->cb->is_playing && d->cb->is_playing(d->cb_param)) {
int nrow = (int)floor(row); if (d->row != row && d->sock != INVALID_SOCKET) {
if (d->row != nrow && d->sock != INVALID_SOCKET) {
unsigned char cmd = SET_ROW; unsigned char cmd = SET_ROW;
int ret = send(d->sock, (char*)&cmd, 1, 0); int ret = send(d->sock, (char*)&cmd, 1, 0);
ret += send(d->sock, (char*)&nrow, sizeof(int), 0); ret += send(d->sock, (char*)&row, sizeof(int), 0);
if (ret != sizeof(int) + 1) if (ret != sizeof(int) + 1)
goto sockerr; goto sockerr;
d->row = nrow; d->row = row;
} }
} }
return; return;

View File

@ -24,7 +24,7 @@ struct sync_cb {
void sync_set_callbacks(struct sync_device *, struct sync_cb *, void *); void sync_set_callbacks(struct sync_device *, struct sync_cb *, void *);
#endif /* !defined(SYNC_PLAYER) */ #endif /* !defined(SYNC_PLAYER) */
void sync_update(struct sync_device *, double); void sync_update(struct sync_device *, int);
const struct sync_track *sync_get_track(struct sync_device *, const char *); const struct sync_track *sync_get_track(struct sync_device *, const char *);
float sync_get_val(const struct sync_track *, double); float sync_get_val(const struct sync_track *, double);