mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 08:15:02 -05:00
Change prototype and return values for new file scanners
This commit is contained in:
parent
92362068c6
commit
7afc55307d
@ -266,7 +266,7 @@ process_media_file(char *file, time_t mtime, off_t size, int compilation)
|
||||
mfi->time_modified = mtime;
|
||||
mfi->file_size = size;
|
||||
|
||||
ret = 0;
|
||||
ret = -1;
|
||||
|
||||
/* Special cases */
|
||||
ext = strrchr(file, '.');
|
||||
@ -275,20 +275,20 @@ process_media_file(char *file, time_t mtime, off_t size, int compilation)
|
||||
if ((strcmp(ext, ".pls") == 0)
|
||||
|| (strcmp(ext, ".url") == 0))
|
||||
{
|
||||
ret = scan_get_urlinfo(file, mfi);
|
||||
if (ret)
|
||||
ret = scan_url_file(file, mfi);
|
||||
if (ret == 0)
|
||||
mfi->data_kind = 1; /* url/stream */
|
||||
}
|
||||
}
|
||||
|
||||
/* General case */
|
||||
if (!ret)
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = scan_get_ffmpeginfo(file, mfi);
|
||||
ret = scan_metadata_ffmpeg(file, mfi);
|
||||
mfi->data_kind = 0; /* real file */
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_SCAN, "Could not extract metadata for %s\n");
|
||||
|
||||
|
@ -12,15 +12,12 @@ filescanner_deinit(void);
|
||||
|
||||
/* Actual scanners */
|
||||
int
|
||||
scan_get_ffmpeginfo(char *filename, struct media_file_info *mfi);
|
||||
scan_metadata_ffmpeg(char *file, struct media_file_info *mfi);
|
||||
|
||||
int
|
||||
scan_get_urlinfo(char *filename, struct media_file_info *mfi);
|
||||
scan_url_file(char *file, struct media_file_info *mfi);
|
||||
|
||||
int
|
||||
scan_static_playlist(char *filename);
|
||||
|
||||
int
|
||||
void
|
||||
scan_m3u_playlist(char *file);
|
||||
|
||||
#endif /* !__FILESCANNER_H__ */
|
||||
|
@ -88,7 +88,8 @@ static struct metadata_map md_map[] =
|
||||
};
|
||||
|
||||
|
||||
int scan_get_ffmpeginfo(char *filename, struct media_file_info *mfi)
|
||||
int
|
||||
scan_metadata_ffmpeg(char *file, struct media_file_info *mfi)
|
||||
{
|
||||
AVFormatContext *ctx;
|
||||
AVMetadataTag *mdt;
|
||||
@ -105,12 +106,12 @@ int scan_get_ffmpeginfo(char *filename, struct media_file_info *mfi)
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
ret = av_open_input_file(&ctx, filename, NULL, 0, NULL);
|
||||
ret = av_open_input_file(&ctx, file, NULL, 0, NULL);
|
||||
if (ret != 0)
|
||||
{
|
||||
DPRINTF(E_WARN, L_SCAN, "Cannot open media file '%s': %s\n", filename, strerror(AVUNERROR(ret)));
|
||||
DPRINTF(E_WARN, L_SCAN, "Cannot open media file '%s': %s\n", file, strerror(AVUNERROR(ret)));
|
||||
|
||||
return FALSE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = av_find_stream_info(ctx);
|
||||
@ -119,12 +120,12 @@ int scan_get_ffmpeginfo(char *filename, struct media_file_info *mfi)
|
||||
DPRINTF(E_WARN, L_SCAN, "Cannot get stream info: %s\n", strerror(AVUNERROR(ret)));
|
||||
|
||||
av_close_input_file(ctx);
|
||||
return FALSE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Dump input format as determined by ffmpeg */
|
||||
dump_format(ctx, 0, filename, FALSE);
|
||||
dump_format(ctx, 0, file, FALSE);
|
||||
#endif
|
||||
|
||||
DPRINTF(E_DBG, L_SCAN, "File has %d streams\n", ctx->nb_streams);
|
||||
@ -372,7 +373,7 @@ int scan_get_ffmpeginfo(char *filename, struct media_file_info *mfi)
|
||||
DPRINTF(E_WARN, L_SCAN, "Falling back to legacy WMA scanner\n");
|
||||
|
||||
av_close_input_file(ctx);
|
||||
return scan_get_wmainfo(filename, mfi);
|
||||
return (scan_get_wmainfo(file, mfi) ? 0 : -1);
|
||||
}
|
||||
#ifdef FLAC
|
||||
else if (codec_id == CODEC_ID_FLAC)
|
||||
@ -380,7 +381,7 @@ int scan_get_ffmpeginfo(char *filename, struct media_file_info *mfi)
|
||||
DPRINTF(E_WARN, L_SCAN, "Falling back to legacy FLAC scanner\n");
|
||||
|
||||
av_close_input_file(ctx);
|
||||
return scan_get_flacinfo(filename, mfi);
|
||||
return (scan_get_flacinfo(file, mfi) ? 0 : -1);
|
||||
}
|
||||
#endif /* FLAC */
|
||||
#ifdef MUSEPACK
|
||||
@ -390,7 +391,7 @@ int scan_get_ffmpeginfo(char *filename, struct media_file_info *mfi)
|
||||
DPRINTF(E_WARN, L_SCAN, "Falling back to legacy Musepack scanner\n");
|
||||
|
||||
av_close_input_file(ctx);
|
||||
return scan_get_mpcinfo(filename, mfi);
|
||||
return (scan_get_mpcinfo(file, mfi) ? 0 : -1);
|
||||
}
|
||||
#endif /* MUSEPACK */
|
||||
else
|
||||
@ -404,5 +405,5 @@ int scan_get_ffmpeginfo(char *filename, struct media_file_info *mfi)
|
||||
/* All done */
|
||||
av_close_input_file(ctx);
|
||||
|
||||
return TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
@ -37,9 +37,10 @@
|
||||
#include "err.h"
|
||||
#include "ff-dbstruct.h"
|
||||
#include "db-generic.h"
|
||||
#include "filescanner.h"
|
||||
|
||||
|
||||
int
|
||||
void
|
||||
scan_m3u_playlist(char *file)
|
||||
{
|
||||
FILE *fp;
|
||||
@ -64,7 +65,7 @@ scan_m3u_playlist(char *file)
|
||||
{
|
||||
DPRINTF(E_LOG, L_SCAN, "Could not stat() '%s': %s\n", file, strerror(errno));
|
||||
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
filename = strrchr(file, '/');
|
||||
@ -82,7 +83,7 @@ scan_m3u_playlist(char *file)
|
||||
DPRINTF(E_DBG, L_SCAN, "Playlist up-to-date\n");
|
||||
|
||||
db_dispose_playlist(pli);
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -98,7 +99,7 @@ scan_m3u_playlist(char *file)
|
||||
{
|
||||
DPRINTF(E_WARN, L_SCAN, "Could not open playlist '%s': %s\n", file, strerror(errno));
|
||||
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get only the basename, to be used as the playlist name */
|
||||
@ -120,7 +121,7 @@ scan_m3u_playlist(char *file)
|
||||
DPRINTF(E_LOG, L_SCAN, "Error adding m3u playlist '%s': %s\n", file, db_errmsg);
|
||||
|
||||
free(db_errmsg);
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
ptr = strrchr(file, '/');
|
||||
@ -128,7 +129,7 @@ scan_m3u_playlist(char *file)
|
||||
{
|
||||
DPRINTF(E_WARN, L_SCAN, "Could not determine playlist base path\n");
|
||||
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
*ptr = '\0';
|
||||
@ -139,7 +140,7 @@ scan_m3u_playlist(char *file)
|
||||
{
|
||||
DPRINTF(E_WARN, L_SCAN, "Out of memory\n");
|
||||
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
DPRINTF(E_INF, L_SCAN | L_PL, "Added playlist as id %d\n", pl_id);
|
||||
@ -217,12 +218,10 @@ scan_m3u_playlist(char *file)
|
||||
DPRINTF(E_LOG, L_SCAN, "Error reading playlist '%s': %s\n", file, strerror(errno));
|
||||
|
||||
fclose(fp);
|
||||
return FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
DPRINTF(E_INF, L_SCAN | L_PL, "Done processing playlist\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -33,10 +33,11 @@
|
||||
#include "daapd.h"
|
||||
#include "err.h"
|
||||
#include "ff-dbstruct.h"
|
||||
#include "filescanner.h"
|
||||
|
||||
|
||||
int
|
||||
scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
||||
scan_url_file(char *file, struct media_file_info *mfi)
|
||||
{
|
||||
FILE *fp;
|
||||
char *head;
|
||||
@ -52,7 +53,7 @@ scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
||||
{
|
||||
DPRINTF(E_WARN, L_SCAN, "Could not open '%s' for reading: %s\n", file, strerror(errno));
|
||||
|
||||
return FALSE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
head = fgets(buf, sizeof(buf), fp);
|
||||
@ -62,7 +63,7 @@ scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
||||
{
|
||||
DPRINTF(E_WARN, L_SCAN, "Error reading from file '%s': %s", file, strerror(errno));
|
||||
|
||||
return FALSE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = strlen(buf);
|
||||
@ -71,7 +72,7 @@ scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
||||
{
|
||||
DPRINTF(E_WARN, L_SCAN, "URL info in file '%s' too large for buffer\n", file);
|
||||
|
||||
return FALSE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (isspace(buf[len - 1]))
|
||||
@ -85,7 +86,7 @@ scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
||||
{
|
||||
DPRINTF(E_LOG, L_SCAN, "Badly formatted .url file; expected format is bitrate,descr,url\n");
|
||||
|
||||
return FALSE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
head = tail + 1;
|
||||
@ -94,7 +95,7 @@ scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
||||
{
|
||||
DPRINTF(E_LOG, L_SCAN, "Badly formatted .url file; expected format is bitrate,descr,url\n");
|
||||
|
||||
return FALSE;
|
||||
return -1;
|
||||
}
|
||||
*tail = '\0';
|
||||
|
||||
@ -111,7 +112,7 @@ scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
||||
|
||||
free(mfi->title);
|
||||
free(mfi->url);
|
||||
return FALSE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tail == buf)
|
||||
@ -120,7 +121,7 @@ scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
||||
|
||||
free(mfi->title);
|
||||
free(mfi->url);
|
||||
return FALSE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (intval > INT_MAX)
|
||||
@ -129,7 +130,7 @@ scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
||||
|
||||
free(mfi->title);
|
||||
free(mfi->url);
|
||||
return FALSE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
mfi->bitrate = (int)intval;
|
||||
@ -142,5 +143,5 @@ scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
||||
/* codectype = NULL */
|
||||
mfi->description = strdup("Playlist URL");
|
||||
|
||||
return TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user