source: titan/titan/audiotrack.h @ 36069

Last change on this file since 36069 was 31293, checked in by nit, 9 years ago

fix

File size: 3.9 KB
Line 
1#ifndef AUDIOTRACK_H
2#define AUDIOTRACK_H
3
4struct audiotrack* checkaudiotrack(struct channel* chnode, struct audiotrack* atrack)
5{
6        struct audiotrack* node = NULL;
7
8        if(chnode != NULL)
9        {
10                node = chnode->audiotrack;
11                while(node != NULL)
12                {
13                        if(node == atrack)
14                                return node;
15                        node = node->next;
16                }
17        }
18        return NULL;
19}
20
21void screenaudiotrack()
22{
23        int rcret = 0, treffer = 0;
24        struct skin* audiotrack = getscreen("audiotrack");
25        struct skin* listbox = getscreennode(audiotrack, "listbox");
26        struct skin* tmp = NULL;
27        struct audiotrack* node = NULL;
28
29        listbox->aktline = 1;
30        listbox->aktpage = -1;
31
32        if(status.aktservice->channel != NULL)
33        {
34                m_lock(&status.audiotrackmutex, 7);
35                node = status.aktservice->channel->audiotrack;
36                while(node != NULL)
37                {
38                        tmp = addlistbox(audiotrack, listbox, tmp, 1);
39                        if(tmp != NULL)
40                        {
41                                changetext(tmp, node->name);
42                                tmp->type = CHOICEBOX;
43                                tmp->del = 1;
44                                tmp->handle = (char*)node;
45
46                                if(status.aktservice->channel->audiopid == node->audiopid)
47                                {
48                                        changeinput(tmp, _("running"));
49                                        treffer = 1;
50                                }
51                                else
52                                        changeinput(tmp, "");
53
54                                if(treffer == 0) listbox->aktline++;
55                        }
56                        node = node->next;
57                }       
58                m_unlock(&status.audiotrackmutex, 7);
59        }
60
61        if(treffer == 0) listbox->aktline = 1;
62
63        drawscreen(audiotrack, 0, 0);
64        addscreenrc(audiotrack, listbox);
65
66        while(1)
67        {
68                rcret = waitrc(audiotrack, 0, 0);
69       
70                if(rcret == getrcconfigint("rcexit", NULL)) break;
71                if(rcret == getrcconfigint("rcok", NULL))
72                {
73                        if(listbox->select != NULL && listbox->select->handle != NULL)
74                        {
75                                m_lock(&status.audiotrackmutex, 7);
76                                if(checkaudiotrack(status.aktservice->channel, (struct audiotrack*)listbox->select->handle) != NULL)
77                                        servicechangeaudio(status.aktservice->channel, (struct audiotrack*)listbox->select->handle);
78                                m_unlock(&status.audiotrackmutex, 7);
79                        }
80                        break;
81                }
82                if(rcret == getrcconfigint("rcyellow", NULL))
83                {
84                        clearscreen(audiotrack);
85                        screensubtitle();
86                        break;
87                }
88        }
89
90        delmarkedscreennodes(audiotrack, 1);
91        delownerrc(audiotrack);
92        clearscreen(audiotrack);
93}
94
95struct audiotrack* addaudiotrack(struct channel* chnode, char* langdesc, int pid, int audiocodec, struct audiotrack* last)
96{
97        struct audiotrack *newnode = NULL, *prev = NULL, *node = NULL;
98        char *tmpstr = NULL;
99
100        if(chnode == NULL)
101        {
102                err("NULL detect");
103                return NULL;
104        }
105
106        newnode = (struct audiotrack*)calloc(1, sizeof(struct audiotrack));
107        if(newnode == NULL)
108        {
109                err("no memory");
110                return NULL;
111        }
112
113        newnode->audiopid = pid;
114        newnode->audiocodec = audiocodec;
115        if(ostrcmp(langdesc, "und") == 0)
116                tmpstr = ostrcat(tmpstr, _("undefined"), 1, 0);
117        else
118                tmpstr = ostrcat(tmpstr, _(langdesc), 1, 0);
119        switch(audiocodec)
120        {
121                case AC3: tmpstr = ostrcat(tmpstr, " (DOLBY DIGITAL)", 1, 0); break;
122                case MPEGA: tmpstr = ostrcat(tmpstr, " (STEREO)", 1, 0); break;
123                case DTS: tmpstr = ostrcat(tmpstr, " (DTS)", 1, 0); break;
124                case LPCM: tmpstr = ostrcat(tmpstr, " (LPCM)", 1, 0); break;
125                case AAC: tmpstr = ostrcat(tmpstr, " (AAC)", 1, 0); break;
126                case AACHE: tmpstr = ostrcat(tmpstr, " (AACHE)", 1, 0); break;
127        }
128
129        newnode->name = tmpstr;
130
131        m_lock(&status.audiotrackmutex, 7);
132        node = chnode->audiotrack;
133        if(last == NULL)
134        {
135                while(node != NULL)
136                {
137                        prev = node;
138                        node = node->next;
139                }
140        }
141        else
142        {
143                prev = last;
144                node = last->next;
145        }
146
147        if(prev == NULL)
148                chnode->audiotrack = newnode;
149        else
150                prev->next = newnode;
151
152        newnode->next = node;
153
154        m_unlock(&status.audiotrackmutex, 7);
155        return newnode;
156}
157
158void freeaudiotrack(struct channel* chnode)
159{
160        struct audiotrack *node = NULL, *prev = NULL;
161
162        if(chnode == NULL)
163        {
164                err("NULL detect");
165                return;
166        }
167
168        m_lock(&status.audiotrackmutex, 7);
169        node = chnode->audiotrack;
170        prev = chnode->audiotrack;
171
172        while(node != NULL)
173        {
174                prev = node;
175                node = node->next;
176                chnode->audiotrack = node;
177
178                free(prev->name);
179                prev->name = NULL;
180
181                free(prev);
182                prev = NULL;
183
184        }
185        m_unlock(&status.audiotrackmutex, 7);
186}
187
188#endif
Note: See TracBrowser for help on using the repository browser.