Skip to content

found some bugs in the cbmp3list function??? #182

Description

@xP373Rx

In my copilation current version the sd track list was screwed up. First track was double , last track was not there and 1 \n was missing after the first track.

Here is the fixed code that works for me.

size_t cb_mp3list ( uint8_t *buffer, size_t maxLen, size_t index )
{
  static int         i ;                              // Index in track list
  static const char* path ;                           // Pointer in file path
  size_t             len = 0 ;                        // Number of bytes filled in buffer
  char*              p = (char*)buffer ;              // Treat as pointer to aray of char
  static bool        eolSeen ;                        // Remember if End Of List

  if ( index == 0 )                                   // First call for this page?
  {
    i = 0 ;                                           // Yes, set index (track number)
    path = getFirstSDFileName() ;                     // Force read of next path
    eolSeen = ( path == nullptr ) ;                   // Any file?
  }
  while ( ( maxLen > len ) && ( ! eolSeen ) )         // Space for another char from path?
  {
    
    
    if ( *path )                                      // End of path?
    {
      *p++ = *path++ ;                                // No, add another character to send buffer
      len++ ;                                         // Update total length
    }
    
    else
    {
      // End of path
      if ( i< SD_filecount-1)                                        // At least one path in output?
      {
        *p++ = '\n' ;                                 // Yes, add separator
        len++ ;                                       // Update total length
      }


      i++;
      path = getSDFileName ( i ) ;                  // Get next path from list
      if ( i >= SD_filecount )                        // No more files?
      {
        eolSeen = true ;                              // Yes, stop
        break ;
      }
    }
  }
  // We arrive here if output buffer is completely full or end of tracklist is reached
  return len ;  
}                                      // Return filled length of buffer

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions