diff options
Diffstat (limited to 'stream/stream_cddb.c')
-rw-r--r-- | stream/stream_cddb.c | 93 |
1 files changed, 42 insertions, 51 deletions
diff --git a/stream/stream_cddb.c b/stream/stream_cddb.c index 47a0321e01..811a1c1570 100644 --- a/stream/stream_cddb.c +++ b/stream/stream_cddb.c @@ -102,7 +102,7 @@ static int read_toc(const char *dev) if (!DeviceIoControl(drive, IOCTL_CDROM_READ_TOC, NULL, 0, &toc, sizeof(CDROM_TOC), &r, 0)) { - mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToReadTOC); + mp_tmsg(MSGT_OPEN, MSGL_ERR, "Failed to read TOC.\n"); return 0; } @@ -150,7 +150,7 @@ static int read_toc(const char *dev) OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE | OPEN_FLAGS_DASD, NULL); if (rc) { - mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToReadTOC); + mp_tmsg(MSGT_OPEN, MSGL_ERR, "Failed to read TOC.\n"); return -1; } @@ -183,7 +183,7 @@ static int read_toc(const char *dev) DosClose(hcd); if (rc) { - mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToReadTOC); + mp_tmsg(MSGT_OPEN, MSGL_ERR, "Failed to read TOC.\n"); return -1; } #else @@ -310,8 +310,7 @@ int cdd_identify(const char *dev) int i, min, sec, frame; cdtoc_last_track = read_toc(dev); if (cdtoc_last_track < 0) { - mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToOpenDevice, - dev); + mp_tmsg(MSGT_OPEN, MSGL_ERR, "Failed to open %s device.\n", dev); return -1; } mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_CDDA_TRACKS=%d\n", cdtoc_last_track); @@ -375,21 +374,19 @@ static int cddb_http_request(char *command, url = url_new(request); if (url == NULL) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_NotAValidURL); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "not a valid URL\n"); return -1; } fd = http_send_request(url,0); if (fd < 0) { - mp_msg(MSGT_DEMUX, MSGL_ERR, - MSGTR_MPDEMUX_CDDB_FailedToSendHTTPRequest); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Failed to send the HTTP request.\n"); return -1; } http_hdr = http_read_response(fd); if (http_hdr == NULL) { - mp_msg(MSGT_DEMUX, MSGL_ERR, - MSGTR_MPDEMUX_CDDB_FailedToReadHTTPResponse); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Failed to read the HTTP response.\n"); return -1; } @@ -401,10 +398,10 @@ static int cddb_http_request(char *command, ret = reply_parser(http_hdr, cddb_data); break; case 400: - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_HTTPErrorNOTFOUND); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Not Found.\n"); break; default: - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_HTTPErrorUnknown); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "unknown error code\n"); } http_free(http_hdr); @@ -427,7 +424,7 @@ static int cddb_read_cache(cddb_data_t *cddb_data) file_fd = open(file_name, O_RDONLY | O_BINARY); if (file_fd < 0) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_NoCacheFound); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "No cache found.\n"); return -1; } @@ -441,14 +438,13 @@ static int cddb_read_cache(cddb_data_t *cddb_data) cddb_data->xmcd_file = malloc(file_size + 1); if (cddb_data->xmcd_file == NULL) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MemAllocFailed); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Memory allocation failed.\n"); close(file_fd); return -1; } cddb_data->xmcd_file_size = read(file_fd, cddb_data->xmcd_file, file_size); if (cddb_data->xmcd_file_size != file_size) { - mp_msg(MSGT_DEMUX, MSGL_WARN, - MSGTR_MPDEMUX_CDDB_NotAllXMCDFileHasBeenRead); + mp_tmsg(MSGT_DEMUX, MSGL_WARN, "Not all the xmcd file has been read.\n"); close(file_fd); return -1; } @@ -481,9 +477,8 @@ static int cddb_write_cache(cddb_data_t *cddb_data) if (ret < 0) { #endif perror("mkdir"); - mp_msg(MSGT_DEMUX, MSGL_ERR, - MSGTR_MPDEMUX_CDDB_FailedToCreateDirectory, - cddb_data->cache_dir); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Failed to create directory %s.\n", + cddb_data->cache_dir); return -1; } } @@ -503,7 +498,7 @@ static int cddb_write_cache(cddb_data_t *cddb_data) return -1; } if ((unsigned int) wrote != cddb_data->xmcd_file_size) { - mp_msg(MSGT_DEMUX, MSGL_WARN, MSGTR_MPDEMUX_CDDB_NotAllXMCDFileHasBeenWritten); + mp_tmsg(MSGT_DEMUX, MSGL_WARN, "Not all of the xmcd file has been written.\n"); close(file_fd); return -1; } @@ -525,7 +520,7 @@ static int cddb_read_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) ret = sscanf(http_hdr->body, "%d ", &status); if (ret != 1) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error"); return -1; } @@ -534,14 +529,14 @@ static int cddb_read_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) ret = sscanf(http_hdr->body, "%d %99s %08lx", &status, category, &disc_id); if (ret != 3) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error"); return -1; } // Check if it's a xmcd database file ptr = strstr(http_hdr->body, "# xmcd"); if (ptr == NULL) { - mp_msg(MSGT_DEMUX, MSGL_ERR, - MSGTR_MPDEMUX_CDDB_InvalidXMCDDatabaseReturned); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, + "Invalid xmcd database file returned.\n"); return -1; } ptr = strdup(ptr); @@ -559,7 +554,7 @@ static int cddb_read_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) // Ok found the end // do a sanity check if (http_hdr->body_size < (unsigned int)(ptr2 - ptr)) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_UnexpectedFIXME); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "unexpected FIXME\n"); return -1; } cddb_data->xmcd_file = ptr; @@ -567,7 +562,7 @@ static int cddb_read_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) cddb_data->xmcd_file[cddb_data->xmcd_file_size] = '\0'; return cddb_write_cache(cddb_data); default: - mp_msg(MSGT_DEMUX, MSGL_FIXME, MSGTR_MPDEMUX_CDDB_UnhandledCode); + mp_tmsg(MSGT_DEMUX, MSGL_FIXME, "unhandled code\n"); } return 0; } @@ -588,7 +583,7 @@ static int cddb_parse_matches_list(HTTP_header_t *http_hdr, cddb_data_t *cddb_da ptr = strstr(http_hdr->body, "\n"); if (ptr == NULL) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_UnableToFindEOL); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Unable to find end of line.\n"); return -1; } ptr++; @@ -597,7 +592,7 @@ static int cddb_parse_matches_list(HTTP_header_t *http_hdr, cddb_data_t *cddb_da ret = sscanf(ptr, "%99s %08lx %99s", cddb_data->category, &(cddb_data->disc_id), album_title); if (ret != 3) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error"); return -1; } ptr = strstr(http_hdr->body, album_title); @@ -614,8 +609,7 @@ static int cddb_parse_matches_list(HTTP_header_t *http_hdr, cddb_data_t *cddb_da strncpy(album_title, ptr, len); album_title[len]='\0'; } - mp_msg(MSGT_DEMUX, MSGL_STATUS, MSGTR_MPDEMUX_CDDB_ParseOKFoundAlbumTitle, - album_title); + mp_tmsg(MSGT_DEMUX, MSGL_STATUS, "Parse OK, found: %s\n", album_title); return 0; } @@ -627,7 +621,7 @@ static int cddb_query_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) ret = sscanf(http_hdr->body, "%d ", &status); if (ret != 1) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error"); return -1; } @@ -637,7 +631,7 @@ static int cddb_query_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) ret = sscanf(http_hdr->body, "%d %99s %08lx %99s", &status, cddb_data->category, &(cddb_data->disc_id), album_title); if (ret != 4) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error"); return -1; } ptr = strstr(http_hdr->body, album_title); @@ -654,12 +648,11 @@ static int cddb_query_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_data) strncpy(album_title, ptr, len); album_title[len]='\0'; } - mp_msg(MSGT_DEMUX, MSGL_STATUS, - MSGTR_MPDEMUX_CDDB_ParseOKFoundAlbumTitle, album_title); + mp_tmsg(MSGT_DEMUX, MSGL_STATUS, "Parse OK, found: %s\n", album_title); return cddb_request_titles(cddb_data); case 202: // No match found - mp_msg(MSGT_DEMUX, MSGL_WARN, MSGTR_MPDEMUX_CDDB_AlbumNotFound); + mp_tmsg(MSGT_DEMUX, MSGL_WARN, "Album not found.\n"); break; case 210: // Found exact matches, list follows @@ -677,11 +670,11 @@ blues c711930d Santana / Supernatural cddb_parse_matches_list(http_hdr, cddb_data); return cddb_request_titles(cddb_data); case 500: - mp_msg(MSGT_DEMUX, MSGL_FIXME, - MSGTR_MPDEMUX_CDDB_ServerReturnsCommandSyntaxErr); + mp_tmsg(MSGT_DEMUX, MSGL_FIXME, + "Server returns: Command syntax error\n"); break; default: - mp_msg(MSGT_DEMUX, MSGL_FIXME, MSGTR_MPDEMUX_CDDB_UnhandledCode); + mp_tmsg(MSGT_DEMUX, MSGL_FIXME, "unhandled code\n"); } return -1; } @@ -694,7 +687,7 @@ static int cddb_proto_level_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_dat ret = sscanf(http_hdr->body, "%d ", &status); if (ret != 1) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error"); return -1; } @@ -702,18 +695,18 @@ static int cddb_proto_level_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_dat case 210: ptr = strstr(http_hdr->body, "max proto:"); if (ptr == NULL) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error"); return -1; } ret = sscanf(ptr, "max proto: %d", &max); if (ret != 1) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error"); return -1; } cddb_data->freedb_proto_level = max; return 0; default: - mp_msg(MSGT_DEMUX, MSGL_FIXME, MSGTR_MPDEMUX_CDDB_UnhandledCode); + mp_tmsg(MSGT_DEMUX, MSGL_FIXME, "unhandled code\n"); } return -1; } @@ -729,7 +722,7 @@ static int cddb_freedb_sites_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_da ret = sscanf(http_hdr->body, "%d ", &status); if (ret != 1) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_ParseError); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "parse error"); return -1; } @@ -739,10 +732,10 @@ static int cddb_freedb_sites_parse(HTTP_header_t *http_hdr, cddb_data_t *cddb_da ret = cddb_data->anonymous; // For gcc complaining about unused parameter. return 0; case 401: - mp_msg(MSGT_DEMUX, MSGL_FIXME, MSGTR_MPDEMUX_CDDB_NoSitesInfoAvailable); + mp_tmsg(MSGT_DEMUX, MSGL_FIXME, "No sites information available.\n"); break; default: - mp_msg(MSGT_DEMUX, MSGL_FIXME, MSGTR_MPDEMUX_CDDB_UnhandledCode); + mp_tmsg(MSGT_DEMUX, MSGL_FIXME, "unhandled code\n"); } return -1; } @@ -796,8 +789,7 @@ static int cddb_retrieve(cddb_data_t *cddb_data) cddb_create_hello(cddb_data); if (cddb_get_proto_level(cddb_data) < 0) { - mp_msg(MSGT_DEMUX, MSGL_ERR, - MSGTR_MPDEMUX_CDDB_FailedToGetProtocolLevel); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Failed to get the protocol level.\n"); return -1; } @@ -824,8 +816,7 @@ int cddb_resolve(const char *dev, char **xmcd_file) if (cdtoc_last_track <= 0) { cdtoc_last_track = read_toc(dev); if (cdtoc_last_track < 0) { - mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_MPDEMUX_CDDB_FailedToOpenDevice, - dev); + mp_tmsg(MSGT_OPEN, MSGL_ERR, "Failed to open %s device.\n", dev); return -1; } } @@ -839,7 +830,7 @@ int cddb_resolve(const char *dev, char **xmcd_file) // Check if there is a CD in the drive // FIXME: That's not really a good way to check if (cddb_data.disc_id == 0) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MPDEMUX_CDDB_NoCDInDrive); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "No CD in the drive.\n"); return -1; } @@ -859,7 +850,7 @@ int cddb_resolve(const char *dev, char **xmcd_file) cddb_data.cache_dir = malloc(strlen(home_dir) + strlen(cddb_cache_dir) + 1); if (cddb_data.cache_dir == NULL) { - mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MemAllocFailed); + mp_tmsg(MSGT_DEMUX, MSGL_ERR, "Memory allocation failed.\n"); return -1; } sprintf(cddb_data.cache_dir, "%s%s", home_dir, cddb_cache_dir); |