Triode,

Can you please add the following patch to git. (I wouldn't have noticed
the snafu with getting linear filter every time if I hadn't been logging
the quality spec immediately before creating the resampler.)


Code:
--------------------
    
  --- /home/clivem/development/git/squeezelite/process.c  2013-06-09 
07:34:29.119
  +++ process.c   2013-06-09 21:08:52.427893190 +0100
  @@ -237,6 +240,10 @@
                        q_spec.phase_response = r->q_phase_response;
                }
  
  +             LOG_DEBUG("resampling with soxr_quality_spec_t[precision: 
%03.1f, passband_end: %03.6f, stopband_begin: %03.6f, "
  +                             "phase_response: %03.1f, flags: 0x%02x], 
soxr_io_spec_t[scale: %03.2f]", q_spec.precision,
  +                             q_spec.passband_end, q_spec.stopband_begin, 
q_spec.phase_response, q_spec.flags, io_spec.scale);
  +
                r->resampler = r->soxr_create(raw_sample_rate, outrate, 2, 
&error, &io_spec, &q_spec, NULL);
                if (error) {
                        LOG_INFO("soxr_create error: %s", soxr_strerror(error));
  
--------------------


Don't know how you feel about this one. Drop the LOCK earlier and try
and avoid the sleep if we don't have enough space to write all frames in
one go. By dropping the LOCK after writing what we can, we give the
output thread a change to remove bytes from the out buf and maybe avoid
a sleep, before looping again.


Code:
--------------------
    
  --- /home/clivem/development/git/squeezelite/process.c        2013-06-09 
07:34:29.119180069 +0100
  +++ process.c 2013-06-09 21:08:52.427893190 +0100
  @@ -66,10 +66,10 @@
        u32_t *iptr   = process.active ? (u32_t *)process.outbuf : (u32_t 
*)process.inbuf;
        unsigned cnt  = 10;
  
  -     LOCK_O;
  -
        while (frames > 0) {
  
  +             LOCK_O;
  +
                frames_t f = min(_buf_space(outputbuf), 
_buf_cont_write(outputbuf)) / BYTES_PER_FRAME;
                u32_t *optr = (u32_t *)outputbuf->writep;
  
  @@ -84,12 +84,13 @@
                        _buf_inc_writep(outputbuf, f * BYTES_PER_FRAME);
                        iptr += f * BYTES_PER_FRAME / sizeof(*iptr);
  
  +                     UNLOCK_O;
  +
                } else if (cnt--) {
  
                        // there should normally be space in the output buffer, 
but may need to wait during drain phase
                        UNLOCK_O;
                        usleep(10000);
  -                     LOCK_O;
  
                } else {
  
  @@ -99,8 +100,6 @@
                        return;
                }
        }
  -
  -     UNLOCK_O;
  }
  
  // process samples - called with decode mutex set but not output mutex
  
--------------------


I'm still tinkering with this....

Code:
--------------------
    
  --- /home/clivem/development/git/squeezelite/output.c 2013-06-09 
07:34:29.118179950 +0100
  +++ output.c  2013-06-10 13:22:26.155018890 +0100
  @@ -710,10 +710,22 @@
                frames = _buf_used(outputbuf) / BYTES_PER_FRAME;
                silence = false;
  
  -             // start when threshold met, note: avail * 4 may need tuning
  -             if (output.state == OUTPUT_BUFFER && frames > avail * 4 && 
frames > output.threshold * output.next_sample_rate / 100) {
  -                     output.state = OUTPUT_RUNNING;
  -                     wake_controller();
  +             if (output.state == OUTPUT_BUFFER) {
  +                     // start when threshold met, note: avail * 4 may need 
tuning
  +                     unsigned int reqd = avail * 4;
  +#if ALSA
  +                     /*
  +                      * When playing high-res or upsampling, clive wants 2 * 
the entire alsa ring
  +                      * buffer capacity in our output buffer before running!
  +                      */
  +                     if (output.next_sample_rate >= 88200) {
  +                             reqd = output.buffer * 2;
  +                     }
  +#endif
  +                     if (frames > reqd && frames > output.threshold * 
output.next_sample_rate / 100) {
  +                             output.state = OUTPUT_RUNNING;
  +                             wake_controller();
  +                     }
                }
  
                // skip ahead - consume outputbuf but play nothing
  
--------------------


+-------------------------------------------------------------------+
|Filename: squeezelite-output.patch                                 |
|Download: http://forums.slimdevices.com/attachment.php?attachmentid=14911|
+-------------------------------------------------------------------+

------------------------------------------------------------------------
JackOfAll's Profile: http://forums.slimdevices.com/member.php?userid=3069
View this thread: http://forums.slimdevices.com/showthread.php?t=98544

_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to