File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -59,9 +59,22 @@ 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
+ global BACKENDS
73
+ if flush :
74
+ BACKENDS .clear ()
75
+
76
+ if BACKENDS :
77
+ return BACKENDS
65
78
66
79
# Standard-library WAV and AIFF readers.
67
80
from . import rawread
@@ -86,7 +99,10 @@ def available_backends():
86
99
if ffdec .available ():
87
100
result .append (ffdec .FFmpegAudioFile )
88
101
89
- return result
102
+ # Cache the backends we found
103
+ BACKENDS .extend (result )
104
+
105
+ return BACKENDS
90
106
91
107
92
108
def audio_open (path , backends = None ):
You can’t perform that action at this time.
0 commit comments