This file is indexed.

/usr/share/veromix/dbus-service/pulseaudio/PulseVolume.py is in veromix-common 0.18.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# -*- coding: utf-8 -*-
# Copyright (C) 2010-2012 Nik Lutz <nik.lutz@gmail.com>
# Copyright (C) 2009 Harry Karvonen <harry.karvonen@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from .lib_pulseaudio import *
import math
from VeromixUtils import *

# This contains all basic volume features
class PulseVolume:
    def __init__(self, vol, channels):
        self.channels = channels
        if vol > 100 or vol < 0:
            print("WARNING: Volume is invalid!")
            vol = 0
        self.values   = [vol] * self.channels
        return

    def __init__(self, values):
        self.channels = len(values)
        self.values   = values
        return

    ##############################
    #
    # Type conversions
    #
    #def fromCtypes(self, pa_cvolume):
    #  self.channels = pa_cvolume.channels
    #  self.values   = map(lambda x: (math.ceil(float(x) * 100 / PA_VOLUME_NORM)),
    #                      pa_cvolume.values[0:self.channels])
    #  return self

    def toCtypes(self):
        ct = struct_pa_cvolume()
        ct.channels = self.channels
        for x in range(0, self.channels):
            ct.values[x] = int((self.values[x] * PA_VOLUME_NORM) / 100)
        return ct

    def toCtypes2(self, num):
        ct = struct_pa_cvolume()
        ct.channels = num
        for x in range(0, num):
            ct.values[x] = (self.values[x] * PA_VOLUME_NORM) / 100
        return ct

    ###

    def printDebug(self):
        print("PulseVolume")
        print("self.channels:", self.channels)
        print("self.values:", self.values)
        #print "self.proplist:", self.proplist

    ###

    def incVolume(self, vol):
        "Increment volume level (mono only)"
        vol += sum(self.values) / len(self.values)
        vol = int(vol)
        if vol > 100:
            vol = 100
        elif vol < 0:
            vol = 0
        self.setVolume(vol)
        return

    ###

    def setVolume(self, vol, balance = None):
        if not balance:
            self.values = [vol] * self.channels
        else:
            self.values[balance] = vol
        return

    ###

    def getVolume(self):
        "Return mono volume"
        return int(sum(self.values) / len(self.values))

    ###

    def __str__(self):
        return "Channels: " + str(self.channels) + \
               ", values: \"" + str([str(x) + "%" for x in self.values]) + "\""

################################################################################

class PulseVolumeCtypes(PulseVolume):
    def __init__(self, pa_cvolume, pa_channel_map):
        self.channels = pa_cvolume.channels
        self.channel_map = pa_channel_map
        self.values   = [(math.ceil(float(x) * 100 / PA_VOLUME_NORM)) for x in pa_cvolume.values[0:self.channels]]
        return

    def getVolumes(self):
        vol = {}
        for i in range(0, self.channels):
            key = pa_channel_position_to_pretty_string(self.channel_map.map[i])
            entry = {}
            entry[in_unicode(key)] = self.values[i]
            vol[i] = entry
        return vol