Changeset 1804

Show
Ignore:
Timestamp:
02/17/10 14:25:46 (5 months ago)
Author:
arnonym
Message:

Less code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/dice/dice_avdevice.cpp

    r1799 r1804  
    577577Device::setNickname( std::string name) 
    578578{ 
    579     return setDeviceNickName(name); 
     579    char namestring[DICE_NICK_NAME_SIZE+1]; 
     580    strncpy(namestring, name.c_str(), DICE_NICK_NAME_SIZE); 
     581 
     582    // Strings from the device are always little-endian, 
     583    // so byteswap for big-endian machines 
     584    #if __BYTE_ORDER == __BIG_ENDIAN 
     585    byteSwapBlock((quadlet_t *)namestring, DICE_NICK_NAME_SIZE/4); 
     586    #endif 
     587 
     588    if (!writeGlobalRegBlock(DICE_REGISTER_GLOBAL_NICK_NAME, 
     589                        (fb_quadlet_t *)namestring, DICE_NICK_NAME_SIZE)) { 
     590        debugError("Could not write nickname string \n"); 
     591        return false; 
     592    } 
     593    return true; 
    580594} 
    581595 
     
    583597Device::getNickname() 
    584598{ 
    585     return getDeviceNickName(); 
     599    char namestring[DICE_NICK_NAME_SIZE+1]; 
     600 
     601    if (!readGlobalRegBlock(DICE_REGISTER_GLOBAL_NICK_NAME, 
     602                        (fb_quadlet_t *)namestring, DICE_NICK_NAME_SIZE)) { 
     603        debugError("Could not read nickname string \n"); 
     604        return std::string("(unknown)"); 
     605    } 
     606 
     607    // Strings from the device are always little-endian, 
     608    // so byteswap for big-endian machines 
     609    #if __BYTE_ORDER == __BIG_ENDIAN 
     610    byteSwapBlock((quadlet_t *)namestring, DICE_NICK_NAME_SIZE/4); 
     611    #endif 
     612    namestring[DICE_NICK_NAME_SIZE]='\0'; 
     613    return std::string(namestring); 
    586614} 
    587615 
     
    613641 
    614642    readGlobalReg(DICE_REGISTER_GLOBAL_NOTIFICATION, &tmp_quadlet); 
    615     debugOutput(DEBUG_LEVEL_NORMAL,"  Nick name        : %s\n",getDeviceNickName().c_str()); 
     643    debugOutput(DEBUG_LEVEL_NORMAL,"  Nick name        : %s\n",getNickname().c_str()); 
    616644 
    617645    readGlobalReg(DICE_REGISTER_GLOBAL_CLOCK_SELECT, &tmp_quadlet); 
     
    15551583} 
    15561584 
    1557 std::string 
    1558 Device::getDeviceNickName() { 
    1559     char namestring[DICE_NICK_NAME_SIZE+1]; 
    1560  
    1561     if (!readGlobalRegBlock(DICE_REGISTER_GLOBAL_NICK_NAME, 
    1562                         (fb_quadlet_t *)namestring, DICE_NICK_NAME_SIZE)) { 
    1563         debugError("Could not read nickname string \n"); 
    1564         return std::string("(unknown)"); 
    1565     } 
    1566  
    1567     // Strings from the device are always little-endian, 
    1568     // so byteswap for big-endian machines 
    1569     #if __BYTE_ORDER == __BIG_ENDIAN 
    1570     byteSwapBlock((quadlet_t *)namestring, DICE_NICK_NAME_SIZE/4); 
    1571     #endif 
    1572     namestring[DICE_NICK_NAME_SIZE]='\0'; 
    1573     return std::string(namestring); 
    1574 } 
    1575  
    1576 bool 
    1577 Device::setDeviceNickName(std::string name) { 
    1578     char namestring[DICE_NICK_NAME_SIZE+1]; 
    1579     strncpy(namestring, name.c_str(), DICE_NICK_NAME_SIZE); 
    1580  
    1581     // Strings from the device are always little-endian, 
    1582     // so byteswap for big-endian machines 
    1583     #if __BYTE_ORDER == __BIG_ENDIAN 
    1584     byteSwapBlock((quadlet_t *)namestring, DICE_NICK_NAME_SIZE/4); 
    1585     #endif 
    1586  
    1587     if (!writeGlobalRegBlock(DICE_REGISTER_GLOBAL_NICK_NAME, 
    1588                         (fb_quadlet_t *)namestring, DICE_NICK_NAME_SIZE)) { 
    1589         debugError("Could not write nickname string \n"); 
    1590         return false; 
    1591     } 
    1592     return true; 
    1593 } 
    1594  
    15951585 
    15961586stringlist 
  • trunk/libffado/src/dice/dice_avdevice.h

    r1774 r1804  
    153153    stringlist getRxNameString(unsigned int i); 
    154154    stringlist getClockSourceNameString(); 
    155     std::string getDeviceNickName(); 
    156     bool setDeviceNickName(std::string name); 
    157155 
    158156    enum eClockSourceType  clockIdToType(unsigned int id);