Plug leak
This commit is contained in:
+5
-5
@@ -79,14 +79,14 @@ std::optional<std::pair<std::string, std::string>> parse_line(std::string_view::
|
|||||||
std::unordered_map<std::string, std::string> parse_config(std::string_view file_content) {
|
std::unordered_map<std::string, std::string> parse_config(std::string_view file_content) {
|
||||||
std::unordered_map<std::string, std::string> vars;
|
std::unordered_map<std::string, std::string> vars;
|
||||||
|
|
||||||
auto pos = std::begin(file_content) - 1;
|
auto pos = std::begin(file_content);
|
||||||
auto end = std::end(file_content);
|
auto end = std::end(file_content);
|
||||||
|
|
||||||
while(pos <= end) {
|
while(pos < end) {
|
||||||
auto newline = std::find(pos, end, '\n');
|
auto newline = std::find_if(pos, end, [](auto ch) { return ch == '\n' || ch == '\r'; });
|
||||||
auto var = parse_line(pos, *(newline - 1) == '\r' ? newline - 1 : newline);
|
auto var = parse_line(pos, newline);
|
||||||
|
|
||||||
pos = newline + 1;
|
pos = (*newline == '\r') ? newline + 2 : newline + 1;
|
||||||
if(!var) {
|
if(!var) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -299,5 +299,5 @@ void reset(std::shared_ptr<input_t> &input) {
|
|||||||
task_pool.push(reset_helper, input);
|
task_pool.push(reset_helper, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
input_t::input_t() : gamepad_state { 0 }, back_timeout_id { nullptr }, input { platf::input() } {}
|
input_t::input_t() : gamepad_state {}, mouse_press {}, back_timeout_id { nullptr }, input { platf::input() } {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,8 +63,6 @@ int main(int argc, char *argv[]) {
|
|||||||
boost::shared_ptr<std::ostream> stream { &std::cout, NoDelete {} };
|
boost::shared_ptr<std::ostream> stream { &std::cout, NoDelete {} };
|
||||||
sink->locked_backend()->add_stream(stream);
|
sink->locked_backend()->add_stream(stream);
|
||||||
sink->set_filter(severity >= config::sunshine.min_log_level);
|
sink->set_filter(severity >= config::sunshine.min_log_level);
|
||||||
// sink->set_formatter(bl::expressions::stream
|
|
||||||
// << "log level "sv << severity << ": "sv << bl::expressions::smessage);
|
|
||||||
|
|
||||||
sink->set_formatter([severity="Severity"s](const bl::record_view &view, bl::formatting_ostream &os) {
|
sink->set_formatter([severity="Severity"s](const bl::record_view &view, bl::formatting_ostream &os) {
|
||||||
auto log_level = view.attribute_values()[severity].extract<int>().get();
|
auto log_level = view.attribute_values()[severity].extract<int>().get();
|
||||||
|
|||||||
@@ -12,9 +12,13 @@ namespace platf {
|
|||||||
|
|
||||||
struct img_t {
|
struct img_t {
|
||||||
public:
|
public:
|
||||||
std::uint8_t *data;
|
std::uint8_t *data {};
|
||||||
std::int32_t width;
|
std::int32_t width {};
|
||||||
std::int32_t height;
|
std::int32_t height {};
|
||||||
|
|
||||||
|
img_t() = default;
|
||||||
|
img_t(const img_t&) = delete;
|
||||||
|
img_t(img_t&&) = delete;
|
||||||
|
|
||||||
virtual ~img_t() = default;
|
virtual ~img_t() = default;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ namespace platf {
|
|||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
void freeImage(XImage *);
|
void freeImage(XImage *);
|
||||||
|
void freeX(XFixesCursorImage *);
|
||||||
|
|
||||||
using ifaddr_t = util::safe_ptr<ifaddrs, freeifaddrs>;
|
using ifaddr_t = util::safe_ptr<ifaddrs, freeifaddrs>;
|
||||||
using xcb_connect_t = util::safe_ptr<xcb_connection_t, xcb_disconnect>;
|
using xcb_connect_t = util::safe_ptr<xcb_connection_t, xcb_disconnect>;
|
||||||
@@ -36,6 +37,7 @@ using xcb_cursor_img = util::c_ptr<xcb_xfixes_get_cursor_image_reply_t>;
|
|||||||
|
|
||||||
using xdisplay_t = util::safe_ptr_v2<Display, int, XCloseDisplay>;
|
using xdisplay_t = util::safe_ptr_v2<Display, int, XCloseDisplay>;
|
||||||
using ximg_t = util::safe_ptr<XImage, freeImage>;
|
using ximg_t = util::safe_ptr<XImage, freeImage>;
|
||||||
|
using xcursor_t = util::safe_ptr<XFixesCursorImage, freeX>;
|
||||||
|
|
||||||
class shm_id_t {
|
class shm_id_t {
|
||||||
public:
|
public:
|
||||||
@@ -80,13 +82,19 @@ struct x11_img_t : public img_t {
|
|||||||
struct shm_img_t : public img_t {
|
struct shm_img_t : public img_t {
|
||||||
~shm_img_t() override {
|
~shm_img_t() override {
|
||||||
if(data) {
|
if(data) {
|
||||||
delete(data);
|
delete[] data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void blend_cursor(Display *display, std::uint8_t *img_data, int width, int height) {
|
void blend_cursor(Display *display, std::uint8_t *img_data, int width, int height) {
|
||||||
XFixesCursorImage *overlay = XFixesGetCursorImage(display);
|
xcursor_t overlay { XFixesGetCursorImage(display) };
|
||||||
|
|
||||||
|
if(!overlay) {
|
||||||
|
BOOST_LOG(error) << "Couldn't get cursor from XFixesGetCursorImage"sv;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
overlay->x -= overlay->xhot;
|
overlay->x -= overlay->xhot;
|
||||||
overlay->y -= overlay->yhot;
|
overlay->y -= overlay->yhot;
|
||||||
|
|
||||||
@@ -219,10 +227,16 @@ struct shm_attr_t : public x11_attr_t {
|
|||||||
return capture_e::reinit;
|
return capture_e::reinit;
|
||||||
}
|
}
|
||||||
|
|
||||||
img->data = new std::uint8_t[frame_size()];
|
if(img->width != display->width_in_pixels || img->height != display->height_in_pixels) {
|
||||||
img->width = display->width_in_pixels;
|
if(img->data) {
|
||||||
img->height = display->height_in_pixels;
|
delete[] img->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
img->data = new std::uint8_t[frame_size()];
|
||||||
|
img->width = display->width_in_pixels;
|
||||||
|
img->height = display->height_in_pixels;
|
||||||
|
}
|
||||||
|
|
||||||
std::copy_n((std::uint8_t*)data.data, frame_size(), img->data);
|
std::copy_n((std::uint8_t*)data.data, frame_size(), img->data);
|
||||||
|
|
||||||
if(cursor) {
|
if(cursor) {
|
||||||
@@ -408,4 +422,7 @@ std::string get_local_ip() { return get_local_ip(AF_INET); }
|
|||||||
void freeImage(XImage *p) {
|
void freeImage(XImage *p) {
|
||||||
XDestroyImage(p);
|
XDestroyImage(p);
|
||||||
}
|
}
|
||||||
|
void freeX(XFixesCursorImage *p) {
|
||||||
|
XFree(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-2
@@ -657,8 +657,12 @@ void audioThread() {
|
|||||||
while (auto packet = packets->pop()) {
|
while (auto packet = packets->pop()) {
|
||||||
audio_packet_t audio_packet { (audio_packet_raw_t*)malloc(sizeof(audio_packet_raw_t) + packet->size()) };
|
audio_packet_t audio_packet { (audio_packet_raw_t*)malloc(sizeof(audio_packet_raw_t) + packet->size()) };
|
||||||
|
|
||||||
audio_packet->rtp.sequenceNumber = util::endian::big(frame++);
|
audio_packet->rtp.header = 0;
|
||||||
audio_packet->rtp.packetType = 97;
|
audio_packet->rtp.packetType = 97;
|
||||||
|
audio_packet->rtp.sequenceNumber = util::endian::big(frame++);
|
||||||
|
audio_packet->rtp.timestamp = 0;
|
||||||
|
audio_packet->rtp.ssrc = 0;
|
||||||
|
|
||||||
std::copy(std::begin(*packet), std::end(*packet), audio_packet->payload());
|
std::copy(std::begin(*packet), std::end(*packet), audio_packet->payload());
|
||||||
|
|
||||||
sock.send_to(asio::buffer((char*)audio_packet.get(), sizeof(audio_packet_raw_t) + packet->size()), *peer);
|
sock.send_to(asio::buffer((char*)audio_packet.get(), sizeof(audio_packet_raw_t) + packet->size()), *peer);
|
||||||
@@ -925,7 +929,7 @@ void cmd_announce(host_t &host, peer_t peer, msg_t &&req) {
|
|||||||
if (whitespace(*pos++)) {
|
if (whitespace(*pos++)) {
|
||||||
lines.emplace_back(begin, pos - begin - 1);
|
lines.emplace_back(begin, pos - begin - 1);
|
||||||
|
|
||||||
while(whitespace(*pos)) { ++pos; }
|
while(pos != std::end(payload) && whitespace(*pos)) { ++pos; }
|
||||||
begin = pos;
|
begin = pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user