Пример #1
0
def query_sound():
    import subprocess
    command = get_sound_command()+["_sound_query"]
    _add_debug_args(command)
    kwargs = exec_kwargs()
    env = exec_env()
    env.update(get_sound_wrapper_env())
    log("query_sound() command=%s, env=%s, kwargs=%s", command, env, kwargs)
    proc = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None, env=env, **kwargs)
    out, err = proc.communicate(None)
    log("query_sound() process returned %s", proc.returncode)
    log("query_sound() out=%s, err=%s", out, err)
    if proc.returncode!=0:
        return typedict()
    d = typedict()
    for x in out.decode("utf8").splitlines():
        kv = x.split("=", 1)
        if len(kv)==2:
            #ie: kv = ["decoders", "mp3,vorbis"]
            k,v = kv
            #fugly warning: all the other values are lists.. but this one is not:
            if k!=b"python.bits":
                v = [x.encode() for x in v.split(",")]
            #d["decoders"] = ["mp3", "vorbis"]
            d[k.encode()] = v
    log("query_sound()=%s", d)
    return d
Пример #2
0
def query_sound():
    import subprocess
    command = get_sound_command()+["_sound_query"]
    _add_debug_args(command)
    kwargs = exec_kwargs()
    env = exec_env()
    env.update(get_sound_wrapper_env())
    log("query_sound() command=%s, env=%s, kwargs=%s", command, env, kwargs)
    proc = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=env, **kwargs)
    out, err = proc.communicate(None)
    log("query_sound() process returned %s", proc.returncode)
    log("query_sound() out=%s, err=%s", out, err)
    if proc.returncode!=0:
        return typedict()
    d = typedict()
    for x in out.decode("utf8").splitlines():
        kv = x.split("=", 1)
        if len(kv)==2:
            #ie: kv = ["decoders", "mp3,vorbis"]
            k,v = kv
            #fugly warning: all the other values are lists.. but this one is not:
            if k!="python.bits":
                v = [x.encode() for x in v.split(",")]
            #d["decoders"] = ["mp3", "vorbis"]
            d[k.encode()] = v
    log("query_sound()=%s", d)
    return d
Пример #3
0
def query_sound():
    import subprocess
    command = get_sound_command() + ["_sound_query"]
    _add_debug_args(command)
    kwargs = exec_kwargs()
    env = exec_env()
    log("query_sound() command=%s, env=%s, kwargs=%s", command, env, kwargs)
    proc = subprocess.Popen(command,
                            stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE,
                            stderr=sys.stderr.fileno(),
                            env=env,
                            **kwargs)
    out, err = proc.communicate(None)
    log("query_sound() process returned %s", proc.returncode)
    log("query_sound() out=%s, err=%s", out, err)
    if proc.returncode != 0:
        return typedict()
    d = typedict()
    for x in out.decode("utf8").splitlines():
        kv = x.split("=", 1)
        if len(kv) == 2:
            #ie: kv = ["decoders", "mp3,vorbis"]
            d[kv[0].encode()] = [x.encode() for x in kv[1].split(",")
                                 ]  #d["decoders"] = ["mp3", "vorbis"]
    log("query_sound()=%s", d)
    return d
Пример #4
0
 def __init__(self, plugin, options, codecs, volume, element_options):
     sound_subprocess_wrapper.__init__(self, "sound source")
     self.large_packets = ["new-buffer"]
     self.command = get_sound_command() + [
         "_sound_record", "-", "-", plugin or "",
         format_element_options(element_options), ",".join(codecs), "",
         str(volume)
     ]
     _add_debug_args(self.command)
Пример #5
0
 def __init__(self, plugin, codec, volume, element_options):
     sound_subprocess_wrapper.__init__(self, "sound output")
     self.large_packets = ["add_data"]
     self.codec = codec
     self.command = get_sound_command() + [
         "_sound_play", "-", "-", plugin or "",
         format_element_options(element_options), codec, "",
         str(volume)
     ]
     _add_debug_args(self.command)
Пример #6
0
def query_sound():
    import subprocess
    command = get_sound_command()+["_sound_query"]
    _add_debug_args(command)
    kwargs = exec_kwargs()
    env = exec_env()
    env.update(get_sound_wrapper_env())
    log("query_sound() command=%s, env=%s, kwargs=%s", command, env, kwargs)
    proc = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=None, env=env, **kwargs)
    out, err = proc.communicate(None)
    log("query_sound() process returned %s", proc.returncode)
    log("query_sound() out=%s, err=%s", out, err)
    if proc.returncode!=0:
        return typedict()
    d = typedict()
    for x in out.decode("utf8").splitlines():
        kv = x.split("=", 1)
        if len(kv)==2:
            #ie: kv = ["decoders", "mp3,vorbis"]
            d[kv[0].encode()] = [x.encode() for x in kv[1].split(",")]     #d["decoders"] = ["mp3", "vorbis"]
    log("query_sound()=%s", d)
    return d
Пример #7
0
 def __init__(self, plugin, options, codec, volume, element_options):
     sound_subprocess_wrapper.__init__(self, "sound output")
     self.large_packets = ["add_data"]
     self.codec = codec
     self.command = get_sound_command()+["_sound_play", "-", "-", plugin or "", format_element_options(element_options), codec, "", str(volume)]
     _add_debug_args(self.command)
Пример #8
0
 def __init__(self, plugin, options, codecs, volume, element_options):
     sound_subprocess_wrapper.__init__(self, "sound source")
     self.large_packets = ["new-buffer"]
     self.command = get_sound_command()+["_sound_record", "-", "-", plugin or "", format_element_options(element_options), ",".join(codecs), "", str(volume)]
     _add_debug_args(self.command)
Пример #9
0
def get_full_sound_command():
    return get_sound_command() + DEFAULT_SOUND_COMMAND_ARGS