pixelflux 1.4.4__tar.gz → 1.4.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pixelflux might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pixelflux
3
- Version: 1.4.4
3
+ Version: 1.4.5
4
4
  Summary: A performant web native pixel delivery pipeline for diverse sources, blending VNC-inspired parallel processing of pixel buffers with flexible modern encoding formats.
5
5
  Home-page: https://github.com/linuxserver/pixelflux
6
6
  Author: Linuxserver.io
@@ -148,6 +148,19 @@ struct VaapiEncoderState {
148
148
  unsigned int frame_count = 0;
149
149
  };
150
150
 
151
+
152
+ /**
153
+ * @brief Custom X11 error handler specifically for the XShmAttach call.
154
+ * This function is temporarily installed as the X11 error handler. It catches
155
+ * any error, sets the g_shm_attach_failed flag to true, and returns 0 to
156
+ * signal that the error has been "handled," preventing program termination.
157
+ */
158
+ static bool g_shm_attach_failed = false;
159
+ static int shm_attach_error_handler(Display* dpy, XErrorEvent* ev) {
160
+ g_shm_attach_failed = true;
161
+ return 0;
162
+ }
163
+
151
164
  /**
152
165
  * @brief Manages a pool of H.264 encoders and associated picture buffers.
153
166
  * This struct provides thread-safe storage and management for x264 encoder
@@ -1873,16 +1886,21 @@ void ScreenCaptureModule::capture_loop() {
1873
1886
  auto next_frame_time =
1874
1887
  std::chrono::high_resolution_clock::now() + target_frame_duration_seconds;
1875
1888
 
1889
+ const int MAX_ATTACH_ATTEMPTS = 5;
1890
+ const int RETRY_BACKOFF_MS = 500;
1876
1891
  char* display_env = std::getenv("DISPLAY");
1877
1892
  const char* display_name = display_env ? display_env : ":0";
1878
1893
  Display* display = XOpenDisplay(display_name);
1894
+
1879
1895
  if (!display) {
1880
1896
  std::cerr << "Error: Failed to open X display " << display_name << std::endl;
1881
1897
  return;
1882
1898
  }
1899
+
1883
1900
  Window root_window = DefaultRootWindow(display);
1884
1901
  int screen = DefaultScreen(display);
1885
1902
  XWindowAttributes attributes;
1903
+
1886
1904
  if (XGetWindowAttributes(display, root_window, &attributes)) {
1887
1905
  if (local_capture_width_actual > attributes.width) {
1888
1906
  local_capture_width_actual = attributes.width;
@@ -1907,6 +1925,7 @@ void ScreenCaptureModule::capture_loop() {
1907
1925
  XCloseDisplay(display);
1908
1926
  return;
1909
1927
  }
1928
+
1910
1929
  std::cout << "X Shared Memory Extension available." << std::endl;
1911
1930
 
1912
1931
  if (local_current_capture_cursor) {
@@ -1915,55 +1934,73 @@ void ScreenCaptureModule::capture_loop() {
1915
1934
  XCloseDisplay(display);
1916
1935
  return;
1917
1936
  }
1918
-
1919
1937
  std::cout << "XFixes Extension available." << std::endl;
1920
1938
  }
1921
1939
 
1922
1940
  XShmSegmentInfo shminfo;
1923
- memset(&shminfo, 0, sizeof(shminfo));
1924
1941
  XImage* shm_image = nullptr;
1942
+ bool shm_setup_complete = false;
1925
1943
 
1926
- shm_image = XShmCreateImage(
1927
- display, DefaultVisual(display, screen), DefaultDepth(display, screen),
1928
- ZPixmap, nullptr, &shminfo, local_capture_width_actual,
1929
- local_capture_height_actual);
1930
- if (!shm_image) {
1931
- std::cerr << "Error: XShmCreateImage failed for "
1932
- << local_capture_width_actual << "x"
1933
- << local_capture_height_actual << std::endl;
1934
- XCloseDisplay(display);
1935
- return;
1936
- }
1944
+ for (int attempt = 1; attempt <= MAX_ATTACH_ATTEMPTS; ++attempt) {
1945
+ memset(&shminfo, 0, sizeof(shminfo));
1946
+ shm_image = XShmCreateImage(display, DefaultVisual(display, screen), DefaultDepth(display, screen),
1947
+ ZPixmap, nullptr, &shminfo, local_capture_width_actual,
1948
+ local_capture_height_actual);
1949
+ if (!shm_image) {
1950
+ std::cerr << "Attempt " << attempt << ": XShmCreateImage failed." << std::endl;
1951
+ if (attempt < MAX_ATTACH_ATTEMPTS) std::this_thread::sleep_for(std::chrono::milliseconds(RETRY_BACKOFF_MS));
1952
+ continue;
1953
+ }
1937
1954
 
1938
- shminfo.shmid = shmget(IPC_PRIVATE,
1939
- static_cast<size_t>(shm_image->bytes_per_line) * shm_image->height,
1940
- IPC_CREAT | 0600);
1941
- if (shminfo.shmid < 0) {
1942
- perror("shmget");
1943
- XDestroyImage(shm_image);
1944
- XCloseDisplay(display);
1945
- return;
1946
- }
1955
+ shminfo.shmid = shmget(IPC_PRIVATE, static_cast<size_t>(shm_image->bytes_per_line) * shm_image->height, IPC_CREAT | 0600);
1956
+ if (shminfo.shmid < 0) {
1957
+ perror("shmget");
1958
+ XDestroyImage(shm_image);
1959
+ if (attempt < MAX_ATTACH_ATTEMPTS) std::this_thread::sleep_for(std::chrono::milliseconds(RETRY_BACKOFF_MS));
1960
+ continue;
1961
+ }
1947
1962
 
1948
- shminfo.shmaddr = (char*)shmat(shminfo.shmid, nullptr, 0);
1949
- if (shminfo.shmaddr == (char*)-1) {
1950
- perror("shmat");
1951
- shmctl(shminfo.shmid, IPC_RMID, 0);
1952
- XDestroyImage(shm_image);
1953
- XCloseDisplay(display);
1954
- return;
1963
+ shminfo.shmaddr = (char*)shmat(shminfo.shmid, nullptr, 0);
1964
+ if (shminfo.shmaddr == (char*)-1) {
1965
+ perror("shmat");
1966
+ shmctl(shminfo.shmid, IPC_RMID, 0);
1967
+ XDestroyImage(shm_image);
1968
+ if (attempt < MAX_ATTACH_ATTEMPTS) std::this_thread::sleep_for(std::chrono::milliseconds(RETRY_BACKOFF_MS));
1969
+ continue;
1970
+ }
1971
+
1972
+ shminfo.readOnly = False;
1973
+ shm_image->data = shminfo.shmaddr;
1974
+ g_shm_attach_failed = false;
1975
+ XErrorHandler old_handler = XSetErrorHandler(shm_attach_error_handler);
1976
+ XShmAttach(display, &shminfo);
1977
+ XSync(display, False);
1978
+ XSetErrorHandler(old_handler);
1979
+
1980
+ if (g_shm_attach_failed) {
1981
+ std::cerr << "Attempt " << attempt << "/" << MAX_ATTACH_ATTEMPTS << ": XShmAttach failed with an X server error." << std::endl;
1982
+ shmdt(shminfo.shmaddr);
1983
+ shmctl(shminfo.shmid, IPC_RMID, 0);
1984
+ XDestroyImage(shm_image);
1985
+ if (attempt < MAX_ATTACH_ATTEMPTS) {
1986
+ std::this_thread::sleep_for(std::chrono::milliseconds(RETRY_BACKOFF_MS));
1987
+ }
1988
+ continue;
1989
+ }
1990
+
1991
+ shm_setup_complete = true;
1992
+ break;
1955
1993
  }
1956
- shminfo.readOnly = False;
1957
- shm_image->data = shminfo.shmaddr;
1958
1994
 
1959
- if (!XShmAttach(display, &shminfo)) {
1960
- std::cerr << "Error: XShmAttach failed" << std::endl;
1961
- shmdt(shminfo.shmaddr);
1962
- shmctl(shminfo.shmid, IPC_RMID, 0);
1963
- XDestroyImage(shm_image);
1964
- XCloseDisplay(display);
1965
- return;
1995
+ if (!shm_setup_complete) {
1996
+ std::cerr << "ERROR: Failed to set up XShm after " << MAX_ATTACH_ATTEMPTS << " attempts. Exiting capture thread." << std::endl;
1997
+ if (display) {
1998
+ XCloseDisplay(display);
1999
+ display = nullptr;
2000
+ }
2001
+ return;
1966
2002
  }
2003
+
1967
2004
  std::cout << "XShm setup complete for " << local_capture_width_actual
1968
2005
  << "x" << local_capture_height_actual << "." << std::endl;
1969
2006
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pixelflux
3
- Version: 1.4.4
3
+ Version: 1.4.5
4
4
  Summary: A performant web native pixel delivery pipeline for diverse sources, blending VNC-inspired parallel processing of pixel buffers with flexible modern encoding formats.
5
5
  Home-page: https://github.com/linuxserver/pixelflux
6
6
  Author: Linuxserver.io
@@ -48,7 +48,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
48
48
  long_description = fh.read()
49
49
  setup(
50
50
  name="pixelflux",
51
- version="1.4.4",
51
+ version="1.4.5",
52
52
  author="Linuxserver.io",
53
53
  author_email="pypi@linuxserver.io",
54
54
  description="A performant web native pixel delivery pipeline for diverse sources, blending VNC-inspired parallel processing of pixel buffers with flexible modern encoding formats.",
File without changes
File without changes
File without changes
File without changes
File without changes