Old 16th April 2007, 17:51   #1
abu
mlipod moderator
(Senior Member)
 
abu's Avatar
 
Join Date: Jun 2005
Location: Germany
Posts: 3,457
API request: Use query engine on external itemRecord

Hi, dev gurus,
I would like to be able to use the Winamp query engine on itemRecords for a file that is not in the ML. I would fill out the itemRecord struct with all the data (basic and extended data), and then call a API function with a query string and a pointer to this itemRecord. Return value would be 1 if the item matches the query rules, 0 if not, -1 if the query is invalid or any other error.

code:
typedef struct
{
char *query;
const itemRecord *ir;
} mlQueryRecordStruct;

#define ML_IPC_DB_RUNQUERY_ONRECORD 0x704 // pass mlQueryRecordStruct*



I'm sure Will will need sth. like this sooner or later for pmp_*, too (if he wants to support smart playlists)

Would that be feasable?

An second approach could be to pass in an itemRecordList, and the API call marks all items that match (it could add the indexes for matching items to a new C_ItemList, for example). That would help if you need to query thousands of tracks, it would be only one call, not thousands...

Would be really great if that could be provided. The query engine is simply too good to leave it for the ML alone

WinAmp Pro 5.5 with ml_iPod 3.10 + dev.patches (download it)
ml_iPod documentation Wiki - ml_iPod FAQ - search ml_iPod forum - iPhone/iTouch - Found a bug?
Donations to support the ml_iPod project can be done HERE
abu is offline   Reply With Quote
Old 17th April 2007, 09:38   #2
will
Nullsoft Newbie (Moderator)
 
will's Avatar
 
Join Date: Mar 2001
Location: Sheffield, England
Posts: 5,569
The query engine actually works on NDE tables, not on itemRecords.

Your best option, therefore, it to load nde.dll (tell the linker it is a delay loaded dll file) and create a table and add your files to it, then run a query.

The NDE source is knocking about on the forums.

DO NOT PM ME WITH TECH SUPPORT QUESTIONS
will is offline   Reply With Quote
Old 17th April 2007, 18:45   #3
abu
mlipod moderator
(Senior Member)
 
abu's Avatar
 
Join Date: Jun 2005
Location: Germany
Posts: 3,457
Thanks, Will,
very helpful. I found the source at http://forums.winamp.com/showthread....54#post2166954

Any chance to get a working example somewhere? There is no documentation included at all
I'd like to build up a table of tracks, then run a regular Winamp style query string on it.

WinAmp Pro 5.5 with ml_iPod 3.10 + dev.patches (download it)
ml_iPod documentation Wiki - ml_iPod FAQ - search ml_iPod forum - iPhone/iTouch - Found a bug?
Donations to support the ml_iPod project can be done HERE
abu is offline   Reply With Quote
Old 18th April 2007, 09:13   #4
will
Nullsoft Newbie (Moderator)
 
will's Avatar
 
Join Date: Mar 2001
Location: Sheffield, England
Posts: 5,569
ok, you do something like this:

db = new Database(hInstance);
table = db->OpenTable( tableFileName,indexFileName, 1, 1);
if you don't want the table to be saved on disk, you might want to tweak these options.

table->NewColumn() for filename,title, artist, album, etc etc
table->PostColumns();
table->AddIndexById() for any indexes you want.

to query:
scanner = table->NewScanner(FALSE);
scanner->Query(L"artist has beatles");
scanner->First();
// get first record, use scanner->GetFieldByName or GetFieldById for artist, album, title, etc
scanner->Next();
// get next record
table->DeleteScanner(scanner);


to add files to the db, get a scanner, call scanner->New(); get a field and simply cast the Field to the correct type (StringField or whatever it is) and use field->SetString
then call scanner->Post();

DO NOT PM ME WITH TECH SUPPORT QUESTIONS
will is offline   Reply With Quote
Old 18th April 2007, 09:35   #5
abu
mlipod moderator
(Senior Member)
 
abu's Avatar
 
Join Date: Jun 2005
Location: Germany
Posts: 3,457
Thanks, Will,
I'll try that whenever I find the time!

WinAmp Pro 5.5 with ml_iPod 3.10 + dev.patches (download it)
ml_iPod documentation Wiki - ml_iPod FAQ - search ml_iPod forum - iPhone/iTouch - Found a bug?
Donations to support the ml_iPod project can be done HERE
abu is offline   Reply With Quote
Old 18th April 2007, 11:17   #6
abu
mlipod moderator
(Senior Member)
 
abu's Avatar
 
Join Date: Jun 2005
Location: Germany
Posts: 3,457
code:
Database *db = new Database;
Table *table = db->OpenTable( "C:/tmp/t1.dat","C:/tmp/t1.idx", 1, 1);
table->NewColumn(0, "artist", FIELD_STRING, 0);
table->NewColumn(1, "title", FIELD_STRING, 0);
table->NewColumn(2, "album", FIELD_STRING, 0);
table->PostColumns();
table->AddIndexById(0, "artist");
Scanner * sc = table->NewScanner(FALSE);
sc->New();
StringField *f;
f = (StringField *)sc->GetFieldById(0);
f->SetString("TestArtist");


Something is missing: f is NULL after GetFieldById(0)???

WinAmp Pro 5.5 with ml_iPod 3.10 + dev.patches (download it)
ml_iPod documentation Wiki - ml_iPod FAQ - search ml_iPod forum - iPhone/iTouch - Found a bug?
Donations to support the ml_iPod project can be done HERE
abu is offline   Reply With Quote
Old 18th April 2007, 11:52   #7
will
Nullsoft Newbie (Moderator)
 
will's Avatar
 
Join Date: Mar 2001
Location: Sheffield, England
Posts: 5,569
I think it might be creating columns in a lazy way.

Instead of using GetFieldById, try this:

code:

Field *f = s->GetFieldById(id);
if(!f) f = s->NewFieldById(id, PERM_READWRITE);
StringField *fs = static_cast<StringField*>(f);


DO NOT PM ME WITH TECH SUPPORT QUESTIONS
will is offline   Reply With Quote
Old 18th April 2007, 14:42   #8
abu
mlipod moderator
(Senior Member)
 
abu's Avatar
 
Join Date: Jun 2005
Location: Germany
Posts: 3,457
Yep, that did the trick! Thanks a lot.

WinAmp Pro 5.5 with ml_iPod 3.10 + dev.patches (download it)
ml_iPod documentation Wiki - ml_iPod FAQ - search ml_iPod forum - iPhone/iTouch - Found a bug?
Donations to support the ml_iPod project can be done HERE
abu is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump