mixer/Type: mixer_type_parse() throws on error
This commit is contained in:
parent
4531e4cc55
commit
aaa438e745
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2017 The Music Player Daemon Project
|
* Copyright 2003-2018 The Music Player Daemon Project
|
||||||
* http://www.musicpd.org
|
* http://www.musicpd.org
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -20,11 +20,13 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "MixerType.hxx"
|
#include "MixerType.hxx"
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
MixerType
|
MixerType
|
||||||
mixer_type_parse(const char *input) noexcept
|
mixer_type_parse(const char *input)
|
||||||
{
|
{
|
||||||
assert(input != NULL);
|
assert(input != NULL);
|
||||||
|
|
||||||
@ -37,5 +39,5 @@ mixer_type_parse(const char *input) noexcept
|
|||||||
else if (strcmp(input, "null") == 0)
|
else if (strcmp(input, "null") == 0)
|
||||||
return MixerType::NULL_;
|
return MixerType::NULL_;
|
||||||
else
|
else
|
||||||
return MixerType::UNKNOWN;
|
throw std::runtime_error("Unrecognized mixer type");
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2017 The Music Player Daemon Project
|
* Copyright 2003-2018 The Music Player Daemon Project
|
||||||
* http://www.musicpd.org
|
* http://www.musicpd.org
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -23,9 +23,6 @@
|
|||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
enum class MixerType {
|
enum class MixerType {
|
||||||
/** parser error */
|
|
||||||
UNKNOWN,
|
|
||||||
|
|
||||||
/** mixer disabled */
|
/** mixer disabled */
|
||||||
NONE,
|
NONE,
|
||||||
|
|
||||||
@ -42,12 +39,12 @@ enum class MixerType {
|
|||||||
/**
|
/**
|
||||||
* Parses a #MixerType setting from the configuration file.
|
* Parses a #MixerType setting from the configuration file.
|
||||||
*
|
*
|
||||||
* @param input the configured string value; must not be NULL @return
|
* Throws if the string could not be parsed.
|
||||||
* a #MixerType value; #MixerType::UNKNOWN means #input could not be
|
*
|
||||||
* parsed
|
* @param input the configured string value
|
||||||
|
* @return a #MixerType value
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
|
||||||
MixerType
|
MixerType
|
||||||
mixer_type_parse(const char *input) noexcept;
|
mixer_type_parse(const char *input);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -87,9 +87,8 @@ audio_output_detect()
|
|||||||
* This handles the deprecated options mixer_type (global) and
|
* This handles the deprecated options mixer_type (global) and
|
||||||
* mixer_enabled, if the mixer_type setting is not configured.
|
* mixer_enabled, if the mixer_type setting is not configured.
|
||||||
*/
|
*/
|
||||||
gcc_pure
|
|
||||||
static MixerType
|
static MixerType
|
||||||
audio_output_mixer_type(const ConfigBlock &block) noexcept
|
audio_output_mixer_type(const ConfigBlock &block)
|
||||||
{
|
{
|
||||||
/* read the local "mixer_type" setting */
|
/* read the local "mixer_type" setting */
|
||||||
const char *p = block.GetBlockValue("mixer_type");
|
const char *p = block.GetBlockValue("mixer_type");
|
||||||
@ -117,7 +116,6 @@ audio_output_load_mixer(EventLoop &event_loop, FilteredAudioOutput &ao,
|
|||||||
|
|
||||||
switch (audio_output_mixer_type(block)) {
|
switch (audio_output_mixer_type(block)) {
|
||||||
case MixerType::NONE:
|
case MixerType::NONE:
|
||||||
case MixerType::UNKNOWN:
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
case MixerType::NULL_:
|
case MixerType::NULL_:
|
||||||
|
Loading…
Reference in New Issue
Block a user