player: add API to save tracks

This is a bit more convenient than having to remember to do
"remote export" from the editor all the time.
This commit is contained in:
Erik Faye-Lund 2010-11-25 14:57:13 +01:00
parent 569f9d082b
commit e43c33a1ab
4 changed files with 12 additions and 5 deletions

1
example_bass/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.track

View File

@ -194,6 +194,11 @@ int main(int argc, char *argv[])
} }
} }
#ifndef SYNC_PLAYER
sync_save_tracks(rocket);
#endif
sync_destroy_device(rocket);
BASS_StreamFree(stream); BASS_StreamFree(stream);
BASS_Free(); BASS_Free();

View File

@ -155,12 +155,12 @@ static int save_track(const struct sync_track *t, const char *path)
return 0; return 0;
} }
static void save_tracks(const char *base, struct sync_data *data) void sync_save_tracks(const struct sync_device *d)
{ {
int i; int i;
for (i = 0; i < (int)data->num_tracks; ++i) { for (i = 0; i < (int)d->data.num_tracks; ++i) {
const struct sync_track *t = data->tracks[i]; const struct sync_track *t = d->data.tracks[i];
save_track(t, sync_track_path(base, t->name)); save_track(t, sync_track_path(d->base, t->name));
} }
} }
@ -282,7 +282,7 @@ int sync_update(struct sync_device *d, int row)
d->cb->pause(d->cb_param, flag); d->cb->pause(d->cb_param, flag);
break; break;
case SAVE_TRACKS: case SAVE_TRACKS:
save_tracks(d->base, &d->data); sync_save_tracks(d);
break; break;
default: default:
fprintf(stderr, "unknown cmd: %02x\n", cmd); fprintf(stderr, "unknown cmd: %02x\n", cmd);

View File

@ -25,6 +25,7 @@ void sync_set_callbacks(struct sync_device *, struct sync_cb *, void *);
#define SYNC_DEFAULT_PORT 1338 #define SYNC_DEFAULT_PORT 1338
int sync_connect(struct sync_device *, const char *, unsigned short); int sync_connect(struct sync_device *, const char *, unsigned short);
int sync_update(struct sync_device *, int); int sync_update(struct sync_device *, int);
void sync_save_tracks(const struct sync_device *);
#endif /* !defined(SYNC_PLAYER) */ #endif /* !defined(SYNC_PLAYER) */
const struct sync_track *sync_get_track(struct sync_device *, const char *); const struct sync_track *sync_get_track(struct sync_device *, const char *);