1 /* 2 * This file is part of mpv. 3 * 4 * mpv is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation; either 7 * version 2.1 of the License, or (at your option) any later version. 8 * 9 * mpv is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU Lesser General Public License for more details. 13 * 14 * You should have received a copy of the GNU Lesser General Public 15 * License along with mpv. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #ifndef MPLAYER_AUDIO_OUT_H 19 #define MPLAYER_AUDIO_OUT_H 20 21 #include <stdbool.h> 22 23 #include "misc/bstr.h" 24 #include "common/common.h" 25 #include "audio/chmap.h" 26 #include "audio/chmap_sel.h" 27 28 enum aocontrol { 29 // _VOLUME commands take struct ao_control_vol pointer for input/output. 30 // If there's only one volume, SET should use average of left/right. 31 AOCONTROL_GET_VOLUME, 32 AOCONTROL_SET_VOLUME, 33 // _MUTE commands take a pointer to bool 34 AOCONTROL_GET_MUTE, 35 AOCONTROL_SET_MUTE, 36 // Has char* as argument, which contains the desired stream title. 37 AOCONTROL_UPDATE_STREAM_TITLE, 38 }; 39 40 // If set, then the queued audio data is the last. Note that after a while, new 41 // data might be written again, instead of closing the AO. 42 #define PLAYER_FINAL_CHUNK 1 43 44 enum { 45 AO_EVENT_RELOAD = 1, 46 AO_EVENT_HOTPLUG = 2, 47 AO_EVENT_INITIAL_UNBLOCK = 4, 48 }; 49 50 enum { 51 // Allow falling back to ao_null if nothing else works. 52 AO_INIT_NULL_FALLBACK = 1 << 0, 53 // Only accept multichannel configurations that are guaranteed to work 54 // (i.e. not sending arbitrary layouts over HDMI). 55 AO_INIT_SAFE_MULTICHANNEL_ONLY = 1 << 1, 56 // Stream silence as long as no audio is playing. 57 AO_INIT_STREAM_SILENCE = 1 << 2, 58 // Force exclusive mode, i.e. lock out the system mixer. 59 AO_INIT_EXCLUSIVE = 1 << 3, 60 }; 61 62 typedef struct ao_control_vol { 63 float left; 64 float right; 65 } ao_control_vol_t; 66 67 struct ao_device_desc { 68 const char *name; // symbolic name; will be set on ao->device 69 const char *desc; // verbose human readable name 70 }; 71 72 struct ao_device_list { 73 struct ao_device_desc *devices; 74 int num_devices; 75 }; 76 77 struct ao; 78 struct mpv_global; 79 struct input_ctx; 80 struct encode_lavc_context; 81 82 struct ao_opts { 83 struct m_obj_settings *audio_driver_list; 84 char *audio_device; 85 char *audio_client_name; 86 double audio_buffer; 87 }; 88 89 struct ao *ao_init_best(struct mpv_global *global, 90 int init_flags, 91 void (*wakeup_cb)(void *ctx), void *wakeup_ctx, 92 struct encode_lavc_context *encode_lavc_ctx, 93 int samplerate, int format, struct mp_chmap channels); 94 void ao_uninit(struct ao *ao); 95 void ao_get_format(struct ao *ao, 96 int *samplerate, int *format, struct mp_chmap *channels); 97 const char *ao_get_name(struct ao *ao); 98 const char *ao_get_description(struct ao *ao); 99 bool ao_untimed(struct ao *ao); 100 int ao_control(struct ao *ao, enum aocontrol cmd, void *arg); 101 void ao_set_gain(struct ao *ao, float gain); 102 double ao_get_delay(struct ao *ao); 103 void ao_reset(struct ao *ao); 104 void ao_start(struct ao *ao); 105 void ao_set_paused(struct ao *ao, bool paused); 106 void ao_drain(struct ao *ao); 107 bool ao_is_playing(struct ao *ao); 108 struct mp_async_queue; 109 struct mp_async_queue *ao_get_queue(struct ao *ao); 110 int ao_query_and_reset_events(struct ao *ao, int events); 111 int ao_add_events(struct ao *ao, int events); 112 void ao_unblock(struct ao *ao); 113 void ao_request_reload(struct ao *ao); 114 void ao_hotplug_event(struct ao *ao); 115 116 struct ao_hotplug; 117 struct ao_hotplug *ao_hotplug_create(struct mpv_global *global, 118 void (*wakeup_cb)(void *ctx), 119 void *wakeup_ctx); 120 void ao_hotplug_destroy(struct ao_hotplug *hp); 121 bool ao_hotplug_check_update(struct ao_hotplug *hp); 122 struct ao_device_list *ao_hotplug_get_device_list(struct ao_hotplug *hp); 123 124 void ao_print_devices(struct mpv_global *global, struct mp_log *log); 125 126 #endif /* MPLAYER_AUDIO_OUT_H */ 127