Announcement

Collapse
No announcement yet.

[Announce] Community Firmware for Squeezebox Radio/Touch/Controller and LMS 8

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Controller synchronization

    Originally posted by nenu
    I don't see this mentioned in the changelog, but would the new firmware improve synchronization for Duet Controllers used as players? That wasn't working (or not implemented) with the official firmware, but maybe now it is?
    I've done a little investigation over the last couple of days.

    There is one basic problem with audio playback on the Controller: there does not seem to be a clock, or clocks, available to allow audio to be played back at the sample rate a particular stream may mandate. Audio is transferred to the audio codec over an I2S interface, and it seems that the clock rate applied to that transfer drives the rate at which audio samples are pumped out to the speaker/earphone/etc. The SOC uses a master clock at 50MHz from which to derive the I2S rates. There are distinctly limited "divide down" capabilities, so we can't get that close to the transfer rate needed.

    Happily the kernel tells us what it is doing:
    Code:
    48khz stream
    
    Jan  4 15:36:05 kernel: 256fs: div 4 => result 48828, deviation 828
    Jan  4 15:36:05 kernel: 512fs: div 2 => result 48828, deviation 828
    Jan  4 15:36:05 kernel: 384fs: div 3 => result 43402, deviation -4598
    Jan  4 15:36:05 kernel: best: fs=256, div=4, rate=48828
    Jan  4 15:36:05 kernel: mapped channel 10 to 2
    
    44.1kHz stream
    Jan  4 15:37:27 kernel: 256fs: div 4 => result 48828, deviation 4728
    Jan  4 15:37:27 kernel: 512fs: div 2 => result 48828, deviation 4728
    Jan  4 15:37:27 kernel: 384fs: div 3 => result 43402, deviation -698
    Jan  4 15:37:27 kernel: best: fs=384, div=3, rate=43402
    Jan  4 15:37:27 kernel: mapped channel 10 to 2
    Translation: "A 48,000 Hz stream will be played out at 48,828 Hz, because that's the closest I can manage, and a 44,100 Hz stream will be played out at 43,402 Hz, because that's also the closest I can manage."

    This becomes quite apparent if you simply compare the audio output for, say, a 500 Hz tone, against that produced by a "good" player. It will be clearly sharp or flat. You could also generate two sample test tracks, one at 44.1kHz and one at 48kHz, and compare them against each other. A 44.1kHz stream is played out too slowly, and a 48kHz stream is played out too quickly.

    My untested hypothesis is that the synchronization code in LMS is unable to successfully cope with such a large deviation in the actual play out rates. Note that a 44.1kHz stream will consistently lag by about 16ms per second, and a 48kHz stream will consistently gain by about 17ms per second. This would require pause/skip commands to be continually issued at, say, half second intervals to prevent them from becoming audible.

    In the context of the Controller, whose prime purpose is to issue audible beeps when its buttons are pressed, well I think it's fine. And also sufficiently fine for casual stand alone playback through earphones. But not "hi-fi".

    My guess is that two Controllers will stay perfectly synchronized with each other. But I only have one Controller, so I can't verify the point.

    Possibly LMS could be tweaked to accommodate matters. It's also possible that a specially tweaked 'jive_alsa' might be able to work around the issue. But that would require constant resampling by the Controller. At this point I don't know whether that is viable, but our current Covid-19 "lockdown" arrangements might just deliver up the time to find out.

    While I was there, I also took the opportunity to check the accuracy of the system clock, and the RTC clock:

    I checked the system clock by firing up an ntpd daemon, and letting it run. After settling down, it indicated that the system clock was running slow as compared with the world outside, by about 50ppm.

    I then tested the RTC clock against that "correct" time using 'adjtimex'. The result surprised me. The RTC clock (which has its own 32kHz crystal, according to the Controller wiki page) appeared to be ticking within 1ppm of real time. Which seems rather good to me. Perhaps I should repeat the experiment in a refrigerator.

    Comment


    • Originally posted by mrw
      I've done a little investigation over the last couple of days.
      I am not sure how to say anything except 'wow' at this point
      Again, I was thinking it might have been as easy (for you guys more like trivial, compared to all the other efforts) to replace some synching code with a newer version, but it clearly isn't. And I am really impressed with how you are figuring this out. At this point I may well be more interested in understanding the problem then having the solution.

      Perhaps I should repeat the experiment in a refrigerator.
      This somehow doesn't seem like an idle comment and instead shows that you really know what you are looking at.

      Comment


      • A big smile on my face

        Last weekend I installed the latest version of the Community Firmware on 2 Radios, 2 Controllers and one Touch without any problems. It just worked via Michaels plugin. I did a factory reset on each device before installing the new firmware. LMS is version 8.1 on max2play. All of my devices are working properly. Maybe it‘s just imagination, but navigating through the menus on the Radio feels a little faster and more responsive.

        I almost cannot believe there is new firmware out for tech gadgets of this age. It puts a big smile on my face.

        This post is just to say thanks to all who make this possible, to Michael and to this wonderful community.

        Comment


        • Originally posted by expectingtofly
          Interestingly, it happens repeatedly and reliably for me for all BBC Sounds streams (yes you are right LMS is fetching them, they are dash streams that are stitched together by the plugin.). There is a lot of stuttering at the start of the stream, and intermittent micro stuttering as the stream is playing, you would have noticed if it was happening for you.
          I should have remarked that my experience has been with LMS 8.0.1. A point of detail that had passed me by.

          I installed LMS 8.1 on a 'spare' server this morning (macOS - plenty power). And I think that I might have experienced something of the same. As in a certain amount of stuttering at the start of the stream. I'm not particularly aware of micro-stuttering, but possibly...

          I'll keep my Radio playing out on LMS 8.1 today in an attempt to see how matters proceed. Perhaps you might add an LMS 8.0.1 vs LMS 8.1 comparison into your investigations.

          Comment


          • Originally posted by mrw
            I should have remarked that my experience has been with LMS 8.0.1. A point of detail that had passed me by.

            I installed LMS 8.1 on a 'spare' server this morning (macOS - plenty power). And I think that I might have experienced something of the same. As in a certain amount of stuttering at the start of the stream. I'm not particularly aware of micro-stuttering, but possibly...

            I'll keep my Radio playing out on LMS 8.1 today in an attempt to see how matters proceed. Perhaps you might add an LMS 8.0.1 vs LMS 8.1 comparison into your investigations.
            I am using 8.1.1 and didn't notice any stuttering from native AAC.

            Sent from my Pixel 3a using Tapatalk
            Living Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
            Bedroom: Radio
            Bathroom: Radio

            Comment


            • Originally posted by mrw
              I should have remarked that my experience has been with LMS 8.0.1. A point of detail that had passed me by.

              I installed LMS 8.1 on a 'spare' server this morning (macOS - plenty power). And I think that I might have experienced something of the same. As in a certain amount of stuttering at the start of the stream. I'm not particularly aware of micro-stuttering, but possibly...

              I'll keep my Radio playing out on LMS 8.1 today in an attempt to see how matters proceed. Perhaps you might add an LMS 8.0.1 vs LMS 8.1 comparison into your investigations.
              I've upgraded the radios again and looked at the var/log/messages log.

              I get these 'Audio underun' and 'OUTPUT UNDERRUN'messages that seem to coincide with the juddering and micro stuttering when playing BBC Sounds AAC streams. Are they relevant? I don't get similar messages with any other format (e.g forcing flac transcoding)

              Code:
              Jan  6 13:23:33 squeezeplay: INFO   audio.decode - decode_start_handler:281 init decoder aac                                                   
              Jan  6 13:23:33 squeezeplay: INFO   audio.decode - Playback.lua:477 connect 172.16.0.8:9000 GET /stream.mp3?player=00:04:20:2a:dd:41 HTTP/1.0^M                   
              Jan  6 13:23:36 squeezeplay: INFO   applet.NowPlaying - NowPlayingApplet.lua:422 enable volume UI in NP                                                           
              Jan  6 13:23:38 squeezeplay: INFO   audio.decode - decode_start_handler:281 init decoder aac                                   
              Jan  6 13:23:38 squeezeplay: INFO   audio.decode - Playback.lua:477 connect 172.16.0.8:9000 GET /stream.mp3?player=00:04:20:2a:dd:41 HTTP/1.0^M
              Jan  6 13:23:42 squeezeplay: INFO   audio.decode - decode_start_handler:281 init decoder aac                                                                         
              Jan  6 13:23:42 squeezeplay: INFO   audio.decode - Playback.lua:477 connect 172.16.0.8:9000 GET /stream.mp3?player=00:04:20:2a:dd:41 HTTP/1.0^M                                           
              Jan  6 13:23:54 squeezeplay: INFO   audio.decode - decode_start_handler:281 init decoder aac                                                                     
              Jan  6 13:23:54 squeezeplay: INFO   audio.decode - Playback.lua:477 connect 172.16.0.8:9000 GET /stream.mp3?player=00:04:20:2a:dd:41 HTTP/1.0^M               
              Jan  6 13:23:56 squeezeplay: playback_callback:346 Audio underrun: used 288 frames, requested 480 frames. elapsed samples 27360                
              Jan  6 13:23:56 squeezeplay: playback_callback:346 Audio underrun: used 192 frames, requested 480 frames. elapsed samples 30528                                                          
              Jan  6 13:23:56 squeezeplay: playback_callback:346 Audio underrun: used 64 frames, requested 480 frames. elapsed samples 31680                 
              Jan  6 13:23:56 squeezeplay: playback_callback:346 Audio underrun: used 128 frames, requested 480 frames. elapsed samples 33664                
              Jan  6 13:23:56 squeezeplay: playback_callback:346 Audio underrun: used 192 frames, requested 480 frames. elapsed samples 36672
              Jan  6 13:23:56 squeezeplay: INFO   audio.decode - Playback.lua:364 OUTPUT UNDERRUN                                                                              
              Jan  6 13:24:02 squeezeplay: INFO   audio.decode - decode_start_handler:281 init decoder aac                         
              Jan  6 13:24:02 squeezeplay: INFO   audio.decode - Playback.lua:477 connect 172.16.0.8:9000 GET /stream.mp3?player=00:04:20:2a:dd:41 HTTP/1.0^M
              Jan  6 13:24:03 squeezeplay: WARN   net.thread - NetworkThread.lua:146 network thread timeout for Task(SocketHttp {baby.squeezenetwork.com}(R))
              Jan  6 13:24:04 squeezeplay: WARN   net.thread - NetworkThread.lua:146 network thread timeout for Task(SocketHttp {baby.squeezenetwork.com}(R))
              Jan  6 13:24:04 squeezeplay: playback_callback:346 Audio underrun: used 224 frames, requested 480 frames. elapsed samples 41760        
              Jan  6 13:24:04 squeezeplay: playback_callback:346 Audio underrun: used 256 frames, requested 480 frames. elapsed samples 45824                                                          
              Jan  6 13:24:04 squeezeplay: INFO   audio.decode - Playback.lua:364 OUTPUT UNDERRUN
              I'll have a go with the LMS 8.0 later.
              Stuart McLean

              ExpectingToFly Plugins :
              BBC Sounds, Global Player (UK), Times Radio, UK Radio Player, Virgin Radio (UK) and the Radio Favourites Plugin

              For BBC Sounds help see the BBC Sounds Wiki.

              Comment


              • Originally posted by expectingtofly
                I've upgraded the radios again and looked at the var/log/messages log.

                I get these 'Audio underun' and 'OUTPUT UNDERRUN'messages that seem to coincide with the juddering and micro stuttering when playing BBC Sounds AAC streams. Are they relevant? I don't get similar messages with any other format (e.g forcing flac transcoding)
                They are very relevant. They imply that the Radio has been running out of decoded audio. My questions are: "why" ?, and "why just aac" ?

                I had a few of this morning on my Radio, and I'm noticing a number of occasions when the stream has stopped and restarted.

                I don't have a good idea. My first thought is that LMS, whether 8.0 or 8.1, and/or BBC Sounds plugin, is not providing sufficient data. Or perhaps just not sufficient aac data. I don't have much experience in tracing these matters.

                I don't see an option in BBC Sounds to choose a lower bit rate stream. Is that something worth trying ?

                Comment


                • Originally posted by mrw
                  They are very relevant. They imply that the Radio has been running out of decoded audio. My questions are: "why" ?, and "why just aac" ?

                  I had a few of this morning on my Radio, and I'm noticing a number of occasions when the stream has stopped and restarted.

                  I don't have a good idea. My first thought is that LMS, whether 8.0 or 8.1, and/or BBC Sounds plugin, is not providing sufficient data. Or perhaps just not sufficient aac data. I don't have much experience in tracing these matters.

                  I don't see an option in BBC Sounds to choose a lower bit rate stream. Is that something worth trying ?
                  Does the same thing happen with BBC iPlayer?

                  Sent from my Pixel 3a using Tapatalk
                  Living Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
                  Bedroom: Radio
                  Bathroom: Radio

                  Comment


                  • Originally posted by mrw
                    They are very relevant. They imply that the Radio has been running out of decoded audio. My questions are: "why" ?, and "why just aac" ?

                    I had a few of this morning on my Radio, and I'm noticing a number of occasions when the stream has stopped and restarted.

                    I don't have a good idea. My first thought is that LMS, whether 8.0 or 8.1, and/or BBC Sounds plugin, is not providing sufficient data. Or perhaps just not sufficient aac data. I don't have much experience in tracing these matters.

                    I don't see an option in BBC Sounds to choose a lower bit rate stream. Is that something worth trying ?
                    There is plenty of data being provided. It even happens on the AOD streams where the buffers are being filled up very quickly...

                    Originally posted by slartibartfast
                    Does the same thing happen with BBC iPlayer?
                    Very interestingly, it doesn't. So it seems that there is something incompatible with the way BBC Sounds provides the data for the new AAC decoder, that was fine on the old decoder. The BBC Iplayer doesn't appear to have the same problem, so I should be able to solve this. I'll have a look.
                    Stuart McLean

                    ExpectingToFly Plugins :
                    BBC Sounds, Global Player (UK), Times Radio, UK Radio Player, Virgin Radio (UK) and the Radio Favourites Plugin

                    For BBC Sounds help see the BBC Sounds Wiki.

                    Comment


                    • I updated to the latest LMS 8.1.1 while my Radio was still playing my alarm radio station. Normally if I do this then the default alarm sound is triggered when LMS shuts down but not this time. This is probably the first time I have done this since updating the firmware so has something changed?

                      Edit. I just tried restarting the server again while an alarm was active and it took more than 60 seconds before the fall back alarm sounded. This used to be virtually instantaneous so something seems to be wrong.

                      Sent from my Pixel 3a using Tapatalk
                      Last edited by slartibartfast; 2021-01-07, 09:32.
                      Living Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
                      Bedroom: Radio
                      Bathroom: Radio

                      Comment


                      • Originally posted by slartibartfast
                        I updated to the latest LMS 8.1.1 while my Radio was still playing my alarm radio station. Normally if I do this then the default alarm sound is triggered when LMS shuts down but not this time. This is probably the first time I have done this since updating the firmware so has something changed?

                        Edit. I just tried restarting the server again while an alarm was active and it took more than 60 seconds before the fall back alarm sounded. This used to be virtually instantaneous so something seems to be wrong.
                        There have been changes to the alarm handling code, but, as far as I am aware, only those that Logitech made between SqueezePlay versions 7.7 and 7.8. Recall that v7.8 was never released for the Radio. So I would now expect the alarm handling on the Radio to match that on a Touch or a Controller. Do you know if a similar issue has already been raised for those two devices ?

                        My own testing has been limited to ensuring that alarms worked, but I did not approach the sort of circumstances you describe. I have linked to the set of patches that Logitech made, does anything look as if it might be a "culprit" ?

                        Alarm - Unifying log messages


                        Alarm
                        - Server input via alarm notification is only used to set or clear an alarm time
                        - Server does not actually start the alarm process on the player (that is done by RTCAlarmTimer)
                        - Server only starts to play the choosen playlist at the alarm time
                        - A separate timer is used for snoozing (snoozeTimer) instead of sharing the alarm timer (RTCAlarmTimer)
                        - Check for good audio has been extended to a total of 60 seconds (was 25 seconds) to allow more time for slow radio stations


                        Enable the backup alarm to handle a repeating alarm (on selected days)
                        Store additonal infomation provided by the server for a given alarm like alarm time, repeat status and selected days.
                        When the alarm fires check this additional information to rearm the RTC timer accordingly.


                        Defect 83 - Alarm timeout does not work
                        Alarm timeout timer needs to run whenever the alarm window is on screen not only when the fallback alarm fires.
                        Reason: the timeout timer is responsible to remove the alarm window, stop the polling etc.

                        Comment


                        • Originally posted by mrw
                          There have been changes to the alarm handling code, but, as far as I am aware, only those that Logitech made between SqueezePlay versions 7.7 and 7.8. Recall that v7.8 was never released for the Radio. So I would now expect the alarm handling on the Radio to match that on a Touch or a Controller. Do you know if a similar issue has already been raised for those two devices ?

                          My own testing has been limited to ensuring that alarms worked, but I did not approach the sort of circumstances you describe. I have linked to the set of patches that Logitech made, does anything look as if it might be a "culprit" ?

                          Alarm - Unifying log messages


                          Alarm
                          - Server input via alarm notification is only used to set or clear an alarm time
                          - Server does not actually start the alarm process on the player (that is done by RTCAlarmTimer)
                          - Server only starts to play the choosen playlist at the alarm time
                          - A separate timer is used for snoozing (snoozeTimer) instead of sharing the alarm timer (RTCAlarmTimer)
                          - Check for good audio has been extended to a total of 60 seconds (was 25 seconds) to allow more time for slow radio stations


                          Enable the backup alarm to handle a repeating alarm (on selected days)
                          Store additonal infomation provided by the server for a given alarm like alarm time, repeat status and selected days.
                          When the alarm fires check this additional information to rearm the RTC timer accordingly.


                          Defect 83 - Alarm timeout does not work
                          Alarm timeout timer needs to run whenever the alarm window is on screen not only when the fallback alarm fires.
                          Reason: the timeout timer is responsible to remove the alarm window, stop the polling etc.
                          https://github.com/ralph-irving/sque...0a91fadd47c38f
                          That might be it then. I have never tried the alarm on the Touch. Maybe the 60 second delay is to ride through short interruptions without triggering the default alarm. At first I thought it wasn't going to trigger the default alarm at all as I was so accustomed to diving for the Radio dial to silence the alarm in those circumstances [emoji3]. I can live with a minute delay.

                          Edit. "- Check for good audio has been extended to a total of 60 seconds (was 25 seconds) to allow more time for slow radio stations" looks like the reason and like you say even the 25 second delay was probably not implemented on the Radio, which is strange as the Radio is the most likely player to be used as a daily alarm.

                          Sent from my Pixel 3a using Tapatalk
                          Last edited by slartibartfast; 2021-01-07, 11:41.
                          Living Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
                          Bedroom: Radio
                          Bathroom: Radio

                          Comment


                          • Originally posted by expectingtofly
                            So it seems that there is something incompatible with the way BBC Sounds provides the data for the new AAC decoder, that was fine on the old decoder.
                            Or perhaps not.

                            What is easy to overlook is "how stressed" the Radio seems to be when decoding aac streams. I've never looked into it in any detail, but an indication can be obtained by setting the 'audio.decode' logging level on the Radio to debug. You'll see a line, each second, looking like:
                            Code:
                            Jan  7 15:01:52 squeezeplay: INFO   audio.decode - Playback.lua:447 0.2%/66.0%
                            The first number is the proportion of the stream buffer available to be filled, i.e. by fetching from the server. The second number is the proportion of the output buffer occupied by decoded samples waiting to be played out.

                            When playing aac streams, particularly high bit rate streams from the BBC (R3 aac @ 320k), that first number generally seems to stay in the 0%->2% range. This is true both with the 'old/stock' firmware and its 'private' aac decoder, and with the 'new' firmware. SqueezePlay will not fetch any audio stream data from the server (either LMS or a remote server) while the decoder is running.

                            Compare this with, say, a Touch (I don't have one, so I can't, but would be interested to see the results), or an MP3 stream.

                            I hypothesize that the fact that the stream buffer is being scarcely filled adversely influences the Radio's resilience to stream interruption and/or temporary glitches.
                            EDIT: Well, the "low" level of stream buffer fullness also seems to be true for some MP3 streams as well. So perhaps not that much of an issue, really.

                            It's possible that matters might be improved by increasing the 'decodeThreshold'. At present it seems to be set at 2,048 bytes, meaning that the decoder will start as soon as 2,048 bytes are available. But the stream buffer doesn't really seem have the chance to fill. It might be worth experimenting to see if increasing it (for aac streams) to a substantially larger number might help resilience. I might give that a go at some point.
                            Last edited by mrw; 2021-01-07, 16:33.

                            Comment


                            • Originally posted by mrw
                              Or perhaps not.

                              What is easy to overlook is "how stressed" the Radio seems to be when decoding aac streams. I've never looked into it in any detail, but an indication can be obtained by setting the 'audio.decode' logging level on the Radio to debug. You'll see a line, each second, looking like:
                              Code:
                              Jan  7 15:01:52 squeezeplay: INFO   audio.decode - Playback.lua:447 0.2%/66.0%
                              The first number is the proportion of the stream buffer available to be filled, i.e. by fetching from the server. The second number is the proportion of the output buffer occupied by decoded samples waiting to be played out.

                              When playing aac streams, particularly high bit rate streams from the BBC (R3 aac @ 320k), that first number generally seems to stay in the 0%->2% range. This is true both with the 'old/stock' firmware and its 'private' aac decoder, and with the 'new' firmware. SqueezePlay will not fetch any audio stream data from the server (either LMS or a remote server) while the decoder is running.

                              Compare this with, say, a Touch (I don't have one, so I can't, but would be interested to see the results), or an MP3 stream.

                              I hypothesize that the fact that the stream buffer is being scarcely filled adversely influences the Radio's resilience to stream interruption and/or temporary glitches.

                              It's possible that matters might be improved by increasing the 'decodeThreshold'. At present it seems to be set at 2,048 bytes, meaning that the decoder will start as soon as 2,048 bytes are available. But the stream buffer doesn't really seem have the chance to fill. It might be worth experimenting to see if increasing it (for aac streams) to a substantially larger number might help resilience. I might give that a go at some point.
                              How do I get to the messages file in the Radio? I am pretty sure I have done this before but it was long ago. I can SSH in using putty but what next? With WinSCP I get "Remote side unexpectedly closed network connection"

                              Sent from my Pixel 3a using Tapatalk
                              Living Room: Touch or Squeezelite (Pi3B) > Topping E30 > Audiolab 8000A > Monitor Audio S5 + BK200-XLS DF
                              Bedroom: Radio
                              Bathroom: Radio

                              Comment


                              • Originally posted by slartibartfast
                                How do I get to the messages file in the Radio? I am pretty sure I have done this before but it was long ago. I can SSH in using putty but what next? With WinSCP I get "Remote side unexpectedly closed network connection"
                                Code:
                                tail -F /var/log/messages
                                is probably your best bet when logged in. It will give a rolling output. Ctrl C to stop.

                                But I'm much less sure of my hypothesis, now, see EDIT to earlier post. I may have inadvertently mislead myself, and you might be wasting your time following up. Nevertheless having a bit of a buffer in hand might still be helpful.

                                SCP should work if you get the command line right. I would do something like:
                                Code:
                                scp root@myradio:/var/log/messages SBRmessages.txt
                                to get it into a local file named 'SBRmessages.txt'. It will/should prompt for a password. I don't know about WinSCP.

                                Comment

                                Working...
                                X
                                😀
                                🥰
                                🤢
                                😎
                                😡
                                👍
                                👎