* Adrien Maglo <magsoft@videolan.org>
* Srikanth Raju <srikiraju at gmail dot com>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef VLC_MEDIA_LIBRARY_H
# endif
#include <vlc_common.h>
-#include <assert.h>
#include <vlc_playlist.h>
/*****************************************************************************
* @return The media library object. NULL if the media library
* object could not be loaded
*/
-VLC_EXPORT( media_library_t*, __ml_Hold, ( vlc_object_t* p_this ) );
-#define ml_Hold( a ) __ml_Hold( VLC_OBJECT(a) )
-
-/**
- * @brief Discard your ref to media library
- * @param p_this The object holding the media library
- */
-VLC_EXPORT( void, __ml_Release, ( vlc_object_t* p_this ) );
-#define ml_Release(a) __ml_Release( VLC_OBJECT(a))
+VLC_API media_library_t* ml_Get( vlc_object_t* p_this );
+#define ml_Get( a ) ml_Get( VLC_OBJECT(a) )
/**
* @brief Create a Media Library VLC object.
* @param psz_name Name for the module
* @return The ML object.
*/
-VLC_EXPORT( media_library_t*, __ml_Create, ( vlc_object_t *p_this, char* psz_name ) );
+VLC_API media_library_t* ml_Create( vlc_object_t *p_this, char* psz_name );
/**
* @brief Destructor for the Media library singleton
* @param p_this Parent the ML object is attached to
*/
-VLC_EXPORT( void, __ml_Destroy, ( vlc_object_t* p_this ) );
+VLC_API void ml_Destroy( vlc_object_t* p_this );
/**
* @brief Control the Media Library
*/
static inline void ml_gc_incref( ml_media_t* p_media )
{
- unsigned refs;
ml_gc_object_t* p_gc = &p_media->ml_gc_data;
- assert( p_gc );
+ if( p_gc == NULL )
+ return;
vlc_spin_lock (&p_gc->spin);
- refs = ++p_gc->refs;
+ ++p_gc->refs;
vlc_spin_unlock (&p_gc->spin);
- assert (refs != 1); /* there had to be a reference already */
}
/**
unsigned refs;
bool pool;
ml_gc_object_t* p_gc = &p_media->ml_gc_data;
- assert( p_gc );
+ if( p_gc == NULL )
+ return;
vlc_spin_lock (&p_gc->spin);
- assert( p_gc->refs != 0 );
refs = --p_gc->refs;
pool = p_gc->pool;
- assert( ( refs != 0 && p_gc->pool == true ) || ( refs == 0 && p_gc->pool == false ) );
vlc_spin_unlock (&p_gc->spin);
- if( refs == 0 && pool == false )
+ if( refs == 0 && !pool )
{
vlc_spin_destroy (&p_gc->spin);
p_gc->pf_destructor (p_gc);
*/
static inline void ml_FreeMediaContent( ml_media_t *p_media )
{
- free( p_media->psz_uri );
- free( p_media->psz_title );
- free( p_media->psz_orig_title );
- free( p_media->psz_cover );
- free( p_media->psz_comment );
- free( p_media->psz_extra );
- free( p_media->psz_genre );
- free( p_media->psz_album );
- free( p_media->psz_preview );
- free( p_media->psz_language );
+ FREENULL( p_media->psz_uri );
+ FREENULL( p_media->psz_title );
+ FREENULL( p_media->psz_orig_title );
+ FREENULL( p_media->psz_cover );
+ FREENULL( p_media->psz_comment );
+ FREENULL( p_media->psz_extra );
+ FREENULL( p_media->psz_genre );
+ FREENULL( p_media->psz_album );
+ FREENULL( p_media->psz_preview );
+ FREENULL( p_media->psz_language );
ml_FreePeople( p_media->p_people );
p_media->b_sparse = true;
p_media->i_id = 0;
* @param select Type of object
* @param reload Whether to reload from database
*/
-VLC_EXPORT( ml_media_t*, media_New, ( media_library_t* p_ml, int id,
- ml_select_e select, bool reload ) );
+VLC_API ml_media_t *media_New( media_library_t* p_ml, int id,
+ ml_select_e select, bool reload );
/* Forward declaration */
static inline int ml_CopyMedia( ml_media_t *b, ml_media_t *a )
{
if( !a || !b ) return VLC_EGENERIC;
- assert( a != b );
+ if( a == b ) return VLC_SUCCESS;
ml_LockMedia( a );
ml_LockMedia( b );
b->b_sparse = a->b_sparse;
b->i_bitrate = a->i_bitrate;
b->i_samplerate = a->i_samplerate;
b->i_bpm = a->i_bpm;
- free( b->psz_uri );
+ FREENULL( b->psz_uri );
if( a->psz_uri )
b->psz_uri = strdup( a->psz_uri );
- free( b->psz_title );
+ FREENULL( b->psz_title );
if( a->psz_title )
b->psz_title = strdup( a->psz_title );
- free( b->psz_orig_title );
+ FREENULL( b->psz_orig_title );
if( a->psz_orig_title )
b->psz_orig_title = strdup( a->psz_orig_title );
- free( b->psz_album );
+ FREENULL( b->psz_album );
if( a->psz_album )
b->psz_album = strdup( a->psz_album );
- free( b->psz_cover );
+ FREENULL( b->psz_cover );
if( a->psz_cover )
b->psz_cover = strdup( a->psz_cover );
- free( b->psz_genre );
+ FREENULL( b->psz_genre );
if( a->psz_genre )
b->psz_genre = strdup( a->psz_genre );
- free( b->psz_comment );
+ FREENULL( b->psz_comment );
if( a->psz_comment )
b->psz_comment = strdup( a->psz_comment );
- free( b->psz_extra );
+ FREENULL( b->psz_extra );
if( a->psz_extra )
b->psz_extra = strdup( a->psz_extra );
- free( b->psz_preview );
+ FREENULL( b->psz_preview );
if( a->psz_preview )
b->psz_preview = strdup( a->psz_preview );
- free( b->psz_language );
+ FREENULL( b->psz_language );
if( a->psz_language )
b->psz_language = strdup( a->psz_language );
ml_FreePeople( b->p_people );
+ b->p_people = NULL;
if( a->p_people ) ml_CopyPersons( &( b->p_people ), a->p_people );
ml_UnlockMedia( b );
ml_UnlockMedia( a );
free( tree->right );
}
if( tree->op == ML_OP_NONE && ml_AttributeIsString( tree->criteria )
- && freestrings == true)
+ && freestrings)
{
free( tree->value.str );
if( tree->criteria == ML_PEOPLE )
* If op = ML_OP_NONE, then you are connecting to a tree consisting of
* only SPECIAL nodes.
* If op = ML_OP_NOT, then right MUST be NULL
- * op must not be ML_OP_SPECIAL, @see __ml_FtreeSpec
+ * op must not be ML_OP_SPECIAL, @see ml_FtreeSpec
* @param left part of the tree
* @param right part of the tree
* @return Pointer to new tree
* @note Use the helpers!
*/
-VLC_EXPORT( ml_ftree_t*, ml_OpConnectChilds, ( ml_op_e op, ml_ftree_t* left,
- ml_ftree_t* right ) );
+VLC_API ml_ftree_t *ml_OpConnectChilds( ml_op_e op, ml_ftree_t* left,
+ ml_ftree_t* right );
/**
* @brief Attaches a special node to a tree
* @return Pointer to new tree
* @note Use the helpers
*/
-VLC_EXPORT( ml_ftree_t*, __ml_FtreeSpec, ( ml_ftree_t* tree,
+VLC_API ml_ftree_t *ml_FtreeSpec( ml_ftree_t* tree,
ml_select_e crit,
int limit,
- char* sort ) );
+ char* sort );
/**
* @brief This function gives quick sequential adding capability
#define ml_FtreeOr( left, right ) ml_OpConnectChilds( ML_OP_OR, left, right )
#define ml_FtreeNot( left ) ml_OpConnectChilds( ML_OP_NOT, left, NULL )
-#define ml_FtreeSpecAsc( tree, str ) __ml_FtreeSpec( tree, ML_SORT_ASC, 0, str )
-#define ml_FtreeSpecDesc( tree, str ) __ml_FtreeSpec( tree, ML_SORT_DESC, 0, str )
-#define ml_FtreeSpecLimit( tree, limit ) __ml_FtreeSpec( tree, ML_LIMIT, limit, NULL )
-#define ml_FtreeSpecDistinct( tree ) __ml_FtreeSpec( tree, ML_DISTINCT, 0, NULL )
+#define ml_FtreeSpecAsc( tree, str ) ml_FtreeSpec( tree, ML_SORT_ASC, 0, str )
+#define ml_FtreeSpecDesc( tree, str ) ml_FtreeSpec( tree, ML_SORT_DESC, 0, str )
+#define ml_FtreeSpecLimit( tree, limit ) ml_FtreeSpec( tree, ML_LIMIT, limit, NULL )
+#define ml_FtreeSpecDistinct( tree ) ml_FtreeSpec( tree, ML_DISTINCT, 0, NULL )
/*****************************************************************************
* @param id The id of the row to update
* @param ... The update data. [SelectType [RoleType] Value]
*/
-#define ml_UpdateSimple( ml, sel, lval, id, ... ) \
- __ml_UpdateSimple( ml, sel, lval, id, __VA_ARGS__, ML_END )
-VLC_EXPORT( int, __ml_UpdateSimple, ( media_library_t *p_media_library,
+VLC_API int ml_UpdateSimple( media_library_t *p_media_library,
ml_select_e selected_type,
const char* psz_lvalue,
- int id, ... ) );
+ int id, ... );
+#define ml_UpdateSimple( ml, sel, lval, id, ... ) \
+ ml_UpdateSimple( ml, sel, lval, id, __VA_ARGS__, ML_END )
/**
* @brief Generic DELETE function
static inline int ml_CreateAppendPersonAdv( ml_person_t **pp_person,
const char* psz_role, const char* psz_name, int i_id )
{
- assert( i_id || ( psz_name && *psz_name && psz_role && *psz_role ) );
+ if( i_id == 0 || !( psz_name && *psz_name && psz_role && *psz_role ) )
+ return VLC_SUCCESS;
if( !pp_person )
return VLC_EGENERIC;
if( *pp_person != NULL )
* @param i_type The person type
* @note This function is thread safe
*/
-VLC_EXPORT( ml_person_t*, ml_GetPersonsFromMedia, ( media_library_t* p_ml,
+VLC_API ml_person_t *ml_GetPersonsFromMedia( media_library_t* p_ml,
ml_media_t* p_media,
- const char *psz_role ) );
+ const char *psz_role );
#define ml_GetAlbumArtistsFromMedia( a, b ) ml_GetPersonsFromMedia( a, b, ML_PERSON_ALBUM_ARTIST );
* @param i_type Type of person to delete
* @note This function is threadsafe
*/
-VLC_EXPORT( void, ml_DeletePersonTypeFromMedia, ( ml_media_t* p_media,
- const char *psz_role ) );
+VLC_API void ml_DeletePersonTypeFromMedia( ml_media_t* p_media,
+ const char *psz_role );
/**
* @param p_tree Find tree to create SELECT
*/
-VLC_EXPORT( void, ml_PlaySmartPlaylistBasedOn, ( media_library_t* p_ml,
- ml_ftree_t* p_tree ) );
+VLC_API void ml_PlaySmartPlaylistBasedOn( media_library_t* p_ml,
+ ml_ftree_t* p_tree );
/**