コード例 #1
0
ファイル: audio.py プロジェクト: johwerm/pilight-cc
            if not self.__audio_analyser.is_running():
                self.__audio_analyser.start()
                self.__audio_effect.reset()

            if self._new_data_event.wait(
                    AudioService.__AUDIO_ANALYSER_TIMEOUT):
                # Only update if not timed out.
                with self.__lock:
                    data = self._data
                    self._new_data_event.clear()

                # Calculate send_effect frame.
                led_data = self.__audio_effect.get_effect(data)

                # Send message.
                self.__hyperion_connector.send_colors(
                    led_data, self._get_setting(Setting.AUDIO_PRIORITY),
                    self.__IMAGE_DURATION)
            else:
                # AudioAnalyser is not sending updates.
                self.__audio_analyser.stop()
                raise AudioAnalyserError("AudioAnalyser error")

        except (HyperionError, AudioAnalyserError) as err:
            self._update_state(AudioService.StateValue.ERROR, err.msg)
            self._safe_delay(AudioService.__ERROR_DELAY)


if __name__ == '__main__':
    ServiceLauncher.parse_args_and_execute("Audio", AudioService)
コード例 #2
0
ファイル: capture.py プロジェクト: johwerm/pilight-cc
        except HyperionError as err:
            self._update_state(CaptureService.StateValue.ERROR, err.msg)
            self._safe_delay(CaptureService.__ERROR_DELAY)

        # Wait until next run.
        self.__delay_timer.delay()

    # TODO Maybe use Gst?
    @staticmethod
    def get_pixel_buffer():
        win = Gdk.get_default_root_window()
        h = win.get_height()
        w = win.get_width()
        return Gdk.pixbuf_get_from_window(win, 0, 0, w, h)

    # @staticmethod
    # def get_pixel_buffer():
    #     from PyQt5.QtWidgets import QApplication
    #     app = QApplication([])
    #     return QApplication.screens()[0].grabWindow(
    #         QApplication.desktop().winId()).toImage()

    @staticmethod
    def scale_pixel_buffer(pixel_buffer, width, height):
        return pixel_buffer.scale_simple(width, height,
                                         GdkPixbuf.InterpType.BILINEAR)


if __name__ == '__main__':
    ServiceLauncher.parse_args_and_execute("Capture", CaptureService)