23 May '13 - 08:40 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: nethradio sample multithreaded in delphi  (Read 838 times)
barpas
Posts: 5


« on: 12 Apr '11 - 20:29 »
Reply with quoteQuote

haloo everybody ...
i'm new here - i'm just starting to lern bass because i need to make simulatously download net radio streams

i take netradio example - in statusproc add few lines to save stream to disk - it working fine

if FileStream = nil then
      FileStream := TFileStream.Create('UrlRecord.mp3', fmCreate);
    if (buffer <> nil) then
      FileStream.Write(buffer^, len)

but how to create simultaneously downloading a stream from 2 servers?

i tray many times to do something to create separate object for each stream

eg .i tray to create class like myRec like this:


  myRec=class
    cthread: DWORD;
    chan: HSTREAM;
    ThreadId: Cardinal;
    constructor create;
    function OpenURL(url: PChar): Integer;

  end;


for first step in constructor i write:

  cthread:=0;
  chan:=0;
  cthread := BeginThread(nil, 0, @myRec.OpenURL, PChar('http://listen.radionomy.com/rock-as-u-like-it.m3u'), 0, ThreadId);

but it not working - in openURL on function

chan := BASS_StreamCreateURL(url, 0, BASS_STREAM_STATUS, @StatusProc, nil);
  
falss whit message:

Exception EOSError in module netradio.exe at 0000d0e9.
System Error. Code 5.


can anybody help me ?

(sory my english - if you dont understand what it means i tray to explain in other words)
« Last Edit: 12 Apr '11 - 20:35 by barpas » Logged
Ian @ un4seen
Administrator
Posts: 15269


« Reply #1 on: 13 Apr '11 - 15:14 »
Reply with quoteQuote

Is it crashing in BASS_StreamCreateURL or in your "StatusProc" callback function, eg. does it still crash if you remove the callback function? If it is crashing in the callback function, are you using a different filename for each recording? If you are not, then I guess that could explain the problem, ie. the "FileStream" creation is failing for the 2nd stream. To be safe, you could check that the file creation is successful before writing to it, something like this...

    if FileStream = nil then
    begin
      FileStream := TFileStream.Create('UrlRecord.mp3', fmCreate);
      if FileStream = nil then // failed
        exit;
    end;
    if (buffer <> nil) then
      FileStream.Write(buffer^, len)
Logged
Wishmaster
Posts: 124


« Reply #2 on: 13 Apr '11 - 22:28 »
Reply with quoteQuote

http://streamwriter.org/en/
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines