source: titan/titan/audiotrack.h @ 44949

Last change on this file since 44949 was 39958, checked in by gost, 7 years ago

complement

File size: 4.7 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* b4 = getscreennode(audiotrack, "b4");
27        struct skin* tmp = NULL;
28        struct audiotrack* node = NULL;
29
30        listbox->aktline = 1;
31        listbox->aktpage = -1;
32
33        if(status.aktservice->channel != NULL)
34        {
35                m_lock(&status.audiotrackmutex, 7);
36                node = status.aktservice->channel->audiotrack;
37
38                while(node != NULL)
39                {
40                        tmp = addlistbox(audiotrack, listbox, tmp, 1);
41                        if(tmp != NULL)
42                        {
43                                changetext(tmp, node->name);
44                                tmp->type = CHOICEBOX;
45                                tmp->del = 1;
46                                tmp->handle = (char*)node;
47
48                                if(status.aktservice->channel->audiopid == node->audiopid)
49                                {
50                                        changeinput(tmp, _("running"));
51                                        treffer = 1;
52                                }
53                                else
54                                        changeinput(tmp, "");
55                        }
56                        node = node->next;
57                }       
58                m_unlock(&status.audiotrackmutex, 7);
59        }
60
61        if(treffer == 0) listbox->aktline = 1;
62               
63        if(status.downmix == 1)
64                changetext(b4, "passthrough");
65        else
66                changetext(b4, getconfig("av_ac3mode", NULL));
67
68        drawscreen(audiotrack, 0, 0);
69        addscreenrc(audiotrack, listbox);
70
71        while(1)
72        {
73                rcret = waitrc(audiotrack, 0, 0);
74       
75                if(rcret == getrcconfigint("rcexit", NULL)) break;
76                if(rcret == getrcconfigint("rcok", NULL))
77                {
78                        if(listbox->select != NULL && listbox->select->handle != NULL)
79                        {
80                                m_lock(&status.audiotrackmutex, 7);
81                                if(checkaudiotrack(status.aktservice->channel, (struct audiotrack*)listbox->select->handle) != NULL)
82                                        servicechangeaudio(status.aktservice->channel, (struct audiotrack*)listbox->select->handle);
83                                m_unlock(&status.audiotrackmutex, 7);
84                        }
85                        break;
86                }
87                if(rcret == getrcconfigint("rcyellow", NULL))
88                {
89                        clearscreen(audiotrack);
90                        screensubtitle();
91                        break;
92                }
93                if(rcret == getrcconfigint("rcblue", NULL))
94                {
95                        char* ac3dev = NULL;
96                        ac3dev = getconfig("ac3dev", NULL);
97                        int ret = 0;
98                        if(ac3dev != NULL)
99                        {
100                                if(status.downmix == 1)
101                                {
102                                        ret = writesys(ac3dev, "passthrough", 0);
103                                        if(ret == 0)
104                                                status.downmix = 0;
105                                        else
106                                                printf("ERROR: set AC3_mode to passthrough\n");
107                                }
108                                else
109                                {
110                                        ret = writesys(ac3dev, getconfig("av_ac3mode", NULL), 0);
111                                        if(ret == 0)
112                                                status.downmix = 1;
113                                        else
114                                                printf("ERROR: set AC3_mode to %s\n", getconfig("av_ac3mode", NULL));
115                                }
116                                if(status.play == 1)
117                                        playerresetts();
118                        }
119                        break;
120                }
121        }
122
123        delmarkedscreennodes(audiotrack, 1);
124        delownerrc(audiotrack);
125        clearscreen(audiotrack);
126}
127
128struct audiotrack* addaudiotrack(struct channel* chnode, char* langdesc, int pid, int audiocodec, struct audiotrack* last)
129{
130        struct audiotrack *newnode = NULL, *prev = NULL, *node = NULL;
131        char *tmpstr = NULL;
132
133        if(chnode == NULL)
134        {
135                err("NULL detect");
136                return NULL;
137        }
138
139        newnode = (struct audiotrack*)calloc(1, sizeof(struct audiotrack));
140        if(newnode == NULL)
141        {
142                err("no memory");
143                return NULL;
144        }
145
146        newnode->audiopid = pid;
147        newnode->audiocodec = audiocodec;
148        if(ostrcmp(langdesc, "und") == 0)
149                tmpstr = ostrcat(tmpstr, _("undefined"), 1, 0);
150        else
151                tmpstr = ostrcat(tmpstr, _(langdesc), 1, 0);
152        switch(audiocodec)
153        {
154                case AC3: tmpstr = ostrcat(tmpstr, " (DOLBY DIGITAL)", 1, 0); break;
155                case MPEGA: tmpstr = ostrcat(tmpstr, " (STEREO)", 1, 0); break;
156                case DTS: tmpstr = ostrcat(tmpstr, " (DTS)", 1, 0); break;
157                case DTSHD: tmpstr = ostrcat(tmpstr, " (DTSHD)", 1, 0); break;
158                case LPCM: tmpstr = ostrcat(tmpstr, " (LPCM)", 1, 0); break;
159                case AAC: tmpstr = ostrcat(tmpstr, " (AAC)", 1, 0); break;
160                case AACHE: tmpstr = ostrcat(tmpstr, " (AACHE)", 1, 0); break;
161                case DDP: tmpstr = ostrcat(tmpstr, " (DDP/AC3Plus)", 1, 0); break;
162        }
163
164        newnode->name = tmpstr;
165
166        m_lock(&status.audiotrackmutex, 7);
167        node = chnode->audiotrack;
168        if(last == NULL)
169        {
170                while(node != NULL)
171                {
172                        prev = node;
173                        node = node->next;
174                }
175        }
176        else
177        {
178                prev = last;
179                node = last->next;
180        }
181
182        if(prev == NULL)
183                chnode->audiotrack = newnode;
184        else
185                prev->next = newnode;
186
187        newnode->next = node;
188
189        m_unlock(&status.audiotrackmutex, 7);
190        return newnode;
191}
192
193void freeaudiotrack(struct channel* chnode)
194{
195        struct audiotrack *node = NULL, *prev = NULL;
196
197        if(chnode == NULL)
198        {
199                err("NULL detect");
200                return;
201        }
202
203        m_lock(&status.audiotrackmutex, 7);
204        node = chnode->audiotrack;
205        prev = chnode->audiotrack;
206
207        while(node != NULL)
208        {
209                prev = node;
210                node = node->next;
211                chnode->audiotrack = node;
212
213                free(prev->name);
214                prev->name = NULL;
215
216                free(prev);
217                prev = NULL;
218
219        }
220        m_unlock(&status.audiotrackmutex, 7);
221}
222
223#endif
Note: See TracBrowser for help on using the repository browser.