mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-14 22:22:18 +00:00
Fix zombie transcoding processes
Fix various artist album track sorting
This commit is contained in:
parent
c5890ab120
commit
1f8289e1c6
16
api/media.py
16
api/media.py
@ -34,9 +34,6 @@ def prepare_transcoding_cmdline(base_cmdline, input_file, input_format, output_f
|
||||
|
||||
return base_cmdline.replace('%srcpath', '"'+input_file+'"').replace('%srcfmt', input_format).replace('%outfmt', output_format).replace('%outrate', str(output_bitrate))
|
||||
|
||||
def transcode(process):
|
||||
for chunk in iter(process, ''):
|
||||
yield chunk
|
||||
|
||||
@app.route('/rest/stream.view', methods = [ 'GET', 'POST' ])
|
||||
def stream_media():
|
||||
@ -51,6 +48,17 @@ def stream_media():
|
||||
response.headers['X-Accel-Redirect'] = redirect + xsendfile.encode('UTF8')
|
||||
app.logger.debug('X-Accel-Redirect: ' + redirect + xsendfile)
|
||||
return response
|
||||
|
||||
def transcode(process):
|
||||
try:
|
||||
for chunk in iter(process.stdout.readline, ''):
|
||||
yield chunk
|
||||
process.wait()
|
||||
except:
|
||||
app.logger.debug('transcoding timeout, killing process')
|
||||
process.terminate()
|
||||
process.wait()
|
||||
|
||||
status, res = get_entity(request, Track)
|
||||
|
||||
if not status:
|
||||
@ -137,7 +145,7 @@ def stream_media():
|
||||
dec_proc = subprocess.Popen(decoder, stdout = subprocess.PIPE, shell=False)
|
||||
proc = subprocess.Popen(encoder, stdin = dec_proc.stdout, stdout = subprocess.PIPE, shell=False)
|
||||
|
||||
response = Response(transcode(proc.stdout.readline), 200, {'Content-Type': dst_mimetype, 'X-Content-Duration': str(duration)})
|
||||
response = Response(transcode(proc), 200, {'Content-Type': dst_mimetype, 'X-Content-Duration': str(duration)})
|
||||
except:
|
||||
return request.error_formatter(0, 'Error while running the transcoding process')
|
||||
|
||||
|
3
db.py
3
db.py
@ -289,7 +289,8 @@ class Track(database.Model):
|
||||
return os.path.splitext(self.path)[1][1:].lower()
|
||||
|
||||
def sort_key(self):
|
||||
return (self.album.artist.name + self.album.name + ("%02i" % self.disc) + ("%02i" % self.number) + self.title).lower()
|
||||
#return (self.album.artist.name + self.album.name + ("%02i" % self.disc) + ("%02i" % self.number) + self.title).lower()
|
||||
return (self.album.name + ("%02i" % self.disc) + ("%02i" % self.number) + self.title).lower()
|
||||
|
||||
class StarredFolder(database.Model):
|
||||
|
||||
|
@ -11,3 +11,4 @@
|
||||
processes = 8
|
||||
harakiri = 60
|
||||
daemonize = uwsgi.log
|
||||
close-on-exec = true
|
||||
|
Loading…
Reference in New Issue
Block a user