root/trunk/libffado/src/genericavc/avc_avdevice.cpp

Revision 784, 22.9 kB (checked in by ppalmers, 15 years ago)

fix shutdown bug

Line 
1 /*
2  * Copyright (C) 2005-2007 by Pieter Palmers
3  * Copyright (C) 2005-2007 by Daniel Wagner
4  *
5  * This file is part of FFADO
6  * FFADO = Free Firewire (pro-)audio drivers for linux
7  *
8  * FFADO is based upon FreeBoB.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #include "genericavc/avc_avdevice.h"
26
27 #include "libieee1394/configrom.h"
28 #include "libieee1394/ieee1394service.h"
29
30 #include "libavc/avc_definitions.h"
31 #include "libavc/general/avc_plug_info.h"
32 #include "libavc/general/avc_extended_plug_info.h"
33
34 #include "debugmodule/debugmodule.h"
35
36 #include "config.h"
37
38 #include <string>
39 #include <stdint.h>
40 #include <assert.h>
41 #include <netinet/in.h>
42 #include <iostream>
43 #include <sstream>
44
45 #include <libraw1394/csr.h>
46
47 using namespace AVC;
48
49 namespace GenericAVC {
50
51 IMPL_DEBUG_MODULE( AvDevice, AvDevice, DEBUG_LEVEL_NORMAL );
52
53 AvDevice::AvDevice( DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ))
54     : FFADODevice( d, configRom )
55 {
56     debugOutput( DEBUG_LEVEL_VERBOSE, "Created GenericAVC::AvDevice (NodeID %d)\n",
57                  getConfigRom().getNodeId() );
58     addOption(Util::OptionContainer::Option("snoopMode",false));
59 }
60
61 AvDevice::~AvDevice()
62 {
63     for ( StreamProcessorVectorIterator it = m_receiveProcessors.begin();
64           it != m_receiveProcessors.end();
65           ++it )
66     {
67         delete *it;
68     }
69     for ( StreamProcessorVectorIterator it = m_transmitProcessors.begin();
70           it != m_transmitProcessors.end();
71           ++it )
72     {
73         delete *it;
74     }
75 }
76
77 bool
78 AvDevice::probe( ConfigRom& configRom )
79 {
80     unsigned int vendorId = configRom.getNodeVendorId();
81     unsigned int modelId = configRom.getModelId();
82
83     GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_genericavc.txt" );
84     if ( vendorModel.parse() ) {
85         return vendorModel.isPresent( vendorId, modelId );
86     }
87
88     return false;
89 }
90
91 FFADODevice *
92 AvDevice::createDevice(DeviceManager& d, std::auto_ptr<ConfigRom>( configRom ))
93 {
94     return new AvDevice(d, configRom );
95 }
96
97 bool
98 AvDevice::discover()
99 {
100     // check if we already have a valid VendorModel entry
101     // e.g. because a subclass called this function
102     if (!GenericAVC::VendorModel::isValid(m_model)) {
103         unsigned int vendorId = getConfigRom().getNodeVendorId();
104         unsigned int modelId = getConfigRom().getModelId();
105
106         GenericAVC::VendorModel vendorModel( SHAREDIR "/ffado_driver_genericavc.txt" );
107         if ( vendorModel.parse() ) {
108             m_model = vendorModel.find( vendorId, modelId );
109         }
110
111         if (!GenericAVC::VendorModel::isValid(m_model)) {
112             return false;
113         }
114         debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n",
115                 m_model.vendor_name.c_str(), m_model.model_name.c_str());
116     }
117
118     if ( !Unit::discover() ) {
119         debugError( "Could not discover unit\n" );
120         return false;
121     }
122
123     if((getAudioSubunit( 0 ) == NULL)) {
124         debugError( "Unit doesn't have an Audio subunit.\n");
125         return false;
126     }
127     if((getMusicSubunit( 0 ) == NULL)) {
128         debugError( "Unit doesn't have a Music subunit.\n");
129         return false;
130     }
131
132     return true;
133 }
134
135 void
136 AvDevice::setVerboseLevel(int l)
137 {
138     setDebugLevel(l);
139     m_pPlugManager->setVerboseLevel(l);
140     FFADODevice::setVerboseLevel(l);
141     AVC::Unit::setVerboseLevel(l);
142     debugOutput( DEBUG_LEVEL_VERBOSE, "Setting verbose level to %d...\n", l );
143 }
144
145 int
146 AvDevice::getSamplingFrequency( ) {
147     AVC::Plug* inputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 );
148     if ( !inputPlug ) {
149         debugError( "setSampleRate: Could not retrieve iso input plug 0\n" );
150         return false;
151     }
152     AVC::Plug* outputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Output, 0 );
153     if ( !outputPlug ) {
154         debugError( "setSampleRate: Could not retrieve iso output plug 0\n" );
155         return false;
156     }
157
158     int samplerate_playback=inputPlug->getSampleRate();
159     int samplerate_capture=outputPlug->getSampleRate();
160
161     if (samplerate_playback != samplerate_capture) {
162         debugWarning("Samplerates for capture and playback differ!\n");
163     }
164     return samplerate_capture;
165 }
166
167 bool
168 AvDevice::setSamplingFrequency( int s )
169 {
170     bool snoopMode=false;
171     if(!getOption("snoopMode", snoopMode)) {
172         debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");
173     }
174
175     if(snoopMode) {
176         int current_sr=getSamplingFrequency();
177         if (current_sr != s ) {
178             debugError("In snoop mode it is impossible to set the sample rate.\n");
179             debugError("Please start the client with the correct setting.\n");
180             return false;
181         }
182         return true;
183     } else {
184         AVC::Plug* plug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 );
185         if ( !plug ) {
186             debugError( "setSampleRate: Could not retrieve iso input plug 0\n" );
187             return false;
188         }
189
190         if ( !plug->setSampleRate( s ) )
191         {
192             debugError( "setSampleRate: Setting sample rate failed\n" );
193             return false;
194         }
195
196         plug = getPlugById( m_pcrPlugs, Plug::eAPD_Output,  0 );
197         if ( !plug ) {
198             debugError( "setSampleRate: Could not retrieve iso output plug 0\n" );
199             return false;
200         }
201
202         if ( !plug->setSampleRate( s ) )
203         {
204             debugError( "setSampleRate: Setting sample rate failed\n" );
205             return false;
206         }
207
208         debugOutput( DEBUG_LEVEL_VERBOSE,
209                      "setSampleRate: Set sample rate to %d\n",
210                      s );
211         return true;
212     }
213     // not executable
214     return false;
215
216 }
217
218 FFADODevice::ClockSourceVector
219 AvDevice::getSupportedClockSources() {
220     FFADODevice::ClockSourceVector r;
221
222     PlugVector syncMSUInputPlugs = m_pPlugManager->getPlugsByType(
223         eST_Music,
224         0,
225         0xff,
226         0xff,
227         Plug::eAPA_SubunitPlug,
228         Plug::eAPD_Input,
229         Plug::eAPT_Sync );
230     if ( !syncMSUInputPlugs.size() ) {
231         debugWarning( "No sync input plug for MSU subunit found\n" );
232         return r;
233     }
234
235     for ( SyncInfoVector::const_iterator it
236               = getSyncInfos().begin();
237           it != getSyncInfos().end();
238           ++it )
239     {
240         const SyncInfo si=*it;
241
242         // check if the destination is a MSU input plug
243         bool found=false;
244         for ( PlugVector::const_iterator it2 = syncMSUInputPlugs.begin();
245               it2 != syncMSUInputPlugs.end();
246               ++it2 )
247         {
248             AVC::Plug* msuPlug = *it2;
249             found |= (msuPlug == si.m_destination);
250         }
251
252         if (found) {
253             ClockSource s=syncInfoToClockSource(*it);
254             r.push_back(s);
255         }
256     }
257
258     return r;
259 }
260
261 bool
262 AvDevice::setActiveClockSource(ClockSource s) {
263     Plug *src=m_pPlugManager->getPlug( s.id );
264     if (!src) {
265         debugError("Could not find plug with id %d\n", s.id);
266         return false;
267     }
268
269     for ( SyncInfoVector::const_iterator it
270               = getSyncInfos().begin();
271           it != getSyncInfos().end();
272           ++it )
273     {
274         const SyncInfo si=*it;
275
276         if (si.m_source==src) {
277             return setActiveSync(si);
278         }
279     }
280
281     return false;
282 }
283
284 FFADODevice::ClockSource
285 AvDevice::getActiveClockSource() {
286     const SyncInfo* si=getActiveSyncInfo();
287     if ( !si ) {
288         debugError( "Could not retrieve active sync information\n" );
289         ClockSource s;
290         s.type=eCT_Invalid;
291         return s;
292     }
293     debugOutput(DEBUG_LEVEL_VERBOSE, "Active Sync mode:  %s\n", si->m_description.c_str() );
294
295     return syncInfoToClockSource(*si);
296 }
297
298 FFADODevice::ClockSource
299 AvDevice::syncInfoToClockSource(const SyncInfo& si) {
300     ClockSource s;
301
302     // the description is easy
303     // it can be that we overwrite it later
304     s.description=si.m_description;
305
306     // FIXME: always valid at the moment
307     s.valid=true;
308
309     assert(si.m_source);
310     s.id=si.m_source->getGlobalId();
311
312     // now figure out what type this is
313     switch(si.m_source->getPlugType()) {
314         case Plug::eAPT_IsoStream:
315             s.type=eCT_SytMatch;
316             break;
317         case Plug::eAPT_Sync:
318             if(si.m_source->getPlugAddressType() == Plug::eAPA_PCR) {
319                 s.type=eCT_SytStream; // this is logical
320             } else if(si.m_source->getPlugAddressType() == Plug::eAPA_SubunitPlug) {
321                 s.type=eCT_Internal; // this assumes some stuff
322             } else if(si.m_source->getPlugAddressType() == Plug::eAPA_ExternalPlug) {
323                 std::string plugname=si.m_source->getName();
324                 s.description=plugname;
325                 // this is basically due to Focusrites interpretation
326                 if(plugname.find( "SPDIF", 0 ) != string::npos) {
327                     s.type=eCT_SPDIF; // this assumes the name will tell us
328                 } else {
329                     s.type=eCT_WordClock; // this assumes a whole lot more
330                 }
331             } else {
332                 s.type=eCT_Invalid;
333             }
334             break;
335         case Plug::eAPT_Digital:
336             if(si.m_source->getPlugAddressType() == Plug::eAPA_ExternalPlug) {
337                 std::string plugname=si.m_source->getName();
338                 s.description=plugname;
339                 // this is basically due to Focusrites interpretation
340                 if(plugname.find( "ADAT", 0 ) != string::npos) {
341                     s.type=eCT_ADAT; // this assumes the name will tell us
342                 } else if(plugname.find( "SPDIF", 0 ) != string::npos) {
343                     s.type=eCT_SPDIF; // this assumes the name will tell us
344                 } else {
345                     s.type=eCT_WordClock; // this assumes a whole lot more
346                 }
347             } else {
348                 s.type=eCT_Invalid;
349             }
350             break;
351         default:
352             s.type=eCT_Invalid; break;
353     }
354
355     // is it active?
356     const SyncInfo* active=getActiveSyncInfo();
357     if (active) {
358         if ((active->m_source == si.m_source)
359            && (active->m_destination == si.m_destination))
360            s.active=true;
361         else s.active=false;
362     } else s.active=false;
363
364     return s;
365 }
366
367 bool
368 AvDevice::lock() {
369     bool snoopMode=false;
370     if(!getOption("snoopMode", snoopMode)) {
371         debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");
372     }
373
374     if (snoopMode) {
375         // don't lock
376     } else {
377 //         return Unit::reserve(4);
378     }
379
380     return true;
381 }
382
383 bool
384 AvDevice::unlock() {
385     bool snoopMode=false;
386     if(!getOption("snoopMode", snoopMode)) {
387         debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");
388     }
389
390     if (snoopMode) {
391         // don't unlock
392     } else {
393 //         return Unit::reserve(0);
394     }
395     return true;
396 }
397
398 void
399 AvDevice::showDevice()
400 {
401     FFADODevice::showDevice();
402
403     AVC::Unit::show();
404     flushDebugOutput();
405 }
406
407 bool
408 AvDevice::prepare() {
409     bool snoopMode=false;
410     if(!getOption("snoopMode", snoopMode)) {
411         debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");
412     }
413
414     ///////////
415     // get plugs
416
417     AVC::Plug* inputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Input, 0 );
418     if ( !inputPlug ) {
419         debugError( "setSampleRate: Could not retrieve iso input plug 0\n" );
420         return false;
421     }
422     AVC::Plug* outputPlug = getPlugById( m_pcrPlugs, Plug::eAPD_Output, 0 );
423     if ( !outputPlug ) {
424         debugError( "setSampleRate: Could not retrieve iso output plug 0\n" );
425         return false;
426     }
427
428     debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing receive processor...\n");
429     // create & add streamprocessors
430     Streaming::StreamProcessor *p;
431
432     if ( outputPlug->getNrOfChannels() == 0 ) {
433         debugError("Receive plug has no channels\n");
434         return false;
435     }
436     p = new Streaming::AmdtpReceiveStreamProcessor(*this,
437                              outputPlug->getNrOfChannels());
438
439     if(!p->init()) {
440         debugFatal("Could not initialize receive processor!\n");
441         delete p;
442         return false;
443     }
444
445     if (!addPlugToProcessor(*outputPlug,p,
446         Streaming::Port::E_Capture)) {
447         debugFatal("Could not add plug to processor!\n");
448         delete p;
449         return false;
450     }
451
452     m_receiveProcessors.push_back(p);
453
454     // do the transmit processor
455     debugOutput( DEBUG_LEVEL_VERBOSE, "Initializing transmit processor%s...\n",
456             (snoopMode?" in snoop mode":""));
457     if (snoopMode) {
458         // we are snooping, so this is receive too.
459         p=new Streaming::AmdtpReceiveStreamProcessor(*this,
460                                   inputPlug->getNrOfChannels());
461     } else {
462         p=new Streaming::AmdtpTransmitStreamProcessor(*this,
463                                 inputPlug->getNrOfChannels());
464     }
465
466     if(!p->init()) {
467         debugFatal("Could not initialize transmit processor %s!\n",
468             (snoopMode?" in snoop mode":""));
469         delete p;
470         return false;
471     }
472
473     if (snoopMode) {
474         if (!addPlugToProcessor(*inputPlug,p,
475             Streaming::Port::E_Capture)) {
476             debugFatal("Could not add plug to processor!\n");
477             return false;
478         }
479     } else {
480         if (!addPlugToProcessor(*inputPlug,p,
481             Streaming::Port::E_Playback)) {
482             debugFatal("Could not add plug to processor!\n");
483             return false;
484         }
485     }
486
487     // we put this SP into the transmit SP vector,
488     // no matter if we are in snoop mode or not
489     // this allows us to find out what direction
490     // a certain stream should have.
491     m_transmitProcessors.push_back(p);
492
493     return true;
494 }
495
496 bool
497 AvDevice::addPlugToProcessor(
498     AVC::Plug& plug,
499     Streaming::StreamProcessor *processor,
500     Streaming::AmdtpAudioPort::E_Direction direction) {
501
502     std::string id=std::string("dev?");
503     if(!getOption("id", id)) {
504         debugWarning("Could not retrieve id parameter, defauling to 'dev?'\n");
505     }
506
507     Plug::ClusterInfoVector& clusterInfos = plug.getClusterInfos();
508     for ( Plug::ClusterInfoVector::const_iterator it = clusterInfos.begin();
509           it != clusterInfos.end();
510           ++it )
511     {
512         const Plug::ClusterInfo* clusterInfo = &( *it );
513
514         Plug::ChannelInfoVector channelInfos = clusterInfo->m_channelInfos;
515         for ( Plug::ChannelInfoVector::const_iterator it = channelInfos.begin();
516               it != channelInfos.end();
517               ++it )
518         {
519             const Plug::ChannelInfo* channelInfo = &( *it );
520             std::ostringstream portname;
521
522             portname << id << "_" << channelInfo->m_name;
523
524             Streaming::Port *p=NULL;
525             switch(clusterInfo->m_portType) {
526             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Speaker:
527             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Headphone:
528             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Microphone:
529             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Line:
530             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Analog:
531                 debugOutput(DEBUG_LEVEL_VERBOSE, " Adding audio channel %s (pos=0x%02X, loc=0x%02X)\n",
532                     channelInfo->m_name.c_str(), channelInfo->m_streamPosition, channelInfo->m_location);
533                 p=new Streaming::AmdtpAudioPort(
534                         portname.str(),
535                         direction,
536                         channelInfo->m_streamPosition,
537                         channelInfo->m_location,
538                         Streaming::AmdtpPortInfo::E_MBLA
539                 );
540                 break;
541
542             case ExtendedPlugInfoClusterInfoSpecificData::ePT_MIDI:
543                 debugOutput(DEBUG_LEVEL_VERBOSE, " Adding MIDI channel %s (pos=0x%02X, loc=0x%02X)\n",
544                     channelInfo->m_name.c_str(), channelInfo->m_streamPosition, processor->getPortCount(Streaming::Port::E_Midi));
545                 p=new Streaming::AmdtpMidiPort(
546                         portname.str(),
547                         direction,
548                         channelInfo->m_streamPosition,
549                         // Workaround for out-of-spec hardware
550                         // should be:
551                         // channelInfo->m_location,
552                         // but now we renumber the midi channels' location as they
553                         // are discovered
554                         processor->getPortCount(Streaming::Port::E_Midi),
555                         Streaming::AmdtpPortInfo::E_Midi
556                 );
557
558                 break;
559             case ExtendedPlugInfoClusterInfoSpecificData::ePT_SPDIF:
560             case ExtendedPlugInfoClusterInfoSpecificData::ePT_ADAT:
561             case ExtendedPlugInfoClusterInfoSpecificData::ePT_TDIF:
562             case ExtendedPlugInfoClusterInfoSpecificData::ePT_MADI:
563             case ExtendedPlugInfoClusterInfoSpecificData::ePT_Digital:
564                 debugOutput(DEBUG_LEVEL_VERBOSE, " Adding digital audio channel %s (pos=0x%02X, loc=0x%02X)\n",
565                     channelInfo->m_name.c_str(), channelInfo->m_streamPosition, channelInfo->m_location);
566                 p=new Streaming::AmdtpAudioPort(
567                         portname.str(),
568                         direction,
569                         channelInfo->m_streamPosition,
570                         channelInfo->m_location,
571                         Streaming::AmdtpPortInfo::E_MBLA
572                 );
573                 break;
574
575             case ExtendedPlugInfoClusterInfoSpecificData::ePT_NoType:
576             default:
577             // unsupported
578                 break;
579             }
580
581             if (!p) {
582                 debugOutput(DEBUG_LEVEL_VERBOSE, "Skipped port %s\n",channelInfo->m_name.c_str());
583             } else {
584
585                 if (!processor->addPort(p)) {
586                     debugWarning("Could not register port with stream processor\n");
587                     return false;
588                 }
589             }
590          }
591     }
592     return true;
593 }
594
595 int
596 AvDevice::getStreamCount() {
597     return m_receiveProcessors.size() + m_transmitProcessors.size();
598     //return 1;
599 }
600
601 Streaming::StreamProcessor *
602 AvDevice::getStreamProcessorByIndex(int i) {
603
604     if (i<(int)m_receiveProcessors.size()) {
605         return m_receiveProcessors.at(i);
606     } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) {
607         return m_transmitProcessors.at(i-m_receiveProcessors.size());
608     }
609
610     return NULL;
611 }
612
613 bool
614 AvDevice::startStreamByIndex(int i) {
615     int iso_channel=-1;
616     bool snoopMode=false;
617     if(!getOption("snoopMode", snoopMode)) {
618         debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");
619     }
620
621     if (i<(int)m_receiveProcessors.size()) {
622         int n=i;
623         Streaming::StreamProcessor *p=m_receiveProcessors.at(n);
624
625         if(snoopMode) { // a stream from the device to another host
626             // FIXME: put this into a decent framework!
627             // we should check the oPCR[n] on the device
628             struct iec61883_oPCR opcr;
629             if (iec61883_get_oPCRX(
630                     get1394Service().getHandle(),
631                     getConfigRom().getNodeId() | 0xffc0,
632                     (quadlet_t *)&opcr,
633                     n)) {
634
635                 debugWarning("Error getting the channel for SP %d\n",i);
636                 return false;
637             }
638
639             iso_channel=opcr.channel;
640         } else {
641             iso_channel=get1394Service().allocateIsoChannelCMP(
642                 getConfigRom().getNodeId() | 0xffc0, n,
643                 get1394Service().getLocalNodeId()| 0xffc0, -1);
644         }
645         if (iso_channel<0) {
646             debugError("Could not allocate ISO channel for SP %d\n",i);
647             return false;
648         }
649
650         debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel);
651
652         p->setChannel(iso_channel);
653         return true;
654
655     } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) {
656         int n=i-m_receiveProcessors.size();
657         Streaming::StreamProcessor *p=m_transmitProcessors.at(n);
658
659         if(snoopMode) { // a stream from another host to the device
660             // FIXME: put this into a decent framework!
661             // we should check the iPCR[n] on the device
662             struct iec61883_iPCR ipcr;
663             if (iec61883_get_iPCRX(
664                     get1394Service().getHandle(),
665                     getConfigRom().getNodeId() | 0xffc0,
666                     (quadlet_t *)&ipcr,
667                     n)) {
668
669                 debugWarning("Error getting the channel for SP %d\n",i);
670                 return false;
671             }
672
673             iso_channel=ipcr.channel;
674
675         } else {
676             iso_channel=get1394Service().allocateIsoChannelCMP(
677                 get1394Service().getLocalNodeId()| 0xffc0, -1,
678                 getConfigRom().getNodeId() | 0xffc0, n);
679         }
680
681         if (iso_channel<0) {
682             debugError("Could not allocate ISO channel for SP %d\n",i);
683             return false;
684         }
685
686         debugOutput(DEBUG_LEVEL_VERBOSE, "Started SP %d on channel %d\n",i,iso_channel);
687
688         p->setChannel(iso_channel);
689         return true;
690     }
691
692     debugError("SP index %d out of range!\n",i);
693     return false;
694 }
695
696 bool
697 AvDevice::stopStreamByIndex(int i) {
698     bool snoopMode=false;
699     if(!getOption("snoopMode", snoopMode)) {
700         debugWarning("Could not retrieve snoopMode parameter, defauling to false\n");
701     }
702
703     if (i<(int)m_receiveProcessors.size()) {
704         int n=i;
705         Streaming::StreamProcessor *p=m_receiveProcessors.at(n);
706
707         if(snoopMode) {
708
709         } else {
710             // deallocate ISO channel
711             if(!get1394Service().freeIsoChannel(p->getChannel())) {
712                 debugError("Could not deallocate iso channel for SP %d\n",i);
713                 return false;
714             }
715         }
716         p->setChannel(-1);
717
718         return true;
719
720     } else if (i<(int)m_receiveProcessors.size() + (int)m_transmitProcessors.size()) {
721         int n=i-m_receiveProcessors.size();
722         Streaming::StreamProcessor *p=m_transmitProcessors.at(n);
723
724         if(snoopMode) {
725
726         } else {
727             // deallocate ISO channel
728             if(!get1394Service().freeIsoChannel(p->getChannel())) {
729                 debugError("Could not deallocate iso channel for SP %d\n",i);
730                 return false;
731             }
732         }
733         p->setChannel(-1);
734
735         return true;
736     }
737
738     debugError("SP index %d out of range!\n",i);
739     return false;
740 }
741
742 bool
743 AvDevice::serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const
744 {
745     bool result;
746     result  = AVC::Unit::serialize( basePath, ser );
747     result &= serializeOptions( basePath + "Options", ser );
748     return result;
749 }
750
751 bool
752 AvDevice::deserialize( Glib::ustring basePath, Util::IODeserialize& deser )
753 {
754     bool result;
755     result = AVC::Unit::deserialize( basePath, deser );
756     return result;
757 }
758
759 }
Note: See TracBrowser for help on using the browser.