diff --git a/src/artwork.c b/src/artwork.c index e9294784..65875a23 100644 --- a/src/artwork.c +++ b/src/artwork.c @@ -1106,7 +1106,7 @@ artwork_get_item_mfi(struct evbuffer *evbuf, struct media_file_info *mfi, int ma return format; } - if (mfi->data_kind == 0) + if (mfi->data_kind == DATA_KIND_FILE) { format = artwork_get_item_path(evbuf, mfi->path, mfi->artwork, max_w, max_h, path); diff --git a/src/db.h b/src/db.h index 36338f2f..e852e6fa 100644 --- a/src/db.h +++ b/src/db.h @@ -85,6 +85,21 @@ struct pairing_info { char *guid; }; +enum media_kind { + MEDIA_KIND_MUSIC = 0, + MEDIA_KIND_MOVIE = 2, + MEDIA_KIND_PODCAST = 4, + MEDIA_KIND_AUDIOBOOK = 8, + MEDIA_KIND_TVSHOW = 64, +}; + +enum data_kind { + DATA_KIND_FILE = 0, + DATA_KIND_URL = 1, + DATA_KIND_SPOTIFY = 2, + DATA_KIND_PIPE = 3, +}; + struct media_file_info { char *path; uint32_t index; diff --git a/src/filescanner.c b/src/filescanner.c index 9f7a9ef1..d3a4fc91 100644 --- a/src/filescanner.c +++ b/src/filescanner.c @@ -537,7 +537,7 @@ fixup_tags(struct media_file_info *mfi) /* Handle TV shows, try to present prettier metadata */ if (mfi->tv_series_name && strlen(mfi->tv_series_name) != 0) { - mfi->media_kind = 64; /* tv show */ + mfi->media_kind = MEDIA_KIND_TVSHOW; /* tv show */ /* Default to artist = series_name */ if (mfi->artist && strlen(mfi->artist) == 0) @@ -608,7 +608,7 @@ fixup_tags(struct media_file_info *mfi) mfi->album_artist_sort = strdup(""); } } - else if (mfi->media_kind == 4) /* Podcast */ + else if (mfi->media_kind == MEDIA_KIND_PODCAST) /* Podcast */ { if (mfi->album_artist) free(mfi->album_artist); @@ -691,12 +691,12 @@ filescanner_process_media(char *path, time_t mtime, off_t size, int type, struct if (type & F_SCAN_TYPE_FILE) { - mfi->data_kind = 0; /* real file */ + mfi->data_kind = DATA_KIND_FILE; /* real file */ ret = scan_metadata_ffmpeg(path, mfi); } else if (type & F_SCAN_TYPE_URL) { - mfi->data_kind = 1; /* url/stream */ + mfi->data_kind = DATA_KIND_URL; /* url/stream */ ret = scan_metadata_ffmpeg(path, mfi); if (ret < 0) { @@ -709,12 +709,12 @@ filescanner_process_media(char *path, time_t mtime, off_t size, int type, struct } else if (type & F_SCAN_TYPE_SPOTIFY) { - mfi->data_kind = 2; /* iTunes has no spotify data kind, but we use 2 */ + mfi->data_kind = DATA_KIND_SPOTIFY; /* iTunes has no spotify data kind, but we use 2 */ ret = mfi->artist && mfi->album && mfi->title; } else if (type & F_SCAN_TYPE_PIPE) { - mfi->data_kind = 3; /* iTunes has no pipe data kind, but we use 3 */ + mfi->data_kind = DATA_KIND_PIPE; /* iTunes has no pipe data kind, but we use 3 */ mfi->type = strdup("wav"); mfi->codectype = strdup("wav"); mfi->description = strdup("PCM16 pipe"); @@ -735,14 +735,14 @@ filescanner_process_media(char *path, time_t mtime, off_t size, int type, struct if (type & F_SCAN_TYPE_COMPILATION) mfi->compilation = 1; if (type & F_SCAN_TYPE_PODCAST) - mfi->media_kind = 4; /* podcast */ + mfi->media_kind = MEDIA_KIND_PODCAST; /* podcast */ if (type & F_SCAN_TYPE_AUDIOBOOK) - mfi->media_kind = 8; /* audiobook */ + mfi->media_kind = MEDIA_KIND_AUDIOBOOK; /* audiobook */ if (!mfi->item_kind) mfi->item_kind = 2; /* music */ if (!mfi->media_kind) - mfi->media_kind = 1; /* music */ + mfi->media_kind = MEDIA_KIND_MUSIC; /* music */ unicode_fixup_mfi(mfi); diff --git a/src/filescanner_ffmpeg.c b/src/filescanner_ffmpeg.c index 5cb032c3..0ed8b90e 100644 --- a/src/filescanner_ffmpeg.c +++ b/src/filescanner_ffmpeg.c @@ -346,14 +346,14 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi) #if LIBAVFORMAT_VERSION_MAJOR >= 54 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR >= 3) # ifndef HAVE_FFMPEG // Without this, libav is slow to probe some internet streams - if (mfi->data_kind == 1) + if (mfi->data_kind == DATA_KIND_URL) { ctx = avformat_alloc_context(); ctx->probesize = 64000; } # endif - if (mfi->data_kind == 1) + if (mfi->data_kind == DATA_KIND_URL) { free(path); ret = http_stream_setup(&path, file); @@ -493,7 +493,7 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi) DPRINTF(E_DBG, L_SCAN, "Duration %d ms, bitrate %d kbps\n", mfi->song_length, mfi->bitrate); /* Try to extract ICY metadata if url/stream */ - if (mfi->data_kind == 1) + if (mfi->data_kind == DATA_KIND_URL) { icy_metadata = http_icy_metadata_get(ctx, 0); if (icy_metadata && icy_metadata->name) @@ -753,12 +753,12 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi) if (mfi->media_kind == 10) { /* I have no idea why this is, but iTunes reports a media kind of 64 for stik==10 (?!) */ - mfi->media_kind = 64; + mfi->media_kind = MEDIA_KIND_TVSHOW; } /* Unspecified video files are "Movies", media_kind 2 */ else if (mfi->has_video == 1) { - mfi->media_kind = 2; + mfi->media_kind = MEDIA_KIND_MOVIE; } skip_extract: diff --git a/src/filescanner_itunes.c b/src/filescanner_itunes.c index 8e05ef9b..084548e0 100644 --- a/src/filescanner_itunes.c +++ b/src/filescanner_itunes.c @@ -474,7 +474,7 @@ process_track_file(plist_t trk) ret = get_dictval_bool_from_key(trk, "Podcast", &boolean); if ((ret == 0) && boolean) { - mfi->media_kind = 4; + mfi->media_kind = MEDIA_KIND_PODCAST; } /* Don't let album_artist set to "Unknown artist" if we've diff --git a/src/httpd.c b/src/httpd.c index 74ef0ba0..ef996fa1 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -415,7 +415,7 @@ httpd_stream_file(struct evhttp_request *req, int id) return; } - if (mfi->data_kind != 0) + if (mfi->data_kind != DATA_KIND_FILE) { evhttp_send_error(req, 500, "Cannot stream radio station"); diff --git a/src/lastfm.c b/src/lastfm.c index 4782a916..ef7296c2 100644 --- a/src/lastfm.c +++ b/src/lastfm.c @@ -590,7 +590,7 @@ scrobble(struct lastfm_command *cmd) goto noscrobble; // Don't scrobble non-music and radio stations - if ((mfi->media_kind != 1) || (mfi->data_kind == 1)) + if ((mfi->media_kind != MEDIA_KIND_MUSIC) || (mfi->data_kind == DATA_KIND_URL)) goto noscrobble; // Don't scrobble songs with unknown artist diff --git a/src/player.c b/src/player.c index c5c885be..e6a93a1a 100644 --- a/src/player.c +++ b/src/player.c @@ -1373,7 +1373,7 @@ source_open(struct player_source *ps, int no_md) // Setup the source type responsible for getting the audio switch (mfi->data_kind) { - case 1: + case DATA_KIND_URL: ps->type = SOURCE_HTTP; ret = http_stream_setup(&url, mfi->path); @@ -1386,7 +1386,7 @@ source_open(struct player_source *ps, int no_md) ret = transcode_setup(&ps->ctx, mfi, NULL, 0); break; - case 2: + case DATA_KIND_SPOTIFY: ps->type = SOURCE_SPOTIFY; #ifdef HAVE_SPOTIFY_H ret = spotify_playback_play(mfi); @@ -1395,7 +1395,7 @@ source_open(struct player_source *ps, int no_md) #endif break; - case 3: + case DATA_KIND_PIPE: ps->type = SOURCE_PIPE; ret = pipe_setup(mfi); break; diff --git a/src/transcode.c b/src/transcode.c index 9d2e1acc..f07f31f3 100644 --- a/src/transcode.c +++ b/src/transcode.c @@ -507,13 +507,13 @@ transcode_setup(struct transcode_ctx **nctx, struct media_file_info *mfi, off_t #if LIBAVFORMAT_VERSION_MAJOR >= 54 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR >= 3) # ifndef HAVE_FFMPEG // Without this, libav is slow to probe some internet streams, which leads to RAOP timeouts - if (mfi->data_kind == 1) + if (mfi->data_kind == DATA_KIND_URL) { ctx->fmtctx = avformat_alloc_context(); ctx->fmtctx->probesize = 64000; } # endif - if (mfi->data_kind == 1) + if (mfi->data_kind == DATA_KIND_URL) av_dict_set(&options, "icy", "1", 0); ret = avformat_open_input(&ctx->fmtctx, mfi->path, NULL, &options);