gpt4 book ai didi

python - shout-python 段错误我该如何解决这个问题?

转载 作者:行者123 更新时间:2023-11-30 17:23:19 26 4
gpt4 key购买 nike

我正在尝试为icecast2/shoutcast 创建源。但编译完所有内容后,我遇到了段错误。使用 gdb 进一步调试后,我得到了更详细的错误。我不知道任何类型的 c,所以我不知道如何处理这个错误

Program received signal SIGSEGV, Segmentation fault.
send_mp3 (self=0x988eb0, buff = 0xa5c154 "" at mp3.c:175175 mp3.c: No such file or directory.

我想可能是循环使用了太多资源。但无论我设置多少 time.sleep() 我仍然得到相同的结果。

import random
import shout
from pyModules import db
from pyModules import error
import ID3
import time
import sys
import glob

class Audio(object):

def __init__(self):
self.count = 0
self.nbuf = 0
self.buf = 0
self.shout = shout.Shout()
self.db = db.database()
self.songs = self.load()

def load(self):
return glob.glob("%s*%s" % (self.config('directory'), self.config('ext')))

def start(self):
self.running = True
self.shout.host = self.config('host')
self.shout.port = self.config('port')
self.shout.mount = self.config('mount')
self.shout.protocol = self.config('protocol')
self.shout.user = self.config('user')
self.shout.password = self.config('password')
self.shout.name = self.config('name')
self.shout.format = self.config('format')
self.shout.genre = self.config('genre')
self.shout.url = self.config('url')
self.shout.public = self.config('public')
self.shout.description = self.config('description')
self.songs = self.load()
self.shout.open()


def cShuffle(self):
sh = self.getSettings(1, key='shuffle')
if sh == 1:
random.shuffle(self.songs)

def cNext(self):
n = self.getSettings(1, key='setSong')
if n == 1:
self.stop()
self.db.setNext(0)
self.Change()

def cPrev(self):
p = self.getSettings(1, key='prevSong')
if p == 1:
self.stop()
if self.count == 0:
self.count -= 1
self.db.setPrev(0)
self.Change()
else:
self.count -= 2
self.Change()

def cReload(self):
r = self.getSettings(1, key='reload')
if r == 1:
self.songs = self.load()

def check(self):
self.cShuffle()
self.cNext()
self.cPrev()
self.cReload()

def getSettings(self, mode=0, key=None):
return self.db.getSettings(mode, key)

def config(self, value):
return self.db.config(value)

def getTitle(self, File, mode=0):
try:
song = ID3.ID3(File)
title = song["TITLE"]
except:
title = "unknown"
title = title.replace("'", "")
if mode == 0:
self.db.setSongTitle(title)
return title
elif mode == 1:
self.db.setNextSongTitle(title)
return title
elif mode == 2:
self.db.setPrevSongTitle(title)

def sendBlankFile(self):
File = open('/home/radio/AudioServer/bin/blank.mp3').read()
self.shout.send(File)

def stop(self):
self.buf = 0
self.nbuf = 0
self.running = 0
self.sendBlankFile()

def Change(self):
self.stop()
if len(self.songs) >= self.count: self.count = 0
else: self.count += 1
song = self.songs[self.count]
psong = self.songs[self.count - 1]
nsong = self.songs[self.count + 1]
self.getTitle(song, mode=0)
self.getTitle(nsong, mode=1)
self.getTitle(psong, mode=2)
self.play()

def play(self):
song = open(self.songs[self.count])
cs = self.songs[self.count]
self.shout.set_metadata({'song': self.getTitle(cs)})
total = 0
st = time.time()
self.nbuf = song.read(4096)
while self.running:
self.check()
self.buf = self.nbuf
self.nbuf = song.read(4096)
self.buf = self.nbuf
total = total + len(self.buf)
if len(self.buf) == 0:
self.running = False
self.Change()
self.shout.send(self.buf)
self.shout.sync()

if __name__ == "__main__":
Server = Audio()
default = Server.config('default')
Server.db.clear(default)
Server.start()

最佳答案

正如 cox 指出的那样,这个问题确实是 libshout 的编译问题。但它只在 debian 7 中有效,在 ubuntu 12 中无效。我认为原因是因为我没有在 ubuntu 中安装 libogg,我只安装了 vorbis,我认为这是同一件事。我还安装了 mp3 编解码器以防万一。

关于python - shout-python 段错误我该如何解决这个问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27654208/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com