Codebase list audioread / 7902b66
Imported Debian patch 0.6-1 Simon Chopin 11 years ago
7 changed file(s) with 43 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
00 Metadata-Version: 1.0
11 Name: audioread
2 Version: 0.5
2 Version: 0.6
33 Summary: multi-library, cross-platform audio decoding
44 Home-page: https://github.com/sampsyo/audioread
55 Author: Adrian Sampson
7070 Version History
7171 ---------------
7272
73 0.6
74 Make FFmpeg timeout more robust.
75 Dump FFmpeg output on timeout.
76 Fix a nondeterministic hang in the Gstreamer backend.
77 Fix a file descriptor leak in the MAD backend.
78
7379 0.5
7480 Fix crash when FFmpeg fails to report a duration.
7581 Fix a hang when FFmpeg fills up its stderr output buffer.
6262 Version History
6363 ---------------
6464
65 0.6
66 Make FFmpeg timeout more robust.
67 Dump FFmpeg output on timeout.
68 Fix a nondeterministic hang in the Gstreamer backend.
69 Fix a file descriptor leak in the MAD backend.
70
6571 0.5
6672 Fix crash when FFmpeg fails to report a duration.
6773 Fix a hang when FFmpeg fills up its stderr output buffer.
1818 import re
1919 import threading
2020 import select
21 import time
2122
2223 class FFmpegError(Exception):
2324 pass
7273
7374 # Start a separate thread to read the rest of the data from
7475 # stderr.
75 stderr_reader = ReaderThread(self.proc.stderr)
76 stderr_reader.start()
76 self.stderr_reader = ReaderThread(self.proc.stderr)
77 self.stderr_reader.start()
7778
7879 def read_data(self, block_size=4096, timeout=10.0):
7980 """Read blocks of raw PCM data from the file."""
8081 # Read from stdout on this thread.
82 start_time = time.time()
8183 while True:
8284 # Wait for data to be available or a timeout.
8385 rready, _, xready = select.select((self.proc.stdout,),
8486 (), (self.proc.stdout,),
8587 timeout)
88 end_time = time.time()
8689 if not rready and not xready:
87 raise ReadTimeoutError()
90 if end_time - start_time >= timeout:
91 # Nothing interesting has happened for a while --
92 # FFmpeg is probably hanging.
93 raise ReadTimeoutError(
94 'ffmpeg output: %s' %
95 ''.join(self.stderr_reader.data)
96 )
97 else:
98 # Keep waiting.
99 continue
100 start_time = end_time
88101
89102 data = self.proc.stdout.read(block_size)
90103 if not data:
105105 def __init__(self):
106106 super(MainLoopThread, self).__init__()
107107 self.loop = gobject.MainLoop()
108 self.running = False
109108 self.daemon = True
110109
111110 def run(self):
112 self.running = True
113111 self.loop.run()
114112
115113
201199 self.read_exc = None
202200
203201 # Return as soon as the stream is ready!
202 self.running = True
204203 self.pipeline.set_state(gst.STATE_PLAYING)
205204 self.ready_sem.acquire()
206205 if self.read_exc:
207206 # An error occurred before the stream became ready.
208207 self.close(True)
209208 raise self.read_exc
210 self.running = True
211209
212210
213211 # Gstreamer callbacks.
253251 # Sent when the pads are done adding (i.e., there are no more
254252 # streams in the file). If we haven't gotten at least one
255253 # decodable stream, raise an exception.
256 if not self.running and not self._got_a_pad:
254 if not self._got_a_pad:
257255 self.read_exc = NoStreamError()
258 self.ready_sem.release()
256 self.ready_sem.release() # No effect if we've already started.
259257
260258 def _new_buffer(self, sink):
261259 if self.running:
2020 class MadAudioFile(object):
2121 """MPEG audio file decoder using the MAD library."""
2222 def __init__(self, filename):
23 self.mf = mad.MadFile(filename)
23 self.fp = open(filename, 'rb')
24 self.mf = mad.MadFile(self.fp)
2425 if not self.mf.total_time(): # Indicates a failed open.
2526 raise UnsupportedError()
2627
2728 def close(self):
29 if hasattr(self, 'fp'):
30 self.fp.close()
2831 if hasattr(self, 'mf'):
2932 del self.mf
3033
0 audioread (0.6-1) unstable; urgency=low
1
2 * New upstream release
3
4 -- Simon Chopin <chopin.simon@gmail.com> Fri, 01 Jun 2012 14:06:51 +0200
5
06 audioread (0.5-1) unstable; urgency=low
17
28 * New upstream release
1919 return open(path).read()
2020
2121 setup(name='audioread',
22 version='0.5',
22 version='0.6',
2323 description='multi-library, cross-platform audio decoding',
2424 author='Adrian Sampson',
2525 author_email='adrian@radbox.org',