beproudstandupcom / pyglet

Automatically exported from code.google.com/p/pyglet
0 stars 0 forks source link

ALSA: too many open files #149

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run the noisy.py example
2. When the ball bounces the bellow traceback occurs
3.

Paste in the traceback or error message:
ajones@dill ~/dev/pyglet/examples/noisy $ python noisy.py 
Traceback (most recent call last):
  File "noisy.py", line 85, in <module>
    ball.update(dt)
  File "noisy.py", line 47, in update
    sound.play()
  File "/usr/lib/python2.5/site-packages/pyglet/media/__init__.py", line
377, in play
    player.queue(self)
  File "/usr/lib/python2.5/site-packages/pyglet/media/__init__.py", line
692, in queue
    self._begin_source()
  File "/usr/lib/python2.5/site-packages/pyglet/media/__init__.py", line
774, in _begin_source
    self._create_audio()
  File "/usr/lib/python2.5/site-packages/pyglet/media/__init__.py", line
607, in _create_audio
    self._audio = audio_player_class(source.audio_format)
  File
"/usr/lib/python2.5/site-packages/pyglet/media/drivers/alsa/__init__.py",
line 97, in __init__
    int(self._buffer_time * audio_format.sample_rate)))
  File
"/usr/lib/python2.5/site-packages/pyglet/media/drivers/alsa/__init__.py",
line 56, in check
    raise ALSAException(asound.snd_strerror(err))
pyglet.media.drivers.alsa.ALSAException: Invalid argument

Paste in the output of tools/gl_info.py:
ajones@dill ~/dev/pyglet $ python tools/gl_info.py 
Platform instance is <pyglet.window.xlib.XlibPlatform object at 0x82f45ec>
Display instance is <pyglet.window.xlib.XlibDisplayDevice object at 0xb7ddfa0c>
Screens:
  XlibScreen(screen=0, x=0, y=0, width=1280, height=800, xinerama=0)
Creating default context...
GL attributes:
double_buffer=c_long(1) stereo=c_long(0) buffer_size=c_long(32)
aux_buffers=c_long(4) sample_buffers=c_long(0) samples=c_long(0)
red_size=c_long(8) green_size=c_long(8) blue_size=c_long(8)
alpha_size=c_long(0) depth_size=c_long(24) stencil_size=c_long(8)
accum_red_size=c_long(16) accum_green_size=c_long(16)
accum_blue_size=c_long(16) accum_alpha_size=c_long(16)
GL version: 2.1.0 NVIDIA 96.31
GL vendor: NVIDIA Corporation
GL renderer: GeForce Go 7400/PCI/SSE2
GL extensions:
  GL_ARB_texture_compression GL_NV_point_sprite
  GL_NV_fragment_program_option GL_NV_vertex_array_range2
  GL_EXT_blend_color GL_EXT_blend_subtract GL_EXT_stencil_wrap
  GL_NV_fence GL_EXT_vertex_array GL_IBM_texture_mirrored_repeat
  GL_EXT_texture_compression_s3tc GL_NV_vertex_program2_option
  GL_ARB_depth_texture GL_NV_packed_depth_stencil GL_EXT_Cg_shader
  GL_NV_primitive_restart GL_EXT_texture_object
  GL_NVX_conditional_render GL_NV_texture_compression_vtc
  GL_NV_texture_shader3 GL_NV_texture_shader2 GL_EXT_blend_func_separate
  GL_EXT_texture_cube_map GL_ARB_occlusion_query GL_ARB_transpose_matrix
  GL_ARB_texture_border_clamp GL_EXT_fog_coord GL_NV_depth_clamp
  GL_ARB_texture_cube_map GL_EXT_blend_equation_separate
  GL_ARB_point_parameters GL_EXT_texture_env_dot3
  GL_EXT_multi_draw_arrays GL_HP_occlusion_test
  GL_EXT_texture_env_combine GL_NV_fog_distance GL_ARB_vertex_program
  GL_ARB_texture_env_dot3 GL_EXT_bgra GL_NV_float_buffer
  GL_NV_texture_env_combine4 GL_ARB_texture_env_combine
  GL_ARB_vertex_buffer_object GL_EXT_shadow_funcs
  GL_NV_vertex_array_range GL_NV_texture_expand_normal
  GL_EXT_separate_specular_color GL_EXT_texture_env_add
  GL_EXT_packed_depth_stencil GL_EXT_texture_mirror_clamp
  GL_EXT_timer_query GL_NV_multisample_filter_hint GL_SUN_slice_accum
  GL_ARB_point_sprite GL_EXT_framebuffer_object GL_ARB_vertex_shader
  GL_ARB_half_float_pixel GL_KTX_buffer_region GL_NV_register_combiners
  GL_ARB_draw_buffers GL_ARB_fragment_program_shadow GL_NV_half_float
  GL_NV_fragment_program GL_ATI_texture_mirror_once
  GL_IBM_rasterpos_clip GL_EXT_texture_sRGB GL_EXT_stencil_two_side
  GL_SGIX_shadow GL_NV_texgen_reflection GL_EXT_compiled_vertex_array
  GL_NV_fragment_program2 GL_EXT_point_parameters GL_ARB_texture_float
  GL_ARB_fragment_shader GL_ATI_texture_float GL_NV_texture_shader
  GL_NV_pixel_data_range GL_ARB_imaging GL_ARB_fragment_program
  GL_ARB_shader_objects GL_ARB_shading_language_100 GL_NV_blend_square
  GL_EXT_secondary_color GL_ARB_texture_non_power_of_two
  GL_EXT_texture_lod_bias GL_NV_texture_rectangle
  GL_EXT_pixel_buffer_object GL_EXT_abgr GL_NV_vertex_program
  GL_ARB_texture_rectangle GL_ARB_multisample GL_SGIS_generate_mipmap
  GL_EXT_texture_filter_anisotropic GL_NV_light_max_exponent
  GL_EXT_blend_minmax GL_SGIS_texture_lod GL_NV_vertex_program3
  GL_NV_vertex_program2 GL_SGIX_depth_texture GL_ARB_color_buffer_float
  GL_EXT_texture_edge_clamp GL_ARB_window_pos GL_ARB_shadow
  GL_ARB_texture_mirrored_repeat GL_EXT_gpu_program_parameters
  GL_EXT_texture_lod GL_S3_s3tc GL_EXT_stencil_clear_tag
  GL_NV_vertex_program1_1 GL_EXT_texture3D GL_ARB_multitexture
  GL_NV_copy_depth_to_color GL_ATI_draw_buffers GL_EXT_depth_bounds_test
  GL_EXT_draw_range_elements GL_NV_occlusion_query
  GL_ARB_texture_env_add GL_EXT_packed_pixels GL_EXT_rescale_normal
  GL_ARB_pixel_buffer_object GL_NV_register_combiners2
