2006-03-26 11:33:42 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 by Miika Pekkarinen
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#ifndef _TAGCACHE_H
|
|
|
|
#define _TAGCACHE_H
|
|
|
|
|
|
|
|
#include "id3.h"
|
|
|
|
|
|
|
|
enum tag_type { tag_artist = 0, tag_album, tag_genre, tag_title,
|
2006-03-30 12:07:32 +00:00
|
|
|
tag_filename, tag_composer, tag_year, tag_tracknumber,
|
|
|
|
tag_bitrate, tag_length };
|
|
|
|
|
|
|
|
#define TAG_COUNT 10
|
2006-03-26 11:33:42 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_DIRCACHE
|
|
|
|
#define HAVE_TC_RAMCACHE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Allow a little drift to the filename ordering. */
|
|
|
|
#define POS_HISTORY_COUNT 4
|
|
|
|
|
|
|
|
/* How many entries we can create in one tag file (for sorting). */
|
|
|
|
#define TAGFILE_MAX_ENTRIES 20000
|
|
|
|
|
|
|
|
#define SEEK_LIST_SIZE 50
|
|
|
|
#define TAGCACHE_MAX_FILTERS 3
|
2006-04-03 18:57:34 +00:00
|
|
|
#define TAGCACHE_MAX_CLAUSES 10
|
|
|
|
|
|
|
|
enum clause { clause_none, clause_is, clause_gt, clause_gteq, clause_lt,
|
|
|
|
clause_lteq, clause_contains, clause_begins_with, clause_ends_with };
|
|
|
|
enum modifies { clause_mod_none, clause_mod_not };
|
|
|
|
|
|
|
|
struct tagcache_search_clause
|
|
|
|
{
|
|
|
|
int tag;
|
|
|
|
int type;
|
|
|
|
bool numeric;
|
2006-04-04 19:28:13 +00:00
|
|
|
bool input;
|
2006-04-03 18:57:34 +00:00
|
|
|
long numeric_data;
|
|
|
|
char str[32];
|
|
|
|
};
|
2006-03-26 11:33:42 +00:00
|
|
|
|
|
|
|
struct tagcache_search {
|
|
|
|
/* For internal use only. */
|
2006-04-03 18:57:34 +00:00
|
|
|
int fd, masterfd;
|
2006-03-26 11:33:42 +00:00
|
|
|
long seek_list[SEEK_LIST_SIZE];
|
|
|
|
long filter_tag[TAGCACHE_MAX_FILTERS];
|
|
|
|
long filter_seek[TAGCACHE_MAX_FILTERS];
|
|
|
|
int filter_count;
|
2006-04-03 18:57:34 +00:00
|
|
|
struct tagcache_search_clause *clause[TAGCACHE_MAX_CLAUSES];
|
|
|
|
int clause_count;
|
2006-03-26 11:33:42 +00:00
|
|
|
int seek_list_count;
|
|
|
|
int seek_pos;
|
2006-03-30 12:07:32 +00:00
|
|
|
int idx_id;
|
2006-03-26 11:33:42 +00:00
|
|
|
long position;
|
|
|
|
int entry_count;
|
|
|
|
bool valid;
|
|
|
|
|
|
|
|
/* Exported variables. */
|
|
|
|
bool ramsearch;
|
|
|
|
int type;
|
|
|
|
char *result;
|
|
|
|
int result_len;
|
|
|
|
long result_seek;
|
|
|
|
};
|
|
|
|
|
2006-04-03 18:57:34 +00:00
|
|
|
bool tagcache_is_numeric_tag(int type);
|
2006-03-26 11:33:42 +00:00
|
|
|
bool tagcache_search(struct tagcache_search *tcs, int tag);
|
|
|
|
bool tagcache_search_add_filter(struct tagcache_search *tcs,
|
|
|
|
int tag, int seek);
|
2006-04-03 18:57:34 +00:00
|
|
|
bool tagcache_search_add_clause(struct tagcache_search *tcs,
|
|
|
|
struct tagcache_search_clause *clause);
|
2006-03-26 11:33:42 +00:00
|
|
|
bool tagcache_get_next(struct tagcache_search *tcs);
|
|
|
|
void tagcache_search_finish(struct tagcache_search *tcs);
|
2006-03-30 12:07:32 +00:00
|
|
|
long tagcache_get_numeric(const struct tagcache_search *tcs, int tag);
|
2006-03-26 11:33:42 +00:00
|
|
|
|
|
|
|
int tagcache_get_progress(void);
|
|
|
|
#ifdef HAVE_TC_RAMCACHE
|
|
|
|
bool tagcache_is_ramcache(void);
|
2006-03-26 16:37:18 +00:00
|
|
|
bool tagcache_fill_tags(struct mp3entry *id3, const char *filename);
|
2006-03-26 11:33:42 +00:00
|
|
|
#endif
|
|
|
|
void tagcache_init(void);
|
|
|
|
void tagcache_start_scan(void);
|
|
|
|
void tagcache_stop_scan(void);
|
|
|
|
bool tagcache_force_update(void);
|
|
|
|
|
|
|
|
#endif
|