Skip to content

Commit

Permalink
final fix for crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
somewhatlurker committed Jul 5, 2019
1 parent 40502fd commit 5f8a745
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
31 changes: 3 additions & 28 deletions DivaSound/src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,47 +199,22 @@ void hookedAudioInit(initClass *cls, uint64_t unk, uint64_t unk2)
{
// setup some variables instead of using the original init function
divaAudCls->mixer = new audioMixer();
divaAudCls->mixer->volume_mutex = new std::mutex();
divaAudCls->mixer->volume_master = 1.0f;
divaAudCls->mixer->volume_channels[0] = 1.0f;
divaAudCls->mixer->volume_channels[1] = 1.0f;
divaAudCls->mixer->volume_channels[2] = 1.0f;
divaAudCls->mixer->volume_channels[3] = 1.0f;
divaAudCls->mixer->audioClass = divaAudCls;

mtx_init(&divaAudCls->mixer->volume_mutex, 2);
}

divaAudioMixCls = divaAudCls->mixer;

divaAudCls->channels = nChannels; // this could replace stereo patch
divaAudCls->rate = 44100; // really does nothing
divaAudCls->depth = bitDepth; // setting this to something other than 16 just removes output

if (!useOldInit)
{
// just trying anything to get stability now
if (FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void**)&(divaAudCls->pEnumerator))))
{
printf("[DivaSound] Dummy WASAPI enumerator creation failed\n");
SAFE_RELEASE(divaAudCls->pEnumerator);
}
if (FAILED(divaAudCls->pEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &(divaAudCls->pDevice))))
{
printf("[DivaSound] Dummy WASAPI device creation failed\n");
SAFE_RELEASE(divaAudCls->pEnumerator);
SAFE_RELEASE(divaAudCls->pDevice);
}
if (FAILED(divaAudCls->pDevice->Activate(IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&(divaAudCls->pAudioClient))))
{
printf("[DivaSound] Dummy WASAPI device activation failed\n");
SAFE_RELEASE(divaAudCls->pEnumerator);
SAFE_RELEASE(divaAudCls->pDevice);
SAFE_RELEASE(divaAudCls->pAudioClient);
}
}
if (!useOldInit)
{
//divaAudCls->hCallback = (HANDLE)39;
}


if (useAsio)
{
Expand Down
6 changes: 4 additions & 2 deletions DivaSound/src/framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <windows.h>
#include <string>
#include <vector>
#include <mutex>
#include <thread>
#define MINIAUDIO_IMPLEMENTATION
#include <miniaudio.h>
#include <bassasio.h>
Expand All @@ -24,6 +24,8 @@ int (__cdecl* divaAudioAllocMixer)(void* cls, uint64_t unk, uint64_t unk2, int64
// cls is the same as mixer in divaAudioFillbuffer
// nFrames is number of audio frames to hold in the mixing buffers (only used when divaAudioFillbuffer is called). Internally this is multiplied by 16 (buffers are built using 32bit floats)

int(__cdecl* mtx_init)(void* mutex, int type) = (int(__cdecl*)(void* mutex, int type))0x14081DEF4;

#pragma pack(push, 1)
struct _50 {
byte padding00[0x50];
Expand Down Expand Up @@ -51,7 +53,7 @@ struct audioMixer {
float* mixbuffer;
uint64_t mixbuffer_size;

std::mutex* volume_mutex; // not sure if this is pointer or not
void* volume_mutex; // not sure if this is pointer or not
float volume_master;
float volume_channels[4];

Expand Down

0 comments on commit 5f8a745

Please sign in to comment.