2009-02-11 18:02:45 +01:00
|
|
|
/*
|
2010-01-01 05:55:13 +01:00
|
|
|
* Copyright (C) 2003-2010 The Music Player Daemon Project
|
2009-02-11 18:02:45 +01:00
|
|
|
* 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.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2009-02-11 18:02:45 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Glue functions for controlling the audio outputs over the MPD
|
|
|
|
* protocol. These functions perform extra validation on all
|
|
|
|
* parameters, because they might be from an untrusted source.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-11-12 09:12:38 +01:00
|
|
|
#include "config.h"
|
2009-02-11 18:02:45 +01:00
|
|
|
#include "output_command.h"
|
|
|
|
#include "output_all.h"
|
|
|
|
#include "output_internal.h"
|
2009-03-12 18:40:03 +01:00
|
|
|
#include "output_plugin.h"
|
2009-03-14 11:36:50 +01:00
|
|
|
#include "mixer_control.h"
|
2009-10-23 10:55:52 +02:00
|
|
|
#include "player_control.h"
|
2009-02-11 18:02:45 +01:00
|
|
|
#include "idle.h"
|
|
|
|
|
2009-10-08 15:22:39 +02:00
|
|
|
extern unsigned audio_output_state_version;
|
|
|
|
|
2009-02-11 18:02:45 +01:00
|
|
|
bool
|
|
|
|
audio_output_enable_index(unsigned idx)
|
|
|
|
{
|
|
|
|
struct audio_output *ao;
|
|
|
|
|
|
|
|
if (idx >= audio_output_count())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ao = audio_output_get(idx);
|
2009-10-23 10:55:52 +02:00
|
|
|
if (ao->enabled)
|
|
|
|
return true;
|
2009-02-11 18:02:45 +01:00
|
|
|
|
|
|
|
ao->enabled = true;
|
|
|
|
idle_add(IDLE_OUTPUT);
|
|
|
|
|
2009-10-23 10:55:52 +02:00
|
|
|
pc_update_audio();
|
|
|
|
|
2009-10-08 15:22:39 +02:00
|
|
|
++audio_output_state_version;
|
|
|
|
|
2009-02-11 18:02:45 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
audio_output_disable_index(unsigned idx)
|
|
|
|
{
|
|
|
|
struct audio_output *ao;
|
2009-03-12 18:40:03 +01:00
|
|
|
struct mixer *mixer;
|
2009-02-11 18:02:45 +01:00
|
|
|
|
|
|
|
if (idx >= audio_output_count())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ao = audio_output_get(idx);
|
2009-10-23 10:55:52 +02:00
|
|
|
if (!ao->enabled)
|
|
|
|
return true;
|
2009-02-11 18:02:45 +01:00
|
|
|
|
|
|
|
ao->enabled = false;
|
|
|
|
idle_add(IDLE_OUTPUT);
|
|
|
|
|
2009-03-26 18:23:23 +01:00
|
|
|
mixer = ao->mixer;
|
2009-03-12 18:40:03 +01:00
|
|
|
if (mixer != NULL) {
|
|
|
|
mixer_close(mixer);
|
|
|
|
idle_add(IDLE_MIXER);
|
|
|
|
}
|
|
|
|
|
2009-10-23 10:55:52 +02:00
|
|
|
pc_update_audio();
|
|
|
|
|
2009-10-08 15:22:39 +02:00
|
|
|
++audio_output_state_version;
|
|
|
|
|
2009-02-11 18:02:45 +01:00
|
|
|
return true;
|
|
|
|
}
|