static void play() { if (!player) return; player->Unload(); if (sound_playing) fmodwrap::DestroySound(sound_playing); recored_list_log(current_sound); sound_playing = fmodwrap::CreateSound(sounds[current_sound]); if (!sound_playing) { next(true); return; } player->Load(sound_playing); player->Play(false); while (list_start + MAX_LIST_INDEX < current_sound) uplist(); while (list_start > current_sound) downlist(); need_next = false; char title[256]; sprintf_s(title, sizeof(title), "%-0.60s - %s", sounds[current_sound] + 2, "CONSOLE PLAYER"); SetConsoleTitleA(title); }
static void cur_down() { if ((size_t)list_cur < MAX_LIST_INDEX && (size_t)list_cur + 1 < SOUND_COUNT) { ++list_cur; needupdatelist = true; } else { uplist(); } }
static void next(bool force) { int p = current_sound; if (force || !one_loop) p++; current_sound = p % SOUND_COUNT; play(); if (current_sound > list_end) uplist(); else needupdatelist = true; }
int main(int argc, char **argv) { printf("read index files\n"); open_index("test1.idx", &name1,0); printf("List the keys in each index file in ascending order:\n\n"); uplist(&name1); printf("List the keys for each index file in decending order\n\n"); downlist(&name1); /* always close all files */ close_index(&name1); }
int main(int argc, char **argv) { int i, num, ret; long ltime; ENTRY e; printf("Make one index files\n"); make_index("test1.idx",&name1, 0); printf("Indexing 100 items in two index files:\n"); /* note the time to index */ time(<ime); printf("%s",ctime(<ime)); /* add 100 keys to each index file */ for (i = MIN_TEST_START; i < MAX_TEST_END; i++) { memset(&e, '\0', sizeof(ENTRY)); e.recptr = i; sprintf(e.key, "%2d",i); if((ret = add_key(&e, &name1)) == IX_OK) printf("add key %s ok.\n", e.key); else if(ret = IX_EXISTED) printf("add key %s is existed.\n", e.key); else printf("add key %s error .\n", e.key); } printf("In Process: ADD %d key ok.\n", MAX_TEST_END); printf("Indexing is complete\n\n"); printf("List the keys in each index file in ascending order:\n\n"); uplist(&name1); /*[>list both files in decending order<]*/ printf("List the keys for each index file in decending order\n\n"); downlist(&name1); /* add key*/ for(i = MIN_TEST_START; i < MAX_TEST_END/2; ++i) { memset(&e, '\0', sizeof(ENTRY)); num = rand_num(); e.recptr = num; sprintf(e.key, "%2d",num); if((ret = add_key(&e, &name1)) == IX_OK) printf("add key %s ok.\n", e.key); else if(ret = IX_EXISTED) printf("add key %s is existed.\n", e.key); else printf("add key %s error.\n", e.key); } /* delete some keys and list again */ printf("\nNow delete half keys in each file\n\n"); for (i = MIN_TEST_START; i < MAX_TEST_END/2 ; i++) { /*memset(&e, '\0', sizeof(ENTRY));*/ num = rand_num(); e.recptr = num; sprintf(e.key, "%2d",num); if((ret = delete_key(&e, &name1)) == IX_OK) printf("delete key %s ok.\n",e.key); else if(ret == IX_NOTEXISTED) printf("delete key %s not existed.\n",e.key); else printf("delete key %s error.\n", e.key); } printf("List the keys now for each index file in ascending order:\n\n"); uplist(&name1); printf("List the keys now for each index file in ascending order:\n\n"); downlist(&name1); printf("exception test.\n"); printf("------------------------------------------------------------\n"); for (i = MIN_TEST_START; i < MAX_TEST_END/2 ; i++) { /*memset(&e, '\0', sizeof(ENTRY));*/ num = rand_num(); e.recptr = num; sprintf(e.key, "%2d",num); if(num %2 == 0) { if((ret = delete_key(&e, &name1)) == IX_OK) printf("delete key %s ok.\n",e.key); else if(ret == IX_NOTEXISTED) printf("delete key %s not existed.\n",e.key); else printf("delete key %s error.\n", e.key); } else { if((ret = add_key(&e, &name1)) == IX_OK) printf("add key %s ok.\n", e.key); else if(ret = IX_EXISTED) printf("add key %s is existed.\n", e.key); else printf("add key %s error .\n", e.key); } if(num %17 == 0) { printf("exception break.\n"); break; } } printf("List the keys now for each index file in ascending order:\n\n"); uplist(&name1); printf("List the keys now for each index file in ascending order:\n\n"); downlist(&name1); /* always close all files */ close_index(&name1); }