aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs71
1 files changed, 31 insertions, 40 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
index 56d34e6..d25bf95 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs
@@ -167,47 +167,48 @@ namespace OpenSim.Region.ClientStack.LindenUDP
167 } 167 }
168 } 168 }
169 169
170 public bool ProcessImageQueue(int count, int maxpack) 170 public bool ProcessImageQueue(int packetsToSend)
171 { 171 {
172 J2KImage imagereq; 172 m_lastloopprocessed = DateTime.Now.Ticks;
173 int numCollected = 0; 173 int packetsSent = 0;
174 174
175 //lock (m_syncRoot) 175 while (packetsSent < packetsToSend)
176 //{ 176 {
177 m_lastloopprocessed = DateTime.Now.Ticks; 177 J2KImage image = GetHighestPriorityImage();
178 178
179 // This can happen during Close() 179 // If null was returned, the texture priority queue is currently empty
180 if (m_client == null) 180 if (image == null)
181 return false; 181 return false;
182
183 while ((imagereq = GetHighestPriorityImage()) != null)
184 {
185 if (imagereq.IsDecoded == true)
186 {
187 ++numCollected;
188 182
189 if (imagereq.SendPackets(m_client, maxpack)) 183 if (image.IsDecoded)
190 { 184 {
191 // Send complete. Destroy any knowledge of this transfer 185 int sent;
192 RemoveImageFromQueue(imagereq); 186 bool imageDone = image.SendPackets(m_client, packetsToSend - packetsSent, out sent);
193 } 187 packetsSent += sent;
194 }
195 188
196 if (numCollected == count) 189 // If the send is complete, destroy any knowledge of this transfer
197 break; 190 if (imageDone)
191 RemoveImageFromQueue(image);
198 } 192 }
199 //} 193 else
194 {
195 // TODO: This is a limitation of how LLImageManager is currently
196 // written. Undecoded textures should not be going into the priority
197 // queue, because a high priority undecoded texture will clog up the
198 // pipeline for a client
199 return true;
200 }
201 }
200 202
201 return m_priorityQueue.Count > 0; 203 return m_priorityQueue.Count > 0;
202 } 204 }
203 205
204 //Faux destructor 206 /// <summary>
207 /// Faux destructor
208 /// </summary>
205 public void Close() 209 public void Close()
206 { 210 {
207 m_shuttingdown = true; 211 m_shuttingdown = true;
208 m_j2kDecodeModule = null;
209 m_assetCache = null;
210 m_client = null;
211 } 212 }
212 213
213 #region Priority Queue Helpers 214 #region Priority Queue Helpers
@@ -218,13 +219,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
218 219
219 lock (m_syncRoot) 220 lock (m_syncRoot)
220 { 221 {
221
222 if (m_priorityQueue.Count > 0) 222 if (m_priorityQueue.Count > 0)
223 { 223 {
224 try 224 try { image = m_priorityQueue.FindMax(); }
225 {
226 image = m_priorityQueue.FindMax();
227 }
228 catch (Exception) { } 225 catch (Exception) { }
229 } 226 }
230 } 227 }
@@ -236,20 +233,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
236 image.PriorityQueueHandle = null; 233 image.PriorityQueueHandle = null;
237 234
238 lock (m_syncRoot) 235 lock (m_syncRoot)
239 try 236 try { m_priorityQueue.Add(ref image.PriorityQueueHandle, image); }
240 {
241 m_priorityQueue.Add(ref image.PriorityQueueHandle, image);
242 }
243 catch (Exception) { } 237 catch (Exception) { }
244 } 238 }
245 239
246 void RemoveImageFromQueue(J2KImage image) 240 void RemoveImageFromQueue(J2KImage image)
247 { 241 {
248 lock (m_syncRoot) 242 lock (m_syncRoot)
249 try 243 try { m_priorityQueue.Delete(image.PriorityQueueHandle); }
250 {
251 m_priorityQueue.Delete(image.PriorityQueueHandle);
252 }
253 catch (Exception) { } 244 catch (Exception) { }
254 } 245 }
255 246