[Approved] AudioPlayer : Fix to avoid scratches (1 Viewer)

Smeulf

Retired Team Member
  • Premium Supporter
  • October 27, 2010
    672
    454
    France
    Home Country
    France France
    This patch is intended to fix the audioringbuffer Read() method to prevent scratches.

    It's a totally different better way to fix the problem than my first appempt.

    Cheers.
     

    Attachments

    • AudioRingBuffer_2.patch
      1.9 KB

    Smeulf

    Retired Team Member
  • Premium Supporter
  • October 27, 2010
    672
    454
    France
    Home Country
    France France
    This patch is intended to fix the audioringbuffer Read() method to prevent scratches.

    New patch, fix both Read() and Peek() methods.

    Be carrefull please to edit AudioRingBuffer.cs to convert CR/LF, I really can't find the good option to avoid this problem with TurtoiseGit :(
     

    Attachments

    • 0001-Fix-AudioRingBuffer-Read-and-Peek-methods-to-avoid-s.patch
      3.2 KB

    Albert

    MP2 Developer
  • Premium Supporter
  • February 18, 2008
    1,297
    1,130
    45
    Freiburg im Breisgau, Germany
    Home Country
    Germany Germany
    AW: AudioPlayer : Fix to avoid scratches

    Hi Smeulf!
    Thank you very much for your work!
    In fact, the fix of the crackle-problem can be done much simpler than in your code; this is the original code, that you can find in methods Read and Peek:

    Code:
            int count2 = Math.Min(requested - count1, writePointer);
            if (count2 > 0)
            {
              if (buffer != IntPtr.Zero)
              {
                IntPtr ptr = new IntPtr(
                    _Is32bit ? buffer.ToInt32() : buffer.ToInt64() + (count1*BassConstants.FloatBytes));
                Marshal.Copy(_buffer, 0, ptr, count2);
              }
              readPointer = count2;
            }
            read = count1 + count2;

    Here are two problems:
    1) The ternary expression _Is32bit ? buffer.ToInt32() : buffer.ToInt64() must be put into parentheses because the + operator binds stronger than the : of the ternary operator.
    2) In case count2 < 0, the last line returns the wrong result.

    So, the correct solution is:

    Code:
            int count2 = Math.Min(requested - count1, writePointer);
            if (count2 > 0)
            {
              if (buffer != IntPtr.Zero)
              {
                IntPtr ptr = new IntPtr(
                    (_Is32bit ? buffer.ToInt32() : buffer.ToInt64()) + (count1*BassConstants.FloatBytes));
                Marshal.Copy(_buffer, 0, ptr, count2);
              }
              readPointer = count2;
            }
            else
              count2 = 0;
            read = count1 + count2;

    Smeulf, it seems that you have found our audioplayer problem! Thank you very much!
     

    Users who are viewing this thread

    Similar threads

    I need to try MadVR, I hope my Intel NAC can manage it.
    I need to try MadVR, I hope my Intel NAC can manage it.
    Remember PAL DVDs of US movies and TV Shows, and how they were converted to 25 fps thus introducing a "smurf lite" pitch on the...
    Replies
    2
    Views
    282
    It works perfect now. All channels have been found, even with the default tuning files. Thank you very much! (y) I'd love seing this change in MP 1.33! :)
    It works perfect now. All channels have been found, even with the default tuning files. Thank you very much! (y) I'd love seing...
    With my new hardware, Windows 11 and MP 1.32 the TV channel scan is not working anymore. The frequencies are scanned but no...
    Replies
    40
    Views
    2K
    What's the best way to select a different backdrop? Sometimes the first selected backdrop is not great and I'd like to select another. Moving Pictures scales down the high res pictures and shrinks the filesize as well so I can't just go to fanart or themoviedb and get the images without doing some extra work to get the file right...
    What's the best way to select a different backdrop? Sometimes the first selected backdrop is not great and I'd like to select...
    What's the best way to select a different backdrop? Sometimes the first selected backdrop is not great and I'd like to select...
    Replies
    0
    Views
    462
    If anyone ever experiences the above, I found a fix. Removing and reinstalling MP-TVSeries fixed it. It must have gotten corrupted during the reinstall of MP. I also had to do the same with TRAKT which had some issues too that were not apparent at the time. All is well once again. :cool:
    If anyone ever experiences the above, I found a fix. Removing and reinstalling MP-TVSeries fixed it. It must have gotten corrupted...
    After much trial and error and comparing this computer with another that was working, I finally found out that Fanarthandler...
    Replies
    1
    Views
    802
    I have all of my media on a NAS. I guess it might just be a network issue, then.
    I have all of my media on a NAS. I guess it might just be a network issue, then.
    Whenever I go into the back end for Moving Pictures, it almost immediately hangs on the Movie Importer tab. If I want to go into...
    Replies
    4
    Views
    363
    Top Bottom