There may be a threading issue here. Feel free to try it yourself with the code below. Here are the steps:
- run in gdb, add a break to main
- step over the call to do_test so you are on the line that says "return 0"
- in a terminal determine the process id of the program
- ls /proc/process_id/fd
There may be a threading issue here. Feel free to try it yourself with the code below. Here are the steps:
- run in gdb, add a break to main
- step over the call to do_test so you are on the line that says "return 0"
- in a terminal determine the process id of the program
- ls /proc/process_id/fd
Sometimes you get this:
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 0 -> /dev/pts/4 [eventfd] [eventfd] plugin- cache-7ODM3W/ 1814837434 [eventfd]
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 1 -> /dev/pts/4
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 10 -> socket:[61063]
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 11 -> anon_inode:
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 12 -> anon_inode:
l-wx------ 1 jpakkane jpakkane 64 syys 12 16:48 13 -> /tmp/grilo-
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 2 -> /dev/pts/4
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 3 -> socket:[66649]
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 4 -> socket:[66650]
lr-x------ 1 jpakkane jpakkane 64 syys 12 16:48 5 -> pipe:[66651]
l-wx------ 1 jpakkane jpakkane 64 syys 12 16:48 6 -> pipe:[66651]
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 7 -> anon_inode:
Note the fd open to grilo-plugin cache.
Other times you get this:
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:47 0 -> /dev/pts/4 [eventfd] [eventfd] [eventfd]
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 1 -> /dev/pts/4
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 10 -> socket:[66165]
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 11 -> anon_inode:
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 12 -> anon_inode:
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 2 -> /dev/pts/4
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 3 -> socket:[66649]
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 4 -> socket:[66650]
lr-x------ 1 jpakkane jpakkane 64 syys 12 16:48 5 -> pipe:[66651]
l-wx------ 1 jpakkane jpakkane 64 syys 12 16:48 6 -> pipe:[66651]
lrwx------ 1 jpakkane jpakkane 64 syys 12 16:48 7 -> anon_inode:
In this case there is no open fd to the cache file. The behaviour is undeteministic.
Here's the code:
#include<cstdio>
#include<grilo.h>
#include<string>
using namespace std;
GrlRegistry* setup() { get_default( ); new("grl- lastfm- albumart" , "grl-lastfm- albumart" ); registry_ add_config( registry, config, 0)) { registry_ load_plugin_ by_id(registry, "grl-lastfm- albumart" , 0)) {
GrlRegistry *registry = grl_registry_
if (!registry) {
printf("Could not get registry.\n");
return 0;
}
GrlConfig *config = grl_config_
if (!config) {
printf("Could not create config.\n");
return 0;
}
if(!grl_
printf("Could not add config.\n");
return 0;
}
if(!grl_
printf("Could not load plugin.\n");
return 0;
}
return registry;
}
void print_sources() { get_sources( registry, 0); )list-> data; get_name( src)); free(orig_ list);
GrlRegistry *registry = setup();
if(!registry)
return;
printf("List of plugins:\n");
GList *orig_list = grl_registry_
for(GList *list = orig_list; list != 0; list = list->next) {
GrlSource *src = (GrlSource*
printf("%s\n", grl_source_
}
g_list_
}
void do_test() { lastfm- albumart" ); lookup_ source( registry, id.c_str()); supported_ operations (source) &
GRL_ OP_RESOLVE) == 0) { "Metadata source doesn't support metadata resolution."); get_plugin( source) ;
string id("grl-
GrlRegistry *registry = setup();
if (!registry) {
printf("Could not get registry.\n");
return;
}
GrlSource *source = grl_registry_
if (!source) {
printf("Could not get source.\n");
return;
}
if ((grl_source_
printf(
return;
}
GrlPlugin *const plugin = grl_source_
printf("Using %s from %s to resolve metadata.\n", get_filename( plugin) ); audio_new( ); "Suck.\ n"); ptions *opts = grl_operation_ options_ new(0); append( keylist,
GRLKEYID_ TO_POINTER( GRL_METADATA_ KEY_THUMBNAIL) ); set_string( d, GRL_METADATA_ KEY_ARTIST, "Butterfingers"); set_string( d, GRL_METADATA_ KEY_ALBUM, "Breakfast at Fatboys"); resolve_ sync(source, m, keylist, opts, 0); free(keylist) ; unref(G_ OBJECT( opts)); data_has_ key(GRL_ DATA(result) , GRL_METADATA_ KEY_THUMBNAIL) ) { "Thumbnail not resolved.\n"); "Thumbnail resolved.\n"); unref(G_ OBJECT( result) );
id.c_str(), grl_plugin_
GrlMedia *m = grl_media_
GrlData *d = GRL_DATA(m);
if(!d) {
printf(
return;
}
GrlOperationO
GList *keylist = 0;
GrlMedia *result;
keylist = g_list_
grl_data_
grl_data_
result = grl_source_
g_list_
g_object_
if(!grl_
printf(
} else {
printf(
}
g_object_
}
int main(int argc, char **argv) { sources( );
grl_init(&argc, &argv);
do_test();
//print_
return 0;
}