2004-02-24 00:41:20 +01:00
|
|
|
/* the Music Player Daemon (MPD)
|
2007-04-05 05:22:33 +02:00
|
|
|
* Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com)
|
2004-02-24 00:41:20 +01:00
|
|
|
* This project's homepage is: http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "audio.h"
|
2008-09-07 19:19:55 +02:00
|
|
|
#include "audio_format.h"
|
2009-02-11 18:00:41 +01:00
|
|
|
#include "audio_parser.h"
|
2008-09-24 07:20:55 +02:00
|
|
|
#include "output_internal.h"
|
2009-02-16 01:51:50 +01:00
|
|
|
#include "output_plugin.h"
|
2009-02-10 18:51:49 +01:00
|
|
|
#include "output_all.h"
|
2009-01-04 17:35:51 +01:00
|
|
|
#include "mixer_api.h"
|
2009-02-16 18:40:04 +01:00
|
|
|
#include "conf.h"
|
2005-08-23 14:01:37 +02:00
|
|
|
|
2008-10-28 20:33:56 +01:00
|
|
|
#include <glib.h>
|
|
|
|
|
2008-12-29 17:28:32 +01:00
|
|
|
#include <assert.h>
|
2009-01-03 13:36:20 +01:00
|
|
|
#include <stdlib.h>
|
2008-12-29 17:28:32 +01:00
|
|
|
|
2008-10-12 01:00:00 +02:00
|
|
|
static struct audio_format configured_audio_format;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2008-09-07 19:19:55 +02:00
|
|
|
void getOutputAudioFormat(const struct audio_format *inAudioFormat,
|
|
|
|
struct audio_format *outAudioFormat)
|
2004-05-10 04:20:15 +02:00
|
|
|
{
|
2008-10-12 01:00:00 +02:00
|
|
|
*outAudioFormat = audio_format_defined(&configured_audio_format)
|
|
|
|
? configured_audio_format
|
2008-09-09 10:04:42 +02:00
|
|
|
: *inAudioFormat;
|
2004-05-10 04:20:15 +02:00
|
|
|
}
|
|
|
|
|
2006-07-20 18:02:40 +02:00
|
|
|
void initAudioConfig(void)
|
|
|
|
{
|
2009-01-25 16:03:49 +01:00
|
|
|
const struct config_param *param = config_get_param(CONF_AUDIO_OUTPUT_FORMAT);
|
2009-02-11 18:00:41 +01:00
|
|
|
GError *error = NULL;
|
|
|
|
bool ret;
|
2004-05-10 04:20:15 +02:00
|
|
|
|
2006-07-20 18:02:40 +02:00
|
|
|
if (NULL == param || NULL == param->value)
|
|
|
|
return;
|
2004-05-10 04:20:15 +02:00
|
|
|
|
2009-02-11 18:00:41 +01:00
|
|
|
ret = audio_format_parse(&configured_audio_format, param->value,
|
|
|
|
&error);
|
|
|
|
if (!ret)
|
|
|
|
g_error("error parsing \"%s\" at line %i: %s",
|
|
|
|
CONF_AUDIO_OUTPUT_FORMAT, param->line, error->message);
|
2004-05-10 04:20:15 +02:00
|
|
|
}
|
|
|
|
|
2006-07-20 18:02:40 +02:00
|
|
|
void finishAudioConfig(void)
|
|
|
|
{
|
2008-10-12 01:00:00 +02:00
|
|
|
audio_format_clear(&configured_audio_format);
|
2004-05-10 04:20:15 +02:00
|
|
|
}
|