GLU version: 1.3
GLU extensions:
  GLU_EXT_nurbs_tessellator GLU_EXT_object_space_tess

Context is XlibGLContext()
GLX is direct
GLX server vendor: NVIDIA Corporation
GLX server version: 1.3
GLX server extensions:
  GLX_EXT_visual_info GLX_EXT_visual_rating GLX_SGIX_fbconfig
  GLX_SGIX_pbuffer GLX_SGI_video_sync GLX_SGI_swap_control
  GLX_EXT_texture_from_pixmap GLX_ARB_multisample GLX_NV_float_buffer
  GLX_ARB_fbconfig_float
GLX client vendor: NVIDIA Corporation
GLX client version: 1.4
GLX client extensions:
  GLX_ARB_get_proc_address GLX_ARB_multisample GLX_EXT_visual_info
  GLX_EXT_visual_rating GLX_EXT_import_context GLX_SGI_video_sync
  GLX_NV_swap_group GLX_NV_video_out GLX_SGIX_fbconfig GLX_SGIX_pbuffer
  GLX_SGI_swap_control GLX_NV_float_buffer GLX_ARB_fbconfig_float
  GLX_EXT_fbconfig_packed_float GLX_EXT_texture_from_pixmap
GLX extensions:
  GLX_EXT_visual_info GLX_EXT_visual_rating GLX_SGIX_fbconfig
  GLX_SGIX_pbuffer GLX_SGI_video_sync GLX_SGI_swap_control
  GLX_EXT_texture_from_pixmap GLX_ARB_multisample GLX_NV_float_buffer
  GLX_ARB_fbconfig_float GLX_ARB_get_proc_address

Any additional info (platform/language/hardware) thaOS: Ubuntu 7.04
$ uname -a
Linux dill 2.6.20-16-generic #2 SMP Sun Sep 23 19:50:39 UTC 2007 i686 GNU/Linux
Harware: Sony VAIO VGN-SZ28GPt may be relevant?

Original issue reported on code.google.com by andy.lar...@gmail.com on 2 Oct 2007 at 12:50

GoogleCodeExporter commented 8 years ago
Can't replicate it here (I have a Creative Audigy 4); I suspect there's a 
hardware
limitation on buffer size.

See if you can get past the error (audio will be broken) by changing the value 
of 

  int(self._buffer_time * audio_format.sample_rate)

at pyglet/media/drivers/alsa/__init__.py:97.  I imagine the number needs to be 
either
smaller, larger, or aligned to some number (for example, a multiple of 4).

If this is the case, we need to find the appropriate ALSA magic that gives the
constraints.

Original comment by Alex.Hol...@gmail.com on 2 Oct 2007 at 1:02

