Stream.Write error. (SetGlobalOnLoadExternalResourceHandler)

F-IN-BOX for Delphi / Builder C++ / VCL
Mantra
Posts: 7
Joined: Wed May 28, 2008 11:44 am

Stream.Write error. (SetGlobalOnLoadExternalResourceHandler)

Postby Mantra » Wed May 28, 2008 12:00 pm

I greet you, the developers so wonderful component.

I have a question to transfer data (stream) in a flash.
I read forum, enjoyed the search, but the question remains open.

Sometimes when I convey the data in flash, using SetGlobalOnLoadExternalResourceHandler, I have an error occurs: "EWriteError with message 'Stream write error'".
Such a mistake can I cause, for example, blocking the computer (Win + L) during the handover flow into the flash.

The code (Delphi 7):

Code: Select all

while i> 0 do
    begin
      FlashMem.Clear;
      FlashMem.Write (Buff, SizeOf (Buff));
      nWrBytes: = Stream.Write (FlashMem.Memory^, FlashMem.Size);
      if nWrBytes = 0 then break;
    end;


FlashMem - TMemoryStream
Buff- array [1 .. 1024] of char

The problem happens rarely, but when it happens flash stops responding to events.
Code working, but I assume that something I missed all the same.

It is hope for your help.
Apologize for my poor English.
Thank you.

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Wed May 28, 2008 12:45 pm

Thank you for your question.

Is it possible to understand, what line of the code causes the exception?
May be you can prepare a small example with source code that I can test and debug... It would be great!

Thank you.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

Mantra
Posts: 7
Joined: Wed May 28, 2008 11:44 am

Postby Mantra » Wed May 28, 2008 1:04 pm

Can i write data to the Stream byte by byte, just like common FlashPlayer plays a swf file on the internet?

I'm trying to implement it in the flow TThread, passing reference to him Stream and recording data so code that I have shown above.

Or maybe you already have an example of such implementation or you can tell me how to write data (Stream.Write) in your Stream.

Mantra
Posts: 7
Joined: Wed May 28, 2008 11:44 am

Postby Mantra » Wed May 28, 2008 1:09 pm

Error occurred here:

Code: Select all

Stream.Write(FlashMem.Memory^, FlashMem.Size);


Please, help me. :cry:

p.s. And not always error occurs.

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Wed May 28, 2008 1:25 pm

We should debug it together. Please check your email, I've just sent you a letter.

Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

Mantra
Posts: 7
Joined: Wed May 28, 2008 11:44 am

Postby Mantra » Tue Jun 03, 2008 8:50 am

This problem is solved.
Thank you, Softanics.

To solve the problem by writing data (Stream) in flash (in the TThread) must be used synchronization in the transfer and the release of Stream. :wink:

The only thing left to do in FlashPlayerControl - this map data downloads result in flash, with "byte by byte" transfer them into the stream. (Illustration downloads in preloading movie) :roll:


We hope for you, Softanics. :wink:

Mantra
Posts: 7
Joined: Wed May 28, 2008 11:44 am

Postby Mantra » Wed Jun 11, 2008 11:22 am

This problem is solved!

Thanks you very much, Softanics, working perfectly now! :!:

andreaarg
Posts: 14
Joined: Tue Aug 26, 2008 11:53 pm

Postby andreaarg » Sat May 30, 2009 12:12 am

I'm developing an application to store and organize image files. The main picture viewer is developed in Flex. It's possible to store pictures in folders, see a thumbnail index and to see the full picture (similar to Picasa).
I have two PCs, one is slower than the other. When running the application on the the slower one, the "Write Stream Error" exception often occurs. On the other Pc, i hardly get the error.
I write to streams from two different parts of the application, one is a thread (using Synchronize, works ok) that handles the data requests, and the other is a singleton non-threaded object which writes the results of thumbnail generation. The exception occurs:
try
flashRequest.Stream.CopyFrom(MsgHiloStream.Stream,MsgHiloStream.Stream.Size)
finally
flashRequest.Stream.Free;
flashRequest.Free;
self.fListaRequestsArchivos.Delete(Indice);
end;

Where:
- "flashRequest" is an object that stores the stream from the OnLoadExternalResourceEx event, and some more information that is parsed from the "URL" String that tells the delphi application what the flex application needs.
- MsgHiloStream.Stream is a "message object" that stores a thumbnail generated by a multithreaded thumbnail generator in which thumbnail requests are queued and served. The thumbnail generator creates the thumbnail, stores it in a message, and posts the message to the singleton "TGUIFlash" object that writes it back to the corresponding stream (stored in "flashRequest")

The error occurs when the flex application is stressed out, when i'm opening several pictures with little time between clicks, etc.

Any recommendation to solve it / avoid it from happening?

Thanks in advance.
Andrea.

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Mon Jun 01, 2009 2:00 pm

andreaarg wrote:Any recommendation to solve it / avoid it from happening?


CopyFrom raises the exception becuase flashRequest.Stream.Write writes returns 0 written bytes. So I recommend just handle the exception, or replace CopyFrom with implementation that doesn't raise the exception.

Thank you.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

andreaarg
Posts: 14
Joined: Tue Aug 26, 2008 11:53 pm

Postby andreaarg » Fri Jun 05, 2009 7:39 pm

Catching the exception and adding some actionscript code to handle thumbnails that should have been loaded but weren't have done the trick.
Thanks a lot.


Return to “Delphi / Builder / VCL Edition”

Who is online

Users browsing this forum: No registered users and 13 guests

cron