2009-03-13 18:43:16 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2003-2009 The Music Player Daemon Project
|
|
|
|
* http://www.musicpd.org
|
2008-09-24 07:20:55 +02:00
|
|
|
*
|
|
|
|
* 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.
|
2008-09-24 07:20:55 +02:00
|
|
|
*/
|
|
|
|
|
2008-10-31 09:19:53 +01:00
|
|
|
#ifndef MPD_OUTPUT_INTERNAL_H
|
|
|
|
#define MPD_OUTPUT_INTERNAL_H
|
2008-09-24 07:20:55 +02:00
|
|
|
|
2009-02-16 01:51:50 +01:00
|
|
|
#include "audio_format.h"
|
2009-01-07 18:53:36 +01:00
|
|
|
#include "pcm_convert.h"
|
2008-09-24 07:20:55 +02:00
|
|
|
#include "notify.h"
|
|
|
|
|
2008-10-29 22:32:50 +01:00
|
|
|
#include <time.h>
|
|
|
|
|
2009-02-16 00:43:12 +01:00
|
|
|
enum audio_output_command {
|
|
|
|
AO_COMMAND_NONE = 0,
|
|
|
|
AO_COMMAND_OPEN,
|
|
|
|
AO_COMMAND_CLOSE,
|
|
|
|
AO_COMMAND_PAUSE,
|
|
|
|
AO_COMMAND_CANCEL,
|
|
|
|
AO_COMMAND_KILL
|
|
|
|
};
|
|
|
|
|
2008-09-24 07:20:55 +02:00
|
|
|
struct audio_output {
|
2008-09-24 07:21:46 +02:00
|
|
|
/**
|
|
|
|
* The device's configured display name.
|
|
|
|
*/
|
2008-09-24 07:20:55 +02:00
|
|
|
const char *name;
|
|
|
|
|
2008-09-24 07:21:46 +02:00
|
|
|
/**
|
|
|
|
* The plugin which implements this output device.
|
|
|
|
*/
|
2008-09-24 07:20:55 +02:00
|
|
|
const struct audio_output_plugin *plugin;
|
|
|
|
|
2008-09-24 07:21:46 +02:00
|
|
|
/**
|
|
|
|
* The plugin's internal data. It is passed to every plugin
|
|
|
|
* method.
|
|
|
|
*/
|
|
|
|
void *data;
|
|
|
|
|
2009-03-20 15:47:50 +01:00
|
|
|
/**
|
|
|
|
* This flag is true, when the audio_format of this device is
|
|
|
|
* configured in mpd.conf.
|
|
|
|
*/
|
|
|
|
bool config_audio_format;
|
|
|
|
|
2008-10-29 20:49:51 +01:00
|
|
|
/**
|
|
|
|
* Has the user enabled this device?
|
|
|
|
*/
|
|
|
|
bool enabled;
|
|
|
|
|
2008-09-24 07:21:46 +02:00
|
|
|
/**
|
|
|
|
* Is the device (already) open and functional?
|
|
|
|
*/
|
2008-10-29 20:40:27 +01:00
|
|
|
bool open;
|
2008-09-24 07:21:46 +02:00
|
|
|
|
2008-10-29 22:32:50 +01:00
|
|
|
/**
|
2009-02-28 20:43:23 +01:00
|
|
|
* If not NULL, the device has failed, and this timer is used
|
|
|
|
* to estimate how long it should stay disabled (unless
|
|
|
|
* explicitly reopened with "play").
|
2008-10-29 22:32:50 +01:00
|
|
|
*/
|
2009-02-28 20:43:23 +01:00
|
|
|
GTimer *fail_timer;
|
2008-10-29 22:32:50 +01:00
|
|
|
|
2008-09-24 07:21:46 +02:00
|
|
|
/**
|
|
|
|
* The audio_format in which audio data is received from the
|
|
|
|
* player thread (which in turn receives it from the decoder).
|
|
|
|
*/
|
2009-02-10 21:50:51 +01:00
|
|
|
struct audio_format in_audio_format;
|
2008-09-24 07:21:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The audio_format which is really sent to the device. This
|
2009-02-10 21:50:51 +01:00
|
|
|
* is basically config_audio_format (if configured) or
|
|
|
|
* in_audio_format, but may have been modified by
|
2008-09-24 07:21:46 +02:00
|
|
|
* plugin->open().
|
|
|
|
*/
|
2009-02-10 21:50:51 +01:00
|
|
|
struct audio_format out_audio_format;
|
2008-09-24 07:21:46 +02:00
|
|
|
|
2009-02-10 21:50:51 +01:00
|
|
|
struct pcm_convert_state convert_state;
|
2008-09-24 07:20:55 +02:00
|
|
|
|
2008-09-24 07:21:46 +02:00
|
|
|
/**
|
2008-12-28 22:09:42 +01:00
|
|
|
* The thread handle, or NULL if the output thread isn't
|
2008-09-24 07:21:46 +02:00
|
|
|
* running.
|
|
|
|
*/
|
2008-12-28 22:09:42 +01:00
|
|
|
GThread *thread;
|
2008-09-24 07:21:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Notify object for the thread.
|
|
|
|
*/
|
2008-09-24 07:20:55 +02:00
|
|
|
struct notify notify;
|
2008-09-24 07:21:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The next command to be performed by the output thread.
|
|
|
|
*/
|
2008-09-24 07:20:55 +02:00
|
|
|
enum audio_output_command command;
|
2008-09-24 07:21:46 +02:00
|
|
|
|
|
|
|
/**
|
2009-03-09 19:25:26 +01:00
|
|
|
* The music pipe which provides music chunks to be played.
|
2008-09-24 07:21:46 +02:00
|
|
|
*/
|
2009-03-09 19:25:26 +01:00
|
|
|
const struct music_pipe *pipe;
|
2008-09-24 07:20:55 +02:00
|
|
|
|
2009-03-09 19:25:26 +01:00
|
|
|
/**
|
|
|
|
* This mutex protects #chunk and #chunk_finished.
|
|
|
|
*/
|
|
|
|
GMutex *mutex;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The #music_chunk which is currently being played. All
|
|
|
|
* chunks before this one may be returned to the
|
|
|
|
* #music_buffer, because they are not going to be used by
|
|
|
|
* this output anymore.
|
|
|
|
*/
|
|
|
|
const struct music_chunk *chunk;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Has the output finished playing #chunk?
|
|
|
|
*/
|
|
|
|
bool chunk_finished;
|
2008-09-24 07:20:55 +02:00
|
|
|
};
|
|
|
|
|
2008-09-24 07:21:46 +02:00
|
|
|
/**
|
|
|
|
* Notify object used by the thread's client, i.e. we will send a
|
|
|
|
* notify signal to this object, expecting the caller to wait on it.
|
|
|
|
*/
|
2008-09-24 07:20:55 +02:00
|
|
|
extern struct notify audio_output_client_notify;
|
|
|
|
|
2008-10-29 20:40:27 +01:00
|
|
|
static inline bool
|
2008-09-24 07:25:07 +02:00
|
|
|
audio_output_is_open(const struct audio_output *ao)
|
|
|
|
{
|
|
|
|
return ao->open;
|
|
|
|
}
|
|
|
|
|
2008-10-29 20:40:27 +01:00
|
|
|
static inline bool
|
2008-09-24 07:23:19 +02:00
|
|
|
audio_output_command_is_finished(const struct audio_output *ao)
|
|
|
|
{
|
|
|
|
return ao->command == AO_COMMAND_NONE;
|
|
|
|
}
|
|
|
|
|
2008-09-24 07:20:55 +02:00
|
|
|
#endif
|