File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -59,9 +59,19 @@ def _mad_available():
59
59
else :
60
60
return True
61
61
62
+ # A place to store available backends
63
+ BACKENDS = []
62
64
63
- def available_backends ():
64
- """Returns a list of backends that are available on this system."""
65
+ def available_backends (flush_cache = False ):
66
+ """Returns a list of backends that are available on this system.
67
+
68
+ The list of backends is cached after the first call.
69
+ If the parameter `flush_cache` is set to `True`, then the cache
70
+ will be flushed and the backend list will be reconstructed.
71
+ """
72
+
73
+ if BACKENDS and not flush_cache :
74
+ return BACKENDS
65
75
66
76
# Standard-library WAV and AIFF readers.
67
77
from . import rawread
@@ -86,7 +96,10 @@ def available_backends():
86
96
if ffdec .available ():
87
97
result .append (ffdec .FFmpegAudioFile )
88
98
89
- return result
99
+ # Cache the backends we found
100
+ BACKENDS [:] = result
101
+
102
+ return BACKENDS
90
103
91
104
92
105
def audio_open (path , backends = None ):
You can’t perform that action at this time.
0 commit comments