Commit 2df75393 authored by sagnowski's avatar sagnowski
Browse files

Fix confusing error message when ism format is incorrectly specified on command line.

parent f429aa57
Loading
Loading
Loading
Loading
+30 −17
Original line number Diff line number Diff line
@@ -1041,6 +1041,20 @@ static IVAS_REND_AudioConfig ambisonicsOrderToEnum(
    return IVAS_REND_AUDIO_CONFIG_UNKNOWN;
}

static const CmdLnParser_Option *findOptionById(
    const int32_t id )
{
    for ( int32_t i = 0; i < numCliOptions; ++i )
    {
        if ( cliOptions[i].id == id )
        {
            return &cliOptions[i];
        }
    }

    return NULL;
}

static bool parseInConfig(
    const char *inFormatStr,
    InputConfig *inConfig,
@@ -1129,7 +1143,8 @@ static bool parseInConfig(
                if ( error == IVAS_ERR_FAILED_FILE_OPEN )
                {
                    /* Failed to open with given string - most likely wasn't a file path */
                    fprintf( stderr, "Unsupported input format: %s\n", inFormatStr );
                    const CmdLnParser_Option *listOption = findOptionById( CmdLnOptionId_listFormats );
                    fprintf( stderr, "Unsupported input format: %s. To list valid formats, use option --%s.\n", inFormatStr, listOption->match );
                    return false;
                }
                if ( error != IVAS_ERR_OK )
@@ -1144,11 +1159,14 @@ static bool parseInConfig(
            }
            break;
        default:
        {
            /* Default case covers formats that are defined in the IVAS_REND_AudioConfig enum,
             * but cannot be used at input, e.g. BINAURAL */
            fprintf( stderr, "Unsupported input format: %s\n", inFormatStr );
            const CmdLnParser_Option *listOption = findOptionById( CmdLnOptionId_listFormats );
            fprintf( stderr, "Unsupported input format: %s. To list valid formats, use option --%s.\n", inFormatStr, listOption->match );
            return false;
        }
    }

    return true;
}
@@ -1285,8 +1303,17 @@ static IVAS_REND_AudioConfig parseAudioConfig(
    }
    if ( strncmp( charBuf, "ISM", 3 ) == 0 )
    {
        /* Accept input config as ISM only if the 4th character is a number from 1 to 4.
         * Otherwise, do nothing. Unknown audio config will be returned. */
        switch ( charBuf[3] )
        {
            case '1':
            case '2':
            case '3':
            case '4':
                return IVAS_REND_AUDIO_CONFIG_OBJECT;
        }
    }
    if ( strncmp( charBuf, "MASA", 4 ) == 0 )
    {
        switch ( charBuf[4] )
@@ -1313,20 +1340,6 @@ static IVAS_REND_AudioConfig parseAudioConfig(
    return IVAS_REND_AUDIO_CONFIG_UNKNOWN;
}

static const CmdLnParser_Option *findOptionById(
    const int32_t id )
{
    for ( int32_t i = 0; i < numCliOptions; ++i )
    {
        if ( cliOptions[i].id == id )
        {
            return &cliOptions[i];
        }
    }

    return NULL;
}

static bool checkRequiredArgs(
    CmdlnArgs args )
{