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
7 src/hairtunes.c | 17 +++++++++++++
8 src/shairport.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
9 2 files changed, 83 insertions(+), 3 deletions(-)
11 diff --git a/src/hairtunes.c b/src/hairtunes.c
12 index 6957da9..2f71429 100644
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;
20 +static int g_initialized = 0;
23 static void die(char *why) {
24 xprintf("FATAL: %s\n", why);
26 @@ -192,6 +196,7 @@ int hairtunes_init(char *pAeskey, char *pAesiv, char *fmtpstr, int pCtrlPort, in
29 pthread_mutex_init(&ab_mutex, NULL);
30 + printf("init hairtune_init\n");
31 pthread_cond_init(&ab_buffer_ready, NULL);
34 @@ -253,6 +258,8 @@ int hairtunes_init(char *pAeskey, char *pAesiv, char *fmtpstr, int pCtrlPort, in
43 @@ -1005,6 +1012,13 @@ void clean_output(void)
45 void hairtunes_cleanup(void)
48 + if( g_initialized == 0 )
50 + printf("hairtunes_cleanup : already initialized\n");
54 pthread_cond_signal(&ab_buffer_ready);
57 @@ -1013,4 +1027,7 @@ void hairtunes_cleanup(void)
59 pthread_mutex_destroy(&ab_mutex);
60 pthread_cond_destroy(&ab_buffer_ready);
65 diff --git a/src/shairport.c b/src/shairport.c
66 index f520990..8edf69f 100644
69 @@ -311,13 +311,16 @@ int shairport_main(int argc, char **argv)
75 +static int tClientSock = 0;
77 int shairport_loop(void)
79 if (!m_running || tServerSock <= 0)
82 - int tClientSock = 0;
84 + static int tClientSock = 0;
89 @@ -395,6 +398,8 @@ void shairport_exit(void)
93 + printf("exit airport\n");
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);
110 @@ -510,7 +519,11 @@ void handleClient(int pSock, char *pPassword, char *pHWADDR)
111 initBuffer(&tConn.resp, 80);
115 + while(1 == tMoreDataNeeded && m_running )
117 while(1 == tMoreDataNeeded)
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)
127 + while(tRetval > 0 && tEnd < 0 && m_running )
129 while(tRetval > 0 && tEnd < 0)
137 // Read from socket until \n\n, \r\n\r\n, or \r\r is found
138 xprintf("Waiting To Read...\n");
143 + FD_SET( (int)pSock, &set );
146 + tv.tv_usec = 200000;
147 + //printf("select\n");
148 + result = select ( (int)pSock + 1, &set, NULL, NULL, &tv );
150 + //printf("select 2\n");
153 + printf("timed out\n");
157 + if( (int)pSock < 0 )
159 + if( FD_ISSET( (int)pSock, &set ) )
161 + //printf("Read Data \n");
162 + tRetval = read(pSock, tReadBuf, MAX_SIZE);
163 + //printf("Read Data2 \n");
165 + else if( result == 0 )
167 + xprintf("ReadTimeout\n");
172 + //printf("other fd\n");
177 tRetval = read(pSock, tReadBuf, MAX_SIZE);
179 // if new buffer contains the end of request string, only copy partial buffer?
180 tEnd = findEnd(tReadBuf);
182 @@ -1101,7 +1161,10 @@ void cleanup(struct connection *pConn)
183 closePipe(&(pConn->hairtunes->out[0]));
184 closePipe(&(pConn->hairtunes->out[1]));
187 + hairtunes_cleanup();
190 if(pConn->keys != NULL)
192 if(pConn->keys->aesiv != NULL)