mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
FIX: use shmget according to bambu_source
Change-Id: Ic791498d4ef1bb012953783222b21e8a0394e3b8 (cherry picked from commit 2893425cdfb688e1b96a38186abef1450f530685)
This commit is contained in:
parent
fb53afe969
commit
7a266ca36a
1 changed files with 2 additions and 18 deletions
|
@ -13,13 +13,9 @@
|
||||||
#include <boost/process.hpp>
|
#include <boost/process.hpp>
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
#include <boost/process/windows.hpp>
|
#include <boost/process/windows.hpp>
|
||||||
#elif __APPLE__
|
#else
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
#else
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/stat.h> /* For mode constants */
|
|
||||||
#include <fcntl.h> /* For O_* constants */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
@ -525,7 +521,7 @@ bool MediaPlayCtrl::get_stream_url(std::string *url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CloseHandle(shm);
|
CloseHandle(shm);
|
||||||
#elif __APPLE__
|
#else
|
||||||
std::string file_url = data_dir() + "/cameratools/url.txt";
|
std::string file_url = data_dir() + "/cameratools/url.txt";
|
||||||
key_t key = ::ftok(file_url.c_str(), 1000);
|
key_t key = ::ftok(file_url.c_str(), 1000);
|
||||||
int shm = ::shmget(key, 1024, 0);
|
int shm = ::shmget(key, 1024, 0);
|
||||||
|
@ -543,18 +539,6 @@ bool MediaPlayCtrl::get_stream_url(std::string *url)
|
||||||
url = nullptr;
|
url = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
int shm = ::shm_open("bambu_stream_url", O_RDONLY, 0);
|
|
||||||
if (shm == -1) return false;
|
|
||||||
if (url) {
|
|
||||||
char *addr = (char *) ::mmap(nullptr, 1024, PROT_READ, MAP_SHARED, shm, 0);
|
|
||||||
if (addr != MAP_FAILED) {
|
|
||||||
*url = addr;
|
|
||||||
::munmap(addr, 1024);
|
|
||||||
url = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
::close(shm);
|
|
||||||
#endif
|
#endif
|
||||||
return url == nullptr;
|
return url == nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue