fetch up pyglet

This commit is contained in:
shenjack 2023-03-25 20:16:08 +08:00
parent f95d7f96ec
commit 5a123389ae

View File

@ -1,55 +1,63 @@
"""Drivers for playing back media.""" """Drivers for playing back media."""
import sys
import atexit import atexit
import pyglet import pyglet
_debug = pyglet.options['debug_media'] _debug = pyglet.options['debug_media']
_is_pyglet_doc_run = hasattr(sys, "is_pyglet_doc_run") and sys.is_pyglet_doc_run
for driver_name in pyglet.options['audio']: if _is_pyglet_doc_run:
try:
if driver_name == 'pulse':
from . import pulse
_audio_driver = pulse.create_audio_driver()
break
elif driver_name == 'xaudio2':
if pyglet.compat_platform in ('win32', 'cygwin'):
from pyglet.libs.win32.constants import WINDOWS_8_OR_GREATER
if WINDOWS_8_OR_GREATER:
from . import xaudio2
_audio_driver = xaudio2.create_audio_driver()
break
elif driver_name == 'directsound':
if pyglet.compat_platform in ('win32', 'cygwin'):
from . import directsound
_audio_driver = directsound.create_audio_driver()
break
elif driver_name == 'openal':
from . import openal
_audio_driver = openal.create_audio_driver()
break
elif driver_name == 'silent':
from . import silent
_audio_driver = silent.create_audio_driver()
break
except Exception:
if _debug:
print(f'Error importing driver {driver_name}:')
import traceback
traceback.print_exc()
else:
from . import silent from . import silent
_audio_driver = silent.create_audio_driver() _audio_driver = silent.create_audio_driver()
else:
for driver_name in pyglet.options['audio']:
try:
if driver_name == 'pulse':
from . import pulse
_audio_driver = pulse.create_audio_driver()
break
elif driver_name == 'xaudio2':
if pyglet.compat_platform in ('win32', 'cygwin'):
from pyglet.libs.win32.constants import WINDOWS_8_OR_GREATER
if WINDOWS_8_OR_GREATER:
from . import xaudio2
_audio_driver = xaudio2.create_audio_driver()
break
elif driver_name == 'directsound':
if pyglet.compat_platform in ('win32', 'cygwin'):
from . import directsound
_audio_driver = directsound.create_audio_driver()
break
elif driver_name == 'openal':
from . import openal
_audio_driver = openal.create_audio_driver()
break
elif driver_name == 'silent':
from . import silent
_audio_driver = silent.create_audio_driver()
break
except Exception:
if _debug:
print(f'Error importing driver {driver_name}:')
import traceback
traceback.print_exc()
else:
from . import silent
_audio_driver = silent.create_audio_driver()
def get_audio_driver(): def get_audio_driver():
"""Get the preferred audio driver for the current platform. """Get the preferred audio driver for the current platform.