Ticket #4103: 0001-cddb_daemon-Various-fixes.patch

File 0001-cddb_daemon-Various-fixes.patch, 3.1 KB (added by waddlesplash, 10 years ago)

Fixes the problem for me.

  • src/servers/cddb_daemon/cddb_daemon.cpp

    From 64b805d78fd027a3bd7e46d26bf587ad3006d0dd Mon Sep 17 00:00:00 2001
    From: Augustin Cavalier <waddlesplash@gmail.com>
    Date: Tue, 8 Jul 2014 12:32:23 -0400
    Subject: [PATCH] cddb_daemon: Various fixes.
    
     * Add ".wav" to the ends of filenames
     * Add a track number at the beginning of the filename, e.g. "01"
     * Don't hard-fail if the FreeDB response contains an invalid year
    ---
     src/servers/cddb_daemon/cddb_daemon.cpp | 24 ++++++++++++++++++------
     src/servers/cddb_daemon/cddb_server.cpp |  4 ++--
     2 files changed, 20 insertions(+), 8 deletions(-)
    
    diff --git a/src/servers/cddb_daemon/cddb_daemon.cpp b/src/servers/cddb_daemon/cddb_daemon.cpp
    index f216173..87a1636 100644
    a b CDDBDaemon::_CanLookup(const dev_t device, uint32* cddbId,  
    162162    if (directory.ReadAttr("CD:do_lookup", B_BOOL_TYPE, 0, (void *)&doLookup,
    163163        sizeof(bool)) < B_OK || !doLookup)
    164164        return false;
    165    
     165
    166166    // Does it have the CD:cddbid attribute?
    167167    if (directory.ReadAttr("CD:cddbid", B_UINT32_TYPE, 0, (void *)cddbId,
    168168        sizeof(uint32)) < B_OK)
    CDDBDaemon::_WriteCDData(dev_t device, QueryResponseData* diskData,  
    237237        name = data->title;
    238238        name.ReplaceSet("/", " ");
    239239       
     240        // Add track number to the beginning of the string.
     241        int trackNum = index + 1; // index=0 is actually Track 1
     242        char trackNumString[3]; // 2 digits + '\0'
     243        snprintf(trackNumString, 3, "%02d", trackNum);
     244        name.Prepend(" ");
     245        name.Prepend(trackNumString, 3);
     246        name.Append(".wav");
     247
    240248        if ((result = entry.Rename(name.String())) != B_OK) {
    241249            printf("Failed renaming entry at index %d to \"%s\".\n", index,
    242250                name.String());
    CDDBDaemon::_WriteCDData(dev_t device, QueryResponseData* diskData,  
    252260        node.WriteAttr("Audio:Album", B_STRING_TYPE, 0,
    253261            (readResponse->title).String(),
    254262            (readResponse->title).Length());
    255         node.WriteAttr("Media:Genre", B_STRING_TYPE, 0,
    256             (readResponse->genre).String(),
    257             (readResponse->genre).Length());
    258         node.WriteAttr("Media:Year", B_INT32_TYPE, 0, &(readResponse->year),
    259             sizeof(int32));
     263        if (readResponse->genre.Length() != 0) {
     264            node.WriteAttr("Media:Genre", B_STRING_TYPE, 0,
     265                (readResponse->genre).String(),
     266                (readResponse->genre).Length());
     267        }
     268        if (readResponse->year != 0) {
     269            node.WriteAttr("Media:Year", B_INT32_TYPE, 0,
     270                &(readResponse->year), sizeof(int32));
     271        }
    260272
    261273        if (data->artist == "") {
    262274            node.WriteAttr("Audio:Artist", B_STRING_TYPE, 0,
  • src/servers/cddb_daemon/cddb_server.cpp

    diff --git a/src/servers/cddb_daemon/cddb_server.cpp b/src/servers/cddb_daemon/cddb_server.cpp
    index 46f369e..fef57bb 100644
    a b CDDBServer::Read(QueryResponseData* diskData, ReadResponseData* readResponse)  
    217217                    || (errno != 0 && year == 0)) {
    218218                    // Year out of range.
    219219                    printf("Year out of range: %s\n", line.String());
    220                     return B_ERROR;
     220                    year = 0;
    221221                }
    222222               
    223223                if (firstInvalid == line.String()) {
    224224                    printf("Invalid year: %s\n", line.String());
    225                     return B_ERROR;
     225                    year = 0;
    226226                }
    227227                           
    228228                readResponse->year = year;