player: unify loader-code a bit
Unify the interface for load_track_data() and request_track_data(), as they essentially perform the same task, but for different compile-time configurations.
This commit is contained in:
parent
687df0876b
commit
9324a1180b
@ -104,10 +104,10 @@ void sync_destroy_device(struct sync_device *d)
|
||||
|
||||
#ifdef SYNC_PLAYER
|
||||
|
||||
static int load_track_data(struct sync_track *t, const char *path)
|
||||
static int get_track_data(struct sync_device *d, struct sync_track *t)
|
||||
{
|
||||
int i;
|
||||
FILE *fp = fopen(path, "rb");
|
||||
FILE *fp = fopen(sync_track_path(d->base, t->name), "rb");
|
||||
if (!fp)
|
||||
return 1;
|
||||
|
||||
@ -157,15 +157,15 @@ void sync_save_tracks(const struct sync_device *d)
|
||||
}
|
||||
}
|
||||
|
||||
static int request_track_data(SOCKET sock, const char *name)
|
||||
static int get_track_data(struct sync_device *d, struct sync_track *t)
|
||||
{
|
||||
unsigned char cmd = GET_TRACK;
|
||||
uint32_t name_len = htonl(strlen(name));
|
||||
uint32_t name_len = htonl(strlen(t->name));
|
||||
|
||||
/* send request data */
|
||||
return xsend(sock, (char *)&cmd, 1, 0) ||
|
||||
xsend(sock, (char *)&name_len, sizeof(name_len), 0) ||
|
||||
xsend(sock, name, (int)strlen(name), 0);
|
||||
return xsend(d->sock, (char *)&cmd, 1, 0) ||
|
||||
xsend(d->sock, (char *)&name_len, sizeof(name_len), 0) ||
|
||||
xsend(d->sock, t->name, (int)strlen(t->name), 0);
|
||||
}
|
||||
|
||||
static int handle_set_key_cmd(SOCKET sock, struct sync_data *data)
|
||||
@ -221,7 +221,7 @@ static int purge_and_rerequest(struct sync_device *d)
|
||||
d->data.tracks[i]->keys = NULL;
|
||||
d->data.tracks[i]->num_keys = 0;
|
||||
|
||||
if (request_track_data(d->sock, d->data.tracks[i]->name))
|
||||
if (get_track_data(d, d->data.tracks[i]))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@ -313,11 +313,6 @@ const struct sync_track *sync_get_track(struct sync_device *d,
|
||||
idx = sync_create_track(&d->data, name);
|
||||
t = d->data.tracks[idx];
|
||||
|
||||
#if SYNC_PLAYER
|
||||
load_track_data(t, sync_track_path(d->base, name));
|
||||
#else
|
||||
request_track_data(d->sock, name);
|
||||
#endif
|
||||
|
||||
get_track_data(d, t);
|
||||
return t;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user