mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-20 03:52:22 +02:00
client API: add mpv_load_config_file()
This is probably a good idea, because it would make it easier for software embedding mpv to configure the mpv parts, without requiring the host program to provide explicit mechanisms for this (other than calling mpv_load_config_file()).
This commit is contained in:
parent
caa939aa91
commit
537ac1a15f
@ -311,6 +311,30 @@ int mpv_initialize(mpv_handle *ctx);
|
|||||||
*/
|
*/
|
||||||
void mpv_destroy(mpv_handle *ctx);
|
void mpv_destroy(mpv_handle *ctx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load a config file. This loads and parses the file, and sets every entry in
|
||||||
|
* the config file's default section as if mpv_set_option_string() is called.
|
||||||
|
*
|
||||||
|
* The filename should be an absolute path. If it isn't, the actual path used
|
||||||
|
* is unspecified. (Note: an absolute path starts with '/' on UNIX.) If the
|
||||||
|
* file wasn't found, MPV_ERROR_INVALID_PARAMETER is returned.
|
||||||
|
*
|
||||||
|
* If a fatal error happens when parsing a config file, MPV_ERROR_OPTION_ERROR
|
||||||
|
* is returned. Errors when setting options as well as other types or errors
|
||||||
|
* are ignored (even if options do not exist). You can still try to capture
|
||||||
|
* the resulting error messages with mpv_request_log_messages(). Note that it's
|
||||||
|
* possible that some options were successfully set even if any of these errors
|
||||||
|
* happen.
|
||||||
|
*
|
||||||
|
* The same restrictions as with mpv_set_option() apply: some options can't
|
||||||
|
* be set outside of idle or uninitialized state, and many options don't
|
||||||
|
* take effect immediately.
|
||||||
|
*
|
||||||
|
* @param filename absolute path to the config file on the local filesystem
|
||||||
|
* @return error code
|
||||||
|
*/
|
||||||
|
int mpv_load_config_file(mpv_handle *ctx, const char *filename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop the playback thread. Normally, the client API stops the playback thread
|
* Stop the playback thread. Normally, the client API stops the playback thread
|
||||||
* automatically in order to process requests. However, the playback thread is
|
* automatically in order to process requests. However, the playback thread is
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
#include "options/m_config.h"
|
#include "options/m_config.h"
|
||||||
#include "options/m_option.h"
|
#include "options/m_option.h"
|
||||||
#include "options/m_property.h"
|
#include "options/m_property.h"
|
||||||
|
#include "options/path.h"
|
||||||
|
#include "options/parse_configfile.h"
|
||||||
#include "osdep/threads.h"
|
#include "osdep/threads.h"
|
||||||
#include "osdep/timer.h"
|
#include "osdep/timer.h"
|
||||||
#include "osdep/io.h"
|
#include "osdep/io.h"
|
||||||
@ -1221,6 +1223,19 @@ static bool gen_property_change_event(struct mpv_handle *ctx)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mpv_load_config_file(mpv_handle *ctx, const char *filename)
|
||||||
|
{
|
||||||
|
int flags = ctx->mpctx->initialized ? M_SETOPT_RUNTIME : 0;
|
||||||
|
lock_core(ctx);
|
||||||
|
int r = m_config_parse_config_file(ctx->mpctx->mconfig, filename, NULL, flags);
|
||||||
|
unlock_core(ctx);
|
||||||
|
if (r == 0)
|
||||||
|
return MPV_ERROR_INVALID_PARAMETER;
|
||||||
|
if (r < 0)
|
||||||
|
return MPV_ERROR_OPTION_ERROR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int mpv_request_log_messages(mpv_handle *ctx, const char *min_level)
|
int mpv_request_log_messages(mpv_handle *ctx, const char *min_level)
|
||||||
{
|
{
|
||||||
int level = -1;
|
int level = -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user