diff --git a/README.md b/README.md index 5a736ed..bfba9ac 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ ogg-winmm also provides separate volume control for CDDA/MIDI/WAVE, which has be 1. Rip the audio tracks from the CD and encode them to ogg files, following naming convention: > **Track02.ogg, Track03.ogg, Track04.ogg, ...** - Note the file names can not contain any whitespace. + Note the file names can not contain any whitespace, and the track numbers must be contiguous without gap in the middle. Also note the numbering usually starts from 02 since on mixed mode CDs the first track is a data track. @@ -42,6 +42,10 @@ NOTE: It actually can also work on Win95/98 if you follow the extra procedure be # Revisions: +v.2023.03.11 +- Allow more than 1 data track before audio track. +- Fix total track number. + v.2023.02.28 - Improve time range precision from second to millisecond. - Add compatibility support for Win95/98. diff --git a/ogg-winmm.c b/ogg-winmm.c index 0a1b186..c26e015 100644 --- a/ogg-winmm.c +++ b/ogg-winmm.c @@ -151,7 +151,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) strcat(music_path, "\\MUSIC"); dprintf("ogg-winmm music directory is %s\n", music_path); - dprintf("ogg-winmm searching tracks...\n"); memset(tracks, 0, sizeof(tracks)); unsigned int position = 0; @@ -164,20 +163,21 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) if (tracks[i].length) { dprintf("Track %02u: %02u:%02u:%03u @ %u ms\n", i, tracks[i].length / 60000, tracks[i].length / 1000 % 60, tracks[i].length % 1000, tracks[i].position); if (!firstTrack) firstTrack = i; - numTracks = lastTrack = i; + lastTrack = i; + numTracks++; position += tracks[i].length; } else { tracks[i].path[0] = '\0'; } - if (i != 1 && !tracks[i].length) break; + if (numTracks && !tracks[i].length) break; } dprintf("Emulating total of %d CD tracks.\n", numTracks); if (numTracks) { event = CreateEvent(NULL, FALSE, FALSE, NULL); player = CreateThread(NULL, 0, player_main, NULL, 0, &thread); - dprintf("Created thread 0x%X\n\n", player); + dprintf("Creating thread 0x%X\n\n", player); } } else if (fdwReason == DLL_PROCESS_DETACH) { #ifdef _DEBUG @@ -263,10 +263,7 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR case MCI_PLAY: { dprintf(" MCI_PLAY\n"); - if (mode == MCI_MODE_PLAY) { - dprintf(" already playing\n"); - break; - } else if (mode == MCI_MODE_PAUSE) { + if (mode == MCI_MODE_PAUSE) { dprintf(" resume instead of new play\n"); mode = MCI_MODE_PLAY; plr_resume(); @@ -349,6 +346,11 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR } } else if ((info.first && (fdwCommand & MCI_FROM)) || (info.last && (fdwCommand & MCI_TO))) { if (event) { + if (mode != MCI_MODE_STOP) { + command = MCI_STOP; + plr_stop(); + while (mode != MCI_MODE_STOP) Sleep(1); + } command = MCI_PLAY; SetEvent(event); } @@ -487,7 +489,7 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR break; case MCI_STATUS_NUMBER_OF_TRACKS: dprintf(" MCI_STATUS_NUMBER_OF_TRACKS\n"); - parms->dwReturn = numTracks; + parms->dwReturn = lastTrack; // including data tracks break; case MCI_STATUS_MODE: dprintf(" MCI_STATUS_MODE\n"); @@ -668,8 +670,8 @@ MCIERROR WINAPI fake_mciSendStringA(LPCSTR cmd, LPSTR ret, UINT cchReturn, HANDL if (strstr(cmdbuf, cmp_str)){ if (strstr(cmdbuf, "number of tracks")) { - dprintf(" Returning number of tracks (%d)\n", numTracks); - sprintf(ret, "%d", numTracks); + dprintf(" Returning number of tracks (%d)\n", lastTrack); + sprintf(ret, "%u", lastTrack); // including data tracks return 0; } int track = 0; diff --git a/player.c b/player.c index 665df2c..f148779 100644 --- a/player.c +++ b/player.c @@ -108,7 +108,7 @@ void plr_stop() if (plr_ev) { SetEvent(plr_ev); while (plr_bsy) { - Sleep(0); + Sleep(1); } } } @@ -192,7 +192,7 @@ int plr_pump() WAVEHDR *hdr = &plr_hdr[plr_que]; if (waveOutPrepareHeader(plr_hw, hdr, sizeof(WAVEHDR)) != MMSYSERR_NOERROR || waveOutWrite(plr_hw, hdr, sizeof(WAVEHDR)) != MMSYSERR_NOERROR) { SetEvent(plr_ev); - Sleep(0); + Sleep(1); break; } plr_sta[plr_que] = 0;