Skip to content

Commit

Permalink
Filter MIDI driver on full file name
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuanx committed Jul 26, 2021
1 parent cae246a commit 6386a95
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ogg-winmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)

/* 100% volume is equivalent to no override */
if (cddaVol < 0 || cddaVol > 99 ) cddaVol = -1;
if (midiVol < 0 || midiVol > 99 ) midiVol= -1;
if (waveVol < 0 || waveVol > 99 ) waveVol= -1;
if (midiVol < 0 || midiVol > 99 ) midiVol = -1;
if (waveVol < 0 || waveVol > 99 ) waveVol = -1;

plr_volume(cddaVol);
stub_midivol(midiVol);
Expand Down
14 changes: 8 additions & 6 deletions stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ MMRESULT WINAPI fake_midiStreamOut(HMIDISTRM a0, LPMIDIHDR a1, UINT a2)
funcp = (void*)GetProcAddress(loadRealDLL(), "midiStreamOut");

#ifdef MIDI_VELOCITY_SCALING
if (midiVol != -1 && a1 && a1->lpData) {
if (midiVol >= 0 && a1 && a1->lpData) {
for (int i = 0, j = a1->dwBytesRecorded; i < j; i += sizeof(DWORD)*3) {
MIDIEVENT *pe = (MIDIEVENT *)(a1->lpData + i);
if (pe->dwEvent & MEVT_F_LONG) {
Expand Down Expand Up @@ -96,19 +96,21 @@ MMRESULT WINAPI fake_waveOutWrite(HWAVEOUT a0, LPWAVEHDR a1, UINT a2)
funcp = (void*)GetProcAddress(loadRealDLL(), "waveOutWrite");

/* let owr own OGG wave pass through */
if ((waveVol != -1 || midiVol != -1) && a1 && a1->lpData && a1->dwUser != 0xBEEF7777) {
if ((waveVol >= 0 || midiVol >= 0 ) && a1 && a1->lpData && a1->dwUser != 0xBEEF7777) {
/* Windows is f**ked up. MIDI synth driver converts MIDI to WAVE and then calls winmm.waveOutWrite!!! */
void *addr = __builtin_return_address(0);
char caller[MAX_PATH];
MEMORY_BASIC_INFORMATION mbi;
VirtualQuery(addr, &mbi, sizeof(MEMORY_BASIC_INFORMATION));
GetModuleFileName(mbi.AllocationBase, caller, MAX_PATH);

float vol;
if (strstr(strrchr(caller, '\\'), ".drv")) vol = midiVol;
else vol = waveVol;
float vol = -1.0;
char *pos = strrchr(caller, '\\');
/* Mixer: msacm32.drv */
if (strstr(pos, "wdmaud.drv")) vol = midiVol;
else if (!strstr(pos, ".drv")) vol = waveVol;

if (vol != -1) {
if (vol >= 0) {
short *wave16;
char *wave8;
switch (waveBits) {
Expand Down

0 comments on commit 6386a95

Please sign in to comment.