Skip to content

Commit

Permalink
Fix Windows fseek issue
Browse files Browse the repository at this point in the history
- Changed to use _ifseeki64 instead of fseek on Windows.
  • Loading branch information
keijiro committed Feb 8, 2019
1 parent 0a84514 commit 8de9f92
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
Binary file modified Assets/Klak/Hap/Plugin/Windows/KlakHap.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion Plugin/Source/Decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace KlakHap
)
{
// FIXME: This should be threaded.
for (auto i = 0; i < count; i++) work(p, i);
for (auto i = 0u; i < count; i++) work(p, i);
}

#pragma endregion
Expand Down
6 changes: 5 additions & 1 deletion Plugin/Source/Demuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ namespace KlakHap
auto inOffs = MP4D__frame_offset(&demux_, 0, index, &inSize, &timestamp, &duration);

// Frame data read
fseek(file_, (long)inOffs, SEEK_SET);
#if defined(_WIN32)
_fseeki64(file_, inOffs, SEEK_SET);
#else
fseek(file_, inOffs, SEEK_SET);
#endif
buffer.storage.resize(inSize);
fread(buffer.storage.data(), inSize, 1, file_);
}
Expand Down
19 changes: 19 additions & 0 deletions Plugin/Source/KlakHap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
#include "ReadBuffer.h"
#include "IUnityRenderingExtensions.h"

#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#include <consoleapi.h>
#endif

using namespace KlakHap;

namespace
Expand Down Expand Up @@ -71,6 +78,18 @@ namespace

#pragma region Plugin common function

#if defined(_WIN32) && defined(_DEBUG)

extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API UnityPluginLoad(IUnityInterfaces* interfaces)
{
// Open a new console for debug logging.
FILE * pConsole;
AllocConsole();
freopen_s(&pConsole, "CONOUT$", "wb", stdout);
}

#endif

extern "C" UnityRenderingEventAndData UNITY_INTERFACE_EXPORT KlakHap_GetTextureUpdateCallback()
{
return TextureUpdateCallback;
Expand Down

0 comments on commit 8de9f92

Please sign in to comment.