Changeset 1322

Show
Ignore:
Timestamp:
09/19/08 14:29:58 (12 years ago)
Author:
jwoithe
Message:

MOTU: make mixer construction more tolerant of incomplete mixer specifications

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/libffado-2.0/src/motu/motu_avdevice.cpp

    r1320 r1322  
    400400 
    401401bool 
    402 MotuDevice::buildMixer() { 
    403     unsigned int i; 
     402MotuDevice::buildMixerAudioControls(void) { 
     403 
    404404    bool result = true; 
    405405    MotuMatrixMixer *fader_mmixer = NULL; 
     
    407407    MotuMatrixMixer *solo_mmixer = NULL; 
    408408    MotuMatrixMixer *mute_mmixer = NULL; 
    409     unsigned int bus, ch; 
    410     debugOutput(DEBUG_LEVEL_VERBOSE, "Building a MOTU mixer...\n"); 
    411  
    412     destroyMixer(); 
    413          
    414     // create the mixer object container 
    415     m_MixerContainer = new Control::Container(this, "Mixer"); 
    416     if (!m_MixerContainer) { 
    417         debugError("Could not create mixer container...\n"); 
    418         return false; 
    419     } 
    420  
    421     /* Create the matrix mixers and populate them */ 
     409    unsigned int bus, ch, i; 
     410 
     411    if (DevicesProperty[m_motu_model-1].mixer == NULL) { 
     412        debugOutput(DEBUG_LEVEL_WARNING, "No mixer controls defined for model %d\n", m_motu_model); 
     413        result = false; 
     414    } 
     415    const struct MatrixMixBus *buses = DevicesProperty[m_motu_model-1].mixer->mixer_buses; 
     416    if (buses == NULL) { 
     417        debugOutput(DEBUG_LEVEL_WARNING, "No buses defined for model %d\n", m_motu_model); 
     418        result = false; 
     419    } 
     420    const struct MatrixMixChannel *channels = DevicesProperty[m_motu_model-1].mixer->mixer_channels; 
     421    if (channels == NULL) { 
     422        debugOutput(DEBUG_LEVEL_WARNING, "No channels defined for model %d\n", m_motu_model); 
     423        result = false; 
     424    } 
     425    if (result == false) { 
     426        return true; 
     427    } 
     428 
     429    /* Create the top-level matrix mixers */ 
    422430    fader_mmixer = new ChannelFaderMatrixMixer(*this, "fader"); 
    423431    result &= m_MixerContainer->addElement(fader_mmixer); 
     
    430438        MOTU_CTRL_MASK_MUTE_VALUE, MOTU_CTRL_MASK_MUTE_SETENABLE); 
    431439    result &= m_MixerContainer->addElement(mute_mmixer); 
    432     const struct MatrixMixBus *buses = DevicesProperty[m_motu_model-1].mixer->mixer_buses; 
     440 
    433441    for (bus=0; bus<DevicesProperty[m_motu_model-1].mixer->n_mixer_buses; bus++) { 
    434442        fader_mmixer->addRowInfo(buses[bus].name, 0, buses[bus].address); 
     
    437445        mute_mmixer->addRowInfo(buses[bus].name, 0, buses[bus].address); 
    438446    } 
    439     const struct MatrixMixChannel *channels = DevicesProperty[m_motu_model-1].mixer->mixer_channels; 
     447 
    440448    for (ch=0; ch<DevicesProperty[m_motu_model-1].mixer->n_mixer_channels; ch++) { 
    441449        uint32_t flags = channels[ch].flags; 
     
    450458        flags &= ~(MOTU_CTRL_CHANNEL_FADER|MOTU_CTRL_CHANNEL_PAN|MOTU_CTRL_CHANNEL_SOLO|MOTU_CTRL_CHANNEL_MUTE); 
    451459        if (flags) { 
    452             debugOutput(DEBUG_LEVEL_VERBOSE, "Control %s: unknown flag bits 0x%08x\n", channels[ch].name, flags); 
     460            debugOutput(DEBUG_LEVEL_WARNING, "Control %s: unknown flag bits 0x%08x\n", channels[ch].name, flags); 
    453461        } 
    454462    } 
     
    458466    for (i=0; i<DevicesProperty[m_motu_model-1].mixer->n_mixer_ctrls; i++) { 
    459467        const struct MixerCtrl *ctrl = &DevicesProperty[m_motu_model-1].mixer->mixer_ctrl[i]; 
    460         unsigned int type = ctrl->type
     468        unsigned int type
    461469        char name[100]; 
    462470        char label[100]; 
     471 
     472        if (ctrl == NULL) { 
     473            debugOutput(DEBUG_LEVEL_WARNING, "NULL control at index %d for model %d\n", i, m_motu_model); 
     474            continue; 
     475        } 
     476        type = ctrl->type; 
    463477        if (type & MOTU_CTRL_CHANNEL_FADER) { 
    464478            snprintf(name, 100, "%s%s", ctrl->name, "fader"); 
     
    598612 
    599613        if (type) { 
    600             debugOutput(DEBUG_LEVEL_VERBOSE, "Unknown mixer control type flag bits 0x%08x\n", ctrl->type); 
    601         } 
    602     } 
     614            debugOutput(DEBUG_LEVEL_WARNING, "Unknown mixer control type flag bits 0x%08x\n", ctrl->type); 
     615        } 
     616    } 
     617    return result; 
     618
     619 
     620bool 
     621MotuDevice::buildMixer() { 
     622    bool result = true; 
     623    debugOutput(DEBUG_LEVEL_VERBOSE, "Building a MOTU mixer...\n"); 
     624 
     625    destroyMixer(); 
     626         
     627    // create the mixer object container 
     628    m_MixerContainer = new Control::Container(this, "Mixer"); 
     629    if (!m_MixerContainer) { 
     630        debugError("Could not create mixer container...\n"); 
     631        return false; 
     632    } 
     633 
     634    // Create and populate the top-level matrix mixers 
     635    result = buildMixerAudioControls(); 
    603636 
    604637    /* Now add some general device information controls.  These may yet 
  • branches/libffado-2.0/src/motu/motu_avdevice.h

    r1315 r1322  
    233233 
    234234private: 
     235    bool buildMixerAudioControls(void); 
    235236    bool addPort(Streaming::StreamProcessor *s_processor, 
    236237        char *name,