Commit 6442a00f authored by Mark Hills's avatar Mark Hills
Browse files

Make deck responsible for timecode init

First step in making the code a bit more logical here, but we are
going to have to pass a lot more variables into the 'deck'.
parent 170b847a
......@@ -41,10 +41,12 @@ static const struct record no_record = {
* A deck is a logical grouping of the various components which
* reflects the user's view on a deck in the system.
*
* Pre: deck->device, deck->timecoder, deck->importer are valid
* Pre: deck->device, deck->importer are valid
*/
int deck_init(struct deck *d, struct rt *rt)
int deck_init(struct deck *d, struct rt *rt,
struct timecode_def *timecode,
double speed, bool phono)
{
unsigned int rate;
......@@ -57,6 +59,8 @@ int deck_init(struct deck *d, struct rt *rt)
d->record = &no_record;
d->punch = NO_PUNCH;
rate = device_sample_rate(&d->device);
assert(timecode != NULL);
timecoder_init(&d->timecoder, timecode, speed, rate, phono);
player_init(&d->player, rate, track_acquire_empty(), &d->timecoder);
cues_reset(&d->cues);
......
......@@ -51,7 +51,9 @@ struct deck {
struct controller *control[4];
};
int deck_init(struct deck *deck, struct rt *rt);
int deck_init(struct deck *deck, struct rt *rt,
struct timecode_def *timecode,
double speed, bool phono);
void deck_clear(struct deck *deck);
bool deck_is_locked(const struct deck *deck);
......
......@@ -288,10 +288,8 @@ int main(int argc, char *argv[])
!strcmp(argv[0], "-j"))
{
int r;
unsigned int sample_rate;
struct deck *ld;
struct device *device;
struct timecoder *timecoder;
/* Create a deck */
......@@ -310,7 +308,6 @@ int main(int argc, char *argv[])
ld = &deck[ndeck];
device = &ld->device;
timecoder = &ld->timecoder;
ld->importer = importer;
ld->protect = protect;
......@@ -343,8 +340,6 @@ int main(int argc, char *argv[])
if (r == -1)
return -1;
sample_rate = device_sample_rate(device);
/* Default timecode decoder where none is specified */
if (timecode == NULL) {
......@@ -352,11 +347,9 @@ int main(int argc, char *argv[])
assert(timecode != NULL);
}
timecoder_init(timecoder, timecode, speed, sample_rate, phono);
/* Connect up the elements to make an operational deck */
r = deck_init(ld, &rt);
r = deck_init(ld, &rt, timecode, speed, phono);
if (r == -1)
return -1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment