1 |
/* |
---|
2 |
* Copyright (C) 2005-2007 by Daniel Wagner |
---|
3 |
* |
---|
4 |
* This file is part of FFADO |
---|
5 |
* FFADO = Free Firewire (pro-)audio drivers for linux |
---|
6 |
* |
---|
7 |
* FFADO is based upon FreeBoB |
---|
8 |
* |
---|
9 |
* This library is free software; you can redistribute it and/or |
---|
10 |
* modify it under the terms of the GNU Lesser General Public |
---|
11 |
* License version 2.1, as published by the Free Software Foundation; |
---|
12 |
* |
---|
13 |
* This library is distributed in the hope that it will be useful, |
---|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 |
* Lesser General Public License for more details. |
---|
17 |
* |
---|
18 |
* You should have received a copy of the GNU Lesser General Public |
---|
19 |
* License along with this library; if not, write to the Free Software |
---|
20 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
---|
21 |
* MA 02110-1301 USA |
---|
22 |
*/ |
---|
23 |
|
---|
24 |
#ifndef BEBOB_AVDEVICE_H |
---|
25 |
#define BEBOB_AVDEVICE_H |
---|
26 |
|
---|
27 |
#include <stdint.h> |
---|
28 |
|
---|
29 |
#include "debugmodule/debugmodule.h" |
---|
30 |
#include "libavc/avc_definitions.h" |
---|
31 |
#include "libavc/general/avc_extended_cmd_generic.h" |
---|
32 |
|
---|
33 |
#include "bebob/bebob_avplug.h" |
---|
34 |
#include "bebob/bebob_avdevice_subunit.h" |
---|
35 |
#include "bebob/GenericMixer.h" |
---|
36 |
|
---|
37 |
#include "libstreaming/AmdtpStreamProcessor.h" |
---|
38 |
#include "libstreaming/AmdtpPort.h" |
---|
39 |
#include "libstreaming/AmdtpPortInfo.h" |
---|
40 |
|
---|
41 |
#include "libutil/serialize.h" |
---|
42 |
|
---|
43 |
#include "ffadodevice.h" |
---|
44 |
|
---|
45 |
#include <sstream> |
---|
46 |
#include <vector> |
---|
47 |
|
---|
48 |
class ConfigRom; |
---|
49 |
class Ieee1394Service; |
---|
50 |
|
---|
51 |
namespace BeBoB { |
---|
52 |
|
---|
53 |
struct VendorModelEntry { |
---|
54 |
unsigned int vendor_id; |
---|
55 |
unsigned int model_id; |
---|
56 |
char *vendor_name; |
---|
57 |
char *model_name; |
---|
58 |
}; |
---|
59 |
|
---|
60 |
class AvDevice : public FFADODevice { |
---|
61 |
public: |
---|
62 |
AvDevice( std::auto_ptr<ConfigRom>( configRom ), |
---|
63 |
Ieee1394Service& ieee1394Service, |
---|
64 |
int nodeId ); |
---|
65 |
virtual ~AvDevice(); |
---|
66 |
|
---|
67 |
void setVerboseLevel(int l); |
---|
68 |
|
---|
69 |
static bool probe( ConfigRom& configRom ); |
---|
70 |
virtual bool discover(); |
---|
71 |
|
---|
72 |
virtual bool setSamplingFrequency( int ); |
---|
73 |
virtual int getSamplingFrequency( ); |
---|
74 |
|
---|
75 |
virtual int getStreamCount(); |
---|
76 |
virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i); |
---|
77 |
|
---|
78 |
virtual bool prepare(); |
---|
79 |
bool lock(); |
---|
80 |
bool unlock(); |
---|
81 |
|
---|
82 |
bool startStreamByIndex(int i); |
---|
83 |
bool stopStreamByIndex(int i); |
---|
84 |
|
---|
85 |
virtual void showDevice(); |
---|
86 |
|
---|
87 |
Ieee1394Service& get1394Service() |
---|
88 |
{ return *m_p1394Service; } |
---|
89 |
|
---|
90 |
AvPlugManager& getPlugManager() |
---|
91 |
{ return *m_pPlugManager; } |
---|
92 |
|
---|
93 |
struct SyncInfo { |
---|
94 |
SyncInfo( AvPlug& source, |
---|
95 |
AvPlug& destination, |
---|
96 |
std::string description ) |
---|
97 |
: m_source( &source ) |
---|
98 |
, m_destination( &destination ) |
---|
99 |
, m_description( description ) |
---|
100 |
{} |
---|
101 |
SyncInfo() |
---|
102 |
: m_source( 0 ) |
---|
103 |
, m_destination( 0 ) |
---|
104 |
, m_description( "" ) |
---|
105 |
{} |
---|
106 |
AvPlug* m_source; |
---|
107 |
AvPlug* m_destination; |
---|
108 |
std::string m_description; |
---|
109 |
}; |
---|
110 |
|
---|
111 |
typedef std::vector<SyncInfo> SyncInfoVector; |
---|
112 |
const SyncInfoVector& getSyncInfos() const |
---|
113 |
{ return m_syncInfos; } |
---|
114 |
const SyncInfo* getActiveSyncInfo() const |
---|
115 |
{ return m_activeSyncInfo; } |
---|
116 |
bool setActiveSync( const SyncInfo& syncInfo ); |
---|
117 |
|
---|
118 |
bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; |
---|
119 |
static AvDevice* deserialize( Glib::ustring basePath, |
---|
120 |
Util::IODeserialize& deser, |
---|
121 |
Ieee1394Service& ieee1394Service ); |
---|
122 |
AvDeviceSubunitAudio* getAudioSubunit( AVC::subunit_id_t subunitId ) |
---|
123 |
{ return dynamic_cast<AvDeviceSubunitAudio*>( |
---|
124 |
getSubunit( AVC1394_SUBUNIT_AUDIO , subunitId ));}; |
---|
125 |
|
---|
126 |
protected: |
---|
127 |
|
---|
128 |
bool enumerateSubUnits(); |
---|
129 |
|
---|
130 |
bool discoverPlugs(); |
---|
131 |
bool discoverPlugsPCR( AvPlug::EAvPlugDirection plugDirection, |
---|
132 |
AVC::plug_id_t plugMaxId ); |
---|
133 |
bool discoverPlugsExternal( AvPlug::EAvPlugDirection plugDirection, |
---|
134 |
AVC::plug_id_t plugMaxId ); |
---|
135 |
bool discoverPlugConnections(); |
---|
136 |
bool discoverSyncModes(); |
---|
137 |
bool discoverSubUnitsPlugConnections(); |
---|
138 |
|
---|
139 |
AvDeviceSubunit* getSubunit( AVC::subunit_type_t subunitType, |
---|
140 |
AVC::subunit_id_t subunitId ) const; |
---|
141 |
|
---|
142 |
unsigned int getNrOfSubunits( AVC::subunit_type_t subunitType ) const; |
---|
143 |
AvPlugConnection* getPlugConnection( AvPlug& srcPlug ) const; |
---|
144 |
|
---|
145 |
AvPlug* getSyncPlug( int maxPlugId, AvPlug::EAvPlugDirection ); |
---|
146 |
|
---|
147 |
AvPlug* getPlugById( AvPlugVector& plugs, |
---|
148 |
AvPlug::EAvPlugDirection plugDireciton, |
---|
149 |
int id ); |
---|
150 |
AvPlugVector getPlugsByType( AvPlugVector& plugs, |
---|
151 |
AvPlug::EAvPlugDirection plugDirection, |
---|
152 |
AvPlug::EAvPlugType type); |
---|
153 |
|
---|
154 |
bool addPlugToProcessor( AvPlug& plug, Streaming::StreamProcessor *processor, |
---|
155 |
Streaming::AmdtpAudioPort::E_Direction direction); |
---|
156 |
|
---|
157 |
bool setSamplingFrequencyPlug( AvPlug& plug, |
---|
158 |
AvPlug::EAvPlugDirection direction, |
---|
159 |
AVC::ESamplingFrequency samplingFrequency ); |
---|
160 |
|
---|
161 |
void showAvPlugs( AvPlugVector& plugs ) const; |
---|
162 |
|
---|
163 |
bool checkSyncConnectionsAndAddToList( AvPlugVector& plhs, |
---|
164 |
AvPlugVector& prhs, |
---|
165 |
std::string syncDescription ); |
---|
166 |
|
---|
167 |
static bool serializeSyncInfoVector( Glib::ustring basePath, |
---|
168 |
Util::IOSerialize& ser, |
---|
169 |
const SyncInfoVector& vec ); |
---|
170 |
static bool deserializeSyncInfoVector( Glib::ustring basePath, |
---|
171 |
Util::IODeserialize& deser, |
---|
172 |
AvDevice& avDevice, |
---|
173 |
SyncInfoVector& vec ); |
---|
174 |
protected: |
---|
175 |
AvPlugVector m_pcrPlugs; |
---|
176 |
AvPlugVector m_externalPlugs; |
---|
177 |
AvPlugConnectionVector m_plugConnections; |
---|
178 |
AvDeviceSubunitVector m_subunits; |
---|
179 |
AvPlugManager* m_pPlugManager; |
---|
180 |
SyncInfoVector m_syncInfos; |
---|
181 |
SyncInfo* m_activeSyncInfo; |
---|
182 |
struct VendorModelEntry* m_model; |
---|
183 |
GenericMixer* m_Mixer; |
---|
184 |
|
---|
185 |
// streaming stuff |
---|
186 |
typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector; |
---|
187 |
StreamProcessorVector m_receiveProcessors; |
---|
188 |
StreamProcessorVector m_transmitProcessors; |
---|
189 |
}; |
---|
190 |
|
---|
191 |
} |
---|
192 |
|
---|
193 |
#endif |
---|