diff options
Merge branch 'master' into vehicles
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs | 76 |
1 files changed, 36 insertions, 40 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs index 343f537..d25bf95 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLImageManager.cs | |||
@@ -59,6 +59,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
59 | private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); | 59 | private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); |
60 | private object m_syncRoot = new object(); | 60 | private object m_syncRoot = new object(); |
61 | 61 | ||
62 | private IHyperAssetService m_hyperAssets; | ||
63 | |||
62 | public LLClientView Client { get { return m_client; } } | 64 | public LLClientView Client { get { return m_client; } } |
63 | public AssetBase MissingImage { get { return m_missingImage; } } | 65 | public AssetBase MissingImage { get { return m_missingImage; } } |
64 | 66 | ||
@@ -74,6 +76,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
74 | m_log.Error("[ClientView] - Couldn't set missing image asset, falling back to missing image packet. This is known to crash the client"); | 76 | m_log.Error("[ClientView] - Couldn't set missing image asset, falling back to missing image packet. This is known to crash the client"); |
75 | 77 | ||
76 | m_j2kDecodeModule = pJ2kDecodeModule; | 78 | m_j2kDecodeModule = pJ2kDecodeModule; |
79 | m_hyperAssets = client.Scene.RequestModuleInterface<IHyperAssetService>(); | ||
77 | } | 80 | } |
78 | 81 | ||
79 | /// <summary> | 82 | /// <summary> |
@@ -146,6 +149,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
146 | imgrequest = new J2KImage(this); | 149 | imgrequest = new J2KImage(this); |
147 | imgrequest.J2KDecoder = m_j2kDecodeModule; | 150 | imgrequest.J2KDecoder = m_j2kDecodeModule; |
148 | imgrequest.AssetService = m_assetCache; | 151 | imgrequest.AssetService = m_assetCache; |
152 | imgrequest.AgentID = m_client.AgentId; | ||
153 | imgrequest.HyperAssets = m_hyperAssets; | ||
149 | imgrequest.DiscardLevel = newRequest.DiscardLevel; | 154 | imgrequest.DiscardLevel = newRequest.DiscardLevel; |
150 | imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); | 155 | imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); |
151 | imgrequest.Priority = newRequest.Priority; | 156 | imgrequest.Priority = newRequest.Priority; |
@@ -162,47 +167,48 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
162 | } | 167 | } |
163 | } | 168 | } |
164 | 169 | ||
165 | public bool ProcessImageQueue(int count, int maxpack) | 170 | public bool ProcessImageQueue(int packetsToSend) |
166 | { | 171 | { |
167 | J2KImage imagereq; | 172 | m_lastloopprocessed = DateTime.Now.Ticks; |
168 | int numCollected = 0; | 173 | int packetsSent = 0; |
169 | 174 | ||
170 | //lock (m_syncRoot) | 175 | while (packetsSent < packetsToSend) |
171 | //{ | 176 | { |
172 | m_lastloopprocessed = DateTime.Now.Ticks; | 177 | J2KImage image = GetHighestPriorityImage(); |
173 | 178 | ||
174 | // This can happen during Close() | 179 | // If null was returned, the texture priority queue is currently empty |
175 | if (m_client == null) | 180 | if (image == null) |
176 | return false; | 181 | return false; |
177 | |||
178 | while ((imagereq = GetHighestPriorityImage()) != null) | ||
179 | { | ||
180 | if (imagereq.IsDecoded == true) | ||
181 | { | ||
182 | ++numCollected; | ||
183 | 182 | ||
184 | if (imagereq.SendPackets(m_client, maxpack)) | 183 | if (image.IsDecoded) |
185 | { | 184 | { |
186 | // Send complete. Destroy any knowledge of this transfer | 185 | int sent; |
187 | RemoveImageFromQueue(imagereq); | 186 | bool imageDone = image.SendPackets(m_client, packetsToSend - packetsSent, out sent); |
188 | } | 187 | packetsSent += sent; |
189 | } | ||
190 | 188 | ||
191 | if (numCollected == count) | 189 | // If the send is complete, destroy any knowledge of this transfer |
192 | break; | 190 | if (imageDone) |
191 | RemoveImageFromQueue(image); | ||
192 | } | ||
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; | ||
193 | } | 200 | } |
194 | //} | 201 | } |
195 | 202 | ||
196 | return m_priorityQueue.Count > 0; | 203 | return m_priorityQueue.Count > 0; |
197 | } | 204 | } |
198 | 205 | ||
199 | //Faux destructor | 206 | /// <summary> |
207 | /// Faux destructor | ||
208 | /// </summary> | ||
200 | public void Close() | 209 | public void Close() |
201 | { | 210 | { |
202 | m_shuttingdown = true; | 211 | m_shuttingdown = true; |
203 | m_j2kDecodeModule = null; | ||
204 | m_assetCache = null; | ||
205 | m_client = null; | ||
206 | } | 212 | } |
207 | 213 | ||
208 | #region Priority Queue Helpers | 214 | #region Priority Queue Helpers |
@@ -213,13 +219,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
213 | 219 | ||
214 | lock (m_syncRoot) | 220 | lock (m_syncRoot) |
215 | { | 221 | { |
216 | |||
217 | if (m_priorityQueue.Count > 0) | 222 | if (m_priorityQueue.Count > 0) |
218 | { | 223 | { |
219 | try | 224 | try { image = m_priorityQueue.FindMax(); } |
220 | { | ||
221 | image = m_priorityQueue.FindMax(); | ||
222 | } | ||
223 | catch (Exception) { } | 225 | catch (Exception) { } |
224 | } | 226 | } |
225 | } | 227 | } |
@@ -231,20 +233,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
231 | image.PriorityQueueHandle = null; | 233 | image.PriorityQueueHandle = null; |
232 | 234 | ||
233 | lock (m_syncRoot) | 235 | lock (m_syncRoot) |
234 | try | 236 | try { m_priorityQueue.Add(ref image.PriorityQueueHandle, image); } |
235 | { | ||
236 | m_priorityQueue.Add(ref image.PriorityQueueHandle, image); | ||
237 | } | ||
238 | catch (Exception) { } | 237 | catch (Exception) { } |
239 | } | 238 | } |
240 | 239 | ||
241 | void RemoveImageFromQueue(J2KImage image) | 240 | void RemoveImageFromQueue(J2KImage image) |
242 | { | 241 | { |
243 | lock (m_syncRoot) | 242 | lock (m_syncRoot) |
244 | try | 243 | try { m_priorityQueue.Delete(image.PriorityQueueHandle); } |
245 | { | ||
246 | m_priorityQueue.Delete(image.PriorityQueueHandle); | ||
247 | } | ||
248 | catch (Exception) { } | 244 | catch (Exception) { } |
249 | } | 245 | } |
250 | 246 | ||