Changeset 55

Show
Ignore:
Timestamp:
01/23/05 07:29:42 (18 years ago)
Author:
wagi
Message:

AvDevice?: Implemented scan and destroy states execute function
Ieee1394Service: Use new execute function interface for AvDevices?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freebob/src/avdevice.cpp

    r46 r55  
    2121#include <libavc1394/avc1394.h> 
    2222#include <libavc1394/avc1394_vcr.h> 
     23#include "threads.h" 
    2324#include "avdevice.h" 
    2425#include "avdevicepool.h" 
     
    6263    } 
    6364    AvDevicePool::instance()->unregisterAvDevice( this ); 
     65} 
     66 
     67void 
     68AvDevice::execute( EStates state ) 
     69{ 
     70    switch ( state ) { 
     71    case eScanAndCreate: 
     72        if ( initialize() == eFBRC_Success ) { 
     73            // Put ourself to sleep until a something happends 
     74            sleepCall( this, &AvDevice::execute, eCheckState ); 
     75        } else { 
     76            asyncCall( this, &AvDevice::execute, eDestroy ); 
     77        } 
     78        break; 
     79    case eCheckState: 
     80        { 
     81            if ( m_iGeneration 
     82                 != Ieee1394Service::instance()->getGenerationCount() ) { 
     83                asyncCall( this, &AvDevice::execute, eDestroy ); 
     84            } 
     85        } 
     86        break; 
     87    case eDestroy: 
     88        destroyCall( this ); 
     89        break; 
     90    default: 
     91        debugError( "Invalid state: %d\n", state ); 
     92    } 
    6493} 
    6594 
     
    178207                "%d Asynchronous destination plugs\n", 
    179208                m_iNbAsyncSourcePlugs, m_iNbAsyncDestinationPlugs); 
     209 
     210 
     211    return eFBRC_Success; 
    180212 
    181213    // create the subunits 
  • trunk/freebob/src/avdevice.h

    r43 r55  
    3333class AvDevice { 
    3434 public: 
    35     enum
     35    enum EStates
    3636        eScanAndCreate = 0, 
    37         eDestroy       = 1 
    38     } EStates; 
     37        eCheckState    = 1,  // put this instance to the sleep queue 
     38        eDestroy       = 2 
     39    }; 
    3940 
    4041    AvDevice( octlet_t oGuid ); 
     
    4950    octlet_t getGuid() 
    5051        { return m_oGuid; } 
     52 
     53    void execute( EStates state ); 
    5154 
    5255    quadlet_t * avcExecuteTransaction( quadlet_t *request,  
  • trunk/freebob/src/ieee1394service.cpp

    r50 r55  
    4141#include "avoutputplugstatusinfoblock.h" 
    4242 
     43USE_GLOBAL_DEBUG_MODULE; 
     44 
    4345Ieee1394Service* Ieee1394Service::m_pInstance = 0; 
    4446 
     
    173175                pAvDevice->setPort( m_iPort ); 
    174176 
    175                 FBReturnCodes eStatus = pAvDevice->initialize(); 
    176                 if ( eStatus != eFBRC_Success ) { 
    177                     debugError( "AvDevice with GUID 0x%08x%08x could " 
    178                                 "not be initialized\n", 
    179                                 (quadlet_t) (oGuid>>32), 
    180                                 (quadlet_t) (oGuid & 0xffffffff) ); 
    181  
    182                     delete pAvDevice; 
    183                     return eStatus; 
    184                 } 
     177                asyncCall( pAvDevice, &AvDevice::execute, 
     178                           AvDevice::eScanAndCreate ); 
    185179 
    186180                // XXX Pieter's test code. 
    187 //                avDeviceTests( oGuid, m_iPort, iNodeId ); 
     181                // avDeviceTests( oGuid, m_iPort, iNodeId ); 
    188182            } 
    189183            break; 
     
    344338                               unsigned int iGeneration ) 
    345339{ 
     340    debugGlobalPrint( DEBUG_LEVEL_SCHEDULER, 
     341                      "Bus reset occured: generation count = %d\n", 
     342                      iGeneration ); 
     343 
    346344    raw1394_update_generation (handle, iGeneration); 
    347345    Ieee1394Service* pInstance 
     
    349347    pInstance->setGenerationCount( iGeneration ); 
    350348 
     349    WorkerThread::instance()->wakeSleepers(); 
    351350    asyncCall( pInstance, &Ieee1394Service::discoveryDevices, iGeneration ); 
    352351    return 0;