Update to v094r25 release.

byuu says:

Windows port should run mostly well now, although exiting fullscreen
breaks the application in a really bizarre way. (clicking on the window
makes it sink to background rather than come to the foreground o_O)

I also need to add the doModalChange => audio.clear() thing for the
accursed menu stuttering with DirectSound.

I also finished porting all of the ruby drivers over to the newer API
changes from nall.

Since I can't compile the Linux or OS X drivers, I have no idea if there
are any typos that will result in compilation errors. If so, please let
me know where they're at and I'll try and fix them. If they're simple,
please try and fix them on your end to test further if you can.

I'm hopeful the udev crash will be gone now that nall::string checks for
null char* values passed to its stringify function. Of course, it's
a problem it's getting a null value in the first place, so it may not
work at all.

If you can compile on Linux (or by some miracle, OS X), please test each
video/audio/input driver if you don't mind, to make sure there's no
"compiles okay but still typos exist" bugs.
This commit is contained in:
Tim Allen
2015-06-16 08:16:43 +10:00
parent f0c17ffc0d
commit bb3c69a30d
75 changed files with 1017 additions and 906 deletions

117
nall/posix/service.hpp Normal file
View File

@@ -0,0 +1,117 @@
#ifndef NALL_POSIX_SERVICE_HPP
#define NALL_POSIX_SERVICE_HPP
#include <signal.h>
namespace nall {
struct service {
inline explicit operator bool() const;
inline auto command(const string& name, const string& command) -> bool;
inline auto receive() -> string;
inline auto name() const -> string;
inline auto stop() const -> bool;
private:
shared_memory shared;
string _name;
bool _stop = false;
};
service::operator bool() const {
return (bool)shared;
}
//returns true on new service process creation (false is not necessarily an error)
auto service::command(const string& name, const string& command) -> bool {
if(!name) return false;
if(!command) return print("[{0}] usage: {service} command\n"
"commands:\n"
" status : query whether service is running\n"
" start : start service if it is not running\n"
" stop : stop service if it is running\n"
" remove : remove semaphore lock if service crashed\n"
" {value} : send custom command to service\n"
"", format{name}), false;
if(shared.open(name, 4096)) {
if(command == "start") {
print("[{0}] already started\n", format{name});
} else if(command == "status") {
print("[{0}] running\n", format{name});
}
if(auto data = shared.acquire()) {
if(command == "stop") print("[{0}] stopped\n", format{name});
memory::copy(data, command.data(), min(command.size(), 4096));
shared.release();
}
if(command == "remove") {
shared.remove();
print("[{0}] removed\n", format{name});
}
return false;
}
if(command == "start") {
if(shared.create(name, 4096)) {
print("[{0}] started\n", format{name});
auto pid = fork();
if(pid == 0) {
signal(SIGHUP, SIG_IGN);
signal(SIGPIPE, SIG_IGN);
_name = name;
return true;
}
shared.close();
} else {
print("[{0}] start failed ({1})\n", format{name, strerror(errno)});
}
return false;
}
if(command == "status") {
print("[{0}] stopped\n", format{name});
return false;
}
return false;
}
auto service::receive() -> string {
string command;
if(shared) {
if(auto data = shared.acquire()) {
if(*data) {
command.resize(4095);
memory::copy(command.pointer(), data, 4095);
memory::fill(data, 4096);
}
shared.release();
if(command == "remove") {
_stop = true;
return "";
} else if(command == "start") {
return "";
} else if(command == "status") {
return "";
} else if(command == "stop") {
_stop = true;
shared.remove();
return "";
}
}
}
return command;
}
auto service::name() const -> string {
return _name;
}
auto service::stop() const -> bool {
return _stop;
}
}
#endif