Changeset 1561

Show
Ignore:
Timestamp:
05/17/09 07:36:44 (11 years ago)
Author:
ppalmers
Message:

fixes #211

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/SConstruct

    r1524 r1561  
    2424# 
    2525 
    26 FFADO_API_VERSION="8" 
    27 FFADO_VERSION="1.999.41" 
     26FFADO_API_VERSION = "8" 
     27FFADO_VERSION = "1.999.41" 
    2828 
    2929import os 
  • branches/libffado-2.0/src/devicemanager.cpp

    r1549 r1561  
    837837 
    838838bool 
     839DeviceManager::startStreamingOnDevice(FFADODevice *device) 
     840{ 
     841    assert(device); 
     842 
     843    int j=0; 
     844    bool all_streams_started = true; 
     845    bool device_start_failed = false; 
     846    for(j=0; j < device->getStreamCount(); j++) { 
     847        debugOutput(DEBUG_LEVEL_VERBOSE,"Starting stream %d of device %p\n", j, device); 
     848        // start the stream 
     849        if (!device->startStreamByIndex(j)) { 
     850            debugWarning("Could not start stream %d of device %p\n", j, device); 
     851            all_streams_started = false; 
     852            break; 
     853        } 
     854    } 
     855 
     856    if(!all_streams_started) { 
     857        // disable all streams that did start up correctly 
     858        for(j = j-1; j >= 0; j--) { 
     859            debugOutput(DEBUG_LEVEL_VERBOSE,"Stopping stream %d of device %p\n", j, device); 
     860            // stop the stream 
     861            if (!device->stopStreamByIndex(j)) { 
     862                debugWarning("Could not stop stream %d of device %p\n", j, device); 
     863            } 
     864        } 
     865        device_start_failed = true; 
     866    } else { 
     867        if (!device->enableStreaming()) { 
     868            debugWarning("Could not enable streaming on device %p!\n", device); 
     869            device_start_failed = true; 
     870        } 
     871    } 
     872    return !device_start_failed; 
     873} 
     874 
     875bool 
    839876DeviceManager::startStreaming() { 
     877    bool device_start_failed = false; 
     878    FFADODeviceVectorIterator it; 
     879 
     880    // create the connections for all devices 
     881    // iterate over the found devices 
     882    for ( it = m_avDevices.begin(); 
     883        it != m_avDevices.end(); 
     884        ++it ) 
     885    { 
     886        if (!startStreamingOnDevice(*it)) { 
     887            debugWarning("Could not start streaming on device %p!\n", *it); 
     888            device_start_failed = true; 
     889            break; 
     890        } 
     891    } 
     892 
     893    // if one of the devices failed to start, 
     894    // the previous routine should have cleaned up the failing one. 
     895    // we still have to stop all devices that were started before this one. 
     896    if(device_start_failed) { 
     897        for (FFADODeviceVectorIterator it2 = m_avDevices.begin(); 
     898            it2 != it; 
     899            ++it2 ) 
     900        { 
     901            if (!stopStreamingOnDevice(*it2)) { 
     902                debugWarning("Could not stop streaming on device %p!\n", *it2); 
     903            } 
     904        } 
     905        return false; 
     906    } 
     907 
     908    // start the stream processor manager to tune in to the channels 
     909    if(m_processorManager->start()) { 
     910        return true; 
     911    } else { 
     912        debugWarning("Failed to start SPM!\n"); 
     913        for( it = m_avDevices.begin(); 
     914             it != m_avDevices.end(); 
     915             ++it ) 
     916        { 
     917            if (!stopStreamingOnDevice(*it)) { 
     918                debugWarning("Could not stop streaming on device %p!\n", *it); 
     919            } 
     920        } 
     921        return false; 
     922    } 
     923} 
     924 
     925bool 
     926DeviceManager::resetStreaming() { 
     927    return true; 
     928} 
     929 
     930bool 
     931DeviceManager::stopStreamingOnDevice(FFADODevice *device) 
     932{ 
     933    assert(device); 
     934    bool result = true; 
     935 
     936    if (!device->disableStreaming()) { 
     937        debugWarning("Could not disable streaming on device %p!\n", device); 
     938    } 
     939 
     940    int j=0; 
     941    for(j=0; j < device->getStreamCount(); j++) { 
     942        debugOutput(DEBUG_LEVEL_VERBOSE,"Stopping stream %d of device %p\n", j, device); 
     943        // stop the stream 
     944        // start the stream 
     945        if (!device->stopStreamByIndex(j)) { 
     946            debugWarning("Could not stop stream %d of device %p\n", j, device); 
     947            result = false; 
     948            continue; 
     949        } 
     950    } 
     951    return result; 
     952} 
     953 
     954bool 
     955DeviceManager::stopStreaming() 
     956{ 
     957    bool result = true; 
     958    m_processorManager->stop(); 
     959 
    840960    // create the connections for all devices 
    841961    // iterate over the found devices 
     
    845965        ++it ) 
    846966    { 
    847         FFADODevice *device = *it; 
    848         assert(device); 
    849  
    850         int j=0; 
    851         for(j=0; j < device->getStreamCount(); j++) { 
    852         debugOutput(DEBUG_LEVEL_VERBOSE,"Starting stream %d of device %p\n", j, device); 
    853             // start the stream 
    854             if (!device->startStreamByIndex(j)) { 
    855                 debugWarning("Could not start stream %d of device %p\n", j, device); 
    856                 continue; 
    857             } 
    858         } 
    859  
    860         if (!device->enableStreaming()) { 
    861             debugWarning("Could not enable streaming on device %p!\n", device); 
    862         } 
    863     } 
    864  
    865     if(m_processorManager->start()) { 
    866         return true; 
    867     } else { 
    868         stopStreaming(); 
    869         return false; 
    870     } 
    871 
    872  
    873 bool 
    874 DeviceManager::resetStreaming() { 
    875     return true; 
    876 
    877  
    878 bool 
    879 DeviceManager::stopStreaming() 
    880 
    881     bool result = true; 
    882     m_processorManager->stop(); 
    883  
    884     // create the connections for all devices 
    885     // iterate over the found devices 
    886     // add the stream processors of the devices to the managers 
    887     for ( FFADODeviceVectorIterator it = m_avDevices.begin(); 
    888         it != m_avDevices.end(); 
    889         ++it ) 
    890     { 
    891         FFADODevice *device = *it; 
    892         assert(device); 
    893  
    894         if (!device->disableStreaming()) { 
    895             debugWarning("Could not disable streaming on device %p!\n", device); 
    896         } 
    897  
    898         int j=0; 
    899         for(j=0; j < device->getStreamCount(); j++) { 
    900             debugOutput(DEBUG_LEVEL_VERBOSE,"Stopping stream %d of device %p\n", j, device); 
    901             // stop the stream 
    902             // start the stream 
    903             if (!device->stopStreamByIndex(j)) { 
    904                 debugWarning("Could not stop stream %d of device %p\n", j, device); 
    905                 result = false; 
    906                 continue; 
    907             } 
    908         } 
     967        stopStreamingOnDevice(*it); 
    909968    } 
    910969    return result; 
  • branches/libffado-2.0/src/devicemanager.h

    r1299 r1561  
    9090    bool prepareStreaming(); 
    9191    bool finishStreaming(); 
     92    bool startStreamingOnDevice(FFADODevice *device); 
    9293    bool startStreaming(); 
     94    bool stopStreamingOnDevice(FFADODevice *device); 
    9395    bool stopStreaming(); 
    9496    bool resetStreaming(); 
  • branches/libffado-2.0/src/libieee1394/IsoHandler.cpp

    r1528 r1561  
    262262 
    263263    // wake ourselves up 
    264     raw1394_wake_up(m_handle); 
     264    if(m_handle) raw1394_wake_up(m_handle); 
    265265} 
    266266