mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-29 00:23:23 -05:00
[filescanner] Add some const's and various fixup
This commit is contained in:
parent
78dd8c89b6
commit
1070f507a2
@ -10,14 +10,14 @@ int
|
|||||||
scan_metadata_ffmpeg(const char *file, struct media_file_info *mfi);
|
scan_metadata_ffmpeg(const char *file, struct media_file_info *mfi);
|
||||||
|
|
||||||
void
|
void
|
||||||
scan_playlist(char *file, time_t mtime, int dir_id);
|
scan_playlist(const char *file, time_t mtime, int dir_id);
|
||||||
|
|
||||||
void
|
void
|
||||||
scan_smartpl(char *file, time_t mtime, int dir_id);
|
scan_smartpl(const char *file, time_t mtime, int dir_id);
|
||||||
|
|
||||||
#ifdef ITUNES
|
#ifdef ITUNES
|
||||||
void
|
void
|
||||||
scan_itunes_itml(char *file);
|
scan_itunes_itml(const char *file);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
@ -688,7 +688,7 @@ ignore_pl(plist_t pl, char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
process_pls(plist_t playlists, char *file)
|
process_pls(plist_t playlists, const char *file)
|
||||||
{
|
{
|
||||||
plist_t pl;
|
plist_t pl;
|
||||||
plist_t items;
|
plist_t items;
|
||||||
@ -730,7 +730,6 @@ process_pls(plist_t playlists, char *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pli = db_pl_fetch_bytitlepath(name, file);
|
pli = db_pl_fetch_bytitlepath(name, file);
|
||||||
|
|
||||||
if (pli)
|
if (pli)
|
||||||
{
|
{
|
||||||
pl_id = pli->id;
|
pl_id = pli->id;
|
||||||
@ -754,19 +753,18 @@ process_pls(plist_t playlists, char *file)
|
|||||||
|
|
||||||
if (pl_id == 0)
|
if (pl_id == 0)
|
||||||
{
|
{
|
||||||
pli = (struct playlist_info *)malloc(sizeof(struct playlist_info));
|
pli = calloc(1, sizeof(struct playlist_info));
|
||||||
if (!pli)
|
if (!pli)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_SCAN, "Out of memory\n");
|
DPRINTF(E_LOG, L_SCAN, "Out of memory\n");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memset(pli, 0, sizeof(struct playlist_info));
|
|
||||||
|
|
||||||
pli->type = PL_PLAIN;
|
pli->type = PL_PLAIN;
|
||||||
pli->title = strdup(name);
|
pli->title = strdup(name);
|
||||||
pli->path = strdup(file);
|
pli->path = strdup(file);
|
||||||
snprintf(virtual_path, PATH_MAX, "/file:%s", file);
|
snprintf(virtual_path, sizeof(virtual_path), "/file:%s", file);
|
||||||
pli->virtual_path = strdup(virtual_path);
|
pli->virtual_path = strdup(virtual_path);
|
||||||
|
|
||||||
ret = db_pl_add(pli, &pl_id);
|
ret = db_pl_add(pli, &pl_id);
|
||||||
@ -790,15 +788,13 @@ process_pls(plist_t playlists, char *file)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
scan_itunes_itml(char *file)
|
scan_itunes_itml(const char *file)
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
char *itml_xml;
|
char *itml_xml;
|
||||||
char *ptr;
|
|
||||||
plist_t itml;
|
plist_t itml;
|
||||||
plist_t node;
|
plist_t node;
|
||||||
int fd;
|
int fd;
|
||||||
int size;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DPRINTF(E_LOG, L_SCAN, "Processing iTunes library: %s\n", file);
|
DPRINTF(E_LOG, L_SCAN, "Processing iTunes library: %s\n", file);
|
||||||
@ -871,8 +867,7 @@ scan_itunes_itml(char *file)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = ID_MAP_SIZE * sizeof(struct itml_to_db_map *);
|
id_map = calloc(ID_MAP_SIZE, sizeof(struct itml_to_db_map *));
|
||||||
id_map = malloc(size);
|
|
||||||
if (!id_map)
|
if (!id_map)
|
||||||
{
|
{
|
||||||
DPRINTF(E_FATAL, L_SCAN, "iTunes library parser could not allocate ID map\n");
|
DPRINTF(E_FATAL, L_SCAN, "iTunes library parser could not allocate ID map\n");
|
||||||
@ -880,19 +875,6 @@ scan_itunes_itml(char *file)
|
|||||||
plist_free(itml);
|
plist_free(itml);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memset(id_map, 0, size);
|
|
||||||
|
|
||||||
ptr = strrchr(file, '/');
|
|
||||||
if (!ptr)
|
|
||||||
{
|
|
||||||
DPRINTF(E_FATAL, L_SCAN, "Invalid filename\n");
|
|
||||||
|
|
||||||
id_map_free();
|
|
||||||
plist_free(itml);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ptr = '\0';
|
|
||||||
|
|
||||||
ret = process_tracks(node);
|
ret = process_tracks(node);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
@ -904,8 +886,6 @@ scan_itunes_itml(char *file)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ptr = '/';
|
|
||||||
|
|
||||||
DPRINTF(E_INFO, L_SCAN, "Loaded %d tracks from iTunes library\n", ret);
|
DPRINTF(E_INFO, L_SCAN, "Loaded %d tracks from iTunes library\n", ret);
|
||||||
|
|
||||||
/* Playlists */
|
/* Playlists */
|
||||||
|
@ -121,7 +121,7 @@ process_url(int pl_id, const char *path, time_t mtime, int extinf, struct media_
|
|||||||
if (!mfi->title)
|
if (!mfi->title)
|
||||||
mfi->title = strdup(mfi->fname);
|
mfi->title = strdup(mfi->fname);
|
||||||
|
|
||||||
snprintf(virtual_path, PATH_MAX, "/http:/%s", mfi->title);
|
snprintf(virtual_path, sizeof(virtual_path), "/http:/%s", mfi->title);
|
||||||
mfi->virtual_path = strdup(virtual_path);
|
mfi->virtual_path = strdup(virtual_path);
|
||||||
|
|
||||||
library_add_media(mfi);
|
library_add_media(mfi);
|
||||||
@ -171,7 +171,7 @@ process_regular_file(int pl_id, char *path)
|
|||||||
|
|
||||||
winner = NULL;
|
winner = NULL;
|
||||||
score = 0;
|
score = 0;
|
||||||
while (((ret = db_query_fetch_string(&qp, &dbpath)) == 0) && (dbpath))
|
while ((db_query_fetch_string(&qp, &dbpath) == 0) && dbpath)
|
||||||
{
|
{
|
||||||
if (qp.results == 1)
|
if (qp.results == 1)
|
||||||
{
|
{
|
||||||
@ -188,7 +188,7 @@ process_regular_file(int pl_id, char *path)
|
|||||||
{
|
{
|
||||||
free(winner);
|
free(winner);
|
||||||
winner = strdup(dbpath);
|
winner = strdup(dbpath);
|
||||||
score = ret;
|
score = i;
|
||||||
}
|
}
|
||||||
else if (i == score)
|
else if (i == score)
|
||||||
{
|
{
|
||||||
@ -214,7 +214,7 @@ process_regular_file(int pl_id, char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
scan_playlist(char *file, time_t mtime, int dir_id)
|
scan_playlist(const char *file, time_t mtime, int dir_id)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
struct media_file_info mfi;
|
struct media_file_info mfi;
|
||||||
@ -230,7 +230,6 @@ scan_playlist(char *file, time_t mtime, int dir_id)
|
|||||||
int pl_format;
|
int pl_format;
|
||||||
int counter;
|
int counter;
|
||||||
int ret;
|
int ret;
|
||||||
char virtual_path[PATH_MAX];
|
|
||||||
|
|
||||||
ptr = strrchr(file, '.');
|
ptr = strrchr(file, '.');
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
@ -278,8 +277,8 @@ scan_playlist(char *file, time_t mtime, int dir_id)
|
|||||||
pli->title = strip_extension(filename);
|
pli->title = strip_extension(filename);
|
||||||
|
|
||||||
pli->path = strdup(file);
|
pli->path = strdup(file);
|
||||||
snprintf(virtual_path, PATH_MAX, "/file:%s", file);
|
snprintf(buf, sizeof(buf), "/file:%s", file);
|
||||||
pli->virtual_path = strip_extension(virtual_path);
|
pli->virtual_path = strip_extension(buf);
|
||||||
|
|
||||||
pli->directory_id = dir_id;
|
pli->directory_id = dir_id;
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ smartpl_parse_file(const char *file, struct playlist_info *pli)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
scan_smartpl(char *file, time_t mtime, int dir_id)
|
scan_smartpl(const char *file, time_t mtime, int dir_id)
|
||||||
{
|
{
|
||||||
struct playlist_info *pli;
|
struct playlist_info *pli;
|
||||||
int pl_id;
|
int pl_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user