Skip to content

Commit

Permalink
Bugfixes for MCISendString
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuanx committed Feb 27, 2022
1 parent fb4f3dc commit d494a06
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ 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 numbering usually starts from 02 since the first track is a data track on mixed mode CD's.
Note the file names can not contain any whitespace.

Also note the numbering usually starts from 02 since on mixed mode CDs the first track is a data track.

In rare cases the games may use a pure audio CD with no data tracks in which case you should start numbering them from "Track01.ogg".

Expand All @@ -34,6 +36,10 @@ ogg-winmm also provides separate volume control for CDDA/MIDI/WAVE, which has be

# Revisions:

v.2022.02.28:
- Implement MCI_INFO
- Fix MCI_SYSINFO

v.2022.02.27:
- Treat MCI_PAUSE as MCI_STOP and MCI_RESUME as MCI_PLAY, since MCICDA does not support resume.

Expand Down
15 changes: 8 additions & 7 deletions ogg-winmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ static struct play_info info = { -1, -1 };
HANDLE player = NULL;
HANDLE event = NULL;
HWND window = NULL;
char alias_s[] = "cdaudio";
const char alias_def[] = "cdaudio";
char alias_s[100] = "cdaudio";
char music_path[MAX_PATH];

int command = 0;
Expand Down Expand Up @@ -260,7 +261,7 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR
dprintf(" MCI_OPEN_TYPE\n");
dprintf(" -> %s\n", parms->lpstrDeviceType);

if (stricmp(parms->lpstrDeviceType, "cdaudio") == 0)
if (stricmp(parms->lpstrDeviceType, alias_def) == 0)
{
dprintf(" Returning magic device id for MCI_DEVTYPE_CD_AUDIO\n");
parms->wDeviceID = MAGIC_DEVICEID;
Expand Down Expand Up @@ -480,7 +481,7 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR
if(fdwCommand & MCI_INFO_PRODUCT)
{
dprintf(" MCI_INFO_PRODUCT\n");
strncpy((char*)parms->lpstrReturn, "cdaudio", parms->dwRetSize); /* name = cdaudio */
strncpy((char*)parms->lpstrReturn, alias_s, parms->dwRetSize); /* name */
}

if(fdwCommand & MCI_INFO_MEDIA_IDENTITY)
Expand All @@ -499,7 +500,7 @@ MCIERROR WINAPI fake_mciSendCommandA(MCIDEVICEID IDDevice, UINT uMsg, DWORD_PTR
if(fdwCommand & MCI_SYSINFO_NAME)
{
dprintf(" MCI_SYSINFO_NAME\n");
strncpy((char*)parms->lpstrReturn, "cdaudio", parms->dwRetSize); /* name = cdaudio */
strncpy((char*)parms->lpstrReturn, alias_s, parms->dwRetSize); /* name */
}

if(fdwCommand & MCI_SYSINFO_QUANTITY)
Expand Down Expand Up @@ -705,9 +706,9 @@ MCIERROR WINAPI fake_mciSendStringA(LPCSTR cmd, LPSTR ret, UINT cchReturn, HANDL
if (strstr(cmdbuf, "type cdaudio alias"))
{
char *tmp_s = strrchr(cmdbuf, ' ');
if (tmp_s && *(tmp_s +1))
if (tmp_s && tmp_s[1])
{
sprintf(alias_s, "%s", tmp_s +1);
sprintf(alias_s, "%s", tmp_s+1);
}
fake_mciSendCommandA(MAGIC_DEVICEID, MCI_OPEN, 0, (DWORD_PTR)NULL);
return 0;
Expand All @@ -723,7 +724,7 @@ MCIERROR WINAPI fake_mciSendStringA(LPCSTR cmd, LPSTR ret, UINT cchReturn, HANDL
sprintf(cmp_str, "close %s", alias_s);
if (strstr(cmdbuf, cmp_str))
{
sprintf(alias_s, "cdaudio");
sprintf(alias_s, alias_def);
return 0;
}

Expand Down

0 comments on commit d494a06

Please sign in to comment.