本文整理汇总了C++中xmms_error_set函数的典型用法代码示例。如果您正苦于以下问题:C++ xmms_error_set函数的具体用法?C++ xmms_error_set怎么用?C++ xmms_error_set使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmms_error_set函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xmms_playlist_client_current_pos
/**
* Retrieve the position of the currently active xmms_medialib_entry_t
*
*/
xmmsv_t *
xmms_playlist_client_current_pos (xmms_playlist_t *playlist, const gchar *plname,
xmms_error_t *err)
{
guint32 pos;
xmmsv_coll_t *plcoll;
xmmsv_t *dict;
g_return_val_if_fail (playlist, 0);
g_mutex_lock (playlist->mutex);
plcoll = xmms_playlist_get_coll (playlist, plname, err);
if (plcoll == NULL) {
g_mutex_unlock (playlist->mutex);
xmms_error_set (err, XMMS_ERROR_INVAL, "no such playlist");
return 0;
}
pos = xmms_playlist_coll_get_currpos (plcoll);
if (pos == -1) {
xmms_error_set (err, XMMS_ERROR_GENERIC, "no current entry");
}
g_mutex_unlock (playlist->mutex);
dict = xmms_playlist_current_pos_msg_new (playlist, pos, plname);
return dict;
}
示例2: xmms_output_volume_set
static void
xmms_output_volume_set (xmms_output_t *output, const gchar *channel,
guint volume, xmms_error_t *error)
{
if (!output->plugin) {
xmms_error_set (error, XMMS_ERROR_GENERIC,
"couldn't set volume, output plugin not loaded");
return;
}
if (!xmms_output_plugin_method_volume_set_available (output->plugin)) {
xmms_error_set (error, XMMS_ERROR_GENERIC,
"operation not supported");
return;
}
if (volume > 100) {
xmms_error_set (error, XMMS_ERROR_INVAL, "volume out of range");
return;
}
if (!xmms_output_plugin_methods_volume_set (output->plugin, output, channel, volume)) {
xmms_error_set (error, XMMS_ERROR_GENERIC,
"couldn't set volume");
}
}
示例3: xmms_visualization_client_set_properties
static int32_t
xmms_visualization_client_set_properties (xmms_visualization_t *vis, int32_t id, xmmsv_t* prop, xmms_error_t *err)
{
xmms_vis_client_t *c;
xmmsv_dict_iter_t *it;
const gchar *key, *valstr;
xmmsv_t *value;
x_fetch_client (id);
if (!xmmsv_get_type (prop) == XMMSV_TYPE_DICT) {
xmms_error_set (err, XMMS_ERROR_INVAL, "properties must be sent as a dict!");
} else {
/* record every pair */
xmmsv_get_dict_iter (prop, &it);
while (xmmsv_dict_iter_valid (it)) {
if (!xmmsv_dict_iter_pair (it, &key, &value)) {
xmms_error_set (err, XMMS_ERROR_INVAL, "key-value property pair could not be read!");
} else if (!xmmsv_get_string (value, &valstr)) {
xmms_error_set (err, XMMS_ERROR_INVAL, "property value could not be read!");
} else if (!property_set (&c->prop, key, valstr)) {
xmms_error_set (err, XMMS_ERROR_INVAL, "property could not be set!");
}
xmmsv_dict_iter_next (it);
}
/* TODO: propagate new format to xform! */
}
x_release_client ();
return (++c->format);
}
示例4: xmms_playlist_client_current_active
/**
* Retrieve a copy of the name of the currently active playlist.
*
*/
static gchar *
xmms_playlist_client_current_active (xmms_playlist_t *playlist, xmms_error_t *err)
{
gchar *alias = NULL;
xmmsv_coll_t *active_coll;
g_return_val_if_fail (playlist, 0);
g_mutex_lock (playlist->mutex);
active_coll = xmms_playlist_get_coll (playlist, XMMS_ACTIVE_PLAYLIST, err);
if (active_coll != NULL) {
alias = xmms_collection_find_alias (playlist->colldag,
XMMS_COLLECTION_NSID_PLAYLISTS,
active_coll, XMMS_ACTIVE_PLAYLIST);
if (alias == NULL) {
xmms_error_set (err, XMMS_ERROR_GENERIC, "active playlist not referenced!");
}
} else {
xmms_error_set (err, XMMS_ERROR_GENERIC, "no active playlist");
}
g_mutex_unlock (playlist->mutex);
return alias;
}
示例5: xmms_fetch_spec_new_organize
static xmms_fetch_spec_t *
xmms_fetch_spec_new_organize (xmmsv_t *fetch, xmms_fetch_info_t *info,
s4_sourcepref_t *prefs, xmms_error_t *err)
{
xmms_fetch_spec_t *spec;
xmmsv_dict_iter_t *it;
s4_sourcepref_t *sp;
xmmsv_t *org_data;
gint org_idx;
if (!xmmsv_dict_get (fetch, "data", &org_data)) {
xmms_error_set (err, XMMS_ERROR_INVAL, "Required field 'data' not set in organize.");
return NULL;
}
if (xmmsv_get_type (org_data) != XMMSV_TYPE_DICT) {
xmms_error_set (err, XMMS_ERROR_INVAL, "Field 'data' in organize must be a dict.");
return NULL;
}
sp = normalize_source_preferences (fetch, prefs, err);
if (xmms_error_iserror (err)) {
return NULL;
}
spec = g_new0 (xmms_fetch_spec_t, 1);
spec->type = FETCH_ORGANIZE;
spec->data.organize.count = xmmsv_dict_get_size (org_data);
spec->data.organize.keys = g_new0 (const char *, spec->data.organize.count);
spec->data.organize.data = g_new0 (xmms_fetch_spec_t *, spec->data.organize.count);
org_idx = 0;
xmmsv_get_dict_iter (org_data, &it);
while (xmmsv_dict_iter_valid (it)) {
xmms_fetch_spec_t *orgee;
const gchar *str;
xmmsv_t *entry;
xmmsv_dict_iter_pair (it, &str, &entry);
orgee = xmms_fetch_spec_new (entry, info, sp, err);
if (xmms_error_iserror (err)) {
xmms_fetch_spec_free (spec);
spec = NULL;
break;
}
spec->data.organize.keys[org_idx] = str;
spec->data.organize.data[org_idx] = orgee;
org_idx++;
xmmsv_dict_iter_next (it);
}
xmmsv_dict_iter_explicit_destroy (it);
s4_sourcepref_unref (sp);
return spec;
}
示例6: xmms_playlist_client_load
static void
xmms_playlist_client_load (xmms_playlist_t *playlist, const gchar *name, xmms_error_t *err)
{
xmmsv_coll_t *plcoll, *active_coll;
if (strcmp (name, XMMS_ACTIVE_PLAYLIST) == 0) {
xmms_error_set (err, XMMS_ERROR_INVAL, "invalid playlist to load");
return;
}
active_coll = xmms_playlist_get_coll (playlist, XMMS_ACTIVE_PLAYLIST, err);
if (active_coll == NULL) {
xmms_error_set (err, XMMS_ERROR_GENERIC, "no active playlist");
return;
}
plcoll = xmms_playlist_get_coll (playlist, name, err);
if (plcoll == NULL) {
xmms_error_set (err, XMMS_ERROR_NOENT, "no such playlist");
return;
}
if (active_coll == plcoll) {
XMMS_DBG ("Not loading %s playlist, already active!", name);
return;
}
XMMS_DBG ("Loading new playlist! %s", name);
xmms_collection_update_pointer (playlist->colldag, XMMS_ACTIVE_PLAYLIST,
XMMS_COLLECTION_NSID_PLAYLISTS, plcoll);
xmms_object_emit (XMMS_OBJECT (playlist),
XMMS_IPC_SIGNAL_PLAYLIST_LOADED,
xmmsv_new_string (name));
}
示例7: __int_xmms_cmd_add
static void
__int_xmms_cmd_add (xmms_object_t *object, xmms_object_cmd_arg_t *arg)
{
xmmsv_t *t;
if (xmmsv_list_get_size (arg->args) != 1) {
XMMS_DBG ("Wrong number of arguments to add (%d)", xmmsv_list_get_size (arg->args));
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Wrong number of arguments to add");
return;
}
GString * argval0;
if (!xmmsv_list_get (arg->args, 0, &t)) {
XMMS_DBG ("Missing arg 0 in add");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Missing arg 0 in add");
return;
}
if (!xmms_bin_to_gstring (t, &argval0)) {
XMMS_DBG ("Error parsing arg 0 in add");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Error parsing arg 0 in add");
return;
}
gchar * retval = xmms_bindata_client_add ((xmms_bindata_t *) object, argval0, &arg->error);
if (retval != NULL) {
arg->retval = xmms_convert_and_kill_string (retval);
}
}
示例8: __int_xmms_cmd_remove
static void
__int_xmms_cmd_remove (xmms_object_t *object, xmms_object_cmd_arg_t *arg)
{
xmmsv_t *t;
if (xmmsv_list_get_size (arg->args) != 1) {
XMMS_DBG ("Wrong number of arguments to remove (%d)", xmmsv_list_get_size (arg->args));
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Wrong number of arguments to remove");
return;
}
const char * argval0;
if (!xmmsv_list_get (arg->args, 0, &t)) {
XMMS_DBG ("Missing arg 0 in remove");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Missing arg 0 in remove");
return;
}
if (!xmmsv_get_string (t, &argval0)) {
XMMS_DBG ("Error parsing arg 0 in remove");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Error parsing arg 0 in remove");
return;
}
xmms_bindata_client_remove ((xmms_bindata_t *) object, argval0, &arg->error);
arg->retval = xmmsv_new_none ();
}
示例9: __int_xmms_cmd_rehash
static void
__int_xmms_cmd_rehash (xmms_object_t *object, xmms_object_cmd_arg_t *arg)
{
xmmsv_t *t;
if (xmmsv_list_get_size (arg->args) != 1) {
XMMS_DBG ("Wrong number of arguments to rehash (%d)", xmmsv_list_get_size (arg->args));
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Wrong number of arguments to rehash");
return;
}
gint32 argval0;
if (!xmmsv_list_get (arg->args, 0, &t)) {
XMMS_DBG ("Missing arg 0 in rehash");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Missing arg 0 in rehash");
return;
}
if (!xmmsv_get_int (t, &argval0)) {
XMMS_DBG ("Error parsing arg 0 in rehash");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Error parsing arg 0 in rehash");
return;
}
xmms_medialib_client_rehash ((xmms_medialib_t *) object, argval0, &arg->error);
arg->retval = xmmsv_new_none ();
}
示例10: xmms_playlist_insert_entry
/**
* Insert an entry at a given position in the playlist without
* validating it.
*
* @internal
*/
void
xmms_playlist_insert_entry (xmms_playlist_t *playlist, const gchar *plname,
guint32 pos, xmms_medialib_entry_t file,
xmms_error_t *err)
{
xmms_medialib_session_t *session;
xmmsv_t *dict;
gint currpos;
gint len;
xmmsv_coll_t *plcoll;
gboolean valid;
g_mutex_lock (playlist->mutex);
do {
session = xmms_medialib_session_begin_ro (playlist->medialib);
valid = xmms_medialib_check_id (session, file);
} while (!xmms_medialib_session_commit (session));
if (!valid) {
g_mutex_unlock (playlist->mutex);
xmms_error_set (err, XMMS_ERROR_NOENT,
"That is not a valid medialib id!");
return;
}
plcoll = xmms_playlist_get_coll (playlist, plname, err);
if (plcoll == NULL) {
/* FIXME: happens ? */
g_mutex_unlock (playlist->mutex);
return;
}
len = xmms_playlist_coll_get_size (plcoll);
if (pos > len) {
xmms_error_set (err, XMMS_ERROR_GENERIC,
"Could not insert entry outside of playlist!");
g_mutex_unlock (playlist->mutex);
return;
}
xmmsv_coll_idlist_insert (plcoll, pos, file);
/** propagate the MID ! */
dict = xmms_playlist_changed_msg_new (playlist, XMMS_PLAYLIST_CHANGED_INSERT, file, plname);
xmmsv_dict_set_int (dict, "position", pos);
xmms_playlist_changed_msg_send (playlist, dict);
/** update position once client is familiar with the new item. */
currpos = xmms_playlist_coll_get_currpos (plcoll);
if (pos <= currpos) {
currpos++;
xmms_collection_set_int_attr (plcoll, "position", currpos);
XMMS_PLAYLIST_CURRPOS_MSG (currpos, plname);
}
g_mutex_unlock (playlist->mutex);
}
示例11: xmms_mpg123_read
static gint
xmms_mpg123_read (xmms_xform_t *xform, xmms_sample_t *buf, gint len,
xmms_error_t *err)
{
xmms_mpg123_data_t *data;
int result = MPG123_OK;
size_t read = 0;
data = xmms_xform_private_data_get (xform);
g_return_val_if_fail (data, -1);
while (read == 0) {
gint ret = 0;
if (result == MPG123_NEED_MORE) {
ret = xmms_xform_read (xform, data->buf, BUFSIZE, err);
if (ret < 0) {
return ret;
} else if (ret == 0) {
data->eof_found = TRUE;
}
}
result = mpg123_decode (data->decoder, data->buf, (size_t) ret,
buf, len, &read);
if (result == MPG123_NEED_MORE && data->eof_found) {
/* We need more data, but there's none available
* so libmpg123 apparently missed an EOF */
result = MPG123_DONE;
break;
} else if (result != MPG123_OK && result != MPG123_NEED_MORE) {
/* This is some uncommon result like EOF, handle outside
* the loop */
break;
}
}
if (result == MPG123_DONE) {
/* This is just normal EOF reported from libmpg123 */
XMMS_DBG ("Got EOF while decoding stream");
return 0;
} else if (result == MPG123_NEW_FORMAT) {
/* FIXME: When we can handle format changes, modify this */
xmms_error_set (err,
XMMS_ERROR_GENERIC,
"The output format changed, XMMS2 can't handle that");
return -1;
} else if (result == MPG123_ERR) {
xmms_error_set (err,
XMMS_ERROR_GENERIC,
mpg123_strerror (data->decoder));
return -1;
}
return (gint) read;
}
示例12: xmms_mpc_read
static gint
xmms_mpc_read (xmms_xform_t *xform, xmms_sample_t *buffer,
gint len, xmms_error_t *err)
{
MPC_SAMPLE_FORMAT internal[MPC_DECODER_BUFFER_LENGTH];
xmms_mpc_data_t *data;
mpc_uint32_t ret;
guint size;
data = xmms_xform_private_data_get (xform);
size = MIN (data->buffer->len, len);
#ifdef HAVE_MPCDEC_OLD
if (size <= 0) {
ret = mpc_decoder_decode (&data->decoder, internal, NULL, NULL);
if (ret == -1) {
xmms_error_set (err, XMMS_ERROR_GENERIC, "Musepack decoder failed");
return -1;
}
ret *= xmms_sample_size_get (XMMS_SAMPLE_FORMAT_FLOAT);
ret *= data->info.channels;
g_string_append_len (data->buffer, (gchar *) internal, ret);
}
#else
if (size <= 0) {
mpc_frame_info frame;
frame.buffer = internal;
do {
ret = mpc_demux_decode (data->demux, &frame);
} while (frame.bits != -1 && frame.samples == 0);
if (frame.bits == -1 && ret != MPC_STATUS_OK) {
xmms_error_set (err, XMMS_ERROR_GENERIC, "Musepack decoder failed");
return -1;
}
ret = frame.samples;
ret *= xmms_sample_size_get (XMMS_SAMPLE_FORMAT_FLOAT);
ret *= data->info.channels;
g_string_append_len (data->buffer, (gchar *) internal, ret);
}
#endif
/* Update the current size of available data */
size = MIN (data->buffer->len, len);
memcpy (buffer, data->buffer->str, size);
g_string_erase (data->buffer, 0, size);
return size;
}
示例13: normalize_metadata_fields
static xmmsv_t *
normalize_metadata_fields (xmmsv_t *fetch, xmms_error_t *err)
{
gpointer SENTINEL = GINT_TO_POINTER (0x31337);
GHashTable *table;
xmmsv_list_iter_t *it;
xmmsv_t *fields;
if (!xmmsv_dict_get (fetch, "fields", &fields)) {
/* No fields means that we should fetch all fields */
return NULL;
}
if (xmmsv_get_type (fields) != XMMSV_TYPE_LIST) {
const gchar *message = "'fields' must be a list of strings.";
xmms_error_set (err, XMMS_ERROR_INVAL, message);
return NULL;
}
if (xmmsv_list_get_size (fields) < 1) {
/* No fields means that we should fetch all fields */
return NULL;
}
table = g_hash_table_new (g_str_hash, g_str_equal);
xmmsv_get_list_iter (fields, &it);
while (xmmsv_list_iter_valid (it)) {
const gchar *value = NULL;
if (!xmmsv_list_iter_entry_string (it, &value)) {
const gchar *message = "'fields' entries must be of string type.";
xmms_error_set (err, XMMS_ERROR_INVAL, message);
g_hash_table_unref (table);
return NULL;
}
if (g_hash_table_lookup (table, (gpointer) value) == SENTINEL) {
const gchar *message = "'fields' entries must be unique.";
xmms_error_set (err, XMMS_ERROR_INVAL, message);
g_hash_table_unref (table);
return NULL;
}
g_hash_table_insert (table, (gpointer) value, SENTINEL);
xmmsv_list_iter_next (it);
}
g_hash_table_unref (table);
return fields;
}
示例14: __int_xmms_cmd_set_property_int
static void
__int_xmms_cmd_set_property_int (xmms_object_t *object, xmms_object_cmd_arg_t *arg)
{
xmmsv_t *t;
if (xmmsv_list_get_size (arg->args) != 4) {
XMMS_DBG ("Wrong number of arguments to set_property_int (%d)", xmmsv_list_get_size (arg->args));
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Wrong number of arguments to set_property_int");
return;
}
gint32 argval0;
const char * argval1;
const char * argval2;
gint32 argval3;
if (!xmmsv_list_get (arg->args, 0, &t)) {
XMMS_DBG ("Missing arg 0 in set_property_int");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Missing arg 0 in set_property_int");
return;
}
if (!xmmsv_get_int (t, &argval0)) {
XMMS_DBG ("Error parsing arg 0 in set_property_int");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Error parsing arg 0 in set_property_int");
return;
}
if (!xmmsv_list_get (arg->args, 1, &t)) {
XMMS_DBG ("Missing arg 1 in set_property_int");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Missing arg 1 in set_property_int");
return;
}
if (!xmmsv_get_string (t, &argval1)) {
XMMS_DBG ("Error parsing arg 1 in set_property_int");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Error parsing arg 1 in set_property_int");
return;
}
if (!xmmsv_list_get (arg->args, 2, &t)) {
XMMS_DBG ("Missing arg 2 in set_property_int");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Missing arg 2 in set_property_int");
return;
}
if (!xmmsv_get_string (t, &argval2)) {
XMMS_DBG ("Error parsing arg 2 in set_property_int");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Error parsing arg 2 in set_property_int");
return;
}
if (!xmmsv_list_get (arg->args, 3, &t)) {
XMMS_DBG ("Missing arg 3 in set_property_int");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Missing arg 3 in set_property_int");
return;
}
if (!xmmsv_get_int (t, &argval3)) {
XMMS_DBG ("Error parsing arg 3 in set_property_int");
xmms_error_set (&arg->error, XMMS_ERROR_INVAL, "Error parsing arg 3 in set_property_int");
return;
}
xmms_medialib_client_set_property_int ((xmms_medialib_t *) object, argval0, argval1, argval2, argval3, &arg->error);
arg->retval = xmmsv_new_none ();
}
示例15: xmms_xspf_browse
static gboolean
xmms_xspf_browse (xmms_xform_t *xform, const gchar *url, xmms_error_t *error)
{
int ret;
char buf[4096];
xmlParserCtxtPtr ctx;
xmlDocPtr doc;
g_return_val_if_fail (xform, FALSE);
xmms_error_reset (error);
ctx = xmlCreatePushParserCtxt (NULL, NULL, buf, 0, NULL);
if (!ctx) {
xmms_error_set (error, XMMS_ERROR_OOM, "Could not allocate xml parser");
return FALSE;
}
while ((ret = xmms_xform_read (xform, buf, sizeof (buf), error)) > 0) {
if ((xmlParseChunk (ctx, buf, ret, 0)) != 0) {
break;
}
}
if (ret < 0) {
xmms_error_set (error, XMMS_ERROR_GENERIC,
"failed to read data from previous xform");
xmlFreeParserCtxt (ctx);
return FALSE;
}
xmlParseChunk (ctx, buf, 0, 1);
if (ctx->lastError.message) {
xmms_error_set (error, XMMS_ERROR_INVAL, ctx->lastError.message);
xmlFreeParserCtxt (ctx);
return FALSE;
}
doc = ctx->myDoc;
if (!xmms_xspf_browse_add_entries (xform, doc, error)) {
xmlFreeParserCtxt (ctx);
return FALSE;
}
xmms_error_reset (error);
xmlFreeParserCtxt (ctx);
return TRUE;
}