[pulseaudio-tickets] [Bug 46296] Sometimes the PA server needs a restart.

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Mon Feb 20 09:41:08 PST 2012


https://bugs.freedesktop.org/show_bug.cgi?id=46296

--- Comment #1 from Jörg Höhle <Joerg-Cyril.Hoehle at T-Systems.com> 2012-02-20 09:41:08 PST ---
Created attachment 57338
  --> https://bugs.freedesktop.org/attachment.cgi?id=57338
Lisp FFI declarations, for use with CLISP

This is the Lisp file that I've used to perform interactive testing of ALSA behaviour. It contains a mixture of foreign function definitions, sample code and
comments about my findings.

What follows are snippets from the file to show how it fits together:

; Initialize once
(load"/path/to/alsa.lisp" :compiling t)
(in-package "ALSA")
(ffi:default-foreign-language :stdc)
(setq *hw-params* (allocate-shallow 'uint8 :count (snd_pcm_hw_params_sizeof)))
(setq *sw-params* (allocate-shallow 'uint8 :count (snd_pcm_sw_params_sizeof)))

(snd_pcm_open "default" 0 (logior snd_pcm_nonblock))
; the pointer is the second value in the special variable named /
(setq *pcm* (second /))
(set-foreign-pointer *pcm* :copy)

; Finalize when you're done
(snd_pcm_close *pcm*)
(setf (validp *pcm*) nil)
(ext:quit) ; to exit CLISP


; set ALSA parameters of your choice
; I typically use 8000x8x1 (because of sineu8)
(multiple-value-call #'list
(snd_pcm_hw_params_any *pcm* *hw-params*)
(snd_pcm_hw_params_set_access *pcm* *hw-params* 3)
(snd_pcm_hw_params_set_format *pcm* *hw-params* SND_PCM_FORMAT_U8)
;(snd_pcm_hw_params_set_format *pcm* *hw-params* SND_PCM_FORMAT_S16_LE)
(snd_pcm_hw_params_set_channels *pcm* *hw-params* 1)
(snd_pcm_hw_params_set_rate_near *pcm* *hw-params* 8000 0)
;(snd_pcm_hw_params_set_rate_near *pcm* *hw-params* 44100 0)
; Wine asks for 10ms and a buffer 4x that period
(snd_pcm_hw_params_set_period_time_near *pcm* *hw-params* 10000 0)
(snd_pcm_hw_params_set_periods_near *pcm* *hw-params* 4 0)
(snd_pcm_hw_params *pcm* *hw-params*))

(multiple-value-bind (err boundary) (snd_pcm_sw_params_get_boundary *sw-params*)
  (multiple-value-call #'list
   boundary
   (snd_pcm_sw_params_set_start_threshold *pcm* *sw-params* 1)
   ;(snd_pcm_sw_params_set_stop_threshold *pcm* *sw-params*  boundary) ; may insert observed buffer size here
   ;(snd_pcm_sw_params_set_avail_min *pcm* *sw-params* 0)
   (snd_pcm_sw_params *pcm* *sw-params*)))


; Repeat any number of times:
;(snd_pcm_recover *pcm* -32 t)
(snd_pcm_prepare *pcm*)

(locally (declare (compile) (special *pcm*))
(time(loop repeat 50
      for e = (snd_pcm_writei_u8 *pcm* (sineu8 *pcm* 440 8000 .1))
      do (print e)
      (print (multiple-value-call #'list (enum-from-value 'snd_pcm_state (snd_pcm_state *pcm*))
                (snd_pcm_avail_update *pcm*) (snd_pcm_delay *pcm*)) )
      (print (multiple-value-call #'list (enum-from-value 'snd_pcm_state (snd_pcm_state *pcm*))
                (snd_pcm_avail_update *pcm*) (snd_pcm_delay *pcm*)) )
      until (minusp e)))
(loop repeat 100
      for v = (multiple-value-call #'list (enum-from-value 'snd_pcm_state (snd_pcm_state *pcm*))
                (snd_pcm_avail_update *pcm*) (snd_pcm_delay *pcm*))
      do (print v) (sleep .005s0)
      until (minusp (second v)))
)

You can vary the number of iterations and sleep delays (in seconds).  It's essential to repeat the loop a few times within a session to investigate underrun
recovery.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA Contact for the bug.
You are the assignee for the bug.


More information about the pulseaudio-bugs mailing list