pyglet: Pulse Audio Exception - Hard to Reproduce

Describe the bug I’m using Python Arcade 3.0.0.dev25 and Pyglet 2.0.0.9. Randomly (usually when I pause a lot when debugging, but also when I’ve been running the game for a while) I get the following exception thrown: Assertion 'q->front' failed at pulsecore/queue.c:81, function pa_queue_push(). Aborting.

The bug is clearly in pulse audio. It was listed as a “closed issue”: https://github.com/mackron/miniaudio/issues/235 And fixed here: https://github.com/mackron/miniaudio/commit/50c9081b19fe4e25c781c78b6b7acfbc5ffdef58

System Information:

pyglet.version: 2.0.9
pyglet.compat_platform: linux
pyglet.__file__: /home/david/.virtualenvs/venv_arcade/lib/python3.10/site-packages/pyglet/__init__.py
pyglet.options['audio'] = ('xaudio2', 'directsound', 'openal', 'pulse', 'silent')
pyglet.options['debug_font'] = False
pyglet.options['debug_gl'] = True
pyglet.options['debug_gl_trace'] = False
pyglet.options['debug_gl_trace_args'] = False
pyglet.options['debug_gl_shaders'] = False
pyglet.options['debug_graphics_batch'] = False
pyglet.options['debug_lib'] = False
pyglet.options['debug_media'] = False
pyglet.options['debug_texture'] = False
pyglet.options['debug_trace'] = False
pyglet.options['debug_trace_args'] = False
pyglet.options['debug_trace_depth'] = 1
pyglet.options['debug_trace_flush'] = True
pyglet.options['debug_win32'] = False
pyglet.options['debug_input'] = False
pyglet.options['debug_x11'] = False
pyglet.options['shadow_window'] = True
pyglet.options['vsync'] = None
pyglet.options['xsync'] = True
pyglet.options['xlib_fullscreen_override_redirect'] = False
pyglet.options['search_local_libs'] = True
pyglet.options['win32_gdi_font'] = False
pyglet.options['headless'] = False
pyglet.options['headless_device'] = 0
pyglet.options['win32_disable_shaping'] = False
pyglet.options['dw_legacy_naming'] = False
pyglet.options['win32_disable_xinput'] = False
pyglet.options['com_mta'] = False
pyglet.options['osx_alt_loop'] = False

pyglet.window
------------------------------------------------------------------------------
display: <pyglet.canvas.xlib.XlibDisplay object at 0x7f8a319e2d10>
screens[0]: XlibScreen(display=<pyglet.canvas.xlib.XlibDisplay object at 0x7f8a319e2d10>, x=0, y=0, width=1920, height=1080, xinerama=False)
config['double_buffer'] = 1
config['stereo'] = 0
config['buffer_size'] = 24
config['aux_buffers'] = 0
config['sample_buffers'] = 0
config['samples'] = 0
config['red_size'] = 8
config['green_size'] = 8
config['blue_size'] = 8
config['alpha_size'] = 0
config['depth_size'] = 24
config['stencil_size'] = 0
config['accum_red_size'] = 0
config['accum_green_size'] = 0
config['accum_blue_size'] = 0
config['accum_alpha_size'] = 0
config['major_version'] = 3
config['minor_version'] = 3
config['forward_compatible'] = None
config['opengl_api'] = 'gl'
config['debug'] = None
context: XlibContext(id=140231516124640, share=XlibContext(id=140231514667616, share=None))

window.context._info
------------------------------------------------------------------------------
gl_info.get_version(): (4, 6)
gl_info.get_vendor(): Intel
gl_info.get_renderer(): Mesa Intel(R) UHD Graphics 630 (CFL GT2)

pyglet.gl.glx_info
------------------------------------------------------------------------------
context.is_direct(): 1
glx_info.get_server_vendor(): SGI
glx_info.get_server_version(): 1.4
glx_info.get_server_extensions():
   GLX_ARB_create_context
   GLX_ARB_create_context_no_error
   GLX_ARB_create_context_profile
   GLX_ARB_create_context_robustness
   GLX_ARB_fbconfig_float
   GLX_ARB_framebuffer_sRGB
   GLX_ARB_multisample
   GLX_EXT_create_context_es_profile
   GLX_EXT_create_context_es2_profile
   GLX_EXT_fbconfig_packed_float
   GLX_EXT_framebuffer_sRGB
   GLX_EXT_import_context
   GLX_EXT_libglvnd
   GLX_EXT_no_config_context
   GLX_EXT_texture_from_pixmap
   GLX_EXT_visual_info
   GLX_EXT_visual_rating
   GLX_MESA_copy_sub_buffer
   GLX_OML_swap_method
   GLX_SGI_make_current_read
   GLX_SGI_swap_control
   GLX_SGIS_multisample
   GLX_SGIX_fbconfig
   GLX_SGIX_pbuffer
   GLX_SGIX_visual_select_group
   GLX_INTEL_swap_event
