Audacious  $Id:Doxyfile42802007-03-2104:39:00Znenolod$
Classes | Macros | Functions | Variables
tuple.c File Reference

Basic Tuple handling API. More...

#include <glib.h>
#include <pthread.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <audacious/i18n.h>
#include "audstrings.h"
#include "tuple.h"
#include "tuple_formatter.h"

Go to the source code of this file.

Classes

struct  TupleBasicType
union  TupleVal
struct  TupleBlock
struct  Tuple
 Structure for holding and passing around miscellaneous track metadata. More...
struct  FieldDictEntry

Macros

#define BLOCK_VALS   4
#define BIT(i)   ((int64_t) 1 << (i))
#define APPEND(b,...)

Functions

static int field_dict_compare (const void *a, const void *b)
EXPORT int tuple_field_by_name (const char *name)
EXPORT const char * tuple_field_get_name (int field)
EXPORT TupleValueType tuple_field_get_type (int field)
static TupleVallookup_val (Tuple *tuple, int field, bool_t add, bool_t remove)
static void tuple_destroy_unlocked (Tuple *tuple)
EXPORT Tuple * tuple_new (void)
EXPORT Tuple * tuple_ref (Tuple *tuple)
EXPORT void tuple_unref (Tuple *tuple)
EXPORT void tuple_set_filename (Tuple *tuple, const char *filename)
 Sets filename/URI related fields of a #Tuple structure, based on the given filename argument.
EXPORT Tuple * tuple_copy (const Tuple *old)
 Creates a copy of given Tuple structure, with copied data.
EXPORT Tuple * tuple_new_from_filename (const char *filename)
 Allocates a new #Tuple structure, setting filename/URI related fields based on the given filename argument by calling tuple_set_filename.
EXPORT void tuple_set_int (Tuple *tuple, int nfield, const char *field, int x)
EXPORT void tuple_set_str (Tuple *tuple, int nfield, const char *field, const char *str)
EXPORT void tuple_unset (Tuple *tuple, int nfield, const char *field)
EXPORT TupleValueType tuple_get_value_type (const Tuple *tuple, int nfield, const char *field)
 Returns TupleValueType of given #Tuple field.
EXPORT char * tuple_get_str (const Tuple *tuple, int nfield, const char *field)
EXPORT int tuple_get_int (const Tuple *tuple, int nfield, const char *field)
 Returns integer associated to #Tuple field.
EXPORT void tuple_set_format (Tuple *t, const char *format, int chans, int rate, int brate)
EXPORT void tuple_set_subtunes (Tuple *tuple, int n_subtunes, const int *subtunes)
EXPORT int tuple_get_n_subtunes (Tuple *tuple)
EXPORT int tuple_get_nth_subtune (Tuple *tuple, int n)
EXPORT char * tuple_format_title (Tuple *tuple, const char *format)

Variables

static const TupleBasicType tuple_fields [TUPLE_FIELDS]
 Ordered table of basic #Tuple field names and their TupleValueType.
static const FieldDictEntry field_dict [TUPLE_FIELDS]
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER

Detailed Description

Basic Tuple handling API.

Definition in file tuple.c.


Macro Definition Documentation

#define APPEND (   b,
  ... 
)
Value:
snprintf (b + strlen (b), sizeof b - strlen (b), \
__VA_ARGS__)

Definition at line 528 of file tuple.c.

Referenced by tuple_set_format().

#define BIT (   i)    ((int64_t) 1 << (i))

Definition at line 76 of file tuple.c.

Referenced by lookup_val().

#define BLOCK_VALS   4

Definition at line 39 of file tuple.c.

Referenced by lookup_val(), and tuple_destroy_unlocked().


Function Documentation

static int field_dict_compare ( const void *  a,
const void *  b 
)
static

Definition at line 160 of file tuple.c.

Referenced by tuple_field_by_name().

static TupleVal* lookup_val ( Tuple *  tuple,
int  field,
bool_t  add,
bool_t  remove 
)
static
EXPORT Tuple* tuple_copy ( const Tuple *  old)

Creates a copy of given Tuple structure, with copied data.

Parameters:
[in]srcTuple structure to be made a copy of.
Returns:
Pointer to newly allocated Tuple.

Definition at line 337 of file tuple.c.

static void tuple_destroy_unlocked ( Tuple *  tuple)
static

Definition at line 243 of file tuple.c.

Referenced by tuple_unref().

EXPORT int tuple_field_by_name ( const char *  name)
EXPORT const char* tuple_field_get_name ( int  field)

Definition at line 178 of file tuple.c.

Referenced by audacious_rc_get_tuple_fields().

EXPORT TupleValueType tuple_field_get_type ( int  field)

Definition at line 186 of file tuple.c.

