本文整理汇总了C++中MP_WARN函数的典型用法代码示例。如果您正苦于以下问题:C++ MP_WARN函数的具体用法?C++ MP_WARN怎么用?C++ MP_WARN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MP_WARN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: video_init_best_codec
bool video_init_best_codec(struct dec_video *d_video, char* video_decoders)
{
assert(!d_video->vd_driver);
video_reset(d_video);
d_video->has_broken_packet_pts = -10; // needs 10 packets to reach decision
struct mp_decoder_entry *decoder = NULL;
struct mp_decoder_list *list =
mp_select_video_decoders(d_video->header->codec->codec, video_decoders);
mp_print_decoders(d_video->log, MSGL_V, "Codec list:", list);
for (int n = 0; n < list->num_entries; n++) {
struct mp_decoder_entry *sel = &list->entries[n];
const struct vd_functions *driver = find_driver(sel->family);
if (!driver)
continue;
MP_VERBOSE(d_video, "Opening video decoder %s:%s\n",
sel->family, sel->decoder);
d_video->vd_driver = driver;
if (init_video_codec(d_video, sel->decoder)) {
decoder = sel;
break;
}
d_video->vd_driver = NULL;
MP_WARN(d_video, "Video decoder init failed for "
"%s:%s\n", sel->family, sel->decoder);
}
if (d_video->vd_driver) {
d_video->decoder_desc =
talloc_asprintf(d_video, "%s [%s:%s]", decoder->desc, decoder->family,
decoder->decoder);
MP_VERBOSE(d_video, "Selected video codec: %s\n", d_video->decoder_desc);
} else {
MP_ERR(d_video, "Failed to initialize a video decoder for codec '%s'.\n",
d_video->header->codec->codec);
}
if (d_video->header->missing_timestamps) {
MP_WARN(d_video, "This stream has no timestamps!\n");
MP_WARN(d_video, "Making up playback time using %f FPS.\n", d_video->fps);
MP_WARN(d_video, "Seeking will probably fail badly.\n");
}
talloc_free(list);
return !!d_video->vd_driver;
}
示例2: encode_2pass_prepare
static void encode_2pass_prepare(struct encode_lavc_context *ctx,
AVDictionary **dictp,
AVStream *stream,
AVCodecContext *codec,
struct stream **bytebuf,
const char *prefix)
{
if (!*bytebuf) {
char buf[sizeof(ctx->avc->filename) + 12];
AVDictionaryEntry *de = av_dict_get(ctx->voptions, "flags", NULL, 0);
snprintf(buf, sizeof(buf), "%s-%s-pass1.log", ctx->avc->filename,
prefix);
buf[sizeof(buf) - 1] = 0;
if (value_has_flag(de ? de->value : "", "pass2")) {
if (!(*bytebuf = stream_open(buf, ctx->global))) {
MP_WARN(ctx, "%s: could not open '%s', "
"disabling 2-pass encoding at pass 2\n", prefix, buf);
codec->flags &= ~AV_CODEC_FLAG_PASS2;
set_to_avdictionary(ctx, dictp, "flags", "-pass2");
} else {
struct bstr content = stream_read_complete(*bytebuf, NULL,
1000000000);
if (content.start == NULL) {
MP_WARN(ctx, "%s: could not read '%s', "
"disabling 2-pass encoding at pass 1\n",
prefix, ctx->avc->filename);
} else {
content.start[content.len] = 0;
codec->stats_in = content.start;
}
free_stream(*bytebuf);
*bytebuf = NULL;
}
}
if (value_has_flag(de ? de->value : "", "pass1")) {
if (!(*bytebuf = open_output_stream(buf, ctx->global))) {
MP_WARN(ctx,
"%s: could not open '%s', disabling "
"2-pass encoding at pass 1\n",
prefix, ctx->avc->filename);
set_to_avdictionary(ctx, dictp, "flags", "-pass1");
}
}
}
}
示例3: cache_wakeup_and_wait
// Used by the main thread to wakeup the cache thread, and to wait for the
// cache thread. The cache mutex has to be locked when calling this function.
// *retry_time should be set to 0 on the first call.
// Returns CACHE_INTERRUPTED if the caller is supposed to abort.
static int cache_wakeup_and_wait(struct priv *s, double *retry_time)
{
if (stream_check_interrupt(s->cache))
return CACHE_INTERRUPTED;
double start = mp_time_sec();
if (!s->last_warn_time || start - s->last_warn_time >= CACHE_NO_SPAM) {
// Print a "more severe" warning after waiting 1 second and no new data
if ((*retry_time) >= 1.0) {
MP_ERR(s, "Cache keeps not responding.\n");
s->last_warn_time = start;
} else if (*retry_time > 0.1) {
MP_WARN(s, "Cache is not responding - slow/stuck network connection?\n");
s->last_warn_time = start;
}
}
pthread_cond_signal(&s->wakeup);
mpthread_cond_timedwait_rel(&s->wakeup, &s->mutex, CACHE_WAIT_TIME);
*retry_time += mp_time_sec() - start;
return 0;
}
示例4: ca_select_device
OSStatus ca_select_device(struct ao *ao, char* name, AudioDeviceID *device)
{
OSStatus err = noErr;
int selection = name ? strtol(name, (char **)NULL, 10) : -1;
if (errno == EINVAL || errno == ERANGE) {
selection = -1;
MP_WARN(ao, "device identifier '%s' is invalid\n", name);
}
*device = 0;
if (selection < 0) {
// device not set by user, get the default one
err = CA_GET(kAudioObjectSystemObject,
kAudioHardwarePropertyDefaultOutputDevice,
device);
CHECK_CA_ERROR("could not get default audio device");
} else {
*device = selection;
}
if (mp_msg_test(ao->log, MSGL_V)) {
char *desc;
err = CA_GET_STR(*device, kAudioObjectPropertyName, &desc);
CHECK_CA_ERROR("could not get selected audio device name");
MP_VERBOSE(ao, "selected audio output device: %s (%" PRIu32 ")\n",
desc, *device);
talloc_free(desc);
}
coreaudio_error:
return err;
}
示例5: config
static int config(struct vf_instance *vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
{
// calculate the missing parameters:
if(vf->priv->crop_w<=0 || vf->priv->crop_w>width) vf->priv->crop_w=width;
if(vf->priv->crop_h<=0 || vf->priv->crop_h>height) vf->priv->crop_h=height;
if(vf->priv->crop_x<0) vf->priv->crop_x=(width-vf->priv->crop_w)/2;
if(vf->priv->crop_y<0) vf->priv->crop_y=(height-vf->priv->crop_h)/2;
// rounding:
struct mp_imgfmt_desc fmt = mp_imgfmt_get_desc(outfmt);
vf->priv->crop_x = MP_ALIGN_DOWN(vf->priv->crop_x, fmt.align_x);
vf->priv->crop_y = MP_ALIGN_DOWN(vf->priv->crop_y, fmt.align_y);
// check:
if(vf->priv->crop_w+vf->priv->crop_x>width ||
vf->priv->crop_h+vf->priv->crop_y>height){
MP_WARN(vf, "Bad position/width/height - cropped area outside of the original!\n");
return 0;
}
vf_rescale_dsize(&d_width, &d_height, width, height,
vf->priv->crop_w, vf->priv->crop_h);
return vf_next_config(vf,vf->priv->crop_w,vf->priv->crop_h,d_width,d_height,flags,outfmt);
}
示例6: try_open
static bool try_open(struct timeline *tl, char *filename)
{
struct bstr bfilename = bstr0(filename);
// Avoid trying to open itself or another .cue file. Best would be
// to check the result of demuxer auto-detection, but the demuxer
// API doesn't allow this without opening a full demuxer.
if (bstr_case_endswith(bfilename, bstr0(".cue"))
|| bstrcasecmp(bstr0(tl->demuxer->filename), bfilename) == 0)
return false;
struct demuxer *d = demux_open_url(filename, NULL, tl->cancel, tl->global);
// Since .bin files are raw PCM data with no headers, we have to explicitly
// open them. Also, try to avoid to open files that are most likely not .bin
// files, as that would only play noise. Checking the file extension is
// fragile, but it's about the only way we have.
// TODO: maybe also could check if the .bin file is a multiple of the Audio
// CD sector size (2352 bytes)
if (!d && bstr_case_endswith(bfilename, bstr0(".bin"))) {
MP_WARN(tl, "CUE: Opening as BIN file!\n");
struct demuxer_params p = {.force_format = "rawaudio"};
d = demux_open_url(filename, &p, tl->cancel, tl->global);
}
if (d) {
add_source(tl, d);
return true;
}
MP_ERR(tl, "Could not open source '%s'!\n", filename);
return false;
}
示例7: init
static int init(struct ao *ao)
{
struct priv *p = ao->priv;
if (AF_FORMAT_IS_IEC61937(ao->format)) {
MP_WARN(ao, "detected IEC61937, redirecting to coreaudio_exclusive\n");
ao->redirect = "coreaudio_exclusive";
return CONTROL_ERROR;
}
if (!reinit_device(ao))
goto coreaudio_error;
if (p->change_physical_format)
init_physical_format(ao);
if (!ca_init_chmap(ao, p->device))
goto coreaudio_error;
ao->format = af_fmt_from_planar(ao->format);
AudioStreamBasicDescription asbd;
ca_fill_asbd(ao, &asbd);
if (!init_audiounit(ao, asbd))
goto coreaudio_error;
return CONTROL_OK;
coreaudio_error:
return CONTROL_ERROR;
}
示例8: ca_get_active_chmap
void ca_get_active_chmap(struct ao *ao, AudioDeviceID device, int channel_count,
struct mp_chmap *out_map)
{
// Apparently, we have to guess by looking back at the supported layouts,
// and I haven't found a property that retrieves the actual currently
// active channel layout.
struct mp_chmap_sel chmap_sel = {0};
ca_retrieve_layouts(ao, &chmap_sel, device);
// Use any exact match.
for (int n = 0; n < chmap_sel.num_chmaps; n++) {
if (chmap_sel.chmaps[n].num == channel_count) {
MP_VERBOSE(ao, "mismatching channels - fallback #%d\n", n);
*out_map = chmap_sel.chmaps[n];
return;
}
}
// Fall back to stereo or mono, and fill the rest with silence. (We don't
// know what the device expects. We could use a larger default layout here,
// but let's not.)
mp_chmap_from_channels(out_map, MPMIN(2, channel_count));
out_map->num = channel_count;
for (int n = 2; n < out_map->num; n++)
out_map->speaker[n] = MP_SPEAKER_ID_NA;
MP_WARN(ao, "mismatching channels - falling back to %s\n",
mp_chmap_to_str(out_map));
}
示例9: decode
static void decode(struct sd *sd, struct demux_packet *packet)
{
struct sd_ass_priv *ctx = sd->priv;
ASS_Track *track = ctx->ass_track;
if (ctx->converter) {
if (!sd->opts->sub_clear_on_seek && packet->pos >= 0 &&
check_packet_seen(sd, packet->pos))
return;
if (packet->duration < 0) {
if (!ctx->duration_unknown) {
MP_WARN(sd, "Subtitle with unknown duration.\n");
ctx->duration_unknown = true;
}
packet->duration = UNKNOWN_DURATION;
}
char **r = lavc_conv_decode(ctx->converter, packet);
for (int n = 0; r && r[n]; n++)
ass_process_data(track, r[n], strlen(r[n]));
if (ctx->duration_unknown) {
for (int n = 0; n < track->n_events - 1; n++) {
if (track->events[n].Duration == UNKNOWN_DURATION * 1000) {
track->events[n].Duration = track->events[n + 1].Start -
track->events[n].Start;
}
}
}
} else {
// Note that for this packet format, libass has an internal mechanism
// for discarding duplicate (already seen) packets.
ass_process_chunk(track, packet->buffer, packet->len,
llrint(packet->pts * 1000),
llrint(packet->duration * 1000));
}
}
示例10: select_format
static void select_format(struct ao *ao, AVCodec *codec)
{
int best_score = INT_MIN;
int best_format = 0;
// Check the encoder's list of supported formats.
for (const enum AVSampleFormat *sampleformat = codec->sample_fmts;
sampleformat && *sampleformat != AV_SAMPLE_FMT_NONE;
++sampleformat)
{
int fmt = af_from_avformat(*sampleformat);
if (!fmt) {
MP_WARN(ao, "unsupported lavc format %s",
av_get_sample_fmt_name(*sampleformat));
continue;
}
int score = af_format_conversion_score(fmt, ao->format);
if (score > best_score) {
best_score = score;
best_format = fmt;
}
}
if (best_format) {
ao->format = best_format;
} else {
MP_ERR(ao, "sample format not found\n"); // shouldn't happen
}
}
示例11: uninit
static void uninit(struct ao *ao)
{
struct priv *ac = ao->priv;
struct encode_lavc_context *ectx = ao->encode_lavc_ctx;
if (!ac || ac->shutdown)
return;
pthread_mutex_lock(&ectx->lock);
if (!encode_lavc_start(ectx)) {
MP_WARN(ao, "not even ready to encode audio at end -> dropped\n");
pthread_mutex_unlock(&ectx->lock);
return;
}
if (ac->stream) {
double outpts = ac->expected_next_pts;
if (!ectx->options->rawts && ectx->options->copyts)
outpts += ectx->discontinuity_pts_offset;
outpts += encode_lavc_getoffset(ectx, ac->codec);
encode(ao, outpts, NULL);
}
pthread_mutex_unlock(&ectx->lock);
ac->shutdown = true;
}
示例12: mp_load_per_file_config
static void mp_load_per_file_config(struct MPContext *mpctx)
{
struct MPOpts *opts = mpctx->opts;
char *confpath;
char cfg[512];
const char *file = mpctx->filename;
if (snprintf(cfg, sizeof(cfg), "%s.conf", file) >= sizeof(cfg)) {
MP_WARN(mpctx, "Filename is too long, "
"can not load file or directory specific config files\n");
return;
}
char *name = mp_basename(cfg);
if (opts->use_filedir_conf) {
bstr dir = mp_dirname(cfg);
char *dircfg = mp_path_join(NULL, dir, bstr0("mpv.conf"));
try_load_config(mpctx, dircfg, FILE_LOCAL_FLAGS);
talloc_free(dircfg);
if (try_load_config(mpctx, cfg, FILE_LOCAL_FLAGS))
return;
}
if ((confpath = mp_find_user_config_file(NULL, mpctx->global, name))) {
try_load_config(mpctx, confpath, FILE_LOCAL_FLAGS);
talloc_free(confpath);
}
}
示例13: drm_egl_init_deprecated
static int drm_egl_init_deprecated(struct MPGLContext *ctx, int flags)
{
if (ctx->vo->probing)
return -1;
MP_WARN(ctx->vo, "'drm-egl' is deprecated, use 'drm' instead.\n");
return drm_egl_init(ctx, flags);
}
示例14: show_sw_adapter_msg
static void show_sw_adapter_msg(struct MPGLContext *ctx)
{
struct priv *p = ctx->priv;
if (p->sw_adapter_msg_shown)
return;
MP_WARN(ctx->vo, "Using a software adapter\n");
p->sw_adapter_msg_shown = true;
}
示例15: archive_entry_seek
static int archive_entry_seek(stream_t *s, int64_t newpos)
{
struct priv *p = s->priv;
if (p->mpa && !p->broken_seek) {
locale_t oldlocale = uselocale(p->mpa->locale);
int r = archive_seek_data(p->mpa->arch, newpos, SEEK_SET);
uselocale(oldlocale);
if (r >= 0)
return 1;
MP_WARN(s, "possibly unsupported seeking - switching to reopening\n");
p->broken_seek = true;
if (reopen_archive(s) < STREAM_OK)
return -1;
}
// libarchive can't seek in most formats.
if (newpos < s->pos) {
// Hack seeking backwards into working by reopening the archive and
// starting over.
MP_VERBOSE(s, "trying to reopen archive for performing seek\n");
if (reopen_archive(s) < STREAM_OK)
return -1;
s->pos = 0;
}
if (newpos > s->pos) {
// For seeking forwards, just keep reading data (there's no libarchive
// skip function either).
char buffer[4096];
while (newpos > s->pos) {
if (mp_cancel_test(s->cancel))
return -1;
int size = MPMIN(newpos - s->pos, sizeof(buffer));
locale_t oldlocale = uselocale(p->mpa->locale);
int r = archive_read_data(p->mpa->arch, buffer, size);
if (r <= 0) {
if (r == 0 && newpos > p->entry_size) {
MP_ERR(s, "demuxer trying to seek beyond end of archive "
"entry\n");
} else if (r == 0) {
MP_ERR(s, "end of archive entry reached while seeking\n");
} else {
MP_ERR(s, "%s\n", archive_error_string(p->mpa->arch));
}
uselocale(oldlocale);
if (mp_archive_check_fatal(p->mpa, r)) {
mp_archive_free(p->mpa);
p->mpa = NULL;
}
return -1;
}
uselocale(oldlocale);
s->pos += r;
}
}
return 1;
}