glx_info.get_client_vendor(): Mesa Project and SGI
glx_info.get_client_version(): 1.4
glx_info.get_client_extensions():
   GLX_ARB_context_flush_control
   GLX_ARB_create_context
   GLX_ARB_create_context_no_error
   GLX_ARB_create_context_profile
   GLX_ARB_create_context_robustness
   GLX_ARB_fbconfig_float
   GLX_ARB_framebuffer_sRGB
   GLX_ARB_get_proc_address
   GLX_ARB_multisample
   GLX_EXT_buffer_age
   GLX_EXT_create_context_es2_profile
   GLX_EXT_create_context_es_profile
   GLX_EXT_fbconfig_packed_float
   GLX_EXT_framebuffer_sRGB
   GLX_EXT_import_context
   GLX_EXT_no_config_context
   GLX_EXT_swap_control
   GLX_EXT_swap_control_tear
   GLX_EXT_texture_from_pixmap
   GLX_EXT_visual_info
   GLX_EXT_visual_rating
   GLX_ATI_pixel_format_float
   GLX_INTEL_swap_event
   GLX_MESA_copy_sub_buffer
   GLX_MESA_multithread_makecurrent
   GLX_MESA_query_renderer
   GLX_MESA_swap_control
   GLX_NV_float_buffer
   GLX_OML_swap_method
   GLX_OML_sync_control
   GLX_SGIS_multisample
   GLX_SGIX_fbconfig
   GLX_SGIX_pbuffer
   GLX_SGIX_visual_select_group
   GLX_SGI_make_current_read
   GLX_SGI_swap_control
   GLX_SGI_video_sync
glx_info.get_extensions():
   GLX_ARB_create_context
   GLX_ARB_create_context_no_error
   GLX_ARB_create_context_profile
   GLX_ARB_create_context_robustness
   GLX_ARB_fbconfig_float
   GLX_ARB_framebuffer_sRGB
   GLX_ARB_get_proc_address
   GLX_ARB_multisample
   GLX_EXT_buffer_age
   GLX_EXT_create_context_es2_profile
   GLX_EXT_create_context_es_profile
   GLX_EXT_fbconfig_packed_float
   GLX_EXT_framebuffer_sRGB
   GLX_EXT_import_context
   GLX_EXT_no_config_context
   GLX_EXT_swap_control
   GLX_EXT_swap_control_tear
   GLX_EXT_texture_from_pixmap
   GLX_EXT_visual_info
   GLX_EXT_visual_rating
   GLX_INTEL_swap_event
   GLX_MESA_copy_sub_buffer
   GLX_MESA_query_renderer
   GLX_MESA_swap_control
   GLX_OML_swap_method
   GLX_OML_sync_control
   GLX_SGIS_multisample
   GLX_SGIX_fbconfig
   GLX_SGIX_pbuffer
   GLX_SGIX_visual_select_group
   GLX_SGI_make_current_read
   GLX_SGI_swap_control
   GLX_SGI_video_sync

pyglet.media
------------------------------------------------------------------------------
audio driver: <pyglet.media.drivers.pulse.adaptation.PulseAudioDriver object at 0x7f8a319e3eb0>

pyglet.media.ffmpeg
------------------------------------------------------------------------------
FFmpeg version: 4.2.7-0ubuntu0.1

pyglet.media.drivers.openal
------------------------------------------------------------------------------
OpenAL not available.

pyglet.input.wintab
------------------------------------------------------------------------------
WinTab not available.

How To Reproduce This is the code I’ve written to start the sound most of the time. When a sprite triggers an action (i.e. starts walking) if the player sprite is close enough, the sound turns on. This code snippet is typical of when I load or turn on sound. Typically there are two sounds playing when the exception happens.

def start(self, player_character: arcade.Sprite, source_sprite: arcade.Sprite, eos=None):
        self.player_character = player_character
        self.sound_source = source_sprite
        self.eos = eos
        self.sound = arcade.Sound(self.file_name, streaming=False)
        if self.min_range <= 0:  # Start playing right away
            self.media_player = self.sound.play(volume=self.max_volume, loop=self.loop)
            # Todo: Add EOS logic

About this issue

  • Original URL
  • State: open
  • Created 10 months ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

AVbin hasn’t been part of pyglet for a while.

This was already corrected in this comment, my apologies.

sudo apt-get install libopenal-dev

Are you sure you need need the -dev version rather than just libopenal? I see the following on my system:

$ dpkg -l | grep openal
ii  libopenal-data                        1:1.19.1-2                       all          Software implementation of the OpenAL audio API (data files)
ii  libopenal1:amd64                      1:1.19.1-2                       amd64        Software implementation of the OpenAL audio API (shared library)

Either way, I think the doc solution is the best short-term option for arcade, if not pyglet. Thank you for reporting this and continuing to help with investigating it.

Even though it looks like one of the lead pyglet maintainers is already aware, the PulseAudio issues could still take a while to get resolved. Race condition bugs aren’t really fun to deal with, especially when the easy workaround is to use an audio backend already present on many distros.