Changeset 4738:0bc3f6243414 in roaraudio


Ignore:
Timestamp:
01/31/11 01:10:01 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

use switch() not if/else if/else

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/req.c

    r4708 r4738  
    14211421 info[2] = ROAR_NET2HOST16(info[2]); 
    14221422 
    1423  if ( info[2] == ROAR_SET_VOL_ALL ) { 
    1424   chans = (mes->datalen/2) - 3; 
    1425   ROAR_DBG("req_on_set_vol(*): mode is ROAR_SET_VOL_ALL, channes=%i", chans); 
    1426  
    1427   if ( chans >= ROAR_MAX_CHANNELS ) 
    1428    return -1; 
    1429  
    1430   ROAR_DBG("req_on_set_vol(*): mixer at %p", s->mixer.mixer); 
    1431  
    1432   for (i = 0; i < chans; i++) { 
    1433    s->mixer.mixer[i] = ROAR_NET2HOST16(info[i+3]); 
    1434    ROAR_DBG("req_on_set_vol(*): channel %i: %i", i, ROAR_NET2HOST16(info[i+3])); 
    1435   } 
    1436  
    1437   s->mixer.scale = scale; 
    1438  
    1439   ROAR_DBG("req_on_set_vol(*): mixer changed!"); 
    1440  
    1441  } else if ( info[2] == ROAR_SET_VOL_ONE ) { 
    1442   ROAR_DBG("req_on_set_vol(*): mode is ROAR_SET_VOL_ONE"); 
    1443   if ( ROAR_NET2HOST16(info[3]) >= ROAR_MAX_CHANNELS ) 
    1444    return -1; 
    1445  
    1446   s->mixer.mixer[ROAR_NET2HOST16(info[3])] = ROAR_NET2HOST16(info[4]); 
    1447  
    1448   s->mixer.scale = scale; 
    1449  } else { 
    1450   return -1; 
     1423 switch (info[2]) { 
     1424  case ROAR_SET_VOL_ALL: 
     1425    chans = (mes->datalen/2) - 3; 
     1426    ROAR_DBG("req_on_set_vol(*): mode is ROAR_SET_VOL_ALL, channes=%i", chans); 
     1427 
     1428    if ( chans >= ROAR_MAX_CHANNELS ) 
     1429     return -1; 
     1430 
     1431    ROAR_DBG("req_on_set_vol(*): mixer at %p", s->mixer.mixer); 
     1432 
     1433    for (i = 0; i < chans; i++) { 
     1434     s->mixer.mixer[i] = ROAR_NET2HOST16(info[i+3]); 
     1435     ROAR_DBG("req_on_set_vol(*): channel %i: %i", i, ROAR_NET2HOST16(info[i+3])); 
     1436    } 
     1437 
     1438    s->mixer.scale = scale; 
     1439 
     1440    ROAR_DBG("req_on_set_vol(*): mixer changed!"); 
     1441 
     1442   break; 
     1443  case ROAR_SET_VOL_ONE: 
     1444    ROAR_DBG("req_on_set_vol(*): mode is ROAR_SET_VOL_ONE"); 
     1445    if ( ROAR_NET2HOST16(info[3]) >= ROAR_MAX_CHANNELS ) 
     1446     return -1; 
     1447 
     1448    s->mixer.mixer[ROAR_NET2HOST16(info[3])] = ROAR_NET2HOST16(info[4]); 
     1449 
     1450    s->mixer.scale = scale; 
     1451   break; 
     1452  default: 
     1453    return -1; 
    14511454 } 
    14521455 
Note: See TracChangeset for help on using the changeset viewer.