1 |
/* $Id$ */ |
---|
2 |
|
---|
3 |
/* |
---|
4 |
* FreeBob Streaming API |
---|
5 |
* FreeBob = Firewire (pro-)audio for linux |
---|
6 |
* |
---|
7 |
* http://freebob.sf.net |
---|
8 |
* |
---|
9 |
* Copyright (C) 2005,2006 Pieter Palmers <pieterpalmers@users.sourceforge.net> |
---|
10 |
* |
---|
11 |
* This program is free software {} you can redistribute it and/or modify |
---|
12 |
* it under the terms of the GNU General Public License as published by |
---|
13 |
* the Free Software Foundation {} either version 2 of the License, or |
---|
14 |
* (at your option) any later version. |
---|
15 |
* |
---|
16 |
* This program is distributed in the hope that it will be useful, |
---|
17 |
* but WITHOUT ANY WARRANTY {} without even the implied warranty of |
---|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
19 |
* GNU General Public License for more details. |
---|
20 |
* |
---|
21 |
* You should have received a copy of the GNU General Public License |
---|
22 |
* along with this program {} if not, write to the Free Software |
---|
23 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
24 |
* |
---|
25 |
* |
---|
26 |
* |
---|
27 |
*/ |
---|
28 |
|
---|
29 |
#include "IsoStreamManager.h" |
---|
30 |
#include "IsoStream.h" |
---|
31 |
|
---|
32 |
#include <assert.h> |
---|
33 |
|
---|
34 |
namespace FreebobStreaming |
---|
35 |
{ |
---|
36 |
|
---|
37 |
IsoStreamManager::IsoStreamManager() |
---|
38 |
{ |
---|
39 |
|
---|
40 |
} |
---|
41 |
|
---|
42 |
IsoStreamManager::~IsoStreamManager() |
---|
43 |
{ |
---|
44 |
|
---|
45 |
} |
---|
46 |
|
---|
47 |
int IsoStreamManager::RegisterStream(IsoStream *stream) |
---|
48 |
{ |
---|
49 |
assert(stream); |
---|
50 |
|
---|
51 |
IsoRecvStream *srx; |
---|
52 |
IsoXmitStream *stx; |
---|
53 |
|
---|
54 |
srx=dynamic_cast<IsoRecvStream *>(stream); |
---|
55 |
|
---|
56 |
if (srx) { |
---|
57 |
m_IsoRecvStreams.push_back(srx); |
---|
58 |
return 0; |
---|
59 |
} |
---|
60 |
|
---|
61 |
stx=dynamic_cast<IsoXmitStream *>(stream); |
---|
62 |
|
---|
63 |
if (stx) { |
---|
64 |
m_IsoXmitStreams.push_back(stx); |
---|
65 |
return 0; |
---|
66 |
} |
---|
67 |
|
---|
68 |
} |
---|
69 |
|
---|
70 |
int IsoStreamManager::UnregisterStream(IsoStream *stream) |
---|
71 |
{ |
---|
72 |
assert(stream); |
---|
73 |
|
---|
74 |
for ( IsoRecvStreamVectorIterator it = m_IsoRecvStreams.begin(); |
---|
75 |
it != m_IsoRecvStreams.end(); |
---|
76 |
++it ) |
---|
77 |
{ |
---|
78 |
// FIXME: how do I compare these two pointers? |
---|
79 |
IsoStream* s = dynamic_cast<IsoStream *>(*it); |
---|
80 |
if ( s == stream ) { |
---|
81 |
m_IsoRecvStreams.erase(it); |
---|
82 |
return 0; |
---|
83 |
} |
---|
84 |
} |
---|
85 |
|
---|
86 |
for ( IsoXmitStreamVectorIterator it = m_IsoXmitStreams.begin(); |
---|
87 |
it != m_IsoXmitStreams.end(); |
---|
88 |
++it ) |
---|
89 |
{ |
---|
90 |
// FIXME: how do I compare these two pointers? |
---|
91 |
IsoStream* s = dynamic_cast<IsoStream *>(*it); |
---|
92 |
if ( s == stream ) { |
---|
93 |
m_IsoXmitStreams.erase(it); |
---|
94 |
return 0; |
---|
95 |
} |
---|
96 |
} |
---|
97 |
|
---|
98 |
return -1; //not found |
---|
99 |
|
---|
100 |
} |
---|
101 |
|
---|
102 |
|
---|
103 |
} |
---|