Support gles animation.
[vuplus_openvuplus_3.0] / meta-openvuplus / recipes-support / libshairport / libshairport / 0001-xbmc-patch-for-xbmc.patch
1 From c9807cd8c7acd23aaef76749888b39f6f0742ce0 Mon Sep 17 00:00:00 2001
2 From: Sangdol Kim <doliyu@marusys.com>
3 Date: Thu, 7 Mar 2013 17:08:41 +0900
4 Subject: [PATCH] [xbmc]patch for xbmc
5
6 ---
7  src/hairtunes.c |   17 +++++++++++++
8  src/shairport.c |   69 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
9  2 files changed, 83 insertions(+), 3 deletions(-)
10
11 diff --git a/src/hairtunes.c b/src/hairtunes.c
12 index 6957da9..2f71429 100644
13 --- a/src/hairtunes.c
14 +++ b/src/hairtunes.c
15 @@ -120,6 +120,10 @@ int ab_buffering = 1, ab_synced = 0;
16  pthread_mutex_t ab_mutex;
17  pthread_cond_t ab_buffer_ready;
18  
19 +#ifdef XBMC
20 +static int g_initialized = 0;
21 +#endif
22 +
23  static void die(char *why) {
24      xprintf("FATAL: %s\n", why);
25      //exit(1);
26 @@ -192,6 +196,7 @@ int hairtunes_init(char *pAeskey, char *pAesiv, char *fmtpstr, int pCtrlPort, in
27      ab_buffering = 1;
28      ab_synced = 0;
29      pthread_mutex_init(&ab_mutex, NULL);
30 +       printf("init hairtune_init\n");
31      pthread_cond_init(&ab_buffer_ready, NULL);
32  
33      if(pAeskey != NULL)    
34 @@ -253,6 +258,8 @@ int hairtunes_init(char *pAeskey, char *pAesiv, char *fmtpstr, int pCtrlPort, in
35      }
36      xprintf("bye!\n");
37      fflush(stderr);
38 +#else
39 +       g_initialized = 1;
40  #endif
41  
42      return EXIT_SUCCESS;
43 @@ -1005,6 +1012,13 @@ void clean_output(void)
44  
45  void hairtunes_cleanup(void)
46  {
47 +#ifdef XBMC
48 +  if( g_initialized == 0 )
49 +  {
50 +    printf("hairtunes_cleanup : already initialized\n");
51 +    return;
52 +  }
53 +#endif
54    pthread_cond_signal(&ab_buffer_ready);
55    clean_output();
56    clean_rtp();
57 @@ -1013,4 +1027,7 @@ void hairtunes_cleanup(void)
58  
59    pthread_mutex_destroy(&ab_mutex);
60    pthread_cond_destroy(&ab_buffer_ready);
61 +#ifdef XBMC
62 +  g_initialized = 0;
63 +#endif
64  }
65 diff --git a/src/shairport.c b/src/shairport.c
66 index f520990..8edf69f 100644
67 --- a/src/shairport.c
68 +++ b/src/shairport.c
69 @@ -311,13 +311,16 @@ int shairport_main(int argc, char **argv)
70      return 1;
71    }
72  }
73 -
74 +#ifdef XBMC
75 +static int tClientSock = 0;
76 +#endif
77  int shairport_loop(void)
78  {
79      if (!m_running || tServerSock <= 0)
80          return 0;
81 -
82 -    int tClientSock = 0;
83 +#ifndef XBMC
84 +    static int tClientSock = 0;
85 +#endif
86  
87      fd_set fds;
88      FD_ZERO(&fds);
89 @@ -395,6 +398,8 @@ void shairport_exit(void)
90  {
91    m_running = 0;
92    close(tServerSock);
93 +       printf("exit airport\n");
94 +
95  }
96  
97  int shairport_is_running(void)
98 @@ -502,7 +507,11 @@ void handleClient(int pSock, char *pPassword, char *pHWADDR)
99    struct connection  tConn;
100    initConnection(&tConn, &tKeys, &tComms, pSock, pPassword);
101  
102 +#ifdef XBMC
103 +  while( m_running )
104 +#else
105    while(1)
106 +#endif
107    {
108      tMoreDataNeeded = 1;
109  
110 @@ -510,7 +519,11 @@ void handleClient(int pSock, char *pPassword, char *pHWADDR)
111      initBuffer(&tConn.resp, 80);
112      
113      int tError = FALSE;
114 +#ifdef XBMC
115 +    while(1 == tMoreDataNeeded && m_running )
116 +#else
117      while(1 == tMoreDataNeeded)
118 +#endif
119      {
120        tError = readDataFromClient(pSock, &(tConn.recv));
121        //if(!tError && strlen(tConn.recv.data) > 0)
122 @@ -565,12 +578,59 @@ int readDataFromClient(int pSock, struct shairbuffer *pClientBuffer)
123  
124    int tRetval = 1;
125    int tEnd = -1;
126 +#ifdef XBMC
127 +  while(tRetval > 0 && tEnd < 0 && m_running )
128 +#else
129    while(tRetval > 0 && tEnd < 0)
130 +#endif
131    {
132 +#ifdef XBMC
133 +       struct timeval  tv;
134 +       fd_set                  set;
135 +       int result;
136 +#endif
137       // Read from socket until \n\n, \r\n\r\n, or \r\r is found
138        xprintf("Waiting To Read...\n");
139        fflush(stdout);
140 +
141 +#ifdef XBMC
142 +       FD_ZERO( &set );
143 +       FD_SET( (int)pSock, &set );
144 +
145 +       tv.tv_sec=0;
146 +       tv.tv_usec = 200000;
147 +       //printf("select\n");
148 +       result = select ( (int)pSock + 1, &set, NULL, NULL, &tv );
149 +
150 +       //printf("select 2\n");
151 +       if( result < 0 )
152 +       {
153 +               printf("timed out\n");
154 +               continue;
155 +       }
156 +
157 +       if( (int)pSock <  0 )
158 +               continue;
159 +       if( FD_ISSET( (int)pSock, &set ) )
160 +       {
161 +               //printf("Read Data \n");
162 +               tRetval = read(pSock, tReadBuf, MAX_SIZE);
163 +               //printf("Read Data2 \n");
164 +       }
165 +       else if( result == 0 )
166 +       {
167 +               xprintf("ReadTimeout\n");
168 +               continue;
169 +       }
170 +       else
171 +       {
172 +               //printf("other fd\n");
173 +               continue;
174 +       }
175 +
176 +#else
177        tRetval = read(pSock, tReadBuf, MAX_SIZE);
178 +#endif
179        // if new buffer contains the end of request string, only copy partial buffer?
180        tEnd = findEnd(tReadBuf);
181        if(tEnd >= 0)
182 @@ -1101,7 +1161,10 @@ void cleanup(struct connection *pConn)
183      closePipe(&(pConn->hairtunes->out[0]));
184      closePipe(&(pConn->hairtunes->out[1]));
185    }
186 +#else
187 +   hairtunes_cleanup();
188  #endif
189 +
190    if(pConn->keys != NULL)
191    {
192      if(pConn->keys->aesiv != NULL)
193 -- 
194 1.7.2.3
195