mas01cr@395: #include "audioDB.h" mas01cr@395: extern "C" { mas01cr@395: #include "audioDB_API.h" mas01cr@402: #include "audioDB-internals.h" mas01cr@395: } mas01cr@395: mas01cr@395: int audiodb_status(adb_t *adb, adb_status_t *status) { mas01cr@395: /* FIXME: it would be nice to be able to test for "is this database mas01cr@395: pointer valid", but at the moment we punt that to memory mas01cr@395: discipline. */ mas01cr@395: mas01cr@395: unsigned dudCount = 0; mas01cr@395: unsigned nullCount = 0; mas01cr@395: mas01cr@399: size_t trackTableLength = ALIGN_PAGE_UP(adb->header->numFiles * O2_TRACKTABLE_ENTRY_SIZE); mas01cr@395: unsigned *trackTable = 0; mas01cr@395: void *tmp = 0; mas01cr@395: if (adb->header->length > 0) { mas01cr@395: tmp = mmap(0, trackTableLength, PROT_READ, MAP_SHARED, adb->fd, adb->header->trackTableOffset); mas01cr@395: if (tmp == (void *) -1) { mas01cr@395: return 1; mas01cr@395: } mas01cr@395: trackTable = (unsigned *) tmp; mas01cr@395: } mas01cr@395: mas01cr@395: for(unsigned k = 0; k < adb->header->numFiles; k++) { mas01cr@395: /* FIXME: this bare "16" here reveals a problem (or maybe two). mas01cr@395: * 16 here means the default value of the sequenceLength parameter mas01cr@395: * initializer (both in C++ and corresponding to the "-l" or mas01cr@395: * "--sequencelength" command-line argument). mas01cr@395: * mas01cr@395: * The problem is that the API as currently designed provides no mas01cr@395: * way to pass that information in to this routine; there's no mas01cr@395: * input parameter; nor is there in the SOAP version of this mas01cr@395: * query. However, there /is/ a way to pass that information on mas01cr@395: * the command-line -- though that codepath is completely mas01cr@395: * untested. I can see that it might be useful to provide this mas01cr@395: * information, but at present it's probably completely unused, so mas01cr@395: * the compromise for now is to hardwire the 16. mas01cr@395: */ mas01cr@395: if(trackTable[k] < 16) { mas01cr@395: dudCount++; mas01cr@395: if(!trackTable[k]) { mas01cr@395: nullCount++; mas01cr@395: } mas01cr@395: } mas01cr@395: } mas01cr@395: mas01cr@395: if(adb->header->length > 0) { mas01cr@395: if(munmap(trackTable, trackTableLength)) { mas01cr@395: return 1; mas01cr@395: } mas01cr@395: } mas01cr@395: mas01cr@395: status->numFiles = adb->header->numFiles; mas01cr@395: status->dim = adb->header->dim; mas01cr@395: status->length = adb->header->length; mas01cr@395: status->dudCount = dudCount; mas01cr@395: status->nullCount = nullCount; mas01cr@395: status->flags = adb->header->flags; mas01cr@395: status->data_region_size = adb->header->timesTableOffset - adb->header->dataOffset; mas01cr@395: mas01cr@395: return 0; mas01cr@395: } mas01cr@395: