mirror of https://github.com/mpv-player/mpv
player/timeline: mp_msg conversions
This commit is contained in:
parent
9825906f73
commit
15ae64d369
|
@ -199,14 +199,14 @@ static bool try_open(struct MPContext *mpctx, char *filename)
|
||||||
// TODO: maybe also could check if the .bin file is a multiple of the Audio
|
// TODO: maybe also could check if the .bin file is a multiple of the Audio
|
||||||
// CD sector size (2352 bytes)
|
// CD sector size (2352 bytes)
|
||||||
if (!d && bstr_case_endswith(bfilename, bstr0(".bin"))) {
|
if (!d && bstr_case_endswith(bfilename, bstr0(".bin"))) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_WARN, "CUE: Opening as BIN file!\n");
|
MP_WARN(mpctx, "CUE: Opening as BIN file!\n");
|
||||||
d = demux_open(s, "rawaudio", NULL, mpctx->opts);
|
d = demux_open(s, "rawaudio", NULL, mpctx->opts);
|
||||||
}
|
}
|
||||||
if (d) {
|
if (d) {
|
||||||
add_source(mpctx, d);
|
add_source(mpctx, d);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_ERR, "Could not open source '%s'!\n", filename);
|
MP_ERR(mpctx, "Could not open source '%s'!\n", filename);
|
||||||
free_stream(s);
|
free_stream(s);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -220,8 +220,7 @@ static bool open_source(struct MPContext *mpctx, struct bstr filename)
|
||||||
|
|
||||||
struct bstr base_filename = bstr0(mp_basename(bstrdup0(ctx, filename)));
|
struct bstr base_filename = bstr0(mp_basename(bstrdup0(ctx, filename)));
|
||||||
if (!base_filename.len) {
|
if (!base_filename.len) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
MP_WARN(mpctx, "CUE: Invalid audio filename in .cue file!\n");
|
||||||
"CUE: Invalid audio filename in .cue file!\n");
|
|
||||||
} else {
|
} else {
|
||||||
char *fullname = mp_path_join(ctx, dirname, base_filename);
|
char *fullname = mp_path_join(ctx, dirname, base_filename);
|
||||||
if (try_open(mpctx, fullname)) {
|
if (try_open(mpctx, fullname)) {
|
||||||
|
@ -246,7 +245,7 @@ static bool open_source(struct MPContext *mpctx, struct bstr filename)
|
||||||
char *dename0 = de->d_name;
|
char *dename0 = de->d_name;
|
||||||
struct bstr dename = bstr0(dename0);
|
struct bstr dename = bstr0(dename0);
|
||||||
if (bstr_case_startswith(dename, cuefile)) {
|
if (bstr_case_startswith(dename, cuefile)) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_WARN, "CUE: No useful audio filename "
|
MP_WARN(mpctx, "CUE: No useful audio filename "
|
||||||
"in .cue file found, trying with '%s' instead!\n",
|
"in .cue file found, trying with '%s' instead!\n",
|
||||||
dename0);
|
dename0);
|
||||||
if (try_open(mpctx, mp_path_join(ctx, dirname, dename))) {
|
if (try_open(mpctx, mp_path_join(ctx, dirname, dename))) {
|
||||||
|
@ -260,7 +259,7 @@ static bool open_source(struct MPContext *mpctx, struct bstr filename)
|
||||||
out:
|
out:
|
||||||
talloc_free(ctx);
|
talloc_free(ctx);
|
||||||
if (!res)
|
if (!res)
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_ERR, "CUE: Could not open audio file!\n");
|
MP_ERR(mpctx, "CUE: Could not open audio file!\n");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +296,7 @@ void build_cue_timeline(struct MPContext *mpctx)
|
||||||
struct bstr param;
|
struct bstr param;
|
||||||
switch (read_cmd(&data, ¶m)) {
|
switch (read_cmd(&data, ¶m)) {
|
||||||
case CUE_ERROR:
|
case CUE_ERROR:
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_ERR, "CUE: error parsing input file!\n");
|
MP_ERR(mpctx, "CUE: error parsing input file!\n");
|
||||||
goto out;
|
goto out;
|
||||||
case CUE_TRACK: {
|
case CUE_TRACK: {
|
||||||
track_count++;
|
track_count++;
|
||||||
|
@ -328,7 +327,7 @@ void build_cue_timeline(struct MPContext *mpctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track_count == 0) {
|
if (track_count == 0) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_ERR, "CUE: no tracks found!\n");
|
MP_ERR(mpctx, "CUE: no tracks found!\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,8 +379,7 @@ void build_cue_timeline(struct MPContext *mpctx)
|
||||||
duration -= tracks[i].start;
|
duration -= tracks[i].start;
|
||||||
}
|
}
|
||||||
if (duration < 0) {
|
if (duration < 0) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
MP_WARN(mpctx, "CUE: Can't get duration of source file!\n");
|
||||||
"CUE: Can't get duration of source file!\n");
|
|
||||||
// xxx: do something more reasonable
|
// xxx: do something more reasonable
|
||||||
duration = 0.0;
|
duration = 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ static bool check_file_seg(struct MPContext *mpctx, struct demuxer ***sources,
|
||||||
* either matches or isn't specified. */
|
* either matches or isn't specified. */
|
||||||
if (!memcmp(uid->segment, m->uid.segment, 16) &&
|
if (!memcmp(uid->segment, m->uid.segment, 16) &&
|
||||||
(!uid->edition || uid->edition == m->uid.edition)) {
|
(!uid->edition || uid->edition == m->uid.edition)) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Match for source %d: %s\n",
|
MP_INFO(mpctx, "Match for source %d: %s\n",
|
||||||
i, d->filename);
|
i, d->filename);
|
||||||
|
|
||||||
for (int j = 0; j < m->num_ordered_chapters; j++) {
|
for (int j = 0; j < m->num_ordered_chapters; j++) {
|
||||||
|
@ -258,10 +258,10 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx,
|
||||||
char **filenames = NULL;
|
char **filenames = NULL;
|
||||||
if (*num_sources > 1) {
|
if (*num_sources > 1) {
|
||||||
char *main_filename = mpctx->demuxer->filename;
|
char *main_filename = mpctx->demuxer->filename;
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_INFO, "This file references data from "
|
MP_INFO(mpctx, "This file references data from "
|
||||||
"other sources.\n");
|
"other sources.\n");
|
||||||
if (opts->ordered_chapters_files && opts->ordered_chapters_files[0]) {
|
if (opts->ordered_chapters_files && opts->ordered_chapters_files[0]) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Loading references from '%s'.\n",
|
MP_INFO(mpctx, "Loading references from '%s'.\n",
|
||||||
opts->ordered_chapters_files);
|
opts->ordered_chapters_files);
|
||||||
struct playlist *pl =
|
struct playlist *pl =
|
||||||
playlist_parse_file(opts->ordered_chapters_files, opts);
|
playlist_parse_file(opts->ordered_chapters_files, opts);
|
||||||
|
@ -269,10 +269,10 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx,
|
||||||
for (struct playlist_entry *e = pl->first; e; e = e->next)
|
for (struct playlist_entry *e = pl->first; e; e = e->next)
|
||||||
MP_TARRAY_APPEND(tmp, filenames, num_filenames, e->filename);
|
MP_TARRAY_APPEND(tmp, filenames, num_filenames, e->filename);
|
||||||
} else if (mpctx->demuxer->stream->uncached_type != STREAMTYPE_FILE) {
|
} else if (mpctx->demuxer->stream->uncached_type != STREAMTYPE_FILE) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_WARN, "Playback source is not a "
|
MP_WARN(mpctx, "Playback source is not a "
|
||||||
"normal disk file. Will not search for related files.\n");
|
"normal disk file. Will not search for related files.\n");
|
||||||
} else {
|
} else {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Will scan other files in the "
|
MP_INFO(mpctx, "Will scan other files in the "
|
||||||
"same directory to find referenced sources.\n");
|
"same directory to find referenced sources.\n");
|
||||||
filenames = find_files(main_filename, ".mkv");
|
filenames = find_files(main_filename, ".mkv");
|
||||||
num_filenames = MP_TALLOC_ELEMS(filenames);
|
num_filenames = MP_TALLOC_ELEMS(filenames);
|
||||||
|
@ -288,14 +288,14 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx,
|
||||||
for (int i = 0; i < num_filenames; i++) {
|
for (int i = 0; i < num_filenames; i++) {
|
||||||
if (!missing(*sources, *num_sources))
|
if (!missing(*sources, *num_sources))
|
||||||
break;
|
break;
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_INFO, "Checking file %s\n", filenames[i]);
|
MP_INFO(mpctx, "Checking file %s\n", filenames[i]);
|
||||||
check_file(mpctx, sources, num_sources, uids, filenames[i], 0);
|
check_file(mpctx, sources, num_sources, uids, filenames[i], 0);
|
||||||
}
|
}
|
||||||
/* Loop while we have new sources to look for. */
|
/* Loop while we have new sources to look for. */
|
||||||
} while (old_source_count != *num_sources);
|
} while (old_source_count != *num_sources);
|
||||||
|
|
||||||
if (missing(*sources, *num_sources)) {
|
if (missing(*sources, *num_sources)) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_ERR, "Failed to find ordered chapter part!\n"
|
MP_ERR(mpctx, "Failed to find ordered chapter part!\n"
|
||||||
"There will be parts MISSING from the video!\n");
|
"There will be parts MISSING from the video!\n");
|
||||||
int j = 1;
|
int j = 1;
|
||||||
for (int i = 1; i < *num_sources; i++)
|
for (int i = 1; i < *num_sources; i++)
|
||||||
|
@ -313,7 +313,7 @@ static int find_ordered_chapter_sources(struct MPContext *mpctx,
|
||||||
return *num_sources;
|
return *num_sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t add_timeline_part(struct MPOpts *opts,
|
static int64_t add_timeline_part(struct MPContext *mpctx,
|
||||||
struct demuxer *source,
|
struct demuxer *source,
|
||||||
struct timeline_part **timeline,
|
struct timeline_part **timeline,
|
||||||
int *part_count,
|
int *part_count,
|
||||||
|
@ -331,7 +331,7 @@ static int64_t add_timeline_part(struct MPOpts *opts,
|
||||||
* we don't want to try seeking over a one frame gap. */
|
* we don't want to try seeking over a one frame gap. */
|
||||||
int64_t join_diff = start - *last_end_time;
|
int64_t join_diff = start - *last_end_time;
|
||||||
if (*part_count == 0
|
if (*part_count == 0
|
||||||
|| FFABS(join_diff) > opts->chapter_merge_threshold * 1e6
|
|| FFABS(join_diff) > mpctx->opts->chapter_merge_threshold * 1e6
|
||||||
|| source != (*timeline)[*part_count - 1].source) {
|
|| source != (*timeline)[*part_count - 1].source) {
|
||||||
struct timeline_part new = {
|
struct timeline_part new = {
|
||||||
.start = *starttime / 1e9,
|
.start = *starttime / 1e9,
|
||||||
|
@ -342,7 +342,7 @@ static int64_t add_timeline_part(struct MPOpts *opts,
|
||||||
} else if (*part_count > 0 && join_diff) {
|
} else if (*part_count > 0 && join_diff) {
|
||||||
/* Chapter was merged at an inexact boundary;
|
/* Chapter was merged at an inexact boundary;
|
||||||
* adjust timestamps to match. */
|
* adjust timestamps to match. */
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_V, "Merging timeline part %d with "
|
MP_VERBOSE(mpctx, "Merging timeline part %d with "
|
||||||
"offset %g ms.\n", *part_count, join_diff / 1e6);
|
"offset %g ms.\n", *part_count, join_diff / 1e6);
|
||||||
*starttime += join_diff;
|
*starttime += join_diff;
|
||||||
return join_diff;
|
return join_diff;
|
||||||
|
@ -351,7 +351,8 @@ static int64_t add_timeline_part(struct MPOpts *opts,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void account_missing_time(uint64_t *total_time,
|
static void account_missing_time(struct MPContext *mpctx,
|
||||||
|
uint64_t *total_time,
|
||||||
uint64_t new_time,
|
uint64_t new_time,
|
||||||
const char *message)
|
const char *message)
|
||||||
{
|
{
|
||||||
|
@ -359,12 +360,11 @@ static void account_missing_time(uint64_t *total_time,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
*total_time += new_time;
|
*total_time += new_time;
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_HINT,
|
MP_INFO(mpctx, "missing %"PRIu64" nanoseconds: %s\n",
|
||||||
"missing %"PRIu64" nanoseconds: %s\n",
|
|
||||||
new_time, message);
|
new_time, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void build_timeline_loop(struct MPOpts *opts,
|
static void build_timeline_loop(struct MPContext *mpctx,
|
||||||
struct demuxer **sources,
|
struct demuxer **sources,
|
||||||
int num_sources,
|
int num_sources,
|
||||||
int current_source,
|
int current_source,
|
||||||
|
@ -432,7 +432,7 @@ static void build_timeline_loop(struct MPOpts *opts,
|
||||||
* nothing we can get from it. Instead, mark the entire chapter
|
* nothing we can get from it. Instead, mark the entire chapter
|
||||||
* as missing and make the chapter length 0. */
|
* as missing and make the chapter length 0. */
|
||||||
if (source_full_length <= c->start) {
|
if (source_full_length <= c->start) {
|
||||||
account_missing_time(missing_time, chapter_length,
|
account_missing_time(mpctx, missing_time, chapter_length,
|
||||||
"referenced segment ends before the requested start time");
|
"referenced segment ends before the requested start time");
|
||||||
chapter_length = 0;
|
chapter_length = 0;
|
||||||
goto found;
|
goto found;
|
||||||
|
@ -444,12 +444,12 @@ static void build_timeline_loop(struct MPOpts *opts,
|
||||||
* we actually have to avoid playing off the end of the file
|
* we actually have to avoid playing off the end of the file
|
||||||
* and not switching to the next source. */
|
* and not switching to the next source. */
|
||||||
if (source_length < chapter_length) {
|
if (source_length < chapter_length) {
|
||||||
account_missing_time(missing_time, chapter_length - source_length,
|
account_missing_time(mpctx, missing_time, chapter_length - source_length,
|
||||||
"referenced segment ends before the requested end time");
|
"referenced segment ends before the requested end time");
|
||||||
chapter_length = source_length;
|
chapter_length = source_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
join_diff = add_timeline_part(opts, linked_source, timeline, part_count,
|
join_diff = add_timeline_part(mpctx, linked_source, timeline, part_count,
|
||||||
c->start, last_end_time, starttime);
|
c->start, last_end_time, starttime);
|
||||||
|
|
||||||
/* If we merged two chapters into a single part due to them
|
/* If we merged two chapters into a single part due to them
|
||||||
|
@ -467,7 +467,7 @@ static void build_timeline_loop(struct MPOpts *opts,
|
||||||
* timeline parts for each of its chapters, but not add them as
|
* timeline parts for each of its chapters, but not add them as
|
||||||
* chapters. */
|
* chapters. */
|
||||||
} else {
|
} else {
|
||||||
build_timeline_loop(opts, sources, num_sources, j, starttime,
|
build_timeline_loop(mpctx, sources, num_sources, j, starttime,
|
||||||
missing_time, last_end_time, timeline,
|
missing_time, last_end_time, timeline,
|
||||||
chapters, part_count, c->start, c->end);
|
chapters, part_count, c->start, c->end);
|
||||||
/* The loop call has added time as needed (we can't add it here
|
/* The loop call has added time as needed (we can't add it here
|
||||||
|
@ -481,7 +481,7 @@ static void build_timeline_loop(struct MPOpts *opts,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We're missing a part of the chapter, so add it to the accounting. */
|
/* We're missing a part of the chapter, so add it to the accounting. */
|
||||||
account_missing_time(missing_time, chapter_length,
|
account_missing_time(mpctx, missing_time, chapter_length,
|
||||||
"the source for a chapter could not be found");
|
"the source for a chapter could not be found");
|
||||||
/* We don't have the source, but don't leave a gap in the timeline for
|
/* We don't have the source, but don't leave a gap in the timeline for
|
||||||
* the source. */
|
* the source. */
|
||||||
|
@ -498,7 +498,7 @@ static void build_timeline_loop(struct MPOpts *opts,
|
||||||
|
|
||||||
/* If we stopped before the limit, add up the missing time. */
|
/* If we stopped before the limit, add up the missing time. */
|
||||||
if (local_starttime < limit)
|
if (local_starttime < limit)
|
||||||
account_missing_time(missing_time, limit - local_starttime,
|
account_missing_time(mpctx, missing_time, limit - local_starttime,
|
||||||
"nested ordered chapter segment is shorter than the requested end time");
|
"nested ordered chapter segment is shorter than the requested end time");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -507,12 +507,12 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx)
|
||||||
struct MPOpts *opts = mpctx->opts;
|
struct MPOpts *opts = mpctx->opts;
|
||||||
|
|
||||||
if (!opts->ordered_chapters) {
|
if (!opts->ordered_chapters) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_INFO, "File uses ordered chapters, but "
|
MP_INFO(mpctx, "File uses ordered chapters, but "
|
||||||
"you have disabled support for them. Ignoring.\n");
|
"you have disabled support for them. Ignoring.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_INFO, "File uses ordered chapters, will build "
|
MP_INFO(mpctx, "File uses ordered chapters, will build "
|
||||||
"edit timeline.\n");
|
"edit timeline.\n");
|
||||||
|
|
||||||
struct demuxer *demuxer = mpctx->demuxer;
|
struct demuxer *demuxer = mpctx->demuxer;
|
||||||
|
@ -558,7 +558,7 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx)
|
||||||
uint64_t missing_time = 0;
|
uint64_t missing_time = 0;
|
||||||
uint64_t last_end_time = 0;
|
uint64_t last_end_time = 0;
|
||||||
int part_count = 0;
|
int part_count = 0;
|
||||||
build_timeline_loop(opts, sources, num_sources, 0, &starttime,
|
build_timeline_loop(mpctx, sources, num_sources, 0, &starttime,
|
||||||
&missing_time, &last_end_time, &timeline,
|
&missing_time, &last_end_time, &timeline,
|
||||||
chapters, &part_count, 0, 0);
|
chapters, &part_count, 0, 0);
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx)
|
||||||
* users really notice less than a millisecond missing, maybe this can be
|
* users really notice less than a millisecond missing, maybe this can be
|
||||||
* revisited. */
|
* revisited. */
|
||||||
if (missing_time >= 1e6)
|
if (missing_time >= 1e6)
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_ERR, "There are %.3f seconds missing "
|
MP_ERR(mpctx, "There are %.3f seconds missing "
|
||||||
"from the timeline!\n", missing_time / 1e9);
|
"from the timeline!\n", missing_time / 1e9);
|
||||||
talloc_free(mpctx->sources);
|
talloc_free(mpctx->sources);
|
||||||
mpctx->sources = sources;
|
mpctx->sources = sources;
|
||||||
|
|
|
@ -133,7 +133,7 @@ static struct demuxer *open_file(char *filename, struct MPContext *mpctx)
|
||||||
d = demux_open(s, NULL, NULL, opts);
|
d = demux_open(s, NULL, NULL, opts);
|
||||||
}
|
}
|
||||||
if (!d) {
|
if (!d) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_ERR, "EDL: Could not open source file '%s'.\n",
|
MP_ERR(mpctx, "EDL: Could not open source file '%s'.\n",
|
||||||
filename);
|
filename);
|
||||||
free_stream(s);
|
free_stream(s);
|
||||||
}
|
}
|
||||||
|
@ -197,8 +197,7 @@ static void build_timeline(struct MPContext *mpctx, struct tl_parts *parts)
|
||||||
|
|
||||||
double len = source_get_length(source);
|
double len = source_get_length(source);
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_WARN,
|
MP_WARN(mpctx, "EDL: source file '%s' has unknown duration.\n",
|
||||||
"EDL: source file '%s' has unknown duration.\n",
|
|
||||||
part->filename);
|
part->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +209,7 @@ static void build_timeline(struct MPContext *mpctx, struct tl_parts *parts)
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
double partlen = part->offset + part->length;
|
double partlen = part->offset + part->length;
|
||||||
if (partlen > len) {
|
if (partlen > len) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_WARN, "EDL: entry %d uses %f "
|
MP_WARN(mpctx, "EDL: entry %d uses %f "
|
||||||
"seconds, but file has only %f seconds.\n",
|
"seconds, but file has only %f seconds.\n",
|
||||||
n, partlen, len);
|
n, partlen, len);
|
||||||
}
|
}
|
||||||
|
@ -263,7 +262,7 @@ void build_mpv_edl_timeline(struct MPContext *mpctx)
|
||||||
{
|
{
|
||||||
struct tl_parts *parts = parse_edl(mpctx->demuxer->file_contents);
|
struct tl_parts *parts = parse_edl(mpctx->demuxer->file_contents);
|
||||||
if (!parts) {
|
if (!parts) {
|
||||||
mp_msg(MSGT_CPLAYER, MSGL_ERR, "Error in EDL.\n");
|
MP_ERR(mpctx, "Error in EDL.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Source is .edl and not edl:// => don't allow arbitrary paths
|
// Source is .edl and not edl:// => don't allow arbitrary paths
|
||||||
|
|
Loading…
Reference in New Issue