mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-16 00:58:18 -04: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->time_modified = mtime;
|
||||||
mfi->file_size = size;
|
mfi->file_size = size;
|
||||||
|
|
||||||
ret = 0;
|
ret = -1;
|
||||||
|
|
||||||
/* Special cases */
|
/* Special cases */
|
||||||
ext = strrchr(file, '.');
|
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)
|
if ((strcmp(ext, ".pls") == 0)
|
||||||
|| (strcmp(ext, ".url") == 0))
|
|| (strcmp(ext, ".url") == 0))
|
||||||
{
|
{
|
||||||
ret = scan_get_urlinfo(file, mfi);
|
ret = scan_url_file(file, mfi);
|
||||||
if (ret)
|
if (ret == 0)
|
||||||
mfi->data_kind = 1; /* url/stream */
|
mfi->data_kind = 1; /* url/stream */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* General case */
|
/* 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 */
|
mfi->data_kind = 0; /* real file */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_SCAN, "Could not extract metadata for %s\n");
|
DPRINTF(E_LOG, L_SCAN, "Could not extract metadata for %s\n");
|
||||||
|
|
||||||
|
@ -12,15 +12,12 @@ filescanner_deinit(void);
|
|||||||
|
|
||||||
/* Actual scanners */
|
/* Actual scanners */
|
||||||
int
|
int
|
||||||
scan_get_ffmpeginfo(char *filename, struct media_file_info *mfi);
|
scan_metadata_ffmpeg(char *file, struct media_file_info *mfi);
|
||||||
|
|
||||||
int
|
int
|
||||||
scan_get_urlinfo(char *filename, struct media_file_info *mfi);
|
scan_url_file(char *file, struct media_file_info *mfi);
|
||||||
|
|
||||||
int
|
void
|
||||||
scan_static_playlist(char *filename);
|
|
||||||
|
|
||||||
int
|
|
||||||
scan_m3u_playlist(char *file);
|
scan_m3u_playlist(char *file);
|
||||||
|
|
||||||
#endif /* !__FILESCANNER_H__ */
|
#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;
|
AVFormatContext *ctx;
|
||||||
AVMetadataTag *mdt;
|
AVMetadataTag *mdt;
|
||||||
@ -105,12 +106,12 @@ int scan_get_ffmpeginfo(char *filename, struct media_file_info *mfi)
|
|||||||
int i;
|
int i;
|
||||||
int ret;
|
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)
|
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);
|
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)));
|
DPRINTF(E_WARN, L_SCAN, "Cannot get stream info: %s\n", strerror(AVUNERROR(ret)));
|
||||||
|
|
||||||
av_close_input_file(ctx);
|
av_close_input_file(ctx);
|
||||||
return FALSE;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Dump input format as determined by ffmpeg */
|
/* Dump input format as determined by ffmpeg */
|
||||||
dump_format(ctx, 0, filename, FALSE);
|
dump_format(ctx, 0, file, FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DPRINTF(E_DBG, L_SCAN, "File has %d streams\n", ctx->nb_streams);
|
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");
|
DPRINTF(E_WARN, L_SCAN, "Falling back to legacy WMA scanner\n");
|
||||||
|
|
||||||
av_close_input_file(ctx);
|
av_close_input_file(ctx);
|
||||||
return scan_get_wmainfo(filename, mfi);
|
return (scan_get_wmainfo(file, mfi) ? 0 : -1);
|
||||||
}
|
}
|
||||||
#ifdef FLAC
|
#ifdef FLAC
|
||||||
else if (codec_id == CODEC_ID_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");
|
DPRINTF(E_WARN, L_SCAN, "Falling back to legacy FLAC scanner\n");
|
||||||
|
|
||||||
av_close_input_file(ctx);
|
av_close_input_file(ctx);
|
||||||
return scan_get_flacinfo(filename, mfi);
|
return (scan_get_flacinfo(file, mfi) ? 0 : -1);
|
||||||
}
|
}
|
||||||
#endif /* FLAC */
|
#endif /* FLAC */
|
||||||
#ifdef MUSEPACK
|
#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");
|
DPRINTF(E_WARN, L_SCAN, "Falling back to legacy Musepack scanner\n");
|
||||||
|
|
||||||
av_close_input_file(ctx);
|
av_close_input_file(ctx);
|
||||||
return scan_get_mpcinfo(filename, mfi);
|
return (scan_get_mpcinfo(file, mfi) ? 0 : -1);
|
||||||
}
|
}
|
||||||
#endif /* MUSEPACK */
|
#endif /* MUSEPACK */
|
||||||
else
|
else
|
||||||
@ -404,5 +405,5 @@ int scan_get_ffmpeginfo(char *filename, struct media_file_info *mfi)
|
|||||||
/* All done */
|
/* All done */
|
||||||
av_close_input_file(ctx);
|
av_close_input_file(ctx);
|
||||||
|
|
||||||
return TRUE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -37,9 +37,10 @@
|
|||||||
#include "err.h"
|
#include "err.h"
|
||||||
#include "ff-dbstruct.h"
|
#include "ff-dbstruct.h"
|
||||||
#include "db-generic.h"
|
#include "db-generic.h"
|
||||||
|
#include "filescanner.h"
|
||||||
|
|
||||||
|
|
||||||
int
|
void
|
||||||
scan_m3u_playlist(char *file)
|
scan_m3u_playlist(char *file)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
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));
|
DPRINTF(E_LOG, L_SCAN, "Could not stat() '%s': %s\n", file, strerror(errno));
|
||||||
|
|
||||||
return FALSE;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = strrchr(file, '/');
|
filename = strrchr(file, '/');
|
||||||
@ -82,7 +83,7 @@ scan_m3u_playlist(char *file)
|
|||||||
DPRINTF(E_DBG, L_SCAN, "Playlist up-to-date\n");
|
DPRINTF(E_DBG, L_SCAN, "Playlist up-to-date\n");
|
||||||
|
|
||||||
db_dispose_playlist(pli);
|
db_dispose_playlist(pli);
|
||||||
return TRUE;
|
return;
|
||||||
}
|
}
|
||||||
else
|
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));
|
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 */
|
/* 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);
|
DPRINTF(E_LOG, L_SCAN, "Error adding m3u playlist '%s': %s\n", file, db_errmsg);
|
||||||
|
|
||||||
free(db_errmsg);
|
free(db_errmsg);
|
||||||
return FALSE;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = strrchr(file, '/');
|
ptr = strrchr(file, '/');
|
||||||
@ -128,7 +129,7 @@ scan_m3u_playlist(char *file)
|
|||||||
{
|
{
|
||||||
DPRINTF(E_WARN, L_SCAN, "Could not determine playlist base path\n");
|
DPRINTF(E_WARN, L_SCAN, "Could not determine playlist base path\n");
|
||||||
|
|
||||||
return FALSE;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
@ -139,7 +140,7 @@ scan_m3u_playlist(char *file)
|
|||||||
{
|
{
|
||||||
DPRINTF(E_WARN, L_SCAN, "Out of memory\n");
|
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);
|
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));
|
DPRINTF(E_LOG, L_SCAN, "Error reading playlist '%s': %s\n", file, strerror(errno));
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return FALSE;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
DPRINTF(E_INF, L_SCAN | L_PL, "Done processing playlist\n");
|
DPRINTF(E_INF, L_SCAN | L_PL, "Done processing playlist\n");
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,11 @@
|
|||||||
#include "daapd.h"
|
#include "daapd.h"
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
#include "ff-dbstruct.h"
|
#include "ff-dbstruct.h"
|
||||||
|
#include "filescanner.h"
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
scan_url_file(char *file, struct media_file_info *mfi)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *head;
|
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));
|
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);
|
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));
|
DPRINTF(E_WARN, L_SCAN, "Error reading from file '%s': %s", file, strerror(errno));
|
||||||
|
|
||||||
return FALSE;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(buf);
|
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);
|
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]))
|
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");
|
DPRINTF(E_LOG, L_SCAN, "Badly formatted .url file; expected format is bitrate,descr,url\n");
|
||||||
|
|
||||||
return FALSE;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
head = tail + 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");
|
DPRINTF(E_LOG, L_SCAN, "Badly formatted .url file; expected format is bitrate,descr,url\n");
|
||||||
|
|
||||||
return FALSE;
|
return -1;
|
||||||
}
|
}
|
||||||
*tail = '\0';
|
*tail = '\0';
|
||||||
|
|
||||||
@ -111,7 +112,7 @@ scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
|||||||
|
|
||||||
free(mfi->title);
|
free(mfi->title);
|
||||||
free(mfi->url);
|
free(mfi->url);
|
||||||
return FALSE;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tail == buf)
|
if (tail == buf)
|
||||||
@ -120,7 +121,7 @@ scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
|||||||
|
|
||||||
free(mfi->title);
|
free(mfi->title);
|
||||||
free(mfi->url);
|
free(mfi->url);
|
||||||
return FALSE;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intval > INT_MAX)
|
if (intval > INT_MAX)
|
||||||
@ -129,7 +130,7 @@ scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
|||||||
|
|
||||||
free(mfi->title);
|
free(mfi->title);
|
||||||
free(mfi->url);
|
free(mfi->url);
|
||||||
return FALSE;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
mfi->bitrate = (int)intval;
|
mfi->bitrate = (int)intval;
|
||||||
@ -142,5 +143,5 @@ scan_get_urlinfo(char *file, struct media_file_info *mfi)
|
|||||||
/* codectype = NULL */
|
/* codectype = NULL */
|
||||||
mfi->description = strdup("Playlist URL");
|
mfi->description = strdup("Playlist URL");
|
||||||
|
|
||||||
return TRUE;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user