[pulseaudio-tickets] [PulseAudio] #837: A52 (ac3/Dolby Digital) encoding for SPDIF / Pulseaudio

PulseAudio trac-noreply at tango.0pointer.de
Sun Jul 4 12:50:52 PDT 2010


#837: A52 (ac3/Dolby Digital) encoding for SPDIF / Pulseaudio
----------------------+-----------------------------------------------------
  Reporter:  mcarans  |       Owner:  lennart      
      Type:  defect   |      Status:  new          
 Milestone:           |   Component:  module-alsa-*
Resolution:           |    Keywords:               
----------------------+-----------------------------------------------------
Changes (by mcarans):

 * cc: rans at email.com (added)


Comment:

 The Alsa developer gave the following detailed analysis. Lennart what do
 you think? Do you think there is a bug in Pulseaudio or Alsa?

 Handshake between application and library
 The ALSA PCM API design uses the states to determine the communication
 phase between application and library. The actual state can be determined
 using snd_pcm_state() call. There are these states:

 SND_PCM_STATE_OPEN
     The PCM device is in the open state. After the snd_pcm_open() open
 call, the device is in this state. Also, when snd_pcm_hw_params() call
 fails, then this state is entered to force application calling
 snd_pcm_hw_params() function to set right communication parameters.

 SND_PCM_STATE_SETUP
     The PCM device has accepted communication parameters and it is waiting
 for snd_pcm_prepare() call to prepare the hardware for selected operation
 (playback or capture).

 SND_PCM_STATE_PREPARE
     The PCM device is prepared for operation. Application can use
 snd_pcm_start() call, write or read data to start the operation.

 SND_PCM_STATE_RUNNING
     The PCM device has been started and is running. It processes the
 samples. The stream can be stopped using the snd_pcm_drop() or
 snd_pcm_drain() calls.







 whenever PA server call pa_alsa_sink_new(), it start a thread after
 snd_pcm_dump() to start the playback

 it call process_rewind() on certain condition , can PA rewind a52 plugin
 since it is compressing data to ac3 ???

 In theory, snd_pcm_rewindable() should return zero for a52 plugin

 why did alsa-lib allow the application to rewind iec958 device when no-
 audio-bit is set since the digital receiver already decoding the received
 compressed data ?

 and then mmap_write() but is there any data for PA server to write ???

 if first time in the loop , PA server call snd_pcm_start() ,but if PA
 server has written data using mmap_write() before, why it call
 snd_pcm_start() ???.


 D: alsa-sink.c: Thread starting up

 Why there is no "Thread shutting down" message in the log ?

 D: main.c: Got org.pulseaudio.Server!
 I: main.c: Daemon startup complete.

 do it mean that the thread is waiting for PA client to connect to provide
 data ?

 This won't work because the digital receiver expect iec958 device
 providing valid AC3 data to decode as PA server has no data to write
 iec958 until PA client connected to provide data



 static void thread_func(void *userdata) {
     struct userdata *u = userdata;
     unsigned short revents = 0;

     pa_assert(u);

     pa_log_debug("Thread starting up");

     if (u->core->realtime_scheduling)
         pa_make_realtime(u->core->realtime_priority);

     pa_thread_mq_install(&u->thread_mq);

     for (;;) {
         int ret;

 #ifdef DEBUG_TIMING
         pa_log_debug("Loop");
 #endif

         /* Render some data and write it to the dsp */
         if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
             int work_done;
             pa_usec_t sleep_usec = 0;
             pa_bool_t on_timeout = pa_rtpoll_timer_elapsed(u->rtpoll);

             if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
                 if (process_rewind(u) < 0)
                         goto fail;

             if (u->use_mmap)
                 work_done = mmap_write(u, &sleep_usec, revents & POLLOUT,
 on_timeout);
             else
                 work_done = unix_write(u, &sleep_usec, revents & POLLOUT,
 on_timeout);

             if (work_done < 0)
                 goto fail;

 /* pa_log_debug("work_done = %i", work_done); */

             if (work_done) {

                 if (u->first) {
                     pa_log_info("Starting playback.");
                     snd_pcm_start(u->pcm_handle);

                     pa_smoother_resume(u->smoother, pa_rtclock_now(),
 TRUE);
                 }
 ...




 finish:
     pa_log_debug("Thread shutting down");

 }

-- 
Ticket URL: <http://pulseaudio.org/ticket/837#comment:4>
PulseAudio <http://pulseaudio.org/>
The PulseAudio Sound Server


More information about the pulseaudio-bugs mailing list