Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MidiJackGetEndpointName() for 64-bit Windows #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion VisualStudio/MidiJackPlugin/MidiJackPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@ namespace
// Basic type aliases
using DeviceHandle = HMIDIIN;
using DeviceID = uint32_t;
const DeviceHandle INVALID_DEVICE_HANDLE = reinterpret_cast<DeviceHandle>(static_cast<intptr_t>(-1));

// Utility functions for Win32/64 compatibility
#ifdef _WIN64
DeviceID DeviceHandleToID(DeviceHandle handle)
{
return static_cast<DeviceID>(reinterpret_cast<uint64_t>(handle));
}
std::map<DeviceID, DeviceHandle> device_id_to_handle;
DeviceHandle DeviceIDToHandle(DeviceID id)
{
return reinterpret_cast<DeviceHandle>(static_cast<uint64_t>(id));
auto itor = device_id_to_handle.find(id);
if (itor != device_id_to_handle.end())
{
return (*itor).second;
}
return INVALID_DEVICE_HANDLE;
}
#else
DeviceID DeviceHandleToID(DeviceHandle handle)
Expand Down Expand Up @@ -111,6 +118,8 @@ namespace
{
resource_lock.lock();
active_handles.push_back(handle);
DeviceID id = DeviceHandleToID(handle);
device_id_to_handle[id] = handle;
resource_lock.unlock();
}
else
Expand All @@ -127,6 +136,8 @@ namespace

resource_lock.lock();
active_handles.remove(handle);
DeviceID id = DeviceHandleToID(handle);
device_id_to_handle.erase(id);
resource_lock.unlock();
}

Expand Down
1 change: 1 addition & 0 deletions VisualStudio/MidiJackPlugin/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <cstdio>
#include <cstdlib>
#include <string>
#include <map>
#include <mutex>
#include <queue>
#include <list>
Expand Down