Mercurial > hg > audiodb
comparison audioDB.cpp @ 167:100b7ba08df3 audiodb-debian
Merge trunk changes -r156:196 to audiodb-debian branch.
(+ new debian/changelog version)
author | mas01cr |
---|---|
date | Tue, 06 Nov 2007 17:16:32 +0000 |
parents | 5bac833c41b5 |
children | 6da72f0e086b |
comparison
equal
deleted
inserted
replaced
136:5bac833c41b5 | 167:100b7ba08df3 |
---|---|
40 printf("%s\n", gengetopt_args_info_purpose); | 40 printf("%s\n", gengetopt_args_info_purpose); |
41 printf("%s\n", gengetopt_args_info_usage); | 41 printf("%s\n", gengetopt_args_info_usage); |
42 printf("%s\n", gengetopt_args_info_help[1]); | 42 printf("%s\n", gengetopt_args_info_help[1]); |
43 printf("%s\n", gengetopt_args_info_help[2]); | 43 printf("%s\n", gengetopt_args_info_help[2]); |
44 printf("%s\n", gengetopt_args_info_help[0]); | 44 printf("%s\n", gengetopt_args_info_help[0]); |
45 exit(1); | 45 error("No command found"); |
46 } | 46 } |
47 | 47 |
48 if(O2_ACTION(COM_SERVER)) | 48 if(O2_ACTION(COM_SERVER)) |
49 startServer(); | 49 startServer(); |
50 | 50 |
80 } | 80 } |
81 | 81 |
82 audioDB::audioDB(const unsigned argc, char* const argv[], adb__queryResponse *adbQueryResponse): O2_AUDIODB_INITIALIZERS | 82 audioDB::audioDB(const unsigned argc, char* const argv[], adb__queryResponse *adbQueryResponse): O2_AUDIODB_INITIALIZERS |
83 { | 83 { |
84 try { | 84 try { |
85 isServer = 1; // FIXME: Hack | |
85 processArgs(argc, argv); | 86 processArgs(argc, argv); |
86 isServer = 1; // FIXME: Hack | |
87 assert(O2_ACTION(COM_QUERY)); | 87 assert(O2_ACTION(COM_QUERY)); |
88 query(dbName, inFile, adbQueryResponse); | 88 query(dbName, inFile, adbQueryResponse); |
89 } catch(char *err) { | 89 } catch(char *err) { |
90 cleanup(); | 90 cleanup(); |
91 throw(err); | 91 throw(err); |
93 } | 93 } |
94 | 94 |
95 audioDB::audioDB(const unsigned argc, char* const argv[], adb__statusResponse *adbStatusResponse): O2_AUDIODB_INITIALIZERS | 95 audioDB::audioDB(const unsigned argc, char* const argv[], adb__statusResponse *adbStatusResponse): O2_AUDIODB_INITIALIZERS |
96 { | 96 { |
97 try { | 97 try { |
98 isServer = 1; // FIXME: Hack | |
98 processArgs(argc, argv); | 99 processArgs(argc, argv); |
99 isServer = 1; // FIXME: Hack | |
100 assert(O2_ACTION(COM_STATUS)); | 100 assert(O2_ACTION(COM_STATUS)); |
101 status(dbName, adbStatusResponse); | 101 status(dbName, adbStatusResponse); |
102 } catch(char *err) { | 102 } catch(char *err) { |
103 cleanup(); | 103 cleanup(); |
104 throw(err); | 104 throw(err); |
135 printf("%s\n", gengetopt_args_info_help[0]); | 135 printf("%s\n", gengetopt_args_info_help[0]); |
136 exit(0); | 136 exit(0); |
137 } | 137 } |
138 | 138 |
139 if (cmdline_parser (argc, argv, &args_info) != 0) | 139 if (cmdline_parser (argc, argv, &args_info) != 0) |
140 exit(1) ; | 140 error("Error parsing command line"); |
141 | 141 |
142 if(args_info.help_given){ | 142 if(args_info.help_given){ |
143 cmdline_parser_print_help(); | 143 cmdline_parser_print_help(); |
144 exit(0); | 144 exit(0); |
145 } | 145 } |
151 verbosity=1; | 151 verbosity=1; |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 if(args_info.size_given) { | 155 if(args_info.size_given) { |
156 if (args_info.size_arg < 250 || args_info.size_arg > 4000) { | 156 if (args_info.size_arg < 50 || args_info.size_arg > 4000) { |
157 error("Size out of range", ""); | 157 error("Size out of range", ""); |
158 } | 158 } |
159 size = args_info.size_arg * 1000000; | 159 size = args_info.size_arg * 1000000; |
160 } | 160 } |
161 | 161 |
173 if(args_info.SERVER_given){ | 173 if(args_info.SERVER_given){ |
174 command=COM_SERVER; | 174 command=COM_SERVER; |
175 port=args_info.SERVER_arg; | 175 port=args_info.SERVER_arg; |
176 if(port<100 || port > 100000) | 176 if(port<100 || port > 100000) |
177 error("port out of range"); | 177 error("port out of range"); |
178 isServer=1; | 178 isServer = 1; |
179 #if defined(O2_DEBUG) | 179 #if defined(O2_DEBUG) |
180 struct sigaction sa; | 180 struct sigaction sa; |
181 sa.sa_sigaction = sigterm_action; | 181 sa.sa_sigaction = sigterm_action; |
182 sa.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER; | 182 sa.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER; |
183 sigaction(SIGTERM, &sa, NULL); | 183 sigaction(SIGTERM, &sa, NULL); |
396 error("mmap error for creating database", "", "mmap"); | 396 error("mmap error for creating database", "", "mmap"); |
397 | 397 |
398 dbH = new dbTableHeaderT(); | 398 dbH = new dbTableHeaderT(); |
399 assert(dbH); | 399 assert(dbH); |
400 | 400 |
401 unsigned int maxfiles = (unsigned int) rint((double) O2_MAXFILES * (double) size / (double) O2_DEFAULTDBSIZE); | |
402 | |
401 // Initialize header | 403 // Initialize header |
402 dbH->magic = O2_MAGIC; | 404 dbH->magic = O2_MAGIC; |
403 dbH->version = O2_FORMAT_VERSION; | 405 dbH->version = O2_FORMAT_VERSION; |
404 dbH->numFiles = 0; | 406 dbH->numFiles = 0; |
405 dbH->dim = 0; | 407 dbH->dim = 0; |
406 dbH->flags = 0; | 408 dbH->flags = 0; |
407 dbH->length = 0; | 409 dbH->length = 0; |
408 dbH->fileTableOffset = ALIGN_UP(O2_HEADERSIZE, 8); | 410 dbH->fileTableOffset = ALIGN_UP(O2_HEADERSIZE, 8); |
409 dbH->trackTableOffset = ALIGN_UP(dbH->fileTableOffset + O2_FILETABLESIZE*O2_MAXFILES, 8); | 411 dbH->trackTableOffset = ALIGN_UP(dbH->fileTableOffset + O2_FILETABLESIZE*maxfiles, 8); |
410 dbH->dataOffset = ALIGN_UP(dbH->trackTableOffset + O2_TRACKTABLESIZE*O2_MAXFILES, 8); | 412 dbH->dataOffset = ALIGN_UP(dbH->trackTableOffset + O2_TRACKTABLESIZE*maxfiles, 8); |
411 dbH->l2normTableOffset = ALIGN_DOWN(size - O2_MAXFILES*O2_MEANNUMVECTORS*sizeof(double), 8); | 413 dbH->l2normTableOffset = ALIGN_DOWN(size - maxfiles*O2_MEANNUMVECTORS*sizeof(double), 8); |
412 dbH->timesTableOffset = ALIGN_DOWN(dbH->l2normTableOffset - O2_MAXFILES*O2_MEANNUMVECTORS*sizeof(double), 8); | 414 dbH->timesTableOffset = ALIGN_DOWN(dbH->l2normTableOffset - maxfiles*O2_MEANNUMVECTORS*sizeof(double), 8); |
413 dbH->dbSize = size; | 415 dbH->dbSize = size; |
414 | 416 |
415 memcpy (db, dbH, O2_HEADERSIZE); | 417 memcpy (db, dbH, O2_HEADERSIZE); |
416 if(verbosity) { | 418 if(verbosity) { |
417 cerr << COM_CREATE << " " << dbName << endl; | 419 cerr << COM_CREATE << " " << dbName << endl; |
2625 const char* argv[] ={ | 2627 const char* argv[] ={ |
2626 "./audioDB", | 2628 "./audioDB", |
2627 COM_QUERY, | 2629 COM_QUERY, |
2628 queryType, // Need to pass a parameter | 2630 queryType, // Need to pass a parameter |
2629 COM_DATABASE, | 2631 COM_DATABASE, |
2630 dbName, | 2632 ENSURE_STRING(dbName), |
2631 COM_FEATURES, | 2633 COM_FEATURES, |
2632 qKey, | 2634 ENSURE_STRING(qKey), |
2633 COM_KEYLIST, | 2635 COM_KEYLIST, |
2634 keyList==0?"":keyList, | 2636 ENSURE_STRING(keyList), |
2635 COM_TIMES, | 2637 COM_TIMES, |
2636 timesFileName==0?"":timesFileName, | 2638 ENSURE_STRING(timesFileName), |
2637 COM_QPOINT, | 2639 COM_QPOINT, |
2638 qPosStr, | 2640 qPosStr, |
2639 COM_POINTNN, | 2641 COM_POINTNN, |
2640 pointNNStr, | 2642 pointNNStr, |
2641 COM_TRACKNN, | 2643 COM_TRACKNN, |