mas01cr@395
|
1 #include "audioDB.h"
|
mas01cr@395
|
2 extern "C" {
|
mas01cr@395
|
3 #include "audioDB_API.h"
|
mas01cr@395
|
4 }
|
mas01cr@395
|
5
|
mas01cr@395
|
6 int audiodb_status(adb_t *adb, adb_status_t *status) {
|
mas01cr@395
|
7 /* FIXME: it would be nice to be able to test for "is this database
|
mas01cr@395
|
8 pointer valid", but at the moment we punt that to memory
|
mas01cr@395
|
9 discipline. */
|
mas01cr@395
|
10
|
mas01cr@395
|
11 unsigned dudCount = 0;
|
mas01cr@395
|
12 unsigned nullCount = 0;
|
mas01cr@395
|
13
|
mas01cr@399
|
14 size_t trackTableLength = ALIGN_PAGE_UP(adb->header->numFiles * O2_TRACKTABLE_ENTRY_SIZE);
|
mas01cr@395
|
15 unsigned *trackTable = 0;
|
mas01cr@395
|
16 void *tmp = 0;
|
mas01cr@395
|
17 if (adb->header->length > 0) {
|
mas01cr@395
|
18 tmp = mmap(0, trackTableLength, PROT_READ, MAP_SHARED, adb->fd, adb->header->trackTableOffset);
|
mas01cr@395
|
19 if (tmp == (void *) -1) {
|
mas01cr@395
|
20 return 1;
|
mas01cr@395
|
21 }
|
mas01cr@395
|
22 trackTable = (unsigned *) tmp;
|
mas01cr@395
|
23 }
|
mas01cr@395
|
24
|
mas01cr@395
|
25 for(unsigned k = 0; k < adb->header->numFiles; k++) {
|
mas01cr@395
|
26 /* FIXME: this bare "16" here reveals a problem (or maybe two).
|
mas01cr@395
|
27 * 16 here means the default value of the sequenceLength parameter
|
mas01cr@395
|
28 * initializer (both in C++ and corresponding to the "-l" or
|
mas01cr@395
|
29 * "--sequencelength" command-line argument).
|
mas01cr@395
|
30 *
|
mas01cr@395
|
31 * The problem is that the API as currently designed provides no
|
mas01cr@395
|
32 * way to pass that information in to this routine; there's no
|
mas01cr@395
|
33 * input parameter; nor is there in the SOAP version of this
|
mas01cr@395
|
34 * query. However, there /is/ a way to pass that information on
|
mas01cr@395
|
35 * the command-line -- though that codepath is completely
|
mas01cr@395
|
36 * untested. I can see that it might be useful to provide this
|
mas01cr@395
|
37 * information, but at present it's probably completely unused, so
|
mas01cr@395
|
38 * the compromise for now is to hardwire the 16.
|
mas01cr@395
|
39 */
|
mas01cr@395
|
40 if(trackTable[k] < 16) {
|
mas01cr@395
|
41 dudCount++;
|
mas01cr@395
|
42 if(!trackTable[k]) {
|
mas01cr@395
|
43 nullCount++;
|
mas01cr@395
|
44 }
|
mas01cr@395
|
45 }
|
mas01cr@395
|
46 }
|
mas01cr@395
|
47
|
mas01cr@395
|
48 if(adb->header->length > 0) {
|
mas01cr@395
|
49 if(munmap(trackTable, trackTableLength)) {
|
mas01cr@395
|
50 return 1;
|
mas01cr@395
|
51 }
|
mas01cr@395
|
52 }
|
mas01cr@395
|
53
|
mas01cr@395
|
54 status->numFiles = adb->header->numFiles;
|
mas01cr@395
|
55 status->dim = adb->header->dim;
|
mas01cr@395
|
56 status->length = adb->header->length;
|
mas01cr@395
|
57 status->dudCount = dudCount;
|
mas01cr@395
|
58 status->nullCount = nullCount;
|
mas01cr@395
|
59 status->flags = adb->header->flags;
|
mas01cr@395
|
60 status->data_region_size = adb->header->timesTableOffset - adb->header->dataOffset;
|
mas01cr@395
|
61
|
mas01cr@395
|
62 return 0;
|
mas01cr@395
|
63 }
|
mas01cr@395
|
64
|