int himd_add_track_info(struct himd * himd, struct trackinfo * t, struct himderrinfo * status) { int idx_freeslot; unsigned char * linkbuffer; unsigned char * trackbuffer; unsigned char * play_order_table = himd->tifdata+0x100; status = status; g_return_val_if_fail(himd != NULL, -1); g_return_val_if_fail(t != NULL, -1); /* get track[0] - the free-chain index */ linkbuffer = get_track(himd, 0); idx_freeslot = beword16(&linkbuffer[38]); /* allocate slot idx_freeslot for the new track*/ trackbuffer = get_track(himd, idx_freeslot); t->tracknum = idx_freeslot; /* update track[] - free-chain index */ setbeword16(&linkbuffer[38], beword16(&trackbuffer[38])); /* copy trackinfo to slot */ settrack(t, trackbuffer); /* increase track count */ setbeword16(play_order_table, himd_track_count(himd)+1); /* add entry for new track in play order table */ setbeword16(play_order_table+2*idx_freeslot, t->tracknum); return idx_freeslot; }
static void print_tracking(struct kmem_cache *s, void *object) { if (!(s->flags & SLAB_STORE_USER)) return; print_track("Allocated", get_track(s, object, TRACK_ALLOC)); print_track("Freed", get_track(s, object, TRACK_FREE)); }
static void set_track(struct kmem_cache *s, void *object, enum track_item alloc, unsigned long addr) { struct track *p = get_track(s, object, alloc); if (addr) { #ifdef CONFIG_STACKTRACE struct stack_trace trace; int i; trace.nr_entries = 0; trace.max_entries = TRACK_ADDRS_COUNT; trace.entries = p->addrs; trace.skip = 3; save_stack_trace(&trace); /* See rant in lockdep.c */ if (trace.nr_entries != 0 && trace.entries[trace.nr_entries - 1] == ULONG_MAX) trace.nr_entries--; for (i = trace.nr_entries; i < TRACK_ADDRS_COUNT; i++) p->addrs[i] = 0; #endif p->addr = addr; p->cpu = smp_processor_id(); p->pid = current->pid; p->when = jiffies; } else memset(p, 0, sizeof(struct track)); }
/* Function to estimate the location of a competitor. */ int estimate_location(event_ptr event, competitor* competitor) { node* nodeA; node* nodeB; node* next_node; int next_node_number; int node_index; int est_arrival_time = 0; int current_competitor_time; int event_time; track* track; if (competitor->status == NS) { return NS; } else { node_index = competitor->last_checkpoint_index; nodeA = get_node(event->node_head, competitor->course_ptr->course_nodes[node_index]->number); node_index += 1; next_node_number = competitor->course_ptr->course_nodes[node_index]->number; /* Gets node number of the next node on the course. */ nodeB = get_node(event->node_head, next_node_number); track = get_track(event->track_head, nodeA->number, nodeB->number); /* Retrieves track that lies between nodeA and nodeB. */ current_competitor_time = (competitor->last_time_recored.hours * 60) + competitor->last_time_recored.minutes; event_time = (event->current_time.hours * 60) + event->current_time.minutes; est_arrival_time = current_competitor_time; if (nodeB->type == JN) { /* While the second node is a junction node. */ track = track_estimation(event, competitor, nodeA, nodeB, node_index, next_node_number, event_time, est_arrival_time); } return track->number; } }
int himd_get_free_trackindex(struct himd * himd) { int idx_freeslot; unsigned char * linkbuffer; linkbuffer = get_track(himd, 0); idx_freeslot = beword16(&linkbuffer[38]); return idx_freeslot; }
void XplodifyPlaylist::flush() { boost::shared_ptr<XplodifySession> sess(m_session.lock()); track_cache_by_rand& t_r = m_track_cache.get<0>(); std::size_t sz = t_r.size(); for(std::size_t i=0 ; i<sz ; i++) { boost::shared_ptr<XplodifyTrack> tr = get_track(0, true); tr.reset(); } sess->update_state_ts(); }
/** * @param search The search result */ static void get_search(sp_search *search) { int i; json_t *json = json_object(); json_t *tracks = json_array(); json_object_set_new(json, "tracks", tracks); for (i = 0; i < sp_search_num_tracks(search); ++i){ json_array_append_new(tracks, get_track(sp_search_track(search, i))); } json_object_set_new_nocheck(json, "query", json_string_nocheck(sp_search_query(search))); cmd_sendresponse(json, 200); }
/* Recursive function that estimates what track the competitor could currently be on. * Recursively calls if the next node is a junction node and the time difference allows for the next track to be considered. */ track* track_estimation(event_ptr event, competitor* competitor, node* nodeA, node* nodeB, int node_index, int next_node_number, int event_time, int est_arrival_time) { node* next_node; track* track; track = get_track(event->track_head, nodeA->number, nodeB->number); /* Obtain track. */ est_arrival_time += track->max_time; /* Increase estimated arrival time for competitor at end of track. */ if (event_time > est_arrival_time) { node_index += 1; next_node_number = competitor->course_ptr->course_nodes[node_index]->number; /* Gets node number of the next node on the course. */ next_node = get_node(event->node_head, next_node_number); nodeA = nodeB; nodeB = next_node; if (nodeB->type == JN) { track = track_estimation(event, competitor, nodeA, nodeB, node_index, next_node_number, event_time, est_arrival_time); } else { /* If the new nodeB is not a junction node. */ track = get_track(event->track_head, nodeA->number, nodeB->number); } } return track; }
int himd_get_track_info(struct himd * himd, unsigned int idx, struct trackinfo * t, struct himderrinfo * status) { unsigned char * trackbuffer; unsigned int firstpart; g_return_val_if_fail(himd != NULL, -1); g_return_val_if_fail(idx >= HIMD_FIRST_TRACK, -1); g_return_val_if_fail(idx <= HIMD_LAST_TRACK, -1); g_return_val_if_fail(t != NULL, -1); trackbuffer = get_track(himd, idx); firstpart = beword16(trackbuffer+36); if(firstpart == 0) { set_status_printf(status, HIMD_ERROR_NO_SUCH_TRACK, _("Track %d is not present on disc"), idx); return -1; } get_dostime(&t->recordingtime,trackbuffer+0); t->ekbnum = beword32(trackbuffer+4); t->title = beword16(trackbuffer+8); t->artist = beword16(trackbuffer+10); t->album = beword16(trackbuffer+12); t->trackinalbum = trackbuffer[14]; memcpy(t->key, trackbuffer+16,8); memcpy(t->mac, trackbuffer+24,8); t->codec_id = trackbuffer[32]; memcpy(t->codecinfo,trackbuffer+33,3); memcpy(t->codecinfo+3,trackbuffer+44,2); t->firstfrag = firstpart; t->tracknum = beword16(trackbuffer+38); t->seconds = beword16(trackbuffer+40); memcpy(t->contentid,trackbuffer+48,20); get_dostime(&t->starttime,trackbuffer+68); get_dostime(&t->endtime,trackbuffer+72); return 0; }
static gint parse_track_list_data(GString *data, GList **list) { gint result = 1; xmlDocPtr doc = NULL; doc = xmlReadMemory(data->str, data->len, NULL, NULL, XML_PARSE_RECOVER | XML_PARSE_NOERROR); if (doc == NULL) return result; do { xmlNodePtr root; xmlNodePtr track_list; xmlNodePtr p; root = xmlDocGetRootElement(doc); if (root == NULL) break; track_list = xml_first_child(root, BAD_CAST "trackList"); if (track_list == NULL) break; for(p = xmlFirstElementChild(track_list); p ; p = xmlNextElementSibling(p)) get_track(p, list); result = 0; } while(0); xmlFreeDoc(doc); return result; }
/** * Callback for libspotify * * @param result The toplist result object that is now done * @param userdata The opaque pointer given to sp_toplistbrowse_create() */ static void got_toplist(sp_toplistbrowse *result, void *userdata) { int i; json_t *json = json_object(); json_t *toplist = json_object(); json_object_set_new(json, "toplist", toplist); json_t *results = json_array(); json_object_set_new(toplist, "result", results); // We print from all types. Only one of the loops will acually yield anything. for(i = 0; i < sp_toplistbrowse_num_artists(result); i++) json_array_append_new(results, get_artist(sp_toplistbrowse_artist(result, i))); for(i = 0; i < sp_toplistbrowse_num_albums(result); i++) json_array_append_new(results, get_album(sp_toplistbrowse_album(result, i))); for(i = 0; i < sp_toplistbrowse_num_tracks(result); i++) json_array_append_new(results, get_track(sp_toplistbrowse_track(result, i))); cmd_sendresponse(json, 200); sp_toplistbrowse_release(result); cmd_done(); }
long rread(Rfile tpf, void *buf, long count) /* Read a buffer from an open ram-disk file. */ { char ***platter; char **track; char *data; int i; int ssize, so; int flags; long filept; long readin; long fsize; flags = tpf->flags; if (!(flags&TF_OPEN)) { rerr = Err_file_not_open; return(0); } if (!(flags&TF_READ)) { rerr = Err_read; return(0); } data = buf; readin = 0; filept = tpf->filep; fsize = tpf->size; if ((tpf->filep = filept+count) > fsize) { rerr = Err_eof; if ((count = fsize-filept) <= 0) return(0); } platter = tpf->platters + get_platter(filept); for (;;) { i = get_track(filept); track = *platter + i; for ( ; i< TRD_TRACK; i++) { so = get_sector(filept); ssize = TRD_SECTOR - so; if (count > ssize) { memcpy(data, *track + so, ssize); readin += ssize; data += ssize; count -= ssize; filept += ssize; } else { memcpy(data, *track + so, (size_t)count); return(readin+count); } track++; } platter++; } }
long rwrite(Rfile tpf, void *buf, long count) /* Write a buffer to an open ram-disk file. */ { char ***platter; char **track; char *data; int i; int ssize, so; int flags; long filept; long written; long new_size; flags = tpf->flags; if (!(flags&TF_OPEN)) { rerr = Err_file_not_open; return(0); } if (!(flags&TF_WRITE)) { rerr = Err_write; return(0); } if (count <= 0) return(0); data = buf; written = 0; filept = tpf->filep; new_size = filept + count; platter = tpf->platters + get_platter(filept); for (;;) { if ((track = *platter) == NULL) if ((*platter = track = tget_clear()) == NULL) goto OUT; i = get_track(filept); track += i; for ( ; i< TRD_TRACK; i++) { if (*track == NULL) if ((*track = tget_sector()) == NULL) goto OUT; so = get_sector(filept); ssize = TRD_SECTOR - so; if (count > ssize) { memcpy(*track + so, data, ssize); written += ssize; data += ssize; count -= ssize; filept += ssize; } else { memcpy(*track + so, data, (size_t)count); written += count; filept += count; goto OUT; } track++; } platter++; } OUT: if (tpf->size < (tpf->filep = filept)) tpf->size = filept; return(written); }