GoogleCodeExporter commented 8 years ago
8192 gets passed it. I get about 4-6 ball bounce sounds before I get the 
following trace.
4096 also works but only get 1 bounce. 
16384 gives the original trace.

Traceback (most recent call last):
  File "noisy.py", line 85, in <module>
    ball.update(dt)
  File "noisy.py", line 47, in update
    sound.play()
  File "/home/ajones/dev/pyglet/pyglet/media/__init__.py", line 377, in play
    player.queue(self)
  File "/home/ajones/dev/pyglet/pyglet/media/__init__.py", line 692, in queue
    self._begin_source()
  File "/home/ajones/dev/pyglet/pyglet/media/__init__.py", line 775, in _begin_source
    self._fill_audio()
  File "/home/ajones/dev/pyglet/pyglet/media/__init__.py", line 628, in _fill_audio
    self._audio.write(audio_data)
  File "/home/ajones/dev/pyglet/pyglet/media/drivers/alsa/__init__.py", line 146, in
write
    check(asound.snd_pcm_delay(self.pcm, delay))
  File "/home/ajones/dev/pyglet/pyglet/media/drivers/alsa/__init__.py", line 56, in check
    raise ALSAException(asound.snd_strerror(err))
pyglet.media.drivers.alsa.ALSAException: Broken pipe

Original comment by andy.lar...@gmail.com on 2 Oct 2007 at 1:45

GoogleCodeExporter commented 8 years ago
Also the value I was getting for int(self._buffer_time * 
audio_format.sample_rate)
was 13230

Original comment by andy.lar...@gmail.com on 2 Oct 2007 at 1:48

GoogleCodeExporter commented 8 years ago
This is the error that I was getting too (see
http://groups.google.com/group/pyglet-users/web/sound-under-ubuntu-feisty for 
details
on switching to openal). I can have a dig around when I get home tonight and 
see if I
can shed more light.

Original comment by anthony....@gmail.com on 3 Oct 2007 at 12:34

GoogleCodeExporter commented 8 years ago
My error is actually on the line above (95), but they may be related. I put the
following debug statements into pyglet/media/drivers/alsa/__init__.py:95:

        print "Sample rate is:", audio_format.sample_rate
        print asound.snd_pcm_hw_params_set_rate(self.pcm, self.hwparams,
audio_format.sample_rate, 0)
        check(asound.snd_pcm_hw_params_set_rate(self.pcm, self.hwparams,
            audio_format.sample_rate, 0))

And got the following output:
Sample rate is: 44100
-22
Traceback (most recent call last):
  File "./test.py", line 6, in <module>
    bullet_sound.play()
  File "/usr/lib/python2.5/site-packages/pyglet/media/__init__.py", line 377, in play
    player.queue(self)
  File "/usr/lib/python2.5/site-packages/pyglet/media/__init__.py", line 692, in queue
    self._begin_source()
  File "/usr/lib/python2.5/site-packages/pyglet/media/__init__.py", line 774, in
_begin_source
    self._create_audio()
  File "/usr/lib/python2.5/site-packages/pyglet/media/__init__.py", line 607, in
_create_audio
    self._audio = audio_player_class(source.audio_format)
  File "/usr/lib/python2.5/site-packages/pyglet/media/drivers/alsa/__init__.py", line
97, in __init__
    audio_format.sample_rate, 0))
  File "/usr/lib/python2.5/site-packages/pyglet/media/drivers/alsa/__init__.py", line
56, in check
    raise ALSAException(asound.snd_strerror(err))
pyglet.media.drivers.alsa.ALSAException: Invalid argument

Other factors:
This is against the latest release (r1308), running on Ubuntu Feisty.
My sound card is also quite old, so your earlier hunch about buffer size may be 
right:
00:08.0 Multimedia audio controller: Ensoniq 5880 AudioPCI (rev 02)
        Subsystem: Ensoniq Creative SoundBlaster AudioPCI 128
        Flags: bus master, slow devsel, latency 64, IRQ 11
        I/O ports at e800 [size=64]
        Capabilities: [dc] Power Management version 1

Hope that helps track down what's going on -- let me know if you need any more 
info.

Original comment by anthony....@gmail.com on 3 Oct 2007 at 1:27

GoogleCodeExporter commented 8 years ago
I've added some commented experimental code to r1309 to address both the buffer 
size
and the sample rate problems.  Before starting, set an environment variable
PYGLET_DEBUG_MEDIA to 1; this will print some things to stdout as well as 
create an
alsa.log file.

Try commenting/uncommenting code in pyglet/media/drivers/alsa/__init__.py around
lines 97 and 122 according to the comments and log what happens.  

Apologies for the experimental nature of this... experiment!

Original comment by Alex.Hol...@gmail.com on 3 Oct 2007 at 3:15