File tree 2 files changed +71
-0
lines changed
2 files changed +71
-0
lines changed Original file line number Diff line number Diff line change 1
1
2
2
#include "util.h"
3
3
4
+ struct Track * track_add (struct Track * * entries , const char * uri , int idx , int st )
5
+ {
6
+ if (!uri )
7
+ return NULL ;
8
+ // Allocate memory for new node;
9
+ struct Track * list = * entries ;
10
+ struct Track * link = (struct Track * ) malloc (sizeof (struct Track ));
11
+ if (!link )
12
+ {
13
+ //NPrintf ("!fm_job_add malloc failed for %d>%s\n", dir, fn);
14
+ return NULL ;
15
+ }
16
+ //
17
+ //Nprintf("adding %s\n", uri);
18
+ link -> uri = strdup (uri );
19
+ link -> index = idx ;
20
+ link -> streamType = st ;
21
+ //
22
+ link -> prev = NULL ;
23
+ link -> next = NULL ;
24
+ // If head is empty, create new list
25
+ if (list == NULL )
26
+ {
27
+ * entries = link ;
28
+ }
29
+ else
30
+ {
31
+ struct Track * current = list ;
32
+ while (current -> next && strcasecmp (current -> uri , uri ) < 0 )
33
+ current = current -> next ;
34
+ //
35
+ if (strcasecmp (current -> uri , uri ) < 0 )
36
+ {
37
+ //Nprintf ("adding after %s\n", current->uri);
38
+ struct Track * next = current -> next ;
39
+ if (next )
40
+ next -> prev = link ;
41
+ current -> next = link ;
42
+ link -> prev = current ;
43
+ link -> next = next ;
44
+ }
45
+ else
46
+ {
47
+ //Nprintf ("adding before %s\n", current->uri);
48
+ struct Track * prev = current -> prev ;
49
+ if (prev )
50
+ prev -> next = link ;
51
+ else
52
+ //new head
53
+ * entries = link ;
54
+ current -> prev = link ;
55
+ link -> prev = prev ;
56
+ link -> next = current ;
57
+ }
58
+ }
59
+ return link ;
60
+ }
61
+
4
62
struct Subs * subs_get (struct Subs * head , long cts )
5
63
{
6
64
struct Subs * node ;
Original file line number Diff line number Diff line change 2
2
#ifndef __UTIL_H__
3
3
#define __UTIL_H__
4
4
5
+ void Nprintf (const char * fmt , ...);
6
+
5
7
struct Subs {
6
8
struct Subs * prev , * next ; //chaining refs
7
9
int idx ; //sub index
@@ -14,4 +16,15 @@ struct Subs *subs_load (char *path);
14
16
struct Subs * subs_clear (struct Subs * subs );
15
17
struct Subs * subs_get (struct Subs * head , long cts );
16
18
19
+
20
+ struct Track {
21
+ struct Track * prev , * next ; //chaining refs
22
+ //
23
+ const char * uri ;
24
+ int index ;
25
+ int streamType ;
26
+ };
27
+
28
+ struct Track * track_add (struct Track * * entries , const char * uri , int idx , int st );
29
+
17
30
#endif
You can’t perform that action at this time.
0 commit comments