From c3c776bc6aa9f550a832ff3a2ace4f7980f6a791 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 7 Jan 2013 08:54:26 +0100 Subject: mixer_all: convert to C++ --- Makefile.am | 6 +- src/Main.cxx | 2 +- src/MixerAll.cxx | 182 +++++++++++++++++++++++++++++++++++++++++++++++++ src/MixerAll.hxx | 60 ++++++++++++++++ src/OutputAll.cxx | 2 +- src/OutputAll.hxx | 173 ++++++++++++++++++++++++++++++++++++++++++++++ src/OutputCommand.cxx | 2 +- src/OutputPrint.cxx | 5 +- src/OutputState.cxx | 5 +- src/PlayerCommands.cxx | 2 +- src/PlayerThread.cxx | 2 +- src/Volume.cxx | 2 +- src/mixer_all.c | 179 ------------------------------------------------ src/mixer_all.h | 62 ----------------- src/output_all.h | 173 ---------------------------------------------- 15 files changed, 425 insertions(+), 432 deletions(-) create mode 100644 src/MixerAll.cxx create mode 100644 src/MixerAll.hxx create mode 100644 src/OutputAll.hxx delete mode 100644 src/mixer_all.c delete mode 100644 src/mixer_all.h delete mode 100644 src/output_all.h diff --git a/Makefile.am b/Makefile.am index 8ccc04f38..132dd6974 100644 --- a/Makefile.am +++ b/Makefile.am @@ -52,7 +52,6 @@ mpd_headers = \ src/audio_parser.h \ src/output_internal.h \ src/output_api.h \ - src/output_all.h \ src/filter_internal.h \ src/filter_config.h \ src/filter_plugin.h \ @@ -97,7 +96,6 @@ mpd_headers = \ src/server_socket.h \ src/log.h \ src/ls.h \ - src/mixer_all.h \ src/mixer_api.h \ src/mixer_control.h \ src/mixer_list.h \ @@ -780,7 +778,7 @@ OUTPUT_LIBS = \ OUTPUT_API_SRC = \ src/OutputList.cxx src/OutputList.hxx \ - src/OutputAll.cxx \ + src/OutputAll.cxx src/OutputAll.hxx \ src/OutputThread.cxx src/OutputThread.hxx \ src/OutputError.hxx \ src/OutputControl.cxx src/OutputControl.hxx \ @@ -802,7 +800,7 @@ MIXER_LIBS = \ MIXER_API_SRC = \ src/mixer_control.c \ src/mixer_type.c \ - src/mixer_all.c \ + src/MixerAll.cxx src/MixerAll.hxx \ src/mixer_api.c libmixer_plugins_a_SOURCES = \ diff --git a/src/Main.cxx b/src/Main.cxx index 82816fcf9..808a445f0 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -35,6 +35,7 @@ #include "AllCommands.hxx" #include "Partition.hxx" #include "Volume.hxx" +#include "OutputAll.hxx" extern "C" { #include "daemon.h" @@ -45,7 +46,6 @@ extern "C" { #include "stats.h" #include "sig_handlers.h" #include "audio_config.h" -#include "output_all.h" #include "log.h" #include "pcm_resample.h" #include "replay_gain_config.h" diff --git a/src/MixerAll.cxx b/src/MixerAll.cxx new file mode 100644 index 000000000..a214c1e24 --- /dev/null +++ b/src/MixerAll.cxx @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2003-2013 The Music Player Daemon Project + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" +#include "MixerAll.hxx" +#include "pcm_volume.h" +#include "OutputAll.hxx" + +extern "C" { +#include "mixer_control.h" +#include "output_internal.h" +#include "mixer_api.h" +} + +#include + +#include + +#undef G_LOG_DOMAIN +#define G_LOG_DOMAIN "mixer" + +static int +output_mixer_get_volume(unsigned i) +{ + struct audio_output *output; + struct mixer *mixer; + int volume; + GError *error = NULL; + + assert(i < audio_output_count()); + + output = audio_output_get(i); + if (!output->enabled) + return -1; + + mixer = output->mixer; + if (mixer == NULL) + return -1; + + volume = mixer_get_volume(mixer, &error); + if (volume < 0 && error != NULL) { + g_warning("Failed to read mixer for '%s': %s", + output->name, error->message); + g_error_free(error); + } + + return volume; +} + +int +mixer_all_get_volume(void) +{ + unsigned count = audio_output_count(), ok = 0; + int volume, total = 0; + + for (unsigned i = 0; i < count; i++) { + volume = output_mixer_get_volume(i); + if (volume >= 0) { + total += volume; + ++ok; + } + } + + if (ok == 0) + return -1; + + return total / ok; +} + +static bool +output_mixer_set_volume(unsigned i, unsigned volume) +{ + struct audio_output *output; + struct mixer *mixer; + bool success; + GError *error = NULL; + + assert(i < audio_output_count()); + assert(volume <= 100); + + output = audio_output_get(i); + if (!output->enabled) + return false; + + mixer = output->mixer; + if (mixer == NULL) + return false; + + success = mixer_set_volume(mixer, volume, &error); + if (!success && error != NULL) { + g_warning("Failed to set mixer for '%s': %s", + output->name, error->message); + g_error_free(error); + } + + return success; +} + +bool +mixer_all_set_volume(unsigned volume) +{ + bool success = false; + unsigned count = audio_output_count(); + + assert(volume <= 100); + + for (unsigned i = 0; i < count; i++) + success = output_mixer_set_volume(i, volume) + || success; + + return success; +} + +static int +output_mixer_get_software_volume(unsigned i) +{ + struct audio_output *output; + struct mixer *mixer; + + assert(i < audio_output_count()); + + output = audio_output_get(i); + if (!output->enabled) + return -1; + + mixer = output->mixer; + if (mixer == NULL || mixer->plugin != &software_mixer_plugin) + return -1; + + return mixer_get_volume(mixer, NULL); +} + +int +mixer_all_get_software_volume(void) +{ + unsigned count = audio_output_count(), ok = 0; + int volume, total = 0; + + for (unsigned i = 0; i < count; i++) { + volume = output_mixer_get_software_volume(i); + if (volume >= 0) { + total += volume; + ++ok; + } + } + + if (ok == 0) + return -1; + + return total / ok; +} + +void +mixer_all_set_software_volume(unsigned volume) +{ + unsigned count = audio_output_count(); + + assert(volume <= PCM_VOLUME_1); + + for (unsigned i = 0; i < count; i++) { + struct audio_output *output = audio_output_get(i); + if (output->mixer != NULL && + output->mixer->plugin == &software_mixer_plugin) + mixer_set_volume(output->mixer, volume, NULL); + } +} diff --git a/src/MixerAll.hxx b/src/MixerAll.hxx new file mode 100644 index 000000000..23350a843 --- /dev/null +++ b/src/MixerAll.hxx @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2003-2013 The Music Player Daemon Project + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/** \file + * + * Functions which affect the mixers of all audio outputs. + */ + +#ifndef MPD_MIXER_ALL_HXX +#define MPD_MIXER_ALL_HXX + +/** + * Returns the average volume of all available mixers (range 0..100). + * Returns -1 if no mixer can be queried. + */ +int +mixer_all_get_volume(void); + +/** + * Sets the volume on all available mixers. + * + * @param volume the volume (range 0..100) + * @return true on success, false on failure + */ +bool +mixer_all_set_volume(unsigned volume); + +/** + * Similar to mixer_all_get_volume(), but gets the volume only for + * software mixers. See #software_mixer_plugin. This function fails + * if no software mixer is configured. + */ +int +mixer_all_get_software_volume(void); + +/** + * Similar to mixer_all_set_volume(), but sets the volume only for + * software mixers. See #software_mixer_plugin. This function cannot + * fail, because the underlying software mixers cannot fail either. + */ +void +mixer_all_set_software_volume(unsigned volume); + +#endif diff --git a/src/OutputAll.cxx b/src/OutputAll.cxx index 9c65ddcae..37f2e1ee9 100644 --- a/src/OutputAll.cxx +++ b/src/OutputAll.cxx @@ -18,9 +18,9 @@ */ #include "config.h" +#include "OutputAll.hxx" extern "C" { -#include "output_all.h" #include "output_internal.h" } diff --git a/src/OutputAll.hxx b/src/OutputAll.hxx new file mode 100644 index 000000000..becf4b695 --- /dev/null +++ b/src/OutputAll.hxx @@ -0,0 +1,173 @@ +/* + * Copyright (C) 2003-2011 The Music Player Daemon Project + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/* + * Functions for dealing with all configured (enabled) audion outputs + * at once. + * + */ + +#ifndef OUTPUT_ALL_H +#define OUTPUT_ALL_H + +#include "replay_gain_info.h" +#include "gerror.h" + +#include +#include + +struct audio_format; +struct music_buffer; +struct music_chunk; +struct player_control; + +/** + * Global initialization: load audio outputs from the configuration + * file and initialize them. + */ +void +audio_output_all_init(struct player_control *pc); + +/** + * Global finalization: free memory occupied by audio outputs. All + */ +void +audio_output_all_finish(void); + +/** + * Returns the total number of audio output devices, including those + * who are disabled right now. + */ +unsigned int audio_output_count(void); + +/** + * Returns the "i"th audio output device. + */ +struct audio_output * +audio_output_get(unsigned i); + +/** + * Returns the audio output device with the specified name. Returns + * NULL if the name does not exist. + */ +struct audio_output * +audio_output_find(const char *name); + +/** + * Checks the "enabled" flag of all audio outputs, and if one has + * changed, commit the change. + */ +void +audio_output_all_enable_disable(void); + +/** + * Opens all audio outputs which are not disabled. + * + * @param audio_format the preferred audio format, or NULL to reuse + * the previous format + * @param buffer the #music_buffer where consumed #music_chunk objects + * should be returned + * @return true on success, false on failure + */ +bool +audio_output_all_open(const struct audio_format *audio_format, + struct music_buffer *buffer, + GError **error_r); + +/** + * Closes all audio outputs. + */ +void +audio_output_all_close(void); + +/** + * Closes all audio outputs. Outputs with the "always_on" flag are + * put into pause mode. + */ +void +audio_output_all_release(void); + +void +audio_output_all_set_replay_gain_mode(enum replay_gain_mode mode); + +/** + * Enqueue a #music_chunk object for playing, i.e. pushes it to a + * #music_pipe. + * + * @param chunk the #music_chunk object to be played + * @return true on success, false if no audio output was able to play + * (all closed then) + */ +bool +audio_output_all_play(struct music_chunk *chunk, GError **error_r); + +/** + * Checks if the output devices have drained their music pipe, and + * returns the consumed music chunks to the #music_buffer. + * + * @return the number of chunks to play left in the #music_pipe + */ +unsigned +audio_output_all_check(void); + +/** + * Checks if the size of the #music_pipe is below the #threshold. If + * not, it attempts to synchronize with all output threads, and waits + * until another #music_chunk is finished. + * + * @param threshold the maximum number of chunks in the pipe + * @return true if there are less than #threshold chunks in the pipe + */ +bool +audio_output_all_wait(struct player_control *pc, unsigned threshold); + +/** + * Puts all audio outputs into pause mode. Most implementations will + * simply close it then. + */ +void +audio_output_all_pause(void); + +/** + * Drain all audio outputs. + */ +void +audio_output_all_drain(void); + +/** + * Try to cancel data which may still be in the device's buffers. + */ +void +audio_output_all_cancel(void); + +/** + * Indicate that a new song will begin now. + */ +void +audio_output_all_song_border(void); + +/** + * Returns the "elapsed_time" stamp of the most recently finished + * chunk. A negative value is returned when no chunk has been + * finished yet. + */ +float +audio_output_all_get_elapsed_time(void); + +#endif diff --git a/src/OutputCommand.cxx b/src/OutputCommand.cxx index cce1a5b04..3c9ff56fe 100644 --- a/src/OutputCommand.cxx +++ b/src/OutputCommand.cxx @@ -26,10 +26,10 @@ #include "config.h" #include "OutputCommand.hxx" +#include "OutputAll.hxx" #include "PlayerControl.hxx" extern "C" { -#include "output_all.h" #include "output_internal.h" #include "output_plugin.h" #include "mixer_control.h" diff --git a/src/OutputPrint.cxx b/src/OutputPrint.cxx index ed4391547..240ea967b 100644 --- a/src/OutputPrint.cxx +++ b/src/OutputPrint.cxx @@ -24,13 +24,10 @@ #include "config.h" #include "OutputPrint.hxx" +#include "OutputAll.hxx" #include "output_internal.h" #include "Client.hxx" -extern "C" { -#include "output_all.h" -} - void printAudioDevices(Client *client) { diff --git a/src/OutputState.cxx b/src/OutputState.cxx index 95aeacbca..27fa34f8f 100644 --- a/src/OutputState.cxx +++ b/src/OutputState.cxx @@ -24,12 +24,9 @@ #include "config.h" #include "OutputState.hxx" +#include "OutputAll.hxx" #include "output_internal.h" -extern "C" { -#include "output_all.h" -} - #include #include diff --git a/src/PlayerCommands.cxx b/src/PlayerCommands.cxx index 5920863a6..c272ae354 100644 --- a/src/PlayerCommands.cxx +++ b/src/PlayerCommands.cxx @@ -25,13 +25,13 @@ #include "UpdateGlue.hxx" #include "ClientInternal.hxx" #include "Volume.hxx" +#include "OutputAll.hxx" #include "protocol/Result.hxx" #include "protocol/ArgParser.hxx" extern "C" { #include "audio_format.h" #include "replay_gain_config.h" -#include "output_all.h" } #include "PlayerControl.hxx" diff --git a/src/PlayerThread.cxx b/src/PlayerThread.cxx index 0343b9fcd..cba6c0fcd 100644 --- a/src/PlayerThread.cxx +++ b/src/PlayerThread.cxx @@ -29,9 +29,9 @@ #include "mpd_error.h" #include "CrossFade.hxx" #include "PlayerControl.hxx" +#include "OutputAll.hxx" extern "C" { -#include "output_all.h" #include "event_pipe.h" #include "tag.h" #include "idle.h" diff --git a/src/Volume.cxx b/src/Volume.cxx index f6643a905..2c954fae9 100644 --- a/src/Volume.cxx +++ b/src/Volume.cxx @@ -19,10 +19,10 @@ #include "config.h" #include "Volume.hxx" +#include "MixerAll.hxx" extern "C" { #include "idle.h" -#include "mixer_all.h" #include "event_pipe.h" } diff --git a/src/mixer_all.c b/src/mixer_all.c deleted file mode 100644 index 5801b7921..000000000 --- a/src/mixer_all.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (C) 2003-2011 The Music Player Daemon Project - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" -#include "mixer_all.h" -#include "mixer_control.h" -#include "output_all.h" -#include "output_internal.h" -#include "pcm_volume.h" -#include "mixer_api.h" - -#include - -#include - -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "mixer" - -static int -output_mixer_get_volume(unsigned i) -{ - struct audio_output *output; - struct mixer *mixer; - int volume; - GError *error = NULL; - - assert(i < audio_output_count()); - - output = audio_output_get(i); - if (!output->enabled) - return -1; - - mixer = output->mixer; - if (mixer == NULL) - return -1; - - volume = mixer_get_volume(mixer, &error); - if (volume < 0 && error != NULL) { - g_warning("Failed to read mixer for '%s': %s", - output->name, error->message); - g_error_free(error); - } - - return volume; -} - -int -mixer_all_get_volume(void) -{ - unsigned count = audio_output_count(), ok = 0; - int volume, total = 0; - - for (unsigned i = 0; i < count; i++) { - volume = output_mixer_get_volume(i); - if (volume >= 0) { - total += volume; - ++ok; - } - } - - if (ok == 0) - return -1; - - return total / ok; -} - -static bool -output_mixer_set_volume(unsigned i, unsigned volume) -{ - struct audio_output *output; - struct mixer *mixer; - bool success; - GError *error = NULL; - - assert(i < audio_output_count()); - assert(volume <= 100); - - output = audio_output_get(i); - if (!output->enabled) - return false; - - mixer = output->mixer; - if (mixer == NULL) - return false; - - success = mixer_set_volume(mixer, volume, &error); - if (!success && error != NULL) { - g_warning("Failed to set mixer for '%s': %s", - output->name, error->message); - g_error_free(error); - } - - return success; -} - -bool -mixer_all_set_volume(unsigned volume) -{ - bool success = false; - unsigned count = audio_output_count(); - - assert(volume <= 100); - - for (unsigned i = 0; i < count; i++) - success = output_mixer_set_volume(i, volume) - || success; - - return success; -} - -static int -output_mixer_get_software_volume(unsigned i) -{ - struct audio_output *output; - struct mixer *mixer; - - assert(i < audio_output_count()); - - output = audio_output_get(i); - if (!output->enabled) - return -1; - - mixer = output->mixer; - if (mixer == NULL || mixer->plugin != &software_mixer_plugin) - return -1; - - return mixer_get_volume(mixer, NULL); -} - -int -mixer_all_get_software_volume(void) -{ - unsigned count = audio_output_count(), ok = 0; - int volume, total = 0; - - for (unsigned i = 0; i < count; i++) { - volume = output_mixer_get_software_volume(i); - if (volume >= 0) { - total += volume; - ++ok; - } - } - - if (ok == 0) - return -1; - - return total / ok; -} - -void -mixer_all_set_software_volume(unsigned volume) -{ - unsigned count = audio_output_count(); - - assert(volume <= PCM_VOLUME_1); - - for (unsigned i = 0; i < count; i++) { - struct audio_output *output = audio_output_get(i); - if (output->mixer != NULL && - output->mixer->plugin == &software_mixer_plugin) - mixer_set_volume(output->mixer, volume, NULL); - } -} diff --git a/src/mixer_all.h b/src/mixer_all.h deleted file mode 100644 index fe873e713..000000000 --- a/src/mixer_all.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2003-2011 The Music Player Daemon Project - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** \file - * - * Functions which affect the mixers of all audio outputs. - */ - -#ifndef MPD_MIXER_ALL_H -#define MPD_MIXER_ALL_H - -#include - -/** - * Returns the average volume of all available mixers (range 0..100). - * Returns -1 if no mixer can be queried. - */ -int -mixer_all_get_volume(void); - -/** - * Sets the volume on all available mixers. - * - * @param volume the volume (range 0..100) - * @return true on success, false on failure - */ -bool -mixer_all_set_volume(unsigned volume); - -/** - * Similar to mixer_all_get_volume(), but gets the volume only for - * software mixers. See #software_mixer_plugin. This function fails - * if no software mixer is configured. - */ -int -mixer_all_get_software_volume(void); - -/** - * Similar to mixer_all_set_volume(), but sets the volume only for - * software mixers. See #software_mixer_plugin. This function cannot - * fail, because the underlying software mixers cannot fail either. - */ -void -mixer_all_set_software_volume(unsigned volume); - -#endif diff --git a/src/output_all.h b/src/output_all.h deleted file mode 100644 index becf4b695..000000000 --- a/src/output_all.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2003-2011 The Music Player Daemon Project - * 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., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* - * Functions for dealing with all configured (enabled) audion outputs - * at once. - * - */ - -#ifndef OUTPUT_ALL_H -#define OUTPUT_ALL_H - -#include "replay_gain_info.h" -#include "gerror.h" - -#include -#include - -struct audio_format; -struct music_buffer; -struct music_chunk; -struct player_control; - -/** - * Global initialization: load audio outputs from the configuration - * file and initialize them. - */ -void -audio_output_all_init(struct player_control *pc); - -/** - * Global finalization: free memory occupied by audio outputs. All - */ -void -audio_output_all_finish(void); - -/** - * Returns the total number of audio output devices, including those - * who are disabled right now. - */ -unsigned int audio_output_count(void); - -/** - * Returns the "i"th audio output device. - */ -struct audio_output * -audio_output_get(unsigned i); - -/** - * Returns the audio output device with the specified name. Returns - * NULL if the name does not exist. - */ -struct audio_output * -audio_output_find(const char *name); - -/** - * Checks the "enabled" flag of all audio outputs, and if one has - * changed, commit the change. - */ -void -audio_output_all_enable_disable(void); - -/** - * Opens all audio outputs which are not disabled. - * - * @param audio_format the preferred audio format, or NULL to reuse - * the previous format - * @param buffer the #music_buffer where consumed #music_chunk objects - * should be returned - * @return true on success, false on failure - */ -bool -audio_output_all_open(const struct audio_format *audio_format, - struct music_buffer *buffer, - GError **error_r); - -/** - * Closes all audio outputs. - */ -void -audio_output_all_close(void); - -/** - * Closes all audio outputs. Outputs with the "always_on" flag are - * put into pause mode. - */ -void -audio_output_all_release(void); - -void -audio_output_all_set_replay_gain_mode(enum replay_gain_mode mode); - -/** - * Enqueue a #music_chunk object for playing, i.e. pushes it to a - * #music_pipe. - * - * @param chunk the #music_chunk object to be played - * @return true on success, false if no audio output was able to play - * (all closed then) - */ -bool -audio_output_all_play(struct music_chunk *chunk, GError **error_r); - -/** - * Checks if the output devices have drained their music pipe, and - * returns the consumed music chunks to the #music_buffer. - * - * @return the number of chunks to play left in the #music_pipe - */ -unsigned -audio_output_all_check(void); - -/** - * Checks if the size of the #music_pipe is below the #threshold. If - * not, it attempts to synchronize with all output threads, and waits - * until another #music_chunk is finished. - * - * @param threshold the maximum number of chunks in the pipe - * @return true if there are less than #threshold chunks in the pipe - */ -bool -audio_output_all_wait(struct player_control *pc, unsigned threshold); - -/** - * Puts all audio outputs into pause mode. Most implementations will - * simply close it then. - */ -void -audio_output_all_pause(void); - -/** - * Drain all audio outputs. - */ -void -audio_output_all_drain(void); - -/** - * Try to cancel data which may still be in the device's buffers. - */ -void -audio_output_all_cancel(void); - -/** - * Indicate that a new song will begin now. - */ -void -audio_output_all_song_border(void); - -/** - * Returns the "elapsed_time" stamp of the most recently finished - * chunk. A negative value is returned when no chunk has been - * finished yet. - */ -float -audio_output_all_get_elapsed_time(void); - -#endif -- cgit v1.2.3