Пример #1
0
    def load_sink(self):
        sink_name = 'PulseEffects'

        self.load_sink_info()

        if not self.sink_is_loaded:
            args = []

            sink_properties = 'device.description=\'PulseEffects\''
            sink_properties += 'device.class=\'sound\''

            args.append('sink_name=' + sink_name)
            args.append('sink_properties=' + sink_properties)
            args.append('channels=2')
            args.append('rate=' + str(self.default_sink_rate))

            argument = ' '.join(map(str, args)).encode('ascii')

            module = b'module-null-sink'

            def module_idx(context, idx, user_data):
                pass

            self.module_idx_cb = p.pa_context_index_cb_t(module_idx)

            o = p.pa_context_load_module(self.ctx, module, argument,
                                         self.module_idx_cb, None)

            while p.pa_operation_get_state(o) == p.PA_OPERATION_RUNNING:
                pass

            p.pa_operation_unref(o)

            self.load_sink_info()
Пример #2
0
    def load_sink(self):
        sink_name = 'PulseEffects'

        self.load_sink_info()

        if not self.sink_is_loaded:
            self.log.info('loading Pulseeffects sink...')

            args = []

            sink_properties = 'device.description=\'PulseEffects\''
            sink_properties += 'device.class=\'sound\''

            args.append('sink_name=' + sink_name)
            args.append('sink_properties=' + sink_properties)
            args.append('channels=2')
            args.append('rate=' + str(self.default_sink_rate))

            argument = ' '.join(map(str, args)).encode('ascii')

            module = b'module-null-sink'

            def module_idx(context, idx, user_data):
                self.log.info('sink owner module index: ' + str(idx))

            self.module_idx_cb = p.pa_context_index_cb_t(module_idx)

            o = p.pa_context_load_module(self.ctx, module, argument,
                                         self.module_idx_cb, None)

            while p.pa_operation_get_state(o) == p.PA_OPERATION_RUNNING:
                pass

            p.pa_operation_unref(o)

            self.load_sink_info()

            if self.sink_is_loaded:
                self.log.info('Pulseeffects sink was successfully loaded')
                self.log.info('Pulseeffects sink index:' + str(self.sink_idx))
                self.log.info('Pulseeffects sink monitor name: ' +
                              self.sink_monitor_name +
                              '. We will process audio from this source.')
            else:
                self.log.critical('Could not load sink')
Пример #3
0
    def load_sink(self, name, description, rate):
        self.sink_is_loaded = False

        self.load_sink_info(name)

        if not self.sink_is_loaded:
            args = []

            sink_properties = description
            sink_properties += 'device.class=\'sound\''

            args.append('sink_name=' + name)
            args.append('sink_properties=' + sink_properties)
            args.append('channels=2')
            args.append('rate=' + str(rate))

            argument = ' '.join(map(str, args)).encode('ascii')

            module = b'module-null-sink'

            def module_idx(context, idx, user_data):
                self.log.info('sink owner module index: ' + str(idx))

            self.module_idx_cb = p.pa_context_index_cb_t(module_idx)

            o = p.pa_context_load_module(self.ctx, module, argument,
                                         self.module_idx_cb, None)

            while p.pa_operation_get_state(o) == p.PA_OPERATION_RUNNING:
                pass

            p.pa_operation_unref(o)

            self.load_sink_info(name)

            if self.sink_is_loaded:
                return True
            else:
                return False
        else:
            return True
Пример #4
0
    def load_sink(self, name, description, rate):
        self.sink_is_loaded = False

        self.load_sink_info(name)

        if not self.sink_is_loaded:
            args = []

            sink_properties = description
            sink_properties += 'device.class=\'sound\''

            args.append('sink_name=' + name)
            args.append('sink_properties=' + sink_properties)
            args.append('channels=2')
            args.append('rate=' + str(rate))

            argument = ' '.join(map(str, args)).encode('ascii')

            module = b'module-null-sink'

            p.pa_threaded_mainloop_lock(self.main_loop)

            o = p.pa_context_load_module(self.ctx, module, argument,
                                         self.module_idx_cb, None)

            while p.pa_operation_get_state(o) == p.PA_OPERATION_RUNNING:
                p.pa_threaded_mainloop_wait(self.main_loop)

            p.pa_operation_unref(o)

            p.pa_threaded_mainloop_unlock(self.main_loop)

            self.load_sink_info(name)  # checking if sink was loaded

            if self.sink_is_loaded:
                return True
            else:
                return False
        else:
            return True