Referenced by tuple_evalctx_add_var().

EXPORT char* tuple_format_title ( Tuple *  tuple,
const char *  format 
)

Definition at line 600 of file tuple.c.

Referenced by title_from_tuple().

EXPORT int tuple_get_int ( const Tuple *  tuple,
int  nfield,
const char *  field 
)

Returns integer associated to #Tuple field.

Desired field can be specified either by key name or if it is one of basic fields, by TupleBasicType index.

Parameters:
[in]tuple#Tuple structure pointer.
[in]cnfieldTupleBasicType index or -1 if key name is to be used instead.
[in]fieldString acting as key name or NULL if nfield is used.
Returns:
Integer value or 0 if the field/key did not exist.
Bug:
There is no way to distinguish error situations if the associated value is zero.

Definition at line 509 of file tuple.c.

Referenced by entry_set_tuple_real(), playback_thread(), read_gain_from_tuple(), tf_get_fieldval(), tuple_compare_int(), and tuple_value_to_gvalue().

EXPORT int tuple_get_n_subtunes ( Tuple *  tuple)

Definition at line 578 of file tuple.c.

Referenced by add_file().

EXPORT int tuple_get_nth_subtune ( Tuple *  tuple,
int  n 
)

Definition at line 588 of file tuple.c.

Referenced by add_file().

EXPORT char* tuple_get_str ( const Tuple *  tuple,
int  nfield,
const char *  field 
)
EXPORT TupleValueType tuple_get_value_type ( const Tuple *  tuple,
int  nfield,
const char *  field 
)

Returns TupleValueType of given #Tuple field.

Desired field can be specified either by key name or if it is one of basic fields, by TupleBasicType index.

Parameters:
[in]tuple#Tuple structure pointer.
[in]cnfieldTupleBasicType index or -1 if key name is to be used instead.
[in]fieldString acting as key name or NULL if nfield is used.
Returns:
TupleValueType of the field or TUPLE_UNKNOWN if there was an error.

Definition at line 459 of file tuple.c.

Referenced by entry_set_tuple_real(), playback_thread(), tf_get_fieldval(), tuple_compare_int(), and tuple_value_to_gvalue().

EXPORT Tuple* tuple_new ( void  )

Definition at line 267 of file tuple.c.

Referenced by tuple_copy(), and tuple_new_from_filename().

EXPORT Tuple* tuple_new_from_filename ( const char *  filename)

Allocates a new #Tuple structure, setting filename/URI related fields based on the given filename argument by calling tuple_set_filename.

Parameters:
[in]filenameFilename URI.
Returns:
Pointer to newly allocated Tuple.

Definition at line 373 of file tuple.c.

Referenced by entry_set_failed().

EXPORT Tuple* tuple_ref ( Tuple *  tuple)

Definition at line 274 of file tuple.c.

Referenced by playback_entry_get_tuple(), and playlist_entry_get_tuple().

EXPORT void tuple_set_filename ( Tuple *  tuple,
const char *  filename 
)

Sets filename/URI related fields of a #Tuple structure, based on the given filename argument.

The fields set are: FIELD_FILE_PATH, FIELD_FILE_NAME and FIELD_FILE_EXT.

Parameters:
[in]filenameFilename URI.
[in,out]tupleTuple structure to manipulate.

Definition at line 305 of file tuple.c.

Referenced by tuple_new_from_filename().

EXPORT void tuple_set_format ( Tuple *  t,
const char *  format,
int  chans,
int  rate,
int  brate 
)

Definition at line 531 of file tuple.c.

EXPORT void tuple_set_int ( Tuple *  tuple,
int  nfield,
const char *  field,
int  x 
)

Definition at line 381 of file tuple.c.

Referenced by tuple_set_filename(), and tuple_set_format().

EXPORT void tuple_set_str ( Tuple *  tuple,
int  nfield,
const char *  field,
const char *  str 
)

Definition at line 396 of file tuple.c.

Referenced by tuple_set_filename(), and tuple_set_format().

EXPORT void tuple_set_subtunes ( Tuple *  tuple,
int  n_subtunes,
const int subtunes 
)

Definition at line 564 of file tuple.c.

EXPORT void tuple_unref ( Tuple *  tuple)
EXPORT void tuple_unset ( Tuple *  tuple,
int  nfield,
const char *  field 
)

Definition at line 425 of file tuple.c.

Referenced by tuple_set_str().


Variable Documentation

const FieldDictEntry field_dict[TUPLE_FIELDS]
static

Definition at line 125 of file tuple.c.

pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER
static
const TupleBasicType tuple_fields[TUPLE_FIELDS]
static

Ordered table of basic #Tuple field names and their TupleValueType.

Definition at line 80 of file tuple.c.