Use the correct sample rate from the header.

The Oceanic and Aeris F11 have a configurable sample rate. The possible
sample intervals are 2, 1, 0.5 and 0.25 seconds. Since our smallest unit
of time is one second, we can't represent the last two, and the extra
samples will get dropped for now.
This commit is contained in:
Jef Driesen 2016-01-12 22:37:46 +01:00
parent 9d856e5a36
commit 49af321bc5

View File

@ -539,6 +539,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
unsigned int time = 0;
unsigned int interval = 1;
unsigned int samplerate = 1;
if (parser->mode != FREEDIVE) {
unsigned int idx = 0x17;
if (parser->model == A300CS || parser->model == VTX)
@ -557,6 +558,30 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
interval = 60;
break;
}
} else if (parser->model == F11A || parser->model == F11B) {
unsigned int idx = 0x29;
switch (data[idx] & 0x03) {
case 0:
interval = 1;
samplerate = 4;
break;
case 1:
interval = 1;
samplerate = 2;
break;
case 2:
interval = 1;
break;
case 3:
interval = 2;
break;
}
if (samplerate > 1) {
// Some models supports multiple samples per second.
// Since our smallest unit of time is one second, we can't
// represent this, and the extra samples will get dropped.
WARNING(abstract->context, "Multiple samples per second are not supported!");
}
}
unsigned int samplesize = PAGESIZE / 2;
@ -635,7 +660,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
// The sample size is usually fixed, but some sample types have a
// larger size. Check whether we have that many bytes available.
unsigned int length = samplesize;
unsigned int length = samplesize * samplerate;
if (sampletype == 0xBB) {
length = PAGESIZE;
if (offset + length > size - PAGESIZE)