OSDN Git Service

Change a directory tree
[peercast-im/PeerCastIM.git] / core / common / icy.cpp
1 #include "icy.h"
2 #include "socket.h"
3 #ifdef _DEBUG
4 #include "chkMemoryLeak.h"
5 #define DEBUG_NEW new(__FILE__, __LINE__)
6 #define new DEBUG_NEW
7 #endif
8
9 // ------------------------------------------------
10 void ICYSource::stream(Channel *ch)
11 {
12         ChannelStream *source=NULL;
13         try 
14         {
15
16                 if (!ch->sock)
17                         throw StreamException("ICY channel has no socket");
18
19                 ch->resetPlayTime();
20
21                 ch->setStatus(Channel::S_BROADCASTING);
22                 source = ch->createSource();
23                 ch->readStream(*ch->sock,source);
24
25         }catch(StreamException &e)
26         {
27                 LOG_ERROR("Channel aborted: %s",e.msg);
28         }
29
30
31         ch->setStatus(Channel::S_CLOSING);
32
33         if (ch->sock)
34         {
35                 ch->sock->close();
36                 delete ch->sock;
37                 ch->sock = NULL;
38         }
39
40         if (source)
41                 delete source;
42
43 }