| 1 | #cxx . . $ `<file>/external/portaudio/pa_linux_alsa.c`/if defined (UNIXcxx . . $ `<built-in>:413:9`!) && defined (ALSAcxx . . $ `<built-in>:416:9`!) |
| 2 | /* |
| 3 | * $Id$ |
| 4 | * PortAudio Portable Real-Time Audio Library |
| 5 | * Latest Version at: http://www.portaudio.com |
| 6 | * ALSA implementation by Joshua Haberman and Arve Knudsen |
| 7 | * |
| 8 | * Copyright (c) 2002 Joshua Haberman <[email protected]> |
| 9 | * Copyright (c) 2005-2009 Arve Knudsen <[email protected]> |
| 10 | * Copyright (c) 2008 Kevin Kofler <[email protected]> |
| 11 | * |
| 12 | * Based on the Open Source API proposed by Ross Bencina |
| 13 | * Copyright (c) 1999-2002 Ross Bencina, Phil Burk |
| 14 | * |
| 15 | * Permission is hereby granted, free of charge, to any person obtaining |
| 16 | * a copy of this software and associated documentation files |
| 17 | * (the "Software"), to deal in the Software without restriction, |
| 18 | * including without limitation the rights to use, copy, modify, merge, |
| 19 | * publish, distribute, sublicense, and/or sell copies of the Software, |
| 20 | * and to permit persons to whom the Software is furnished to do so, |
| 21 | * subject to the following conditions: |
| 22 | * |
| 23 | * The above copyright notice and this permission notice shall be |
| 24 | * included in all copies or substantial portions of the Software. |
| 25 | * |
| 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 27 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 29 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR |
| 30 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 31 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 32 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 33 | */ |
| 34 | |
| 35 | /* |
| 36 | * The text above constitutes the entire PortAudio license; however, |
| 37 | * the PortAudio community also makes the following non-binding requests: |
| 38 | * |
| 39 | * Any person wishing to distribute modifications to the Software is |
| 40 | * requested to send the modifications to the original developer so that |
| 41 | * they can be incorporated into the canonical version. It is also |
| 42 | * requested that these non-binding requests be included along with the |
| 43 | * license above. |
| 44 | */ |
| 45 | |
| 46 | /** |
| 47 | @file |
| 48 | @ingroup hostapi_src |
| 49 | */ |
| 50 | |
| 51 | #define ALSA_PCM_NEW_HW_PARAMS_APIcxx . . $ `external/portaudio/pa_linux_alsa.c:51:9`! |
| 52 | #define ALSA_PCM_NEW_SW_PARAMS_APIcxx . . $ `external/portaudio/pa_linux_alsa.c:52:9`! |
| 53 | #include <alsa/asoundlib.h> |
| 54 | #undef ALSA_PCM_NEW_HW_PARAMS_APIcxx . . $ `external/portaudio/pa_linux_alsa.c:51:9`! |
| 55 | #undef ALSA_PCM_NEW_SW_PARAMS_APIcxx . . $ `external/portaudio/pa_linux_alsa.c:52:9`! |
| 56 | |
| 57 | #include <sys/poll.h> |
| 58 | #include <string.h> /* strlen() */ |
| 59 | #include <limits.h> |
| 60 | #include <math.h> |
| 61 | #include <pthread.h> |
| 62 | #include <signal.h> |
| 63 | #include <time.h> |
| 64 | #include <sys/mman.h> |
| 65 | #include <signal.h> /* For sig_atomic_t */ |
| 66 | #ifdef PA_ALSA_DYNAMIC |
| 67 | #include <dlfcn.h> /* For dlXXX functions */ |
| 68 | #endif |
| 69 | |
| 70 | #include "portaudio.h"cxx . . $ `<file>/external/portaudio/portaudio.h`/ |
| 71 | #include "pa_util.h"cxx . . $ `<file>/external/portaudio/pa_util.h`/ |
| 72 | #include "pa_unix_util.h"cxx . . $ `<file>/external/portaudio/pa_unix_util.h`/ |
| 73 | #include "pa_allocation.h"cxx . . $ `<file>/external/portaudio/pa_allocation.h`/ |
| 74 | #include "pa_hostapi.h"cxx . . $ `<file>/external/portaudio/pa_hostapi.h`/ |
| 75 | #include "pa_stream.h"cxx . . $ `<file>/external/portaudio/pa_stream.h`/ |
| 76 | #include "pa_cpuload.h"cxx . . $ `<file>/external/portaudio/pa_cpuload.h`/ |
| 77 | #include "pa_process.h"cxx . . $ `<file>/external/portaudio/pa_process.h`/ |
| 78 | #include "pa_endianness.h"cxx . . $ `<file>/external/portaudio/pa_endianness.h`/ |
| 79 | #include "pa_debugprint.h"cxx . . $ `<file>/external/portaudio/pa_debugprint.h`/ |
| 80 | |
| 81 | #include "pa_linux_alsa.h"cxx . . $ `<file>/external/portaudio/pa_linux_alsa.h`/ |
| 82 | |
| 83 | /* Add missing define (for compatibility with older ALSA versions) */ |
| 84 | #ifndef SND_PCM_TSTAMP_ENABLE |
| 85 | #define SND_PCM_TSTAMP_ENABLEcxx . . $ `external/portaudio/pa_linux_alsa.c:85:13`! SND_PCM_TSTAMP_MMAP |
| 86 | #endif |
| 87 | |
| 88 | /* Combine version elements into a single (unsigned) integer */ |
| 89 | #define ALSA_VERSION_INTcxx . . $ `external/portaudio/pa_linux_alsa.c:89:9`!(major, minor, subminor) ((major << 16) | (minor << 8) | subminor) |
| 90 | |
| 91 | /* The acceptable tolerance of sample rate set, to that requested (as a ratio, eg 50 is 2%, 100 is 1%) */ |
| 92 | #define RATE_MAX_DEVIATE_RATIOcxx . . $ `external/portaudio/pa_linux_alsa.c:92:9`! 100 |
| 93 | |
| 94 | /* Defines Alsa function types and pointers to these functions. */ |
| 95 | #define _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(x) typedef typeof(x) x##_ft; static x##_ft *alsa_##x = 0 |
| 96 | |
| 97 | /* Alloca helper. */ |
| 98 | #define __alsa_snd_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:98:9`!(ptr,type) do { size_t __alsa_alloca_size = alsa_##type##_sizeof(); (*ptr) = (type##_t *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(__alsa_alloca_size); memset(*ptr, 0, __alsa_alloca_size); } while (0) |
| 99 | |
| 100 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_open); |
| 101 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_close); |
| 102 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_nonblock); |
| 103 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_frames_to_bytes); |
| 104 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_prepare); |
| 105 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_start); |
| 106 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_resume); |
| 107 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_wait); |
| 108 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_state); |
| 109 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_avail_update); |
| 110 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_areas_silence); |
| 111 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_mmap_begin); |
| 112 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_mmap_commit); |
| 113 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_readi); |
| 114 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_readn); |
| 115 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_writei); |
| 116 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_writen); |
| 117 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_drain); |
| 118 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_recover); |
| 119 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_drop); |
| 120 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_area_copy); |
| 121 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_poll_descriptors); |
| 122 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_poll_descriptors_count); |
| 123 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_poll_descriptors_revents); |
| 124 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_format_size); |
| 125 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_link); |
| 126 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_delay); |
| 127 | |
| 128 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_sizeof); |
| 129 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_malloc); |
| 130 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_free); |
| 131 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_any); |
| 132 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_set_access); |
| 133 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_set_format); |
| 134 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_set_channels); |
| 135 | //_PA_DEFINE_FUNC(snd_pcm_hw_params_set_periods_near); |
| 136 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_set_rate_near); //!!! |
| 137 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_set_rate); |
| 138 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_set_rate_resample); |
| 139 | //_PA_DEFINE_FUNC(snd_pcm_hw_params_set_buffer_time_near); |
| 140 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_set_buffer_size); |
| 141 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_set_buffer_size_near); //!!! |
| 142 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_set_buffer_size_min); |
| 143 | //_PA_DEFINE_FUNC(snd_pcm_hw_params_set_period_time_near); |
| 144 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_set_period_size_near); |
| 145 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_set_periods_integer); |
| 146 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_set_periods_min); |
| 147 | |
| 148 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_get_buffer_size); |
| 149 | //_PA_DEFINE_FUNC(snd_pcm_hw_params_get_period_size); |
| 150 | //_PA_DEFINE_FUNC(snd_pcm_hw_params_get_access); |
| 151 | //_PA_DEFINE_FUNC(snd_pcm_hw_params_get_periods); |
| 152 | //_PA_DEFINE_FUNC(snd_pcm_hw_params_get_rate); |
| 153 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_get_channels_min); |
| 154 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_get_channels_max); |
| 155 | |
| 156 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_test_period_size); |
| 157 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_test_format); |
| 158 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_test_access); |
| 159 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_dump); |
| 160 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params); |
| 161 | |
| 162 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_get_periods_min); |
| 163 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_get_periods_max); |
| 164 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_set_period_size); |
| 165 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_get_period_size_min); |
| 166 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_get_period_size_max); |
| 167 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_get_buffer_size_max); |
| 168 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_get_rate_min); |
| 169 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_get_rate_max); |
| 170 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_hw_params_get_rate_numden); |
| 171 | #define alsa_snd_pcm_hw_params_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:171:9`!(ptr) __alsa_snd_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:98:9`!(ptr, snd_pcm_hw_params) |
| 172 | |
| 173 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_sw_params_sizeof); |
| 174 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_sw_params_malloc); |
| 175 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_sw_params_current); |
| 176 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_sw_params_set_avail_min); |
| 177 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_sw_params); |
| 178 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_sw_params_free); |
| 179 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_sw_params_set_start_threshold); |
| 180 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_sw_params_set_stop_threshold); |
| 181 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_sw_params_get_boundary); |
| 182 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_sw_params_set_silence_threshold); |
| 183 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_sw_params_set_silence_size); |
| 184 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_sw_params_set_xfer_align); |
| 185 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_sw_params_set_tstamp_mode); |
| 186 | #define alsa_snd_pcm_sw_params_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:186:9`!(ptr) __alsa_snd_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:98:9`!(ptr, snd_pcm_sw_params) |
| 187 | |
| 188 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_info); |
| 189 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_info_sizeof); |
| 190 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_info_malloc); |
| 191 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_info_free); |
| 192 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_info_set_device); |
| 193 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_info_set_subdevice); |
| 194 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_info_set_stream); |
| 195 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_info_get_name); |
| 196 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_info_get_card); |
| 197 | #define alsa_snd_pcm_info_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:197:9`!(ptr) __alsa_snd_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:98:9`!(ptr, snd_pcm_info) |
| 198 | |
| 199 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_ctl_pcm_next_device); |
| 200 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_ctl_pcm_info); |
| 201 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_ctl_open); |
| 202 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_ctl_close); |
| 203 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_ctl_card_info_malloc); |
| 204 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_ctl_card_info_free); |
| 205 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_ctl_card_info); |
| 206 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_ctl_card_info_sizeof); |
| 207 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_ctl_card_info_get_name); |
| 208 | #define alsa_snd_ctl_card_info_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:208:9`!(ptr) __alsa_snd_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:98:9`!(ptr, snd_ctl_card_info) |
| 209 | |
| 210 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_config); |
| 211 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_config_update); |
| 212 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_config_search); |
| 213 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_config_iterator_entry); |
| 214 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_config_iterator_first); |
| 215 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_config_iterator_end); |
| 216 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_config_iterator_next); |
| 217 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_config_get_string); |
| 218 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_config_get_id); |
| 219 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_config_update_free_global); |
| 220 | |
| 221 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_status); |
| 222 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_status_sizeof); |
| 223 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_status_get_tstamp); |
| 224 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_status_get_state); |
| 225 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_status_get_trigger_tstamp); |
| 226 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_pcm_status_get_delay); |
| 227 | #define alsa_snd_pcm_status_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:227:9`!(ptr) __alsa_snd_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:98:9`!(ptr, snd_pcm_status) |
| 228 | |
| 229 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_card_next); |
| 230 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_asoundlib_version); |
| 231 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_strerror); |
| 232 | _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`!(snd_output_stdio_attach); |
| 233 | |
| 234 | #define alsa_snd_config_for_eachcxx . . $ `external/portaudio/pa_linux_alsa.c:234:9`!(pos, next, node)\ |
| 235 | for (pos = alsa_snd_config_iterator_first(node),\ |
| 236 | next = alsa_snd_config_iterator_next(pos);\ |
| 237 | pos != alsa_snd_config_iterator_end(node); pos = next, next = alsa_snd_config_iterator_next(pos)) |
| 238 | |
| 239 | #undef _PA_DEFINE_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:95:9`! |
| 240 | |
| 241 | /* Redefine 'PA_ALSA_PATHNAME' to a different Alsa library name if desired. */ |
| 242 | #ifndef PA_ALSA_PATHNAME |
| 243 | #define PA_ALSA_PATHNAMEcxx . . $ `external/portaudio/pa_linux_alsa.c:243:13`! "libasound.so" |
| 244 | #endif |
| 245 | static const char *g_AlsaLibNamecxx . . $ g_AlsaLibName. = PA_ALSA_PATHNAMEcxx . . $ `external/portaudio/pa_linux_alsa.c:243:13`!; |
| 246 | |
| 247 | /* Handle to dynamically loaded library. */ |
| 248 | static void *g_AlsaLibcxx . . $ g_AlsaLib. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 249 | |
| 250 | #ifdef PA_ALSA_DYNAMIC |
| 251 | |
| 252 | #define _PA_LOCAL_IMPL(x) __pa_local_##x |
| 253 | |
| 254 | int _PA_LOCAL_IMPL(snd_pcm_hw_params_set_rate_near) (snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir) |
| 255 | { |
| 256 | int ret; |
| 257 | |
| 258 | if(( ret = alsa_snd_pcm_hw_params_set_rate(pcm, params, (*val), (*dir)) ) < 0 ) |
| 259 | return ret; |
| 260 | |
| 261 | return 0; |
| 262 | } |
| 263 | |
| 264 | int _PA_LOCAL_IMPL(snd_pcm_hw_params_set_buffer_size_near) (snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val) |
| 265 | { |
| 266 | int ret; |
| 267 | |
| 268 | if(( ret = alsa_snd_pcm_hw_params_set_buffer_size(pcm, params, (*val)) ) < 0 ) |
| 269 | return ret; |
| 270 | |
| 271 | return 0; |
| 272 | } |
| 273 | |
| 274 | int _PA_LOCAL_IMPL(snd_pcm_hw_params_set_period_size_near) (snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val, int *dir) |
| 275 | { |
| 276 | int ret; |
| 277 | |
| 278 | if(( ret = alsa_snd_pcm_hw_params_set_period_size(pcm, params, (*val), (*dir)) ) < 0 ) |
| 279 | return ret; |
| 280 | |
| 281 | return 0; |
| 282 | } |
| 283 | |
| 284 | int _PA_LOCAL_IMPL(snd_pcm_hw_params_get_channels_min) (const snd_pcm_hw_params_t *params, unsigned int *val) |
| 285 | { |
| 286 | (*val) = 1; |
| 287 | return 0; |
| 288 | } |
| 289 | |
| 290 | int _PA_LOCAL_IMPL(snd_pcm_hw_params_get_channels_max) (const snd_pcm_hw_params_t *params, unsigned int *val) |
| 291 | { |
| 292 | (*val) = 2; |
| 293 | return 0; |
| 294 | } |
| 295 | |
| 296 | int _PA_LOCAL_IMPL(snd_pcm_hw_params_get_periods_min) (const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) |
| 297 | { |
| 298 | (*val) = 2; |
| 299 | return 0; |
| 300 | } |
| 301 | |
| 302 | int _PA_LOCAL_IMPL(snd_pcm_hw_params_get_periods_max) (const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) |
| 303 | { |
| 304 | (*val) = 8; |
| 305 | return 0; |
| 306 | } |
| 307 | |
| 308 | int _PA_LOCAL_IMPL(snd_pcm_hw_params_get_period_size_min) (const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir) |
| 309 | { |
| 310 | (*frames) = 64; |
| 311 | return 0; |
| 312 | } |
| 313 | |
| 314 | int _PA_LOCAL_IMPL(snd_pcm_hw_params_get_period_size_max) (const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir) |
| 315 | { |
| 316 | (*frames) = 512; |
| 317 | return 0; |
| 318 | } |
| 319 | |
| 320 | int _PA_LOCAL_IMPL(snd_pcm_hw_params_get_buffer_size_max) (const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val) |
| 321 | { |
| 322 | int ret; |
| 323 | int dir = 0; |
| 324 | snd_pcm_uframes_t pmax = 0; |
| 325 | unsigned int pcnt = 0; |
| 326 | |
| 327 | dir = 0; |
| 328 | if(( ret = _PA_LOCAL_IMPL(snd_pcm_hw_params_get_period_size_max)(params, &pmax, &dir) ) < 0 ) |
| 329 | return ret; |
| 330 | dir = 0; |
| 331 | if(( ret = _PA_LOCAL_IMPL(snd_pcm_hw_params_get_periods_max)(params, &pcnt, &dir) ) < 0 ) |
| 332 | return ret; |
| 333 | |
| 334 | (*val) = pmax * pcnt; |
| 335 | return 0; |
| 336 | } |
| 337 | |
| 338 | int _PA_LOCAL_IMPL(snd_pcm_hw_params_get_rate_min) (const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) |
| 339 | { |
| 340 | (*val) = 44100; |
| 341 | return 0; |
| 342 | } |
| 343 | |
| 344 | int _PA_LOCAL_IMPL(snd_pcm_hw_params_get_rate_max) (const snd_pcm_hw_params_t *params, unsigned int *val, int *dir) |
| 345 | { |
| 346 | (*val) = 44100; |
| 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | #endif // PA_ALSA_DYNAMIC |
| 351 | |
| 352 | /* Trying to load Alsa library dynamically if 'PA_ALSA_DYNAMIC' is defined, othervise |
| 353 | will link during compilation. |
| 354 | */ |
| 355 | static int PaAlsa_LoadLibrarycxx . . $ PaAlsa_LoadLibrary(d1b40a211a1a4e4c).() |
| 356 | { |
| 357 | #ifdef PA_ALSA_DYNAMIC |
| 358 | |
| 359 | PA_DEBUG(( "%s: loading ALSA library file - %s\n", __FUNCTION__, g_AlsaLibName )); |
| 360 | |
| 361 | dlerror(); |
| 362 | g_AlsaLib = dlopen(g_AlsaLibName, (RTLD_NOW|RTLD_GLOBAL) ); |
| 363 | if (g_AlsaLib == NULL) |
| 364 | { |
| 365 | PA_DEBUG(( "%s: failed dlopen() ALSA library file - %s, error: %s\n", __FUNCTION__, g_AlsaLibName, dlerror() )); |
| 366 | return 0; |
| 367 | } |
| 368 | |
| 369 | PA_DEBUG(( "%s: loading ALSA API\n", __FUNCTION__ )); |
| 370 | |
| 371 | #define _PA_LOAD_FUNC(x) do { \ |
| 372 | alsa_##x = dlsym( g_AlsaLib, #x ); \ |
| 373 | if( alsa_##x == NULL ) { \ |
| 374 | PA_DEBUG(( "%s: symbol [%s] not found in - %s, error: %s\n", __FUNCTION__, #x, g_AlsaLibName, dlerror() )); }\ |
| 375 | } while(0) |
| 376 | |
| 377 | #else |
| 378 | |
| 379 | #define _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(x) alsa_##x = &x |
| 380 | |
| 381 | #endif |
| 382 | |
| 383 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_open); |
| 384 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_close); |
| 385 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_nonblock); |
| 386 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_frames_to_bytes); |
| 387 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_prepare); |
| 388 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_start); |
| 389 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_resume); |
| 390 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_wait); |
| 391 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_state); |
| 392 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_avail_update); |
| 393 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_areas_silence); |
| 394 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_mmap_begin); |
| 395 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_mmap_commit); |
| 396 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_readi); |
| 397 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_readn); |
| 398 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_writei); |
| 399 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_writen); |
| 400 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_drain); |
| 401 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_recover); |
| 402 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_drop); |
| 403 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_area_copy); |
| 404 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_poll_descriptors); |
| 405 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_poll_descriptors_count); |
| 406 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_poll_descriptors_revents); |
| 407 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_format_size); |
| 408 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_link); |
| 409 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_delay); |
| 410 | |
| 411 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_sizeof); |
| 412 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_malloc); |
| 413 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_free); |
| 414 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_any); |
| 415 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_set_access); |
| 416 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_set_format); |
| 417 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_set_channels); |
| 418 | // _PA_LOAD_FUNC(snd_pcm_hw_params_set_periods_near); |
| 419 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_set_rate_near); |
| 420 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_set_rate); |
| 421 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_set_rate_resample); |
| 422 | // _PA_LOAD_FUNC(snd_pcm_hw_params_set_buffer_time_near); |
| 423 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_set_buffer_size); |
| 424 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_set_buffer_size_near); |
| 425 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_set_buffer_size_min); |
| 426 | // _PA_LOAD_FUNC(snd_pcm_hw_params_set_period_time_near); |
| 427 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_set_period_size_near); |
| 428 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_set_periods_integer); |
| 429 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_set_periods_min); |
| 430 | |
| 431 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_get_buffer_size); |
| 432 | // _PA_LOAD_FUNC(snd_pcm_hw_params_get_period_size); |
| 433 | // _PA_LOAD_FUNC(snd_pcm_hw_params_get_access); |
| 434 | // _PA_LOAD_FUNC(snd_pcm_hw_params_get_periods); |
| 435 | // _PA_LOAD_FUNC(snd_pcm_hw_params_get_rate); |
| 436 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_get_channels_min); |
| 437 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_get_channels_max); |
| 438 | |
| 439 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_test_period_size); |
| 440 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_test_format); |
| 441 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_test_access); |
| 442 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_dump); |
| 443 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params); |
| 444 | |
| 445 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_get_periods_min); |
| 446 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_get_periods_max); |
| 447 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_set_period_size); |
| 448 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_get_period_size_min); |
| 449 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_get_period_size_max); |
| 450 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_get_buffer_size_max); |
| 451 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_get_rate_min); |
| 452 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_get_rate_max); |
| 453 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_hw_params_get_rate_numden); |
| 454 | |
| 455 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_sw_params_sizeof); |
| 456 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_sw_params_malloc); |
| 457 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_sw_params_current); |
| 458 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_sw_params_set_avail_min); |
| 459 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_sw_params); |
| 460 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_sw_params_free); |
| 461 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_sw_params_set_start_threshold); |
| 462 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_sw_params_set_stop_threshold); |
| 463 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_sw_params_get_boundary); |
| 464 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_sw_params_set_silence_threshold); |
| 465 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_sw_params_set_silence_size); |
| 466 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_sw_params_set_xfer_align); |
| 467 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_sw_params_set_tstamp_mode); |
| 468 | |
| 469 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_info); |
| 470 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_info_sizeof); |
| 471 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_info_malloc); |
| 472 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_info_free); |
| 473 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_info_set_device); |
| 474 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_info_set_subdevice); |
| 475 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_info_set_stream); |
| 476 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_info_get_name); |
| 477 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_info_get_card); |
| 478 | |
| 479 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_ctl_pcm_next_device); |
| 480 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_ctl_pcm_info); |
| 481 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_ctl_open); |
| 482 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_ctl_close); |
| 483 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_ctl_card_info_malloc); |
| 484 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_ctl_card_info_free); |
| 485 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_ctl_card_info); |
| 486 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_ctl_card_info_sizeof); |
| 487 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_ctl_card_info_get_name); |
| 488 | |
| 489 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_config); |
| 490 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_config_update); |
| 491 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_config_search); |
| 492 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_config_iterator_entry); |
| 493 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_config_iterator_first); |
| 494 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_config_iterator_end); |
| 495 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_config_iterator_next); |
| 496 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_config_get_string); |
| 497 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_config_get_id); |
| 498 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_config_update_free_global); |
| 499 | |
| 500 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_status); |
| 501 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_status_sizeof); |
| 502 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_status_get_tstamp); |
| 503 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_status_get_state); |
| 504 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_status_get_trigger_tstamp); |
| 505 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_pcm_status_get_delay); |
| 506 | |
| 507 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_card_next); |
| 508 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_asoundlib_version); |
| 509 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_strerror); |
| 510 | _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`!(snd_output_stdio_attach); |
| 511 | #undef _PA_LOAD_FUNCcxx . . $ `external/portaudio/pa_linux_alsa.c:379:13`! |
| 512 | |
| 513 | #ifdef PA_ALSA_DYNAMIC |
| 514 | PA_DEBUG(( "%s: loaded ALSA API - ok\n", __FUNCTION__ )); |
| 515 | |
| 516 | #define _PA_VALIDATE_LOAD_REPLACEMENT(x)\ |
| 517 | do {\ |
| 518 | if( alsa_##x == NULL )\ |
| 519 | {\ |
| 520 | alsa_##x = &_PA_LOCAL_IMPL(x);\ |
| 521 | PA_DEBUG(( "%s: replacing [%s] with local implementation\n", __FUNCTION__, #x ));\ |
| 522 | }\ |
| 523 | } while (0) |
| 524 | |
| 525 | _PA_VALIDATE_LOAD_REPLACEMENT(snd_pcm_hw_params_set_rate_near); |
| 526 | _PA_VALIDATE_LOAD_REPLACEMENT(snd_pcm_hw_params_set_buffer_size_near); |
| 527 | _PA_VALIDATE_LOAD_REPLACEMENT(snd_pcm_hw_params_set_period_size_near); |
| 528 | _PA_VALIDATE_LOAD_REPLACEMENT(snd_pcm_hw_params_get_channels_min); |
| 529 | _PA_VALIDATE_LOAD_REPLACEMENT(snd_pcm_hw_params_get_channels_max); |
| 530 | _PA_VALIDATE_LOAD_REPLACEMENT(snd_pcm_hw_params_get_periods_min); |
| 531 | _PA_VALIDATE_LOAD_REPLACEMENT(snd_pcm_hw_params_get_periods_max); |
| 532 | _PA_VALIDATE_LOAD_REPLACEMENT(snd_pcm_hw_params_get_period_size_min); |
| 533 | _PA_VALIDATE_LOAD_REPLACEMENT(snd_pcm_hw_params_get_period_size_max); |
| 534 | _PA_VALIDATE_LOAD_REPLACEMENT(snd_pcm_hw_params_get_buffer_size_max); |
| 535 | _PA_VALIDATE_LOAD_REPLACEMENT(snd_pcm_hw_params_get_rate_min); |
| 536 | _PA_VALIDATE_LOAD_REPLACEMENT(snd_pcm_hw_params_get_rate_max); |
| 537 | |
| 538 | #undef _PA_LOCAL_IMPL |
| 539 | #undef _PA_VALIDATE_LOAD_REPLACEMENT |
| 540 | |
| 541 | #endif // PA_ALSA_DYNAMIC |
| 542 | |
| 543 | return 1; |
| 544 | } |
| 545 | |
| 546 | void PaAlsa_SetLibraryPathNamecxx . . $ PaAlsa_SetLibraryPathName(85c52e162fed56f9).( const char *pathName ) |
| 547 | { |
| 548 | #ifdef PA_ALSA_DYNAMIC |
| 549 | g_AlsaLibName = pathName; |
| 550 | #else |
| 551 | (void)pathName; |
| 552 | #endif |
| 553 | } |
| 554 | |
| 555 | /* Close handle to Alsa library. */ |
| 556 | static void PaAlsa_CloseLibrarycxx . . $ PaAlsa_CloseLibrary(d878ad36e69247c7).() |
| 557 | { |
| 558 | #ifdef PA_ALSA_DYNAMIC |
| 559 | dlclose(g_AlsaLib); |
| 560 | g_AlsaLib = NULL; |
| 561 | #endif |
| 562 | } |
| 563 | |
| 564 | /* Check return value of ALSA function, and map it to PaError */ |
| 565 | #define ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!(expr, code) \ |
| 566 | do { \ |
| 567 | int __pa_unsure_error_id;\ |
| 568 | if( UNLIKELYcxx . . $ `external/portaudio/pa_unix_util.h:62:9`!( (__pa_unsure_error_id = (expr)) < 0 ) ) \ |
| 569 | { \ |
| 570 | /* PaUtil_SetLastHostErrorInfo should only be used in the main thread */ \ |
| 571 | if( (code) == paUnanticipatedHostError && pthread_equal( pthread_self(), paUnixMainThread) ) \ |
| 572 | { \ |
| 573 | PaUtil_SetLastHostErrorInfo( paALSA, __pa_unsure_error_id, alsa_snd_strerror( __pa_unsure_error_id ) ); \ |
| 574 | } \ |
| 575 | PaUtil_DebugPrint( "Expression '" #expr "' failed in '" __FILE__ "', line: " STRINGIZEcxx . . $ `external/portaudio/pa_unix_util.h:68:9`!( __LINE__ ) "\n" ); \ |
| 576 | if( (code) == paUnanticipatedHostError ) \ |
| 577 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "Host error description: %s\n", alsa_snd_strerror( __pa_unsure_error_id ) )); \ |
| 578 | result = (code); \ |
| 579 | goto error; \ |
| 580 | } \ |
| 581 | } while (0) |
| 582 | |
| 583 | #define ASSERT_CALL_cxx . . $ `external/portaudio/pa_linux_alsa.c:583:9`!(expr, success) \ |
| 584 | do {\ |
| 585 | int __pa_assert_error_id;\ |
| 586 | __pa_assert_error_id = (expr);\ |
| 587 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( success == __pa_assert_error_id );\ |
| 588 | } while (0) |
| 589 | |
| 590 | static int numPeriods_cxx . . $ numPeriods_. = 4; |
| 591 | static int busyRetries_cxx . . $ busyRetries_. = 100; |
| 592 | |
| 593 | int PaAlsa_SetNumPeriodscxx . . $ PaAlsa_SetNumPeriods(7864480464b09eea).( int numPeriods ) |
| 594 | { |
| 595 | numPeriods_cxx . . $ numPeriods_. = numPeriods; |
| 596 | return paNoErrorcxx . . $ paNoError.; |
| 597 | } |
| 598 | |
| 599 | typedef enumcxx . . $ $anonymous_type_c42756aa1fb35d76_0# |
| 600 | { |
| 601 | StreamDirection_Incxx . . $ StreamDirection_In., |
| 602 | StreamDirection_Outcxx . . $ StreamDirection_Out. |
| 603 | } StreamDirectioncxx . . $ StreamDirection#; |
| 604 | |
| 605 | typedef structcxx . . $ $anonymous_type_c42756aa1fb35d76_1# |
| 606 | { |
| 607 | PaSampleFormatcxx . . $ PaSampleFormat# hostSampleFormatcxx . . $ $anonymous_type_c42756aa1fb35d76_1#hostSampleFormat.; |
| 608 | int numUserChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numUserChannels., numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels.; |
| 609 | int userInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#userInterleaved., hostInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#hostInterleaved.; |
| 610 | int canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap.; |
| 611 | void *nonMmapBuffercxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBuffer.; |
| 612 | unsigned int nonMmapBufferSizecxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBufferSize.; |
| 613 | PaDeviceIndexcxx . . $ PaDeviceIndex# devicecxx . . $ $anonymous_type_c42756aa1fb35d76_1#device.; /* Keep the device index */ |
| 614 | int deviceIsPlugcxx . . $ $anonymous_type_c42756aa1fb35d76_1#deviceIsPlug.; /* Distinguish plug types from direct 'hw:' devices */ |
| 615 | int useReventFixcxx . . $ $anonymous_type_c42756aa1fb35d76_1#useReventFix.; /* Alsa older than 1.0.16, plug devices need a fix */ |
| 616 | |
| 617 | snd_pcm_tcxx . . $ snd_pcm_t# *pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm.; |
| 618 | snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t# framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod., alsaBufferSizecxx . . $ $anonymous_type_c42756aa1fb35d76_1#alsaBufferSize.; |
| 619 | snd_pcm_format_tcxx . . $ snd_pcm_format_t# nativeFormatcxx . . $ $anonymous_type_c42756aa1fb35d76_1#nativeFormat.; |
| 620 | unsigned int nfdscxx . . $ $anonymous_type_c42756aa1fb35d76_1#nfds.; |
| 621 | int readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready.; /* Marked ready from poll */ |
| 622 | void **userBufferscxx . . $ $anonymous_type_c42756aa1fb35d76_1#userBuffers.; |
| 623 | snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t# offsetcxx . . $ $anonymous_type_c42756aa1fb35d76_1#offset.; |
| 624 | StreamDirectioncxx . . $ StreamDirection# streamDircxx . . $ $anonymous_type_c42756aa1fb35d76_1#streamDir.; |
| 625 | |
| 626 | snd_pcm_channel_area_tcxx . . $ snd_pcm_channel_area_t# *channelAreascxx . . $ $anonymous_type_c42756aa1fb35d76_1#channelAreas.; /* Needed for channel adaption */ |
| 627 | } PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent#; |
| 628 | |
| 629 | /* Implementation specific stream structure */ |
| 630 | typedef struct PaAlsaStreamcxx . . $ PaAlsaStream# |
| 631 | { |
| 632 | PaUtilStreamRepresentationcxx . . $ PaUtilStreamRepresentation# streamRepresentationcxx . . $ PaAlsaStream#streamRepresentation.; |
| 633 | PaUtilCpuLoadMeasurercxx . . $ PaUtilCpuLoadMeasurer# cpuLoadMeasurercxx . . $ PaAlsaStream#cpuLoadMeasurer.; |
| 634 | PaUtilBufferProcessorcxx . . $ PaUtilBufferProcessor# bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor.; |
| 635 | PaUnixThreadcxx . . $ PaUnixThread# threadcxx . . $ PaAlsaStream#thread.; |
| 636 | |
| 637 | unsigned long framesPerUserBuffercxx . . $ PaAlsaStream#framesPerUserBuffer., maxFramesPerHostBuffercxx . . $ PaAlsaStream#maxFramesPerHostBuffer.; |
| 638 | |
| 639 | int primeBufferscxx . . $ PaAlsaStream#primeBuffers.; |
| 640 | int callbackModecxx . . $ PaAlsaStream#callbackMode.; /* bool: are we running in callback mode? */ |
| 641 | int pcmsSyncedcxx . . $ PaAlsaStream#pcmsSynced.; /* Have we successfully synced pcms */ |
| 642 | int rtSchedcxx . . $ PaAlsaStream#rtSched.; |
| 643 | |
| 644 | /* the callback thread uses these to poll the sound device(s), waiting |
| 645 | * for data to be ready/available */ |
| 646 | struct pollfdcxx . . $ pollfd#* pfdscxx . . $ PaAlsaStream#pfds.; |
| 647 | int pollTimeoutcxx . . $ PaAlsaStream#pollTimeout.; |
| 648 | |
| 649 | /* Used in communication between threads */ |
| 650 | volatile sig_atomic_tcxx . . $ sig_atomic_t# callback_finishedcxx . . $ PaAlsaStream#callback_finished.; /* bool: are we in the "callback finished" state? */ |
| 651 | volatile sig_atomic_tcxx . . $ sig_atomic_t# callbackAbortcxx . . $ PaAlsaStream#callbackAbort.; /* Drop frames? */ |
| 652 | volatile sig_atomic_tcxx . . $ sig_atomic_t# isActivecxx . . $ PaAlsaStream#isActive.; /* Is stream in active state? (Between StartStream and StopStream || !paContinue) */ |
| 653 | PaUnixMutexcxx . . $ PaUnixMutex# stateMtxcxx . . $ PaAlsaStream#stateMtx.; /* Used to synchronize access to stream state */ |
| 654 | |
| 655 | int neverDropInputcxx . . $ PaAlsaStream#neverDropInput.; |
| 656 | |
| 657 | PaTimecxx . . $ PaTime# underruncxx . . $ PaAlsaStream#underrun.; |
| 658 | PaTimecxx . . $ PaTime# overruncxx . . $ PaAlsaStream#overrun.; |
| 659 | |
| 660 | PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent# capturecxx . . $ PaAlsaStream#capture., playbackcxx . . $ PaAlsaStream#playback.; |
| 661 | } |
| 662 | PaAlsaStreamcxx . . $ PaAlsaStream#; |
| 663 | |
| 664 | /* PaAlsaHostApiRepresentation - host api datastructure specific to this implementation */ |
| 665 | |
| 666 | typedef struct PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation# |
| 667 | { |
| 668 | PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# baseHostApiRepcxx . . $ PaAlsaHostApiRepresentation#baseHostApiRep.; |
| 669 | PaUtilStreamInterfacecxx . . $ PaUtilStreamInterface# callbackStreamInterfacecxx . . $ PaAlsaHostApiRepresentation#callbackStreamInterface.; |
| 670 | PaUtilStreamInterfacecxx . . $ PaUtilStreamInterface# blockingStreamInterfacecxx . . $ PaAlsaHostApiRepresentation#blockingStreamInterface.; |
| 671 | |
| 672 | PaUtilAllocationGroupcxx . . $ PaUtilAllocationGroup# *allocationscxx . . $ PaAlsaHostApiRepresentation#allocations.; |
| 673 | |
| 674 | PaHostApiIndexcxx . . $ PaHostApiIndex# hostApiIndexcxx . . $ PaAlsaHostApiRepresentation#hostApiIndex.; |
| 675 | PaUint32cxx . . $ PaUint32# alsaLibVersioncxx . . $ PaAlsaHostApiRepresentation#alsaLibVersion.; /* Retrieved from the library at run-time */ |
| 676 | } |
| 677 | PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation#; |
| 678 | |
| 679 | typedef struct PaAlsaDeviceInfocxx . . $ PaAlsaDeviceInfo# |
| 680 | { |
| 681 | PaDeviceInfocxx . . $ PaDeviceInfo# baseDeviceInfocxx . . $ PaAlsaDeviceInfo#baseDeviceInfo.; |
| 682 | char *alsaNamecxx . . $ PaAlsaDeviceInfo#alsaName.; |
| 683 | int isPlugcxx . . $ PaAlsaDeviceInfo#isPlug.; |
| 684 | int minInputChannelscxx . . $ PaAlsaDeviceInfo#minInputChannels.; |
| 685 | int minOutputChannelscxx . . $ PaAlsaDeviceInfo#minOutputChannels.; |
| 686 | } |
| 687 | PaAlsaDeviceInfocxx . . $ PaAlsaDeviceInfo#; |
| 688 | |
| 689 | /* prototypes for functions declared in this file */ |
| 690 | |
| 691 | static void Terminatecxx . . $ Terminate(79277cf7c6a25a16).( struct PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi ); |
| 692 | static PaErrorcxx . . $ PaError# IsFormatSupportedcxx . . $ IsFormatSupported(dbae6b543f13ee5).( struct PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi, |
| 693 | const PaStreamParameterscxx . . $ PaStreamParameters# *inputParameters, |
| 694 | const PaStreamParameterscxx . . $ PaStreamParameters# *outputParameters, |
| 695 | double sampleRate ); |
| 696 | static PaErrorcxx . . $ PaError# OpenStreamcxx . . $ OpenStream(dd932161c061c960).( struct PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi, |
| 697 | PaStreamcxx . . $ PaStream#** s, |
| 698 | const PaStreamParameterscxx . . $ PaStreamParameters# *inputParameters, |
| 699 | const PaStreamParameterscxx . . $ PaStreamParameters# *outputParameters, |
| 700 | double sampleRate, |
| 701 | unsigned long framesPerBuffer, |
| 702 | PaStreamFlagscxx . . $ PaStreamFlags# streamFlags, |
| 703 | PaStreamCallbackcxx . . $ PaStreamCallback# *callback, |
| 704 | void *userData ); |
| 705 | static PaErrorcxx . . $ PaError# CloseStreamcxx . . $ CloseStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream#* stream ); |
| 706 | static PaErrorcxx . . $ PaError# StartStreamcxx . . $ StartStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *stream ); |
| 707 | static PaErrorcxx . . $ PaError# StopStreamcxx . . $ StopStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *stream ); |
| 708 | static PaErrorcxx . . $ PaError# AbortStreamcxx . . $ AbortStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *stream ); |
| 709 | static PaErrorcxx . . $ PaError# IsStreamStoppedcxx . . $ IsStreamStopped(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *s ); |
| 710 | static PaErrorcxx . . $ PaError# IsStreamActivecxx . . $ IsStreamActive(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *stream ); |
| 711 | static PaTimecxx . . $ PaTime# GetStreamTimecxx . . $ GetStreamTime(a405b17f82753acc).( PaStreamcxx . . $ PaStream# *stream ); |
| 712 | static double GetStreamCpuLoadcxx . . $ GetStreamCpuLoad(a405b17f82753acc).( PaStreamcxx . . $ PaStream#* stream ); |
| 713 | static PaErrorcxx . . $ PaError# BuildDeviceListcxx . . $ BuildDeviceList(2668720138906f3c).( PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation# *hostApi ); |
| 714 | static int SetApproximateSampleRatecxx . . $ SetApproximateSampleRate(95b810ef3c6fd091).( snd_pcm_tcxx . . $ snd_pcm_t# *pcm, snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t# *hwParams, double sampleRate ); |
| 715 | static int GetExactSampleRatecxx . . $ GetExactSampleRate(cb757e2e28b05fce).( snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t# *hwParams, double *sampleRate ); |
| 716 | static PaUint32cxx . . $ PaUint32# PaAlsaVersionNumcxx . . $ PaAlsaVersionNum(db52760e79bf9054).(void); |
| 717 | |
| 718 | /* Callback prototypes */ |
| 719 | static void *CallbackThreadFunccxx . . $ CallbackThreadFunc(9f162e79bfc6c74).( void *userData ); |
| 720 | |
| 721 | /* Blocking prototypes */ |
| 722 | static signed long GetStreamReadAvailablecxx . . $ GetStreamReadAvailable(72c1818a5177f981).( PaStreamcxx . . $ PaStream#* s ); |
| 723 | static signed long GetStreamWriteAvailablecxx . . $ GetStreamWriteAvailable(72c1818a5177f981).( PaStreamcxx . . $ PaStream#* s ); |
| 724 | static PaErrorcxx . . $ PaError# ReadStreamcxx . . $ ReadStream(c5040b39c98d43dd).( PaStreamcxx . . $ PaStream#* stream, void *buffer, unsigned long frames ); |
| 725 | static PaErrorcxx . . $ PaError# WriteStreamcxx . . $ WriteStream(72e086fd9bc8337a).( PaStreamcxx . . $ PaStream#* stream, const void *buffer, unsigned long frames ); |
| 726 | |
| 727 | |
| 728 | static const PaAlsaDeviceInfocxx . . $ PaAlsaDeviceInfo# *GetDeviceInfocxx . . $ GetDeviceInfo(db6649f25e165c42).( const PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi, int device ) |
| 729 | { |
| 730 | return (const PaAlsaDeviceInfocxx . . $ PaAlsaDeviceInfo# *)hostApi->deviceInfoscxx . . $ PaUtilHostApiRepresentation#deviceInfos.[device]; |
| 731 | } |
| 732 | |
| 733 | /** Uncommented because AlsaErrorHandler is unused for anything good yet. If AlsaErrorHandler is |
| 734 | to be used, do not forget to register this callback in PaAlsa_Initialize, and unregister in Terminate. |
| 735 | */ |
| 736 | /*static void AlsaErrorHandler(const char *file, int line, const char *function, int err, const char *fmt, ...) |
| 737 | { |
| 738 | }*/ |
| 739 | |
| 740 | PaErrorcxx . . $ PaError# PaAlsa_Initializecxx . . $ PaAlsa_Initialize(73d6fc5159ec0bfd).( PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# **hostApi, PaHostApiIndexcxx . . $ PaHostApiIndex# hostApiIndex ) |
| 741 | { |
| 742 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 743 | PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation# *alsaHostApi = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 744 | |
| 745 | /* Try loading Alsa library. */ |
| 746 | if (!PaAlsa_LoadLibrarycxx . . $ PaAlsa_LoadLibrary(d1b40a211a1a4e4c).()) |
| 747 | return paHostApiNotFoundcxx . . $ paHostApiNotFound.; |
| 748 | |
| 749 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( alsaHostApi = (PaAlsaHostApiRepresentation*) PaUtil_AllocateMemory( |
| 750 | sizeof(PaAlsaHostApiRepresentation) ), paInsufficientMemory ); |
| 751 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( alsaHostApi->allocations = PaUtil_CreateAllocationGroup(), paInsufficientMemory ); |
| 752 | alsaHostApi->hostApiIndexcxx . . $ PaAlsaHostApiRepresentation#hostApiIndex. = hostApiIndex; |
| 753 | alsaHostApi->alsaLibVersioncxx . . $ PaAlsaHostApiRepresentation#alsaLibVersion. = PaAlsaVersionNumcxx . . $ PaAlsaVersionNum(db52760e79bf9054).(); |
| 754 | |
| 755 | *hostApi = (PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation#*)alsaHostApi; |
| 756 | (*hostApi)->infocxx . . $ PaUtilHostApiRepresentation#info..structVersioncxx . . $ PaHostApiInfo#structVersion. = 1; |
| 757 | (*hostApi)->infocxx . . $ PaUtilHostApiRepresentation#info..typecxx . . $ PaHostApiInfo#type. = paALSAcxx . . $ paALSA.; |
| 758 | (*hostApi)->infocxx . . $ PaUtilHostApiRepresentation#info..namecxx . . $ PaHostApiInfo#name. = "ALSA"; |
| 759 | |
| 760 | (*hostApi)->Terminatecxx . . $ PaUtilHostApiRepresentation#Terminate. = Terminatecxx . . $ Terminate(79277cf7c6a25a16).; |
| 761 | (*hostApi)->OpenStreamcxx . . $ PaUtilHostApiRepresentation#OpenStream. = OpenStreamcxx . . $ OpenStream(dd932161c061c960).; |
| 762 | (*hostApi)->IsFormatSupportedcxx . . $ PaUtilHostApiRepresentation#IsFormatSupported. = IsFormatSupportedcxx . . $ IsFormatSupported(dbae6b543f13ee5).; |
| 763 | |
| 764 | /** If AlsaErrorHandler is to be used, do not forget to unregister callback pointer in |
| 765 | Terminate function. |
| 766 | */ |
| 767 | /*ENSURE_( snd_lib_error_set_handler(AlsaErrorHandler), paUnanticipatedHostError );*/ |
| 768 | |
| 769 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( BuildDeviceList( alsaHostApi ) ); |
| 770 | |
| 771 | PaUtil_InitializeStreamInterfacecxx . . $ PaUtil_InitializeStreamInterface(4b35ac35495e68b2).( &alsaHostApi->callbackStreamInterfacecxx . . $ PaAlsaHostApiRepresentation#callbackStreamInterface., |
| 772 | CloseStreamcxx . . $ CloseStream(dedf1e9b1c614a07)., StartStreamcxx . . $ StartStream(dedf1e9b1c614a07)., |
| 773 | StopStreamcxx . . $ StopStream(dedf1e9b1c614a07)., AbortStreamcxx . . $ AbortStream(dedf1e9b1c614a07)., |
| 774 | IsStreamStoppedcxx . . $ IsStreamStopped(dedf1e9b1c614a07)., IsStreamActivecxx . . $ IsStreamActive(dedf1e9b1c614a07)., |
| 775 | GetStreamTimecxx . . $ GetStreamTime(a405b17f82753acc)., GetStreamCpuLoadcxx . . $ GetStreamCpuLoad(a405b17f82753acc)., |
| 776 | PaUtil_DummyReadcxx . . $ PaUtil_DummyRead(c5040b39c98d43dd)., PaUtil_DummyWritecxx . . $ PaUtil_DummyWrite(72e086fd9bc8337a)., |
| 777 | PaUtil_DummyGetReadAvailablecxx . . $ PaUtil_DummyGetReadAvailable(72c1818a5177f981)., |
| 778 | PaUtil_DummyGetWriteAvailablecxx . . $ PaUtil_DummyGetWriteAvailable(72c1818a5177f981). ); |
| 779 | |
| 780 | PaUtil_InitializeStreamInterfacecxx . . $ PaUtil_InitializeStreamInterface(4b35ac35495e68b2).( &alsaHostApi->blockingStreamInterfacecxx . . $ PaAlsaHostApiRepresentation#blockingStreamInterface., |
| 781 | CloseStreamcxx . . $ CloseStream(dedf1e9b1c614a07)., StartStreamcxx . . $ StartStream(dedf1e9b1c614a07)., |
| 782 | StopStreamcxx . . $ StopStream(dedf1e9b1c614a07)., AbortStreamcxx . . $ AbortStream(dedf1e9b1c614a07)., |
| 783 | IsStreamStoppedcxx . . $ IsStreamStopped(dedf1e9b1c614a07)., IsStreamActivecxx . . $ IsStreamActive(dedf1e9b1c614a07)., |
| 784 | GetStreamTimecxx . . $ GetStreamTime(a405b17f82753acc)., PaUtil_DummyGetCpuLoadcxx . . $ PaUtil_DummyGetCpuLoad(a405b17f82753acc)., |
| 785 | ReadStreamcxx . . $ ReadStream(c5040b39c98d43dd)., WriteStreamcxx . . $ WriteStream(72e086fd9bc8337a)., |
| 786 | GetStreamReadAvailablecxx . . $ GetStreamReadAvailable(72c1818a5177f981)., |
| 787 | GetStreamWriteAvailablecxx . . $ GetStreamWriteAvailable(72c1818a5177f981). ); |
| 788 | |
| 789 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaUnixThreading_Initialize() ); |
| 790 | |
| 791 | return result; |
| 792 | |
| 793 | error: |
| 794 | if( alsaHostApi ) |
| 795 | { |
| 796 | if( alsaHostApi->allocationscxx . . $ PaAlsaHostApiRepresentation#allocations. ) |
| 797 | { |
| 798 | PaUtil_FreeAllAllocationscxx . . $ PaUtil_FreeAllAllocations(312b3fcc9bc2c5fe).( alsaHostApi->allocationscxx . . $ PaAlsaHostApiRepresentation#allocations. ); |
| 799 | PaUtil_DestroyAllocationGroupcxx . . $ PaUtil_DestroyAllocationGroup(312b3fcc9bc2c5fe).( alsaHostApi->allocationscxx . . $ PaAlsaHostApiRepresentation#allocations. ); |
| 800 | } |
| 801 | |
| 802 | PaUtil_FreeMemorycxx . . $ PaUtil_FreeMemory(5d22bdacc48458e8).( alsaHostApi ); |
| 803 | } |
| 804 | |
| 805 | return result; |
| 806 | } |
| 807 | |
| 808 | static void Terminatecxx . . $ Terminate(79277cf7c6a25a16).( struct PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi ) |
| 809 | { |
| 810 | PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation# *alsaHostApi = (PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation#*)hostApi; |
| 811 | |
| 812 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( hostApi ); |
| 813 | |
| 814 | /** See AlsaErrorHandler and PaAlsa_Initialize for details. |
| 815 | */ |
| 816 | /*snd_lib_error_set_handler(NULL);*/ |
| 817 | |
| 818 | if( alsaHostApi->allocationscxx . . $ PaAlsaHostApiRepresentation#allocations. ) |
| 819 | { |
| 820 | PaUtil_FreeAllAllocationscxx . . $ PaUtil_FreeAllAllocations(312b3fcc9bc2c5fe).( alsaHostApi->allocationscxx . . $ PaAlsaHostApiRepresentation#allocations. ); |
| 821 | PaUtil_DestroyAllocationGroupcxx . . $ PaUtil_DestroyAllocationGroup(312b3fcc9bc2c5fe).( alsaHostApi->allocationscxx . . $ PaAlsaHostApiRepresentation#allocations. ); |
| 822 | } |
| 823 | |
| 824 | PaUtil_FreeMemorycxx . . $ PaUtil_FreeMemory(5d22bdacc48458e8).( alsaHostApi ); |
| 825 | alsa_snd_config_update_free_globalcxx . . $ alsa_snd_config_update_free_global.(); |
| 826 | |
| 827 | /* Close Alsa library. */ |
| 828 | PaAlsa_CloseLibrarycxx . . $ PaAlsa_CloseLibrary(d878ad36e69247c7).(); |
| 829 | } |
| 830 | |
| 831 | /** Determine max channels and default latencies. |
| 832 | * |
| 833 | * This function provides functionality to grope an opened (might be opened for capture or playback) pcm device for |
| 834 | * traits like max channels, suitable default latencies and default sample rate. Upon error, max channels is set to zero, |
| 835 | * and a suitable result returned. The device is closed before returning. |
| 836 | */ |
| 837 | static PaErrorcxx . . $ PaError# GropeDevicecxx . . $ GropeDevice(f6333026cde00488).( snd_pcm_tcxx . . $ snd_pcm_t#* pcm, int isPlug, StreamDirectioncxx . . $ StreamDirection# mode, int openBlocking, |
| 838 | PaAlsaDeviceInfocxx . . $ PaAlsaDeviceInfo#* devInfo ) |
| 839 | { |
| 840 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 841 | snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t# *hwParams; |
| 842 | snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t# alsaBufferFrames, alsaPeriodFrames; |
| 843 | unsigned int minChans, maxChans; |
| 844 | int* minChannels, * maxChannels; |
| 845 | double * defaultLowLatency, * defaultHighLatency, * defaultSampleRate = |
| 846 | &devInfo->baseDeviceInfocxx . . $ PaAlsaDeviceInfo#baseDeviceInfo..defaultSampleRatecxx . . $ PaDeviceInfo#defaultSampleRate.; |
| 847 | double defaultSr = *defaultSampleRate; |
| 848 | |
| 849 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( pcm ); |
| 850 | |
| 851 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: collecting info ..\n", __FUNCTION__ )); |
| 852 | |
| 853 | if( StreamDirection_Incxx . . $ StreamDirection_In. == mode ) |
| 854 | { |
| 855 | minChannels = &devInfo->minInputChannelscxx . . $ PaAlsaDeviceInfo#minInputChannels.; |
| 856 | maxChannels = &devInfo->baseDeviceInfocxx . . $ PaAlsaDeviceInfo#baseDeviceInfo..maxInputChannelscxx . . $ PaDeviceInfo#maxInputChannels.; |
| 857 | defaultLowLatency = &devInfo->baseDeviceInfocxx . . $ PaAlsaDeviceInfo#baseDeviceInfo..defaultLowInputLatencycxx . . $ PaDeviceInfo#defaultLowInputLatency.; |
| 858 | defaultHighLatency = &devInfo->baseDeviceInfocxx . . $ PaAlsaDeviceInfo#baseDeviceInfo..defaultHighInputLatencycxx . . $ PaDeviceInfo#defaultHighInputLatency.; |
| 859 | } |
| 860 | else |
| 861 | { |
| 862 | minChannels = &devInfo->minOutputChannelscxx . . $ PaAlsaDeviceInfo#minOutputChannels.; |
| 863 | maxChannels = &devInfo->baseDeviceInfocxx . . $ PaAlsaDeviceInfo#baseDeviceInfo..maxOutputChannelscxx . . $ PaDeviceInfo#maxOutputChannels.; |
| 864 | defaultLowLatency = &devInfo->baseDeviceInfocxx . . $ PaAlsaDeviceInfo#baseDeviceInfo..defaultLowOutputLatencycxx . . $ PaDeviceInfo#defaultLowOutputLatency.; |
| 865 | defaultHighLatency = &devInfo->baseDeviceInfocxx . . $ PaAlsaDeviceInfo#baseDeviceInfo..defaultHighOutputLatencycxx . . $ PaDeviceInfo#defaultHighOutputLatency.; |
| 866 | } |
| 867 | |
| 868 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_nonblock( pcm, 0 ), paUnanticipatedHostError ); |
| 869 | |
| 870 | alsa_snd_pcm_hw_params_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:171:9`!( &hwParams ); |
| 871 | alsa_snd_pcm_hw_params_anycxx . . $ alsa_snd_pcm_hw_params_any.( pcm, hwParams ); |
| 872 | |
| 873 | if( defaultSr >= 0 ) |
| 874 | { |
| 875 | /* Could be that the device opened in one mode supports samplerates that the other mode wont have, |
| 876 | * so try again .. */ |
| 877 | if( SetApproximateSampleRatecxx . . $ SetApproximateSampleRate(95b810ef3c6fd091).( pcm, hwParams, defaultSr ) < 0 ) |
| 878 | { |
| 879 | defaultSr = -1.; |
| 880 | alsa_snd_pcm_hw_params_anycxx . . $ alsa_snd_pcm_hw_params_any.( pcm, hwParams ); /* Clear any params (rate) that might have been set */ |
| 881 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Original default samplerate failed, trying again ..\n", __FUNCTION__ )); |
| 882 | } |
| 883 | } |
| 884 | |
| 885 | if( defaultSr < 0. ) /* Default sample rate not set */ |
| 886 | { |
| 887 | unsigned int sampleRate = 44100; /* Will contain approximate rate returned by alsa-lib */ |
| 888 | |
| 889 | /* Don't allow rate resampling when probing for the default rate (but ignore if this call fails) */ |
| 890 | alsa_snd_pcm_hw_params_set_rate_resamplecxx . . $ alsa_snd_pcm_hw_params_set_rate_resample.( pcm, hwParams, 0 ); |
| 891 | if( alsa_snd_pcm_hw_params_set_rate_nearcxx . . $ alsa_snd_pcm_hw_params_set_rate_near.( pcm, hwParams, &sampleRate, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) < 0 ) |
| 892 | { |
| 893 | result = paUnanticipatedHostErrorcxx . . $ paUnanticipatedHostError.; |
| 894 | goto error; |
| 895 | } |
| 896 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( GetExactSampleRate( hwParams, &defaultSr ), paUnanticipatedHostError ); |
| 897 | } |
| 898 | |
| 899 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_channels_min( hwParams, &minChans ), paUnanticipatedHostError ); |
| 900 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_channels_max( hwParams, &maxChans ), paUnanticipatedHostError ); |
| 901 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( maxChans <= INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`! ); |
| 902 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( maxChans > 0 ); /* Weird linking issue could cause wrong version of ALSA symbols to be called, |
| 903 | resulting in zeroed values */ |
| 904 | |
| 905 | /* XXX: Limit to sensible number (ALSA plugins accept a crazy amount of channels)? */ |
| 906 | if( isPlug && maxChans > 128 ) |
| 907 | { |
| 908 | maxChans = 128; |
| 909 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Limiting number of plugin channels to %u\n", __FUNCTION__, maxChans )); |
| 910 | } |
| 911 | |
| 912 | /* TWEAKME: |
| 913 | * Giving values for default min and max latency is not straightforward. |
| 914 | * * for low latency, we want to give the lowest value that will work reliably. |
| 915 | * This varies based on the sound card, kernel, CPU, etc. Better to give |
| 916 | * sub-optimal latency than to give a number too low and cause dropouts. |
| 917 | * * for high latency we want to give a large enough value that dropouts are basically impossible. |
| 918 | * This doesn't really require as much tweaking, since providing too large a number will |
| 919 | * just cause us to select the nearest setting that will work at stream config time. |
| 920 | */ |
| 921 | /* Try low latency values, (sometimes the buffer & period that result are larger) */ |
| 922 | alsaBufferFrames = 512; |
| 923 | alsaPeriodFrames = 128; |
| 924 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_buffer_size_near( pcm, hwParams, &alsaBufferFrames ), paUnanticipatedHostError ); |
| 925 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ), paUnanticipatedHostError ); |
| 926 | *defaultLowLatency = (double) (alsaBufferFrames - alsaPeriodFrames) / defaultSr; |
| 927 | |
| 928 | /* Base the high latency case on values four times larger */ |
| 929 | alsaBufferFrames = 2048; |
| 930 | alsaPeriodFrames = 512; |
| 931 | /* Have to reset hwParams, to set new buffer size; need to also set sample rate again */ |
| 932 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_any( pcm, hwParams ), paUnanticipatedHostError ); |
| 933 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( SetApproximateSampleRate( pcm, hwParams, defaultSr ), paUnanticipatedHostError ); |
| 934 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_buffer_size_near( pcm, hwParams, &alsaBufferFrames ), paUnanticipatedHostError ); |
| 935 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_period_size_near( pcm, hwParams, &alsaPeriodFrames, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ), paUnanticipatedHostError ); |
| 936 | *defaultHighLatency = (double) (alsaBufferFrames - alsaPeriodFrames) / defaultSr; |
| 937 | |
| 938 | *minChannels = (int)minChans; |
| 939 | *maxChannels = (int)maxChans; |
| 940 | *defaultSampleRate = defaultSr; |
| 941 | |
| 942 | end: |
| 943 | alsa_snd_pcm_closecxx . . $ alsa_snd_pcm_close.( pcm ); |
| 944 | return result; |
| 945 | |
| 946 | error: |
| 947 | goto end; |
| 948 | } |
| 949 | |
| 950 | /* Initialize device info with invalid values (maxInputChannels and maxOutputChannels are set to zero since these indicate |
| 951 | * whether input/output is available) */ |
| 952 | static void InitializeDeviceInfocxx . . $ InitializeDeviceInfo(816c9ebd6c697476).( PaDeviceInfocxx . . $ PaDeviceInfo# *deviceInfo ) |
| 953 | { |
| 954 | deviceInfo->structVersioncxx . . $ PaDeviceInfo#structVersion. = -1; |
| 955 | deviceInfo->namecxx . . $ PaDeviceInfo#name. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 956 | deviceInfo->hostApicxx . . $ PaDeviceInfo#hostApi. = -1; |
| 957 | deviceInfo->maxInputChannelscxx . . $ PaDeviceInfo#maxInputChannels. = 0; |
| 958 | deviceInfo->maxOutputChannelscxx . . $ PaDeviceInfo#maxOutputChannels. = 0; |
| 959 | deviceInfo->defaultLowInputLatencycxx . . $ PaDeviceInfo#defaultLowInputLatency. = -1.; |
| 960 | deviceInfo->defaultLowOutputLatencycxx . . $ PaDeviceInfo#defaultLowOutputLatency. = -1.; |
| 961 | deviceInfo->defaultHighInputLatencycxx . . $ PaDeviceInfo#defaultHighInputLatency. = -1.; |
| 962 | deviceInfo->defaultHighOutputLatencycxx . . $ PaDeviceInfo#defaultHighOutputLatency. = -1.; |
| 963 | deviceInfo->defaultSampleRatecxx . . $ PaDeviceInfo#defaultSampleRate. = -1.; |
| 964 | } |
| 965 | |
| 966 | |
| 967 | /* Retrieve the version of the runtime Alsa-lib, as a single number equivalent to |
| 968 | * SND_LIB_VERSION. Only a version string is available ("a.b.c") so this has to be converted. |
| 969 | * Assume 'a' and 'b' are single digits only. |
| 970 | */ |
| 971 | static PaUint32cxx . . $ PaUint32# PaAlsaVersionNumcxx . . $ PaAlsaVersionNum(db52760e79bf9054).(void) |
| 972 | { |
| 973 | char* verStr; |
| 974 | PaUint32cxx . . $ PaUint32# verNum; |
| 975 | |
| 976 | verStr = (char*) alsa_snd_asoundlib_versioncxx . . $ alsa_snd_asoundlib_version.(); |
| 977 | verNum = ALSA_VERSION_INTcxx . . $ `external/portaudio/pa_linux_alsa.c:89:9`!( atoi(verStr), atoi(verStr + 2), atoi(verStr + 4) ); |
| 978 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "ALSA version (build): " SND_LIB_VERSION_STR "\nALSA version (runtime): %s\n", verStr )); |
| 979 | |
| 980 | return verNum; |
| 981 | } |
| 982 | |
| 983 | |
| 984 | /* Helper struct */ |
| 985 | typedef structcxx . . $ $anonymous_type_c42756aa1fb35d76_2# |
| 986 | { |
| 987 | char *alsaNamecxx . . $ $anonymous_type_c42756aa1fb35d76_2#alsaName.; |
| 988 | char *namecxx . . $ $anonymous_type_c42756aa1fb35d76_2#name.; |
| 989 | int isPlugcxx . . $ $anonymous_type_c42756aa1fb35d76_2#isPlug.; |
| 990 | int hasPlaybackcxx . . $ $anonymous_type_c42756aa1fb35d76_2#hasPlayback.; |
| 991 | int hasCapturecxx . . $ $anonymous_type_c42756aa1fb35d76_2#hasCapture.; |
| 992 | } HwDevInfocxx . . $ HwDevInfo#; |
| 993 | |
| 994 | |
| 995 | HwDevInfocxx . . $ HwDevInfo# predefinedNamescxx . . $ predefinedNames.[] = { |
| 996 | { "center_lfe", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 997 | /* { "default", NULL, 0, 1, 1 }, */ |
| 998 | { "dmix", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 999 | /* { "dpl", NULL, 0, 1, 0 }, */ |
| 1000 | /* { "dsnoop", NULL, 0, 0, 1 }, */ |
| 1001 | { "front", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1002 | { "iec958", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1003 | /* { "modem", NULL, 0, 1, 0 }, */ |
| 1004 | { "rear", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1005 | { "side", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1006 | /* { "spdif", NULL, 0, 0, 0 }, */ |
| 1007 | { "surround40", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1008 | { "surround41", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1009 | { "surround50", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1010 | { "surround51", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1011 | { "surround71", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1012 | |
| 1013 | { "AndroidPlayback_Earpiece_normal", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1014 | { "AndroidPlayback_Speaker_normal", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1015 | { "AndroidPlayback_Bluetooth_normal", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1016 | { "AndroidPlayback_Headset_normal", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1017 | { "AndroidPlayback_Speaker_Headset_normal", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1018 | { "AndroidPlayback_Bluetooth-A2DP_normal", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1019 | { "AndroidPlayback_ExtraDockSpeaker_normal", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1020 | { "AndroidPlayback_TvOut_normal", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 }, |
| 1021 | |
| 1022 | { "AndroidRecord_Microphone", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 0, 1 }, |
| 1023 | { "AndroidRecord_Earpiece_normal", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 0, 1 }, |
| 1024 | { "AndroidRecord_Speaker_normal", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 0, 1 }, |
| 1025 | { "AndroidRecord_Headset_normal", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 0, 1 }, |
| 1026 | { "AndroidRecord_Bluetooth_normal", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 0, 1 }, |
| 1027 | { "AndroidRecord_Speaker_Headset_normal", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 0, 1 }, |
| 1028 | |
| 1029 | { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, 1, 0 } |
| 1030 | }; |
| 1031 | |
| 1032 | static const HwDevInfocxx . . $ HwDevInfo# *FindDeviceNamecxx . . $ FindDeviceName(f35a89d0bea698c2).( const char *name ) |
| 1033 | { |
| 1034 | int i; |
| 1035 | |
| 1036 | for( i = 0; predefinedNamescxx . . $ predefinedNames.[i].alsaNamecxx . . $ $anonymous_type_c42756aa1fb35d76_2#alsaName.; i++ ) |
| 1037 | { |
| 1038 | if( strcmpcxx . . $ strcmp(5ae29d726ae57f88).( name, predefinedNamescxx . . $ predefinedNames.[i].alsaNamecxx . . $ $anonymous_type_c42756aa1fb35d76_2#alsaName. ) == 0 ) |
| 1039 | { |
| 1040 | return &predefinedNamescxx . . $ predefinedNames.[i]; |
| 1041 | } |
| 1042 | } |
| 1043 | |
| 1044 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1045 | } |
| 1046 | |
| 1047 | static PaErrorcxx . . $ PaError# PaAlsa_StrDupcxx . . $ PaAlsa_StrDup(a4ef2dbc370b9c53).( PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation# *alsaApi, |
| 1048 | char **dst, |
| 1049 | const char *src) |
| 1050 | { |
| 1051 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1052 | int len = strlencxx . . $ strlen(751346f8406fd082).( src ) + 1; |
| 1053 | |
| 1054 | /* PA_DEBUG(("PaStrDup %s %d\n", src, len)); */ |
| 1055 | |
| 1056 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( *dst = (char *)PaUtil_GroupAllocateMemory( alsaApi->allocations, len ), |
| 1057 | paInsufficientMemory ); |
| 1058 | strncpycxx . . $ strncpy(255158a415b673b0).( *dst, src, len ); |
| 1059 | |
| 1060 | error: |
| 1061 | return result; |
| 1062 | } |
| 1063 | |
| 1064 | /* Disregard some standard plugins |
| 1065 | */ |
| 1066 | static int IgnorePlugincxx . . $ IgnorePlugin(5c4306d8553b3696).( const char *pluginId ) |
| 1067 | { |
| 1068 | static const char *ignoredPlugins[] = {"hw", "plughw", "plug", "dsnoop", "tee", |
| 1069 | "file", "null", "shm", "cards", "rate_convert", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!}; |
| 1070 | int i = 0; |
| 1071 | |
| 1072 | if( getenvcxx . . $ getenv(a8b8e32347182212).( "PA_ALSA_IGNORE_ALL_PLUGINS" ) && atoicxx . . $ atoi(5c4306d8553b3696).( getenvcxx . . $ getenv(a8b8e32347182212).( "PA_ALSA_IGNORE_ALL_PLUGINS") ) ) |
| 1073 | return 1; |
| 1074 | |
| 1075 | while( ignoredPlugins[i] ) |
| 1076 | { |
| 1077 | if( !strcmpcxx . . $ strcmp(5ae29d726ae57f88).( pluginId, ignoredPlugins[i] ) ) |
| 1078 | { |
| 1079 | return 1; |
| 1080 | } |
| 1081 | ++i; |
| 1082 | } |
| 1083 | |
| 1084 | return 0; |
| 1085 | } |
| 1086 | |
| 1087 | /* Skip past parts at the beginning of a (pcm) info name that are already in the card name, to avoid duplication */ |
| 1088 | static char *SkipCardDetailsInNamecxx . . $ SkipCardDetailsInName(5bd1a890f71b1efd).( char *infoSkipName, char *cardRefName ) |
| 1089 | { |
| 1090 | char *lastSpacePosn = infoSkipName; |
| 1091 | |
| 1092 | /* Skip matching chars; but only in chunks separated by ' ' (not part words etc), so track lastSpacePosn */ |
| 1093 | while( *cardRefName ) |
| 1094 | { |
| 1095 | while( *infoSkipName && *cardRefName && *infoSkipName == *cardRefName) |
| 1096 | { |
| 1097 | infoSkipName++; |
| 1098 | cardRefName++; |
| 1099 | if( *infoSkipName == ' ' || *infoSkipName == '\0' ) |
| 1100 | lastSpacePosn = infoSkipName; |
| 1101 | } |
| 1102 | infoSkipName = lastSpacePosn; |
| 1103 | /* Look for another chunk; post-increment means ends pointing to next char */ |
| 1104 | while( *cardRefName && ( *cardRefName++ != ' ' )); |
| 1105 | } |
| 1106 | if( *infoSkipName == '\0' ) |
| 1107 | return "-"; /* The 2 names were identical; instead of a nul-string, return a marker string */ |
| 1108 | |
| 1109 | /* Now want to move to the first char after any spaces */ |
| 1110 | while( *lastSpacePosn && *lastSpacePosn == ' ' ) |
| 1111 | lastSpacePosn++; |
| 1112 | /* Skip a single separator char if present in the remaining pcm name; (pa will add its own) */ |
| 1113 | if(( *lastSpacePosn == '-' || *lastSpacePosn == ':' ) && *(lastSpacePosn + 1) == ' ' ) |
| 1114 | lastSpacePosn += 2; |
| 1115 | |
| 1116 | return lastSpacePosn; |
| 1117 | } |
| 1118 | |
| 1119 | /** Open PCM device. |
| 1120 | * |
| 1121 | * Wrapper around alsa_snd_pcm_open which may repeatedly retry opening a device if it is busy, for |
| 1122 | * a certain time. This is because dmix may temporarily hold on to a device after it (dmix) |
| 1123 | * has been opened and closed. |
| 1124 | * @param mode: Open mode (e.g., SND_PCM_BLOCKING). |
| 1125 | * @param waitOnBusy: Retry opening busy device for up to one second? |
| 1126 | **/ |
| 1127 | static int OpenPcmcxx . . $ OpenPcm(c50056988e97fbd2).( snd_pcm_tcxx . . $ snd_pcm_t# **pcmp, const char *name, snd_pcm_stream_tcxx . . $ snd_pcm_stream_t# stream, int mode, int waitOnBusy ) |
| 1128 | { |
| 1129 | int ret, tries = 0, maxTries = waitOnBusy ? busyRetries_cxx . . $ busyRetries_. : 0; |
| 1130 | |
| 1131 | ret = alsa_snd_pcm_opencxx . . $ alsa_snd_pcm_open.( pcmp, name, stream, mode ); |
| 1132 | |
| 1133 | for( tries = 0; tries < maxTries && -EBUSYcxx . . $ `<external>/8987895939074593727/errno-base.h:20:9`! == ret; ++tries ) |
| 1134 | { |
| 1135 | Pa_Sleepcxx . . $ Pa_Sleep(1624ee8275b10bda).( 10 ); |
| 1136 | ret = alsa_snd_pcm_opencxx . . $ alsa_snd_pcm_open.( pcmp, name, stream, mode ); |
| 1137 | if( -EBUSYcxx . . $ `<external>/8987895939074593727/errno-base.h:20:9`! != ret ) |
| 1138 | { |
| 1139 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Successfully opened initially busy device after %d tries\n", __FUNCTION__, tries )); |
| 1140 | } |
| 1141 | } |
| 1142 | if( -EBUSYcxx . . $ `<external>/8987895939074593727/errno-base.h:20:9`! == ret ) |
| 1143 | { |
| 1144 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Failed to open busy device '%s'\n", __FUNCTION__, name )); |
| 1145 | } |
| 1146 | else |
| 1147 | { |
| 1148 | if( ret < 0 ) |
| 1149 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Opened device '%s' ptr[%p] - result: [%d:%s]\n", __FUNCTION__, name, *pcmp, ret, alsa_snd_strerror(ret) )); |
| 1150 | } |
| 1151 | |
| 1152 | return ret; |
| 1153 | } |
| 1154 | |
| 1155 | static PaErrorcxx . . $ PaError# FillInDevInfocxx . . $ FillInDevInfo(fdadf2ff155a95ff).( PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation# *alsaApi, HwDevInfocxx . . $ HwDevInfo#* deviceHwInfo, int blocking, |
| 1156 | PaAlsaDeviceInfocxx . . $ PaAlsaDeviceInfo#* devInfo, int* devIdx ) |
| 1157 | { |
| 1158 | PaErrorcxx . . $ PaError# result = 0; |
| 1159 | PaDeviceInfocxx . . $ PaDeviceInfo# *baseDeviceInfo = &devInfo->baseDeviceInfocxx . . $ PaAlsaDeviceInfo#baseDeviceInfo.; |
| 1160 | snd_pcm_tcxx . . $ snd_pcm_t# *pcm = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1161 | PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *baseApi = &alsaApi->baseHostApiRepcxx . . $ PaAlsaHostApiRepresentation#baseHostApiRep.; |
| 1162 | |
| 1163 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Filling device info for: %s\n", __FUNCTION__, deviceHwInfo->name )); |
| 1164 | |
| 1165 | /* Zero fields */ |
| 1166 | InitializeDeviceInfocxx . . $ InitializeDeviceInfo(816c9ebd6c697476).( baseDeviceInfo ); |
| 1167 | |
| 1168 | /* To determine device capabilities, we must open the device and query the |
| 1169 | * hardware parameter configuration space */ |
| 1170 | |
| 1171 | /* Query capture */ |
| 1172 | if( deviceHwInfo->hasCapturecxx . . $ $anonymous_type_c42756aa1fb35d76_2#hasCapture. && |
| 1173 | OpenPcmcxx . . $ OpenPcm(c50056988e97fbd2).( &pcm, deviceHwInfo->alsaNamecxx . . $ $anonymous_type_c42756aa1fb35d76_2#alsaName., SND_PCM_STREAM_CAPTUREcxx . . $ SND_PCM_STREAM_CAPTURE., blocking, 0 ) >= 0 ) |
| 1174 | { |
| 1175 | if( GropeDevicecxx . . $ GropeDevice(f6333026cde00488).( pcm, deviceHwInfo->isPlugcxx . . $ $anonymous_type_c42756aa1fb35d76_2#isPlug., StreamDirection_Incxx . . $ StreamDirection_In., blocking, devInfo ) != paNoErrorcxx . . $ paNoError. ) |
| 1176 | { |
| 1177 | /* Error */ |
| 1178 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Failed groping %s for capture\n", __FUNCTION__, deviceHwInfo->alsaName )); |
| 1179 | goto end; |
| 1180 | } |
| 1181 | } |
| 1182 | |
| 1183 | /* Query playback */ |
| 1184 | if( deviceHwInfo->hasPlaybackcxx . . $ $anonymous_type_c42756aa1fb35d76_2#hasPlayback. && |
| 1185 | OpenPcmcxx . . $ OpenPcm(c50056988e97fbd2).( &pcm, deviceHwInfo->alsaNamecxx . . $ $anonymous_type_c42756aa1fb35d76_2#alsaName., SND_PCM_STREAM_PLAYBACKcxx . . $ SND_PCM_STREAM_PLAYBACK., blocking, 0 ) >= 0 ) |
| 1186 | { |
| 1187 | if( GropeDevicecxx . . $ GropeDevice(f6333026cde00488).( pcm, deviceHwInfo->isPlugcxx . . $ $anonymous_type_c42756aa1fb35d76_2#isPlug., StreamDirection_Outcxx . . $ StreamDirection_Out., blocking, devInfo ) != paNoErrorcxx . . $ paNoError. ) |
| 1188 | { |
| 1189 | /* Error */ |
| 1190 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Failed groping %s for playback\n", __FUNCTION__, deviceHwInfo->alsaName )); |
| 1191 | goto end; |
| 1192 | } |
| 1193 | } |
| 1194 | |
| 1195 | baseDeviceInfo->structVersioncxx . . $ PaDeviceInfo#structVersion. = 2; |
| 1196 | baseDeviceInfo->hostApicxx . . $ PaDeviceInfo#hostApi. = alsaApi->hostApiIndexcxx . . $ PaAlsaHostApiRepresentation#hostApiIndex.; |
| 1197 | baseDeviceInfo->namecxx . . $ PaDeviceInfo#name. = deviceHwInfo->namecxx . . $ $anonymous_type_c42756aa1fb35d76_2#name.; |
| 1198 | devInfo->alsaNamecxx . . $ PaAlsaDeviceInfo#alsaName. = deviceHwInfo->alsaNamecxx . . $ $anonymous_type_c42756aa1fb35d76_2#alsaName.; |
| 1199 | devInfo->isPlugcxx . . $ PaAlsaDeviceInfo#isPlug. = deviceHwInfo->isPlugcxx . . $ $anonymous_type_c42756aa1fb35d76_2#isPlug.; |
| 1200 | |
| 1201 | /* A: Storing pointer to PaAlsaDeviceInfo object as pointer to PaDeviceInfo object. |
| 1202 | * Should now be safe to add device info, unless the device supports neither capture nor playback |
| 1203 | */ |
| 1204 | if( baseDeviceInfo->maxInputChannelscxx . . $ PaDeviceInfo#maxInputChannels. > 0 || baseDeviceInfo->maxOutputChannelscxx . . $ PaDeviceInfo#maxOutputChannels. > 0 ) |
| 1205 | { |
| 1206 | /* Make device default if there isn't already one or it is the ALSA "default" device */ |
| 1207 | if( ( baseApi->infocxx . . $ PaUtilHostApiRepresentation#info..defaultInputDevicecxx . . $ PaHostApiInfo#defaultInputDevice. == paNoDevicecxx . . $ `external/portaudio/portaudio.h:220:9`! || |
| 1208 | !strcmpcxx . . $ strcmp(5ae29d726ae57f88).( deviceHwInfo->alsaNamecxx . . $ $anonymous_type_c42756aa1fb35d76_2#alsaName., "default" ) ) && baseDeviceInfo->maxInputChannelscxx . . $ PaDeviceInfo#maxInputChannels. > 0 ) |
| 1209 | { |
| 1210 | baseApi->infocxx . . $ PaUtilHostApiRepresentation#info..defaultInputDevicecxx . . $ PaHostApiInfo#defaultInputDevice. = *devIdx; |
| 1211 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "Default input device: %s\n", deviceHwInfo->name )); |
| 1212 | } |
| 1213 | if( ( baseApi->infocxx . . $ PaUtilHostApiRepresentation#info..defaultOutputDevicecxx . . $ PaHostApiInfo#defaultOutputDevice. == paNoDevicecxx . . $ `external/portaudio/portaudio.h:220:9`! || |
| 1214 | !strcmpcxx . . $ strcmp(5ae29d726ae57f88).( deviceHwInfo->alsaNamecxx . . $ $anonymous_type_c42756aa1fb35d76_2#alsaName., "default" ) ) && baseDeviceInfo->maxOutputChannelscxx . . $ PaDeviceInfo#maxOutputChannels. > 0 ) |
| 1215 | { |
| 1216 | baseApi->infocxx . . $ PaUtilHostApiRepresentation#info..defaultOutputDevicecxx . . $ PaHostApiInfo#defaultOutputDevice. = *devIdx; |
| 1217 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "Default output device: %s\n", deviceHwInfo->name )); |
| 1218 | } |
| 1219 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Adding device %s: %d\n", __FUNCTION__, deviceHwInfo->name, *devIdx )); |
| 1220 | baseApi->deviceInfoscxx . . $ PaUtilHostApiRepresentation#deviceInfos.[*devIdx] = (PaDeviceInfocxx . . $ PaDeviceInfo# *) devInfo; |
| 1221 | (*devIdx) += 1; |
| 1222 | } |
| 1223 | else |
| 1224 | { |
| 1225 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Skipped device: %s, all channels == 0\n", __FUNCTION__, deviceHwInfo->name )); |
| 1226 | } |
| 1227 | |
| 1228 | end: |
| 1229 | return result; |
| 1230 | } |
| 1231 | |
| 1232 | /* Build PaDeviceInfo list, ignore devices for which we cannot determine capabilities (possibly busy, sigh) */ |
| 1233 | static PaErrorcxx . . $ PaError# BuildDeviceListcxx . . $ BuildDeviceList(2668720138906f3c).( PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation# *alsaApi ) |
| 1234 | { |
| 1235 | PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *baseApi = &alsaApi->baseHostApiRepcxx . . $ PaAlsaHostApiRepresentation#baseHostApiRep.; |
| 1236 | PaAlsaDeviceInfocxx . . $ PaAlsaDeviceInfo# *deviceInfoArray; |
| 1237 | int cardIdx = -1, devIdx = 0; |
| 1238 | snd_ctl_card_info_tcxx . . $ snd_ctl_card_info_t# *cardInfo; |
| 1239 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1240 | size_t numDeviceNames = 0, maxDeviceNames = 1, i; |
| 1241 | HwDevInfocxx . . $ HwDevInfo# *hwDevInfos = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1242 | snd_config_tcxx . . $ snd_config_t# *topNode = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1243 | snd_pcm_info_tcxx . . $ snd_pcm_info_t# *pcmInfo; |
| 1244 | int res; |
| 1245 | int blocking = SND_PCM_NONBLOCKcxx . . $ `<external>/1940241556234150319/pcm.h:405:9`!; |
| 1246 | int usePlughw = 0; |
| 1247 | char *hwPrefix = ""; |
| 1248 | char alsaCardName[50]; |
| 1249 | #ifdef PA_ENABLE_DEBUG_OUTPUT |
| 1250 | PaTime startTime = PaUtil_GetTime(); |
| 1251 | #endif |
| 1252 | |
| 1253 | if( getenvcxx . . $ getenv(a8b8e32347182212).( "PA_ALSA_INITIALIZE_BLOCK" ) && atoicxx . . $ atoi(5c4306d8553b3696).( getenvcxx . . $ getenv(a8b8e32347182212).( "PA_ALSA_INITIALIZE_BLOCK" ) ) ) |
| 1254 | blocking = 0; |
| 1255 | |
| 1256 | /* If PA_ALSA_PLUGHW is 1 (non-zero), use the plughw: pcm throughout instead of hw: */ |
| 1257 | if( getenvcxx . . $ getenv(a8b8e32347182212).( "PA_ALSA_PLUGHW" ) && atoicxx . . $ atoi(5c4306d8553b3696).( getenvcxx . . $ getenv(a8b8e32347182212).( "PA_ALSA_PLUGHW" ) ) ) |
| 1258 | { |
| 1259 | usePlughw = 1; |
| 1260 | hwPrefix = "plug"; |
| 1261 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Using Plughw\n", __FUNCTION__ )); |
| 1262 | } |
| 1263 | |
| 1264 | /* These two will be set to the first working input and output device, respectively */ |
| 1265 | baseApi->infocxx . . $ PaUtilHostApiRepresentation#info..defaultInputDevicecxx . . $ PaHostApiInfo#defaultInputDevice. = paNoDevicecxx . . $ `external/portaudio/portaudio.h:220:9`!; |
| 1266 | baseApi->infocxx . . $ PaUtilHostApiRepresentation#info..defaultOutputDevicecxx . . $ PaHostApiInfo#defaultOutputDevice. = paNoDevicecxx . . $ `external/portaudio/portaudio.h:220:9`!; |
| 1267 | |
| 1268 | /* Gather info about hw devices |
| 1269 | |
| 1270 | * alsa_snd_card_next() modifies the integer passed to it to be: |
| 1271 | * the index of the first card if the parameter is -1 |
| 1272 | * the index of the next card if the parameter is the index of a card |
| 1273 | * -1 if there are no more cards |
| 1274 | * |
| 1275 | * The function itself returns 0 if it succeeded. */ |
| 1276 | cardIdx = -1; |
| 1277 | alsa_snd_ctl_card_info_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:208:9`!( &cardInfo ); |
| 1278 | alsa_snd_pcm_info_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:197:9`!( &pcmInfo ); |
| 1279 | while( alsa_snd_card_nextcxx . . $ alsa_snd_card_next.( &cardIdx ) == 0 && cardIdx >= 0 ) |
| 1280 | { |
| 1281 | char *cardName; |
| 1282 | int devIdx = -1; |
| 1283 | snd_ctl_tcxx . . $ snd_ctl_t# *ctl; |
| 1284 | char buf[50]; |
| 1285 | |
| 1286 | snprintfcxx . . $ snprintf(ea502d73e74c754c).( alsaCardName, sizeof (alsaCardName), "hw:%d", cardIdx ); |
| 1287 | |
| 1288 | /* Acquire name of card */ |
| 1289 | if( alsa_snd_ctl_opencxx . . $ alsa_snd_ctl_open.( &ctl, alsaCardName, 0 ) < 0 ) |
| 1290 | { |
| 1291 | /* Unable to open card :( */ |
| 1292 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Unable to open device %s\n", __FUNCTION__, alsaCardName )); |
| 1293 | continue; |
| 1294 | } |
| 1295 | alsa_snd_ctl_card_infocxx . . $ alsa_snd_ctl_card_info.( ctl, cardInfo ); |
| 1296 | |
| 1297 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsa_StrDup( alsaApi, &cardName, alsa_snd_ctl_card_info_get_name( cardInfo )) ); |
| 1298 | |
| 1299 | while( alsa_snd_ctl_pcm_next_devicecxx . . $ alsa_snd_ctl_pcm_next_device.( ctl, &devIdx ) == 0 && devIdx >= 0 ) |
| 1300 | { |
| 1301 | char *alsaDeviceName, *deviceName, *infoName; |
| 1302 | size_t len; |
| 1303 | int hasPlayback = 0, hasCapture = 0; |
| 1304 | |
| 1305 | snprintfcxx . . $ snprintf(ea502d73e74c754c).( buf, sizeof (buf), "%s%s,%d", hwPrefix, alsaCardName, devIdx ); |
| 1306 | |
| 1307 | /* Obtain info about this particular device */ |
| 1308 | alsa_snd_pcm_info_set_devicecxx . . $ alsa_snd_pcm_info_set_device.( pcmInfo, devIdx ); |
| 1309 | alsa_snd_pcm_info_set_subdevicecxx . . $ alsa_snd_pcm_info_set_subdevice.( pcmInfo, 0 ); |
| 1310 | alsa_snd_pcm_info_set_streamcxx . . $ alsa_snd_pcm_info_set_stream.( pcmInfo, SND_PCM_STREAM_CAPTUREcxx . . $ SND_PCM_STREAM_CAPTURE. ); |
| 1311 | if( alsa_snd_ctl_pcm_infocxx . . $ alsa_snd_ctl_pcm_info.( ctl, pcmInfo ) >= 0 ) |
| 1312 | { |
| 1313 | hasCapture = 1; |
| 1314 | } |
| 1315 | |
| 1316 | alsa_snd_pcm_info_set_streamcxx . . $ alsa_snd_pcm_info_set_stream.( pcmInfo, SND_PCM_STREAM_PLAYBACKcxx . . $ SND_PCM_STREAM_PLAYBACK. ); |
| 1317 | if( alsa_snd_ctl_pcm_infocxx . . $ alsa_snd_ctl_pcm_info.( ctl, pcmInfo ) >= 0 ) |
| 1318 | { |
| 1319 | hasPlayback = 1; |
| 1320 | } |
| 1321 | |
| 1322 | if( !hasPlayback && !hasCapture ) |
| 1323 | { |
| 1324 | /* Error */ |
| 1325 | continue; |
| 1326 | } |
| 1327 | |
| 1328 | infoName = SkipCardDetailsInNamecxx . . $ SkipCardDetailsInName(5bd1a890f71b1efd).( (char *)alsa_snd_pcm_info_get_namecxx . . $ alsa_snd_pcm_info_get_name.( pcmInfo ), cardName ); |
| 1329 | |
| 1330 | /* The length of the string written by snprintf plus terminating 0 */ |
| 1331 | len = snprintfcxx . . $ snprintf(ea502d73e74c754c).( NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0, "%s: %s (%s)", cardName, infoName, buf ) + 1; |
| 1332 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( deviceName = (char *)PaUtil_GroupAllocateMemory( alsaApi->allocations, len ), |
| 1333 | paInsufficientMemory ); |
| 1334 | snprintfcxx . . $ snprintf(ea502d73e74c754c).( deviceName, len, "%s: %s (%s)", cardName, infoName, buf ); |
| 1335 | |
| 1336 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Found device [%d]: %s\n", __FUNCTION__, numDeviceNames, deviceName )); |
| 1337 | |
| 1338 | ++numDeviceNames; |
| 1339 | if( !hwDevInfos || numDeviceNames > maxDeviceNames ) |
| 1340 | { |
| 1341 | maxDeviceNames *= 2; |
| 1342 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( hwDevInfos = (HwDevInfo *) realloc( hwDevInfos, maxDeviceNames * sizeof (HwDevInfo) ), |
| 1343 | paInsufficientMemory ); |
| 1344 | } |
| 1345 | |
| 1346 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsa_StrDup( alsaApi, &alsaDeviceName, buf ) ); |
| 1347 | |
| 1348 | hwDevInfos[ numDeviceNames - 1 ].alsaNamecxx . . $ $anonymous_type_c42756aa1fb35d76_2#alsaName. = alsaDeviceName; |
| 1349 | hwDevInfos[ numDeviceNames - 1 ].namecxx . . $ $anonymous_type_c42756aa1fb35d76_2#name. = deviceName; |
| 1350 | hwDevInfos[ numDeviceNames - 1 ].isPlugcxx . . $ $anonymous_type_c42756aa1fb35d76_2#isPlug. = usePlughw; |
| 1351 | hwDevInfos[ numDeviceNames - 1 ].hasPlaybackcxx . . $ $anonymous_type_c42756aa1fb35d76_2#hasPlayback. = hasPlayback; |
| 1352 | hwDevInfos[ numDeviceNames - 1 ].hasCapturecxx . . $ $anonymous_type_c42756aa1fb35d76_2#hasCapture. = hasCapture; |
| 1353 | } |
| 1354 | alsa_snd_ctl_closecxx . . $ alsa_snd_ctl_close.( ctl ); |
| 1355 | } |
| 1356 | |
| 1357 | /* Iterate over plugin devices */ |
| 1358 | if( NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! == (*alsa_snd_configcxx . . $ alsa_snd_config.) ) |
| 1359 | { |
| 1360 | /* alsa_snd_config_update is called implicitly by some functions, if this hasn't happened snd_config will be NULL (bleh) */ |
| 1361 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_config_update(), paUnanticipatedHostError ); |
| 1362 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "Updating snd_config\n" )); |
| 1363 | } |
| 1364 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( *alsa_snd_config ); |
| 1365 | if( ( res = alsa_snd_config_searchcxx . . $ alsa_snd_config_search.( *alsa_snd_configcxx . . $ alsa_snd_config., "pcm", &topNode ) ) >= 0 ) |
| 1366 | { |
| 1367 | snd_config_iterator_tcxx . . $ snd_config_iterator_t# i, next; |
| 1368 | |
| 1369 | alsa_snd_config_for_eachcxx . . $ `external/portaudio/pa_linux_alsa.c:234:9`!( i, next, topNode ) |
| 1370 | { |
| 1371 | const char *tpStr = "unknown", *idStr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1372 | int err = 0; |
| 1373 | |
| 1374 | char *alsaDeviceName, *deviceName; |
| 1375 | const HwDevInfocxx . . $ HwDevInfo# *predefined = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1376 | snd_config_tcxx . . $ snd_config_t# *n = alsa_snd_config_iterator_entrycxx . . $ alsa_snd_config_iterator_entry.( i ), * tp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;; |
| 1377 | |
| 1378 | if( (err = alsa_snd_config_searchcxx . . $ alsa_snd_config_search.( n, "type", &tp )) < 0 ) |
| 1379 | { |
| 1380 | if( -ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`! != err ) |
| 1381 | { |
| 1382 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!(err, paUnanticipatedHostError); |
| 1383 | } |
| 1384 | } |
| 1385 | else |
| 1386 | { |
| 1387 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_config_get_string( tp, &tpStr ), paUnanticipatedHostError ); |
| 1388 | } |
| 1389 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_config_get_id( n, &idStr ), paUnanticipatedHostError ); |
| 1390 | if( IgnorePlugincxx . . $ IgnorePlugin(5c4306d8553b3696).( idStr ) ) |
| 1391 | { |
| 1392 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Ignoring ALSA plugin device [%s] of type [%s]\n", __FUNCTION__, idStr, tpStr )); |
| 1393 | continue; |
| 1394 | } |
| 1395 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Found plugin [%s] of type [%s]\n", __FUNCTION__, idStr, tpStr )); |
| 1396 | |
| 1397 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( alsaDeviceName = (char*)PaUtil_GroupAllocateMemory( alsaApi->allocations, |
| 1398 | strlen(idStr) + 6 ), paInsufficientMemory ); |
| 1399 | strcpycxx . . $ strcpy(b7b3a83273496486).( alsaDeviceName, idStr ); |
| 1400 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( deviceName = (char*)PaUtil_GroupAllocateMemory( alsaApi->allocations, |
| 1401 | strlen(idStr) + 1 ), paInsufficientMemory ); |
| 1402 | strcpycxx . . $ strcpy(b7b3a83273496486).( deviceName, idStr ); |
| 1403 | |
| 1404 | ++numDeviceNames; |
| 1405 | if( !hwDevInfos || numDeviceNames > maxDeviceNames ) |
| 1406 | { |
| 1407 | maxDeviceNames *= 2; |
| 1408 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( hwDevInfos = (HwDevInfo *) realloc( hwDevInfos, maxDeviceNames * sizeof (HwDevInfo) ), |
| 1409 | paInsufficientMemory ); |
| 1410 | } |
| 1411 | |
| 1412 | predefined = FindDeviceNamecxx . . $ FindDeviceName(f35a89d0bea698c2).( alsaDeviceName ); |
| 1413 | |
| 1414 | hwDevInfos[numDeviceNames - 1].alsaNamecxx . . $ $anonymous_type_c42756aa1fb35d76_2#alsaName. = alsaDeviceName; |
| 1415 | hwDevInfos[numDeviceNames - 1].namecxx . . $ $anonymous_type_c42756aa1fb35d76_2#name. = deviceName; |
| 1416 | hwDevInfos[numDeviceNames - 1].isPlugcxx . . $ $anonymous_type_c42756aa1fb35d76_2#isPlug. = 1; |
| 1417 | |
| 1418 | if( predefined ) |
| 1419 | { |
| 1420 | hwDevInfos[numDeviceNames - 1].hasPlaybackcxx . . $ $anonymous_type_c42756aa1fb35d76_2#hasPlayback. = predefined->hasPlaybackcxx . . $ $anonymous_type_c42756aa1fb35d76_2#hasPlayback.; |
| 1421 | hwDevInfos[numDeviceNames - 1].hasCapturecxx . . $ $anonymous_type_c42756aa1fb35d76_2#hasCapture. = predefined->hasCapturecxx . . $ $anonymous_type_c42756aa1fb35d76_2#hasCapture.; |
| 1422 | } |
| 1423 | else |
| 1424 | { |
| 1425 | hwDevInfos[numDeviceNames - 1].hasPlaybackcxx . . $ $anonymous_type_c42756aa1fb35d76_2#hasPlayback. = 1; |
| 1426 | hwDevInfos[numDeviceNames - 1].hasCapturecxx . . $ $anonymous_type_c42756aa1fb35d76_2#hasCapture. = 1; |
| 1427 | } |
| 1428 | } |
| 1429 | } |
| 1430 | else |
| 1431 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Iterating over ALSA plugins failed: %s\n", __FUNCTION__, alsa_snd_strerror( res ) )); |
| 1432 | |
| 1433 | /* allocate deviceInfo memory based on the number of devices */ |
| 1434 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( baseApi->deviceInfos = (PaDeviceInfo**)PaUtil_GroupAllocateMemory( |
| 1435 | alsaApi->allocations, sizeof(PaDeviceInfo*) * (numDeviceNames) ), paInsufficientMemory ); |
| 1436 | |
| 1437 | /* allocate all device info structs in a contiguous block */ |
| 1438 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( deviceInfoArray = (PaAlsaDeviceInfo*)PaUtil_GroupAllocateMemory( |
| 1439 | alsaApi->allocations, sizeof(PaAlsaDeviceInfo) * numDeviceNames ), paInsufficientMemory ); |
| 1440 | |
| 1441 | /* Loop over list of cards, filling in info. If a device is deemed unavailable (can't get name), |
| 1442 | * it's ignored. |
| 1443 | * |
| 1444 | * Note that we do this in two stages. This is a workaround owing to the fact that the 'dmix' |
| 1445 | * plugin may cause the underlying hardware device to be busy for a short while even after it |
| 1446 | * (dmix) is closed. The 'default' plugin may also point to the dmix plugin, so the same goes |
| 1447 | * for this. |
| 1448 | */ |
| 1449 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Filling device info for %d devices\n", __FUNCTION__, numDeviceNames )); |
| 1450 | for( i = 0, devIdx = 0; i < numDeviceNames; ++i ) |
| 1451 | { |
| 1452 | PaAlsaDeviceInfocxx . . $ PaAlsaDeviceInfo#* devInfo = &deviceInfoArray[i]; |
| 1453 | HwDevInfocxx . . $ HwDevInfo#* hwInfo = &hwDevInfos[i]; |
| 1454 | if( !strcmpcxx . . $ strcmp(5ae29d726ae57f88).( hwInfo->namecxx . . $ $anonymous_type_c42756aa1fb35d76_2#name., "dmix" ) || !strcmpcxx . . $ strcmp(5ae29d726ae57f88).( hwInfo->namecxx . . $ $anonymous_type_c42756aa1fb35d76_2#name., "default" ) ) |
| 1455 | { |
| 1456 | continue; |
| 1457 | } |
| 1458 | |
| 1459 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( FillInDevInfo( alsaApi, hwInfo, blocking, devInfo, &devIdx ) ); |
| 1460 | } |
| 1461 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( devIdx <= numDeviceNames ); |
| 1462 | /* Now inspect 'dmix' and 'default' plugins */ |
| 1463 | for( i = 0; i < numDeviceNames; ++i ) |
| 1464 | { |
| 1465 | PaAlsaDeviceInfocxx . . $ PaAlsaDeviceInfo#* devInfo = &deviceInfoArray[i]; |
| 1466 | HwDevInfocxx . . $ HwDevInfo#* hwInfo = &hwDevInfos[i]; |
| 1467 | if( strcmpcxx . . $ strcmp(5ae29d726ae57f88).( hwInfo->namecxx . . $ $anonymous_type_c42756aa1fb35d76_2#name., "dmix" ) && strcmpcxx . . $ strcmp(5ae29d726ae57f88).( hwInfo->namecxx . . $ $anonymous_type_c42756aa1fb35d76_2#name., "default" ) ) |
| 1468 | { |
| 1469 | continue; |
| 1470 | } |
| 1471 | |
| 1472 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( FillInDevInfo( alsaApi, hwInfo, blocking, devInfo, &devIdx ) ); |
| 1473 | } |
| 1474 | freecxx . . $ free(5d22bdacc48458e8).( hwDevInfos ); |
| 1475 | |
| 1476 | baseApi->infocxx . . $ PaUtilHostApiRepresentation#info..deviceCountcxx . . $ PaHostApiInfo#deviceCount. = devIdx; /* Number of successfully queried devices */ |
| 1477 | |
| 1478 | #ifdef PA_ENABLE_DEBUG_OUTPUT |
| 1479 | PA_DEBUG(( "%s: Building device list took %f seconds\n", __FUNCTION__, PaUtil_GetTime() - startTime )); |
| 1480 | #endif |
| 1481 | |
| 1482 | end: |
| 1483 | return result; |
| 1484 | |
| 1485 | error: |
| 1486 | /* No particular action */ |
| 1487 | goto end; |
| 1488 | } |
| 1489 | |
| 1490 | /* Check against known device capabilities */ |
| 1491 | static PaErrorcxx . . $ PaError# ValidateParameterscxx . . $ ValidateParameters(141352f0a7bf99aa).( const PaStreamParameterscxx . . $ PaStreamParameters# *parameters, PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi, StreamDirectioncxx . . $ StreamDirection# mode ) |
| 1492 | { |
| 1493 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1494 | int maxChans; |
| 1495 | const PaAlsaDeviceInfocxx . . $ PaAlsaDeviceInfo# *deviceInfo = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1496 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( parameters ); |
| 1497 | |
| 1498 | if( parameters->devicecxx . . $ PaStreamParameters#device. != paUseHostApiSpecificDeviceSpecificationcxx . . $ `external/portaudio/portaudio.h:228:9`! ) |
| 1499 | { |
| 1500 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( parameters->device < hostApi->info.deviceCount ); |
| 1501 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( parameters->hostApiSpecificStreamInfo == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, paBadIODeviceCombination ); |
| 1502 | deviceInfo = GetDeviceInfocxx . . $ GetDeviceInfo(db6649f25e165c42).( hostApi, parameters->devicecxx . . $ PaStreamParameters#device. ); |
| 1503 | } |
| 1504 | else |
| 1505 | { |
| 1506 | const PaAlsaStreamInfocxx . . $ PaAlsaStreamInfo# *streamInfo = parameters->hostApiSpecificStreamInfocxx . . $ PaStreamParameters#hostApiSpecificStreamInfo.; |
| 1507 | |
| 1508 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( parameters->device == paUseHostApiSpecificDeviceSpecificationcxx . . $ `external/portaudio/portaudio.h:228:9`!, paInvalidDevice ); |
| 1509 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( streamInfo->size == sizeof (PaAlsaStreamInfo) && streamInfo->version == 1, |
| 1510 | paIncompatibleHostApiSpecificStreamInfo ); |
| 1511 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( streamInfo->deviceString != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, paInvalidDevice ); |
| 1512 | |
| 1513 | /* Skip further checking */ |
| 1514 | return paNoErrorcxx . . $ paNoError.; |
| 1515 | } |
| 1516 | |
| 1517 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( deviceInfo ); |
| 1518 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( parameters->hostApiSpecificStreamInfo == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ); |
| 1519 | maxChans = ( StreamDirection_Incxx . . $ StreamDirection_In. == mode ? deviceInfo->baseDeviceInfocxx . . $ PaAlsaDeviceInfo#baseDeviceInfo..maxInputChannelscxx . . $ PaDeviceInfo#maxInputChannels. : |
| 1520 | deviceInfo->baseDeviceInfocxx . . $ PaAlsaDeviceInfo#baseDeviceInfo..maxOutputChannelscxx . . $ PaDeviceInfo#maxOutputChannels. ); |
| 1521 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( parameters->channelCount <= maxChans, paInvalidChannelCount ); |
| 1522 | |
| 1523 | error: |
| 1524 | return result; |
| 1525 | } |
| 1526 | |
| 1527 | /* Given an open stream, what sample formats are available? */ |
| 1528 | static PaSampleFormatcxx . . $ PaSampleFormat# GetAvailableFormatscxx . . $ GetAvailableFormats(794069174ef75b71).( snd_pcm_tcxx . . $ snd_pcm_t# *pcm ) |
| 1529 | { |
| 1530 | PaSampleFormatcxx . . $ PaSampleFormat# available = 0; |
| 1531 | snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t# *hwParams; |
| 1532 | alsa_snd_pcm_hw_params_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:171:9`!( &hwParams ); |
| 1533 | |
| 1534 | alsa_snd_pcm_hw_params_anycxx . . $ alsa_snd_pcm_hw_params_any.( pcm, hwParams ); |
| 1535 | |
| 1536 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_FLOATcxx . . $ SND_PCM_FORMAT_FLOAT. ) >= 0) |
| 1537 | available |= paFloat32cxx . . $ `external/portaudio/portaudio.h:487:9`!; |
| 1538 | |
| 1539 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S32cxx . . $ SND_PCM_FORMAT_S32. ) >= 0) |
| 1540 | available |= paInt32cxx . . $ `external/portaudio/portaudio.h:488:9`!; |
| 1541 | |
| 1542 | #if __BYTE_ORDER__cxx . . $ `<built-in>:48:9`! == __ORDER_LITTLE_ENDIAN__cxx . . $ `<built-in>:45:9`! |
| 1543 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S24_3LEcxx . . $ SND_PCM_FORMAT_S24_3LE. ) >= 0) |
| 1544 | available |= paInt24cxx . . $ `external/portaudio/portaudio.h:489:9`!; |
| 1545 | #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
| 1546 | if( alsa_snd_pcm_hw_params_test_format( pcm, hwParams, SND_PCM_FORMAT_S24_3BE ) >= 0) |
| 1547 | available |= paInt24; |
| 1548 | #endif |
| 1549 | |
| 1550 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S16cxx . . $ SND_PCM_FORMAT_S16. ) >= 0) |
| 1551 | available |= paInt16cxx . . $ `external/portaudio/portaudio.h:490:9`!; |
| 1552 | |
| 1553 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U8cxx . . $ SND_PCM_FORMAT_U8. ) >= 0) |
| 1554 | available |= paUInt8cxx . . $ `external/portaudio/portaudio.h:492:9`!; |
| 1555 | |
| 1556 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S8cxx . . $ SND_PCM_FORMAT_S8. ) >= 0) |
| 1557 | available |= paInt8cxx . . $ `external/portaudio/portaudio.h:491:9`!; |
| 1558 | |
| 1559 | return available; |
| 1560 | } |
| 1561 | |
| 1562 | /* Output to console all formats supported by device */ |
| 1563 | static void LogAllAvailableFormatscxx . . $ LogAllAvailableFormats(bb145a214a065ee8).( snd_pcm_tcxx . . $ snd_pcm_t# *pcm ) |
| 1564 | { |
| 1565 | PaSampleFormatcxx . . $ PaSampleFormat# available = 0; |
| 1566 | snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t# *hwParams; |
| 1567 | alsa_snd_pcm_hw_params_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:171:9`!( &hwParams ); |
| 1568 | |
| 1569 | alsa_snd_pcm_hw_params_anycxx . . $ alsa_snd_pcm_hw_params_any.( pcm, hwParams ); |
| 1570 | |
| 1571 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( " --- Supported Formats ---\n" )); |
| 1572 | |
| 1573 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S8cxx . . $ SND_PCM_FORMAT_S8. ) >= 0) |
| 1574 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S8\n" )); |
| 1575 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U8cxx . . $ SND_PCM_FORMAT_U8. ) >= 0) |
| 1576 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U8\n" )); |
| 1577 | |
| 1578 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S16_LEcxx . . $ SND_PCM_FORMAT_S16_LE. ) >= 0) |
| 1579 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S16_LE\n" )); |
| 1580 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S16_BEcxx . . $ SND_PCM_FORMAT_S16_BE. ) >= 0) |
| 1581 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S16_BE\n" )); |
| 1582 | |
| 1583 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U16_LEcxx . . $ SND_PCM_FORMAT_U16_LE. ) >= 0) |
| 1584 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U16_LE\n" )); |
| 1585 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U16_BEcxx . . $ SND_PCM_FORMAT_U16_BE. ) >= 0) |
| 1586 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U16_BE\n" )); |
| 1587 | |
| 1588 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S24_LEcxx . . $ SND_PCM_FORMAT_S24_LE. ) >= 0) |
| 1589 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S24_LE\n" )); |
| 1590 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S24_BEcxx . . $ SND_PCM_FORMAT_S24_BE. ) >= 0) |
| 1591 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S24_BE\n" )); |
| 1592 | |
| 1593 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U24_LEcxx . . $ SND_PCM_FORMAT_U24_LE. ) >= 0) |
| 1594 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U24_LE\n" )); |
| 1595 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U24_BEcxx . . $ SND_PCM_FORMAT_U24_BE. ) >= 0) |
| 1596 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U24_BE\n" )); |
| 1597 | |
| 1598 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_FLOAT_LEcxx . . $ SND_PCM_FORMAT_FLOAT_LE. ) >= 0) |
| 1599 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_FLOAT_LE\n" )); |
| 1600 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_FLOAT_BEcxx . . $ SND_PCM_FORMAT_FLOAT_BE. ) >= 0) |
| 1601 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_FLOAT_BE\n" )); |
| 1602 | |
| 1603 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_FLOAT64_LEcxx . . $ SND_PCM_FORMAT_FLOAT64_LE. ) >= 0) |
| 1604 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_FLOAT64_LE\n" )); |
| 1605 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_FLOAT64_BEcxx . . $ SND_PCM_FORMAT_FLOAT64_BE. ) >= 0) |
| 1606 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_FLOAT64_BE\n" )); |
| 1607 | |
| 1608 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_IEC958_SUBFRAME_LEcxx . . $ SND_PCM_FORMAT_IEC958_SUBFRAME_LE. ) >= 0) |
| 1609 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_IEC958_SUBFRAME_LE\n" )); |
| 1610 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_IEC958_SUBFRAME_BEcxx . . $ SND_PCM_FORMAT_IEC958_SUBFRAME_BE. ) >= 0) |
| 1611 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_IEC958_SUBFRAME_BE\n" )); |
| 1612 | |
| 1613 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_MU_LAWcxx . . $ SND_PCM_FORMAT_MU_LAW. ) >= 0) |
| 1614 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_MU_LAW\n" )); |
| 1615 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_A_LAWcxx . . $ SND_PCM_FORMAT_A_LAW. ) >= 0) |
| 1616 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_A_LAW\n" )); |
| 1617 | |
| 1618 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_IMA_ADPCMcxx . . $ SND_PCM_FORMAT_IMA_ADPCM. ) >= 0) |
| 1619 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_IMA_ADPCM\n" )); |
| 1620 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_MPEGcxx . . $ SND_PCM_FORMAT_MPEG. ) >= 0) |
| 1621 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_MPEG\n" )); |
| 1622 | |
| 1623 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_GSMcxx . . $ SND_PCM_FORMAT_GSM. ) >= 0) |
| 1624 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_GSM\n" )); |
| 1625 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_SPECIALcxx . . $ SND_PCM_FORMAT_SPECIAL. ) >= 0) |
| 1626 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_SPECIAL\n" )); |
| 1627 | |
| 1628 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S24_3LEcxx . . $ SND_PCM_FORMAT_S24_3LE. ) >= 0) |
| 1629 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S24_3LE\n" )); |
| 1630 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S24_3BEcxx . . $ SND_PCM_FORMAT_S24_3BE. ) >= 0) |
| 1631 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S24_3BE\n" )); |
| 1632 | |
| 1633 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U24_3LEcxx . . $ SND_PCM_FORMAT_U24_3LE. ) >= 0) |
| 1634 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U24_3LE\n" )); |
| 1635 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U24_3BEcxx . . $ SND_PCM_FORMAT_U24_3BE. ) >= 0) |
| 1636 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U24_3BE\n" )); |
| 1637 | |
| 1638 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S20_3LEcxx . . $ SND_PCM_FORMAT_S20_3LE. ) >= 0) |
| 1639 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S20_3LE\n" )); |
| 1640 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S20_3BEcxx . . $ SND_PCM_FORMAT_S20_3BE. ) >= 0) |
| 1641 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S20_3BE\n" )); |
| 1642 | |
| 1643 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U20_3LEcxx . . $ SND_PCM_FORMAT_U20_3LE. ) >= 0) |
| 1644 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U20_3LE\n" )); |
| 1645 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U20_3BEcxx . . $ SND_PCM_FORMAT_U20_3BE. ) >= 0) |
| 1646 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U20_3BE\n" )); |
| 1647 | |
| 1648 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S18_3LEcxx . . $ SND_PCM_FORMAT_S18_3LE. ) >= 0) |
| 1649 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S18_3LE\n" )); |
| 1650 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S18_3BEcxx . . $ SND_PCM_FORMAT_S18_3BE. ) >= 0) |
| 1651 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S18_3BE\n" )); |
| 1652 | |
| 1653 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U18_3LEcxx . . $ SND_PCM_FORMAT_U18_3LE. ) >= 0) |
| 1654 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U18_3LE\n" )); |
| 1655 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U18_3BEcxx . . $ SND_PCM_FORMAT_U18_3BE. ) >= 0) |
| 1656 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U18_3BE\n" )); |
| 1657 | |
| 1658 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S16cxx . . $ SND_PCM_FORMAT_S16. ) >= 0) |
| 1659 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S16\n" )); |
| 1660 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U16cxx . . $ SND_PCM_FORMAT_U16. ) >= 0) |
| 1661 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U16\n" )); |
| 1662 | |
| 1663 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S24cxx . . $ SND_PCM_FORMAT_S24. ) >= 0) |
| 1664 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S24\n" )); |
| 1665 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U24cxx . . $ SND_PCM_FORMAT_U24. ) >= 0) |
| 1666 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U24\n" )); |
| 1667 | |
| 1668 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_S32cxx . . $ SND_PCM_FORMAT_S32. ) >= 0) |
| 1669 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_S32\n" )); |
| 1670 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_U32cxx . . $ SND_PCM_FORMAT_U32. ) >= 0) |
| 1671 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_U32\n" )); |
| 1672 | |
| 1673 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_FLOATcxx . . $ SND_PCM_FORMAT_FLOAT. ) >= 0) |
| 1674 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_FLOAT\n" )); |
| 1675 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_FLOAT64cxx . . $ SND_PCM_FORMAT_FLOAT64. ) >= 0) |
| 1676 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_FLOAT64\n" )); |
| 1677 | |
| 1678 | if( alsa_snd_pcm_hw_params_test_formatcxx . . $ alsa_snd_pcm_hw_params_test_format.( pcm, hwParams, SND_PCM_FORMAT_IEC958_SUBFRAMEcxx . . $ SND_PCM_FORMAT_IEC958_SUBFRAME. ) >= 0) |
| 1679 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "SND_PCM_FORMAT_IEC958_SUBFRAME\n" )); |
| 1680 | |
| 1681 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( " -------------------------\n" )); |
| 1682 | } |
| 1683 | |
| 1684 | static snd_pcm_format_tcxx . . $ snd_pcm_format_t# Pa2AlsaFormatcxx . . $ Pa2AlsaFormat(659333b6cfdc828d).( PaSampleFormatcxx . . $ PaSampleFormat# paFormat ) |
| 1685 | { |
| 1686 | switch( paFormat ) |
| 1687 | { |
| 1688 | case paFloat32cxx . . $ `external/portaudio/portaudio.h:487:9`!: |
| 1689 | return SND_PCM_FORMAT_FLOATcxx . . $ SND_PCM_FORMAT_FLOAT.; |
| 1690 | |
| 1691 | case paInt16cxx . . $ `external/portaudio/portaudio.h:490:9`!: |
| 1692 | return SND_PCM_FORMAT_S16cxx . . $ SND_PCM_FORMAT_S16.; |
| 1693 | |
| 1694 | case paInt24cxx . . $ `external/portaudio/portaudio.h:489:9`!: |
| 1695 | #if __BYTE_ORDER__cxx . . $ `<built-in>:48:9`! == __ORDER_LITTLE_ENDIAN__cxx . . $ `<built-in>:45:9`! |
| 1696 | return SND_PCM_FORMAT_S24_3LEcxx . . $ SND_PCM_FORMAT_S24_3LE.; |
| 1697 | #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
| 1698 | return SND_PCM_FORMAT_S24_3BE; |
| 1699 | #endif |
| 1700 | |
| 1701 | case paInt32cxx . . $ `external/portaudio/portaudio.h:488:9`!: |
| 1702 | return SND_PCM_FORMAT_S32cxx . . $ SND_PCM_FORMAT_S32.; |
| 1703 | |
| 1704 | case paInt8cxx . . $ `external/portaudio/portaudio.h:491:9`!: |
| 1705 | return SND_PCM_FORMAT_S8cxx . . $ SND_PCM_FORMAT_S8.; |
| 1706 | |
| 1707 | case paUInt8cxx . . $ `external/portaudio/portaudio.h:492:9`!: |
| 1708 | return SND_PCM_FORMAT_U8cxx . . $ SND_PCM_FORMAT_U8.; |
| 1709 | |
| 1710 | default: |
| 1711 | return SND_PCM_FORMAT_UNKNOWNcxx . . $ SND_PCM_FORMAT_UNKNOWN.; |
| 1712 | } |
| 1713 | } |
| 1714 | |
| 1715 | /** Open an ALSA pcm handle. |
| 1716 | * |
| 1717 | * The device to be open can be specified by name in a custom PaAlsaStreamInfo struct, or it will be by |
| 1718 | * the Portaudio device number supplied in the stream parameters. |
| 1719 | */ |
| 1720 | static PaErrorcxx . . $ PaError# AlsaOpencxx . . $ AlsaOpen(ae7ceb39d19c78c5).( const PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi, const PaStreamParameterscxx . . $ PaStreamParameters# *params, StreamDirectioncxx . . $ StreamDirection# |
| 1721 | streamDir, snd_pcm_tcxx . . $ snd_pcm_t# **pcm ) |
| 1722 | { |
| 1723 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1724 | int ret; |
| 1725 | const char* deviceName = ""; |
| 1726 | const PaAlsaDeviceInfocxx . . $ PaAlsaDeviceInfo# *deviceInfo = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1727 | PaAlsaStreamInfocxx . . $ PaAlsaStreamInfo# *streamInfo = (PaAlsaStreamInfocxx . . $ PaAlsaStreamInfo# *)params->hostApiSpecificStreamInfocxx . . $ PaStreamParameters#hostApiSpecificStreamInfo.; |
| 1728 | |
| 1729 | if( !streamInfo ) |
| 1730 | { |
| 1731 | deviceInfo = GetDeviceInfocxx . . $ GetDeviceInfo(db6649f25e165c42).( hostApi, params->devicecxx . . $ PaStreamParameters#device. ); |
| 1732 | deviceName = deviceInfo->alsaNamecxx . . $ PaAlsaDeviceInfo#alsaName.; |
| 1733 | } |
| 1734 | else |
| 1735 | deviceName = streamInfo->deviceStringcxx . . $ PaAlsaStreamInfo#deviceString.; |
| 1736 | |
| 1737 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Opening device %s\n", __FUNCTION__, deviceName )); |
| 1738 | if( (ret = OpenPcmcxx . . $ OpenPcm(c50056988e97fbd2).( pcm, deviceName, streamDir == StreamDirection_Incxx . . $ StreamDirection_In. ? SND_PCM_STREAM_CAPTUREcxx . . $ SND_PCM_STREAM_CAPTURE. : SND_PCM_STREAM_PLAYBACKcxx . . $ SND_PCM_STREAM_PLAYBACK., |
| 1739 | SND_PCM_NONBLOCKcxx . . $ `<external>/1940241556234150319/pcm.h:405:9`!, 1 )) < 0 ) |
| 1740 | { |
| 1741 | /* Not to be closed */ |
| 1742 | *pcm = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1743 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( ret, -EBUSYcxx . . $ `<external>/8987895939074593727/errno-base.h:20:9`! == ret ? paDeviceUnavailable : paBadIODeviceCombination ); |
| 1744 | } |
| 1745 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_nonblock( *pcm, 0 ), paUnanticipatedHostError ); |
| 1746 | |
| 1747 | end: |
| 1748 | return result; |
| 1749 | |
| 1750 | error: |
| 1751 | goto end; |
| 1752 | } |
| 1753 | |
| 1754 | static PaErrorcxx . . $ PaError# TestParameterscxx . . $ TestParameters(9ab7b7bab10d8cf7).( const PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi, const PaStreamParameterscxx . . $ PaStreamParameters# *parameters, |
| 1755 | double sampleRate, StreamDirectioncxx . . $ StreamDirection# streamDir ) |
| 1756 | { |
| 1757 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1758 | snd_pcm_tcxx . . $ snd_pcm_t# *pcm = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1759 | PaSampleFormatcxx . . $ PaSampleFormat# availableFormats; |
| 1760 | /* We are able to adapt to a number of channels less than what the device supports */ |
| 1761 | unsigned int numHostChannels; |
| 1762 | PaSampleFormatcxx . . $ PaSampleFormat# hostFormat; |
| 1763 | snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t# *hwParams; |
| 1764 | alsa_snd_pcm_hw_params_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:171:9`!( &hwParams ); |
| 1765 | |
| 1766 | if( !parameters->hostApiSpecificStreamInfocxx . . $ PaStreamParameters#hostApiSpecificStreamInfo. ) |
| 1767 | { |
| 1768 | const PaAlsaDeviceInfocxx . . $ PaAlsaDeviceInfo# *devInfo = GetDeviceInfocxx . . $ GetDeviceInfo(db6649f25e165c42).( hostApi, parameters->devicecxx . . $ PaStreamParameters#device. ); |
| 1769 | numHostChannels = PA_MAXcxx . . $ `external/portaudio/pa_unix_util.h:58:9`!( parameters->channelCount, StreamDirection_In == streamDir ? |
| 1770 | devInfo->minInputChannels : devInfo->minOutputChannels ); |
| 1771 | } |
| 1772 | else |
| 1773 | numHostChannels = parameters->channelCountcxx . . $ PaStreamParameters#channelCount.; |
| 1774 | |
| 1775 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( AlsaOpen( hostApi, parameters, streamDir, &pcm ) ); |
| 1776 | |
| 1777 | alsa_snd_pcm_hw_params_anycxx . . $ alsa_snd_pcm_hw_params_any.( pcm, hwParams ); |
| 1778 | |
| 1779 | if( SetApproximateSampleRatecxx . . $ SetApproximateSampleRate(95b810ef3c6fd091).( pcm, hwParams, sampleRate ) < 0 ) |
| 1780 | { |
| 1781 | result = paInvalidSampleRatecxx . . $ paInvalidSampleRate.; |
| 1782 | goto error; |
| 1783 | } |
| 1784 | |
| 1785 | if( alsa_snd_pcm_hw_params_set_channelscxx . . $ alsa_snd_pcm_hw_params_set_channels.( pcm, hwParams, numHostChannels ) < 0 ) |
| 1786 | { |
| 1787 | result = paInvalidChannelCountcxx . . $ paInvalidChannelCount.; |
| 1788 | goto error; |
| 1789 | } |
| 1790 | |
| 1791 | /* See if we can find a best possible match */ |
| 1792 | availableFormats = GetAvailableFormatscxx . . $ GetAvailableFormats(794069174ef75b71).( pcm ); |
| 1793 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( hostFormat = PaUtil_SelectClosestAvailableFormat( availableFormats, parameters->sampleFormat ) ); |
| 1794 | |
| 1795 | /* Some specific hardware (reported: Audio8 DJ) can fail with assertion during this step. */ |
| 1796 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_format( pcm, hwParams, Pa2AlsaFormat( hostFormat ) ), paUnanticipatedHostError ); |
| 1797 | |
| 1798 | { |
| 1799 | /* It happens that this call fails because the device is busy */ |
| 1800 | int ret = 0; |
| 1801 | if( ( ret = alsa_snd_pcm_hw_paramscxx . . $ alsa_snd_pcm_hw_params.( pcm, hwParams ) ) < 0 ) |
| 1802 | { |
| 1803 | if( -EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`! == ret ) |
| 1804 | { |
| 1805 | /* Don't know what to return here */ |
| 1806 | result = paBadIODeviceCombinationcxx . . $ paBadIODeviceCombination.; |
| 1807 | goto error; |
| 1808 | } |
| 1809 | else if( -EBUSYcxx . . $ `<external>/8987895939074593727/errno-base.h:20:9`! == ret ) |
| 1810 | { |
| 1811 | result = paDeviceUnavailablecxx . . $ paDeviceUnavailable.; |
| 1812 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Device is busy\n", __FUNCTION__ )); |
| 1813 | } |
| 1814 | else |
| 1815 | { |
| 1816 | result = paUnanticipatedHostErrorcxx . . $ paUnanticipatedHostError.; |
| 1817 | } |
| 1818 | |
| 1819 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( ret, result ); |
| 1820 | } |
| 1821 | } |
| 1822 | |
| 1823 | end: |
| 1824 | if( pcm ) |
| 1825 | { |
| 1826 | alsa_snd_pcm_closecxx . . $ alsa_snd_pcm_close.( pcm ); |
| 1827 | } |
| 1828 | return result; |
| 1829 | |
| 1830 | error: |
| 1831 | goto end; |
| 1832 | } |
| 1833 | |
| 1834 | static PaErrorcxx . . $ PaError# IsFormatSupportedcxx . . $ IsFormatSupported(dbae6b543f13ee5).( struct PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi, |
| 1835 | const PaStreamParameterscxx . . $ PaStreamParameters# *inputParameters, |
| 1836 | const PaStreamParameterscxx . . $ PaStreamParameters# *outputParameters, |
| 1837 | double sampleRate ) |
| 1838 | { |
| 1839 | int inputChannelCount = 0, outputChannelCount = 0; |
| 1840 | PaSampleFormatcxx . . $ PaSampleFormat# inputSampleFormat, outputSampleFormat; |
| 1841 | PaErrorcxx . . $ PaError# result = paFormatIsSupportedcxx . . $ `external/portaudio/portaudio.h:585:9`!; |
| 1842 | |
| 1843 | if( inputParameters ) |
| 1844 | { |
| 1845 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( ValidateParameters( inputParameters, hostApi, StreamDirection_In ) ); |
| 1846 | |
| 1847 | inputChannelCount = inputParameters->channelCountcxx . . $ PaStreamParameters#channelCount.; |
| 1848 | inputSampleFormat = inputParameters->sampleFormatcxx . . $ PaStreamParameters#sampleFormat.; |
| 1849 | } |
| 1850 | |
| 1851 | if( outputParameters ) |
| 1852 | { |
| 1853 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( ValidateParameters( outputParameters, hostApi, StreamDirection_Out ) ); |
| 1854 | |
| 1855 | outputChannelCount = outputParameters->channelCountcxx . . $ PaStreamParameters#channelCount.; |
| 1856 | outputSampleFormat = outputParameters->sampleFormatcxx . . $ PaStreamParameters#sampleFormat.; |
| 1857 | } |
| 1858 | |
| 1859 | if( inputChannelCount ) |
| 1860 | { |
| 1861 | if( ( result = TestParameterscxx . . $ TestParameters(9ab7b7bab10d8cf7).( hostApi, inputParameters, sampleRate, StreamDirection_Incxx . . $ StreamDirection_In. ) ) |
| 1862 | != paNoErrorcxx . . $ paNoError. ) |
| 1863 | goto error; |
| 1864 | } |
| 1865 | if ( outputChannelCount ) |
| 1866 | { |
| 1867 | if( ( result = TestParameterscxx . . $ TestParameters(9ab7b7bab10d8cf7).( hostApi, outputParameters, sampleRate, StreamDirection_Outcxx . . $ StreamDirection_Out. ) ) |
| 1868 | != paNoErrorcxx . . $ paNoError. ) |
| 1869 | goto error; |
| 1870 | } |
| 1871 | |
| 1872 | return paFormatIsSupportedcxx . . $ `external/portaudio/portaudio.h:585:9`!; |
| 1873 | |
| 1874 | error: |
| 1875 | return result; |
| 1876 | } |
| 1877 | |
| 1878 | |
| 1879 | static PaErrorcxx . . $ PaError# PaAlsaStreamComponent_Initializecxx . . $ PaAlsaStreamComponent_Initialize(977dc296ed52bd9c).( PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent# *self, PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation# *alsaApi, |
| 1880 | const PaStreamParameterscxx . . $ PaStreamParameters# *params, StreamDirectioncxx . . $ StreamDirection# streamDir, int callbackMode ) |
| 1881 | { |
| 1882 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1883 | PaSampleFormatcxx . . $ PaSampleFormat# userSampleFormat = params->sampleFormatcxx . . $ PaStreamParameters#sampleFormat., hostSampleFormat = paNoErrorcxx . . $ paNoError.; |
| 1884 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( params->channelCount > 0 ); |
| 1885 | |
| 1886 | /* Make sure things have an initial value */ |
| 1887 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( self, 0, sizeof (PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent#) ); |
| 1888 | |
| 1889 | if( NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! == params->hostApiSpecificStreamInfocxx . . $ PaStreamParameters#hostApiSpecificStreamInfo. ) |
| 1890 | { |
| 1891 | const PaAlsaDeviceInfocxx . . $ PaAlsaDeviceInfo# *devInfo = GetDeviceInfocxx . . $ GetDeviceInfo(db6649f25e165c42).( &alsaApi->baseHostApiRepcxx . . $ PaAlsaHostApiRepresentation#baseHostApiRep., params->devicecxx . . $ PaStreamParameters#device. ); |
| 1892 | self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels. = PA_MAXcxx . . $ `external/portaudio/pa_unix_util.h:58:9`!( params->channelCount, StreamDirection_In == streamDir ? devInfo->minInputChannels |
| 1893 | : devInfo->minOutputChannels ); |
| 1894 | self->deviceIsPlugcxx . . $ $anonymous_type_c42756aa1fb35d76_1#deviceIsPlug. = devInfo->isPlugcxx . . $ PaAlsaDeviceInfo#isPlug.; |
| 1895 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Host Chans %c %i\n", __FUNCTION__, streamDir == StreamDirection_In ? 'C' : 'P', self->numHostChannels )); |
| 1896 | } |
| 1897 | else |
| 1898 | { |
| 1899 | /* We're blissfully unaware of the minimum channelCount */ |
| 1900 | self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels. = params->channelCountcxx . . $ PaStreamParameters#channelCount.; |
| 1901 | /* Check if device name does not start with hw: to determine if it is a 'plug' device */ |
| 1902 | if( strncmpcxx . . $ strncmp(fd278af2f295fa2e).( "hw:", ((PaAlsaStreamInfocxx . . $ PaAlsaStreamInfo# *)params->hostApiSpecificStreamInfocxx . . $ PaStreamParameters#hostApiSpecificStreamInfo.)->deviceStringcxx . . $ PaAlsaStreamInfo#deviceString., 3 ) != 0 ) |
| 1903 | self->deviceIsPlugcxx . . $ $anonymous_type_c42756aa1fb35d76_1#deviceIsPlug. = 1; /* An Alsa plug device, not a direct hw device */ |
| 1904 | } |
| 1905 | if( self->deviceIsPlugcxx . . $ $anonymous_type_c42756aa1fb35d76_1#deviceIsPlug. && alsaApi->alsaLibVersioncxx . . $ PaAlsaHostApiRepresentation#alsaLibVersion. < ALSA_VERSION_INTcxx . . $ `external/portaudio/pa_linux_alsa.c:89:9`!( 1, 0, 16 ) ) |
| 1906 | self->useReventFixcxx . . $ $anonymous_type_c42756aa1fb35d76_1#useReventFix. = 1; /* Prior to Alsa1.0.16, plug devices may stutter without this fix */ |
| 1907 | |
| 1908 | self->devicecxx . . $ $anonymous_type_c42756aa1fb35d76_1#device. = params->devicecxx . . $ PaStreamParameters#device.; |
| 1909 | |
| 1910 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm ) ); |
| 1911 | self->nfdscxx . . $ $anonymous_type_c42756aa1fb35d76_1#nfds. = alsa_snd_pcm_poll_descriptors_countcxx . . $ alsa_snd_pcm_poll_descriptors_count.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ); |
| 1912 | |
| 1913 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( hostSampleFormat = PaUtil_SelectClosestAvailableFormat( GetAvailableFormats( self->pcm ), userSampleFormat ) ); |
| 1914 | |
| 1915 | self->hostSampleFormatcxx . . $ $anonymous_type_c42756aa1fb35d76_1#hostSampleFormat. = hostSampleFormat; |
| 1916 | self->nativeFormatcxx . . $ $anonymous_type_c42756aa1fb35d76_1#nativeFormat. = Pa2AlsaFormatcxx . . $ Pa2AlsaFormat(659333b6cfdc828d).( hostSampleFormat ); |
| 1917 | self->hostInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#hostInterleaved. = self->userInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#userInterleaved. = !( userSampleFormat & paNonInterleavedcxx . . $ `external/portaudio/portaudio.h:495:9`! ); |
| 1918 | self->numUserChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numUserChannels. = params->channelCountcxx . . $ PaStreamParameters#channelCount.; |
| 1919 | self->streamDircxx . . $ $anonymous_type_c42756aa1fb35d76_1#streamDir. = streamDir; |
| 1920 | self->canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. = 0; |
| 1921 | self->nonMmapBuffercxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBuffer. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1922 | self->nonMmapBufferSizecxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBufferSize. = 0; |
| 1923 | |
| 1924 | if( !callbackMode && !self->userInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#userInterleaved. ) |
| 1925 | { |
| 1926 | /* Pre-allocate non-interleaved user provided buffers */ |
| 1927 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( self->userBuffers = PaUtil_AllocateMemory( sizeof (void *) * self->numUserChannels ), |
| 1928 | paInsufficientMemory ); |
| 1929 | } |
| 1930 | |
| 1931 | error: |
| 1932 | |
| 1933 | /* Log all available formats. */ |
| 1934 | if ( hostSampleFormat == paSampleFormatNotSupportedcxx . . $ paSampleFormatNotSupported. ) |
| 1935 | { |
| 1936 | LogAllAvailableFormatscxx . . $ LogAllAvailableFormats(bb145a214a065ee8).( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ); |
| 1937 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Please provide the log output to PortAudio developers, your hardware does not have any sample format implemented yet.\n", __FUNCTION__ )); |
| 1938 | } |
| 1939 | |
| 1940 | return result; |
| 1941 | } |
| 1942 | |
| 1943 | static void PaAlsaStreamComponent_Terminatecxx . . $ PaAlsaStreamComponent_Terminate(1b03962f3c64b779).( PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent# *self ) |
| 1944 | { |
| 1945 | alsa_snd_pcm_closecxx . . $ alsa_snd_pcm_close.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ); |
| 1946 | PaUtil_FreeMemorycxx . . $ PaUtil_FreeMemory(5d22bdacc48458e8).( self->userBufferscxx . . $ $anonymous_type_c42756aa1fb35d76_1#userBuffers. ); /* (Ptr can be NULL; PaUtil_FreeMemory includes a NULL check) */ |
| 1947 | PaUtil_FreeMemorycxx . . $ PaUtil_FreeMemory(5d22bdacc48458e8).( self->nonMmapBuffercxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBuffer. ); |
| 1948 | } |
| 1949 | |
| 1950 | /* |
| 1951 | static int nearbyint_(float value) { |
| 1952 | if( value - (int)value > .5 ) |
| 1953 | return (int)ceil( value ); |
| 1954 | return (int)floor( value ); |
| 1955 | } |
| 1956 | */ |
| 1957 | |
| 1958 | /** Initiate configuration, preparing for determining a period size suitable for both capture and playback components. |
| 1959 | * |
| 1960 | */ |
| 1961 | static PaErrorcxx . . $ PaError# PaAlsaStreamComponent_InitialConfigurecxx . . $ PaAlsaStreamComponent_InitialConfigure(ea850c79ec27c30d).( PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent# *self, const PaStreamParameterscxx . . $ PaStreamParameters# *params, |
| 1962 | int primeBuffers, snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t# *hwParams, double *sampleRate ) |
| 1963 | { |
| 1964 | /* Configuration consists of setting all of ALSA's parameters. |
| 1965 | * These parameters come in two flavors: hardware parameters |
| 1966 | * and software parameters. Hardware parameters will affect |
| 1967 | * the way the device is initialized, software parameters |
| 1968 | * affect the way ALSA interacts with me, the user-level client. |
| 1969 | */ |
| 1970 | |
| 1971 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 1972 | snd_pcm_access_tcxx . . $ snd_pcm_access_t# accessMode, alternateAccessMode; |
| 1973 | int dir = 0; |
| 1974 | snd_pcm_tcxx . . $ snd_pcm_t# *pcm = self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm.; |
| 1975 | double sr = *sampleRate; |
| 1976 | unsigned int minPeriods = 2; |
| 1977 | |
| 1978 | /* self->framesPerPeriod = framesPerHostBuffer; */ |
| 1979 | |
| 1980 | /* ... fill up the configuration space with all possible |
| 1981 | * combinations of parameters this device will accept */ |
| 1982 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_any( pcm, hwParams ), paUnanticipatedHostError ); |
| 1983 | |
| 1984 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_periods_integer( pcm, hwParams ), paUnanticipatedHostError ); |
| 1985 | /* I think there should be at least 2 periods (even though ALSA doesn't appear to enforce this) */ |
| 1986 | dir = 0; |
| 1987 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_periods_min( pcm, hwParams, &minPeriods, &dir ), paUnanticipatedHostError ); |
| 1988 | |
| 1989 | if( self->userInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#userInterleaved. ) |
| 1990 | { |
| 1991 | accessMode = SND_PCM_ACCESS_MMAP_INTERLEAVEDcxx . . $ SND_PCM_ACCESS_MMAP_INTERLEAVED.; |
| 1992 | alternateAccessMode = SND_PCM_ACCESS_MMAP_NONINTERLEAVEDcxx . . $ SND_PCM_ACCESS_MMAP_NONINTERLEAVED.; |
| 1993 | |
| 1994 | /* test if MMAP supported */ |
| 1995 | self->canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. = alsa_snd_pcm_hw_params_test_accesscxx . . $ alsa_snd_pcm_hw_params_test_access.( pcm, hwParams, accessMode ) >= 0 || |
| 1996 | alsa_snd_pcm_hw_params_test_accesscxx . . $ alsa_snd_pcm_hw_params_test_access.( pcm, hwParams, alternateAccessMode ) >= 0; |
| 1997 | |
| 1998 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: device MMAP SND_PCM_ACCESS_MMAP_INTERLEAVED: %s\n", __FUNCTION__, ( alsa_snd_pcm_hw_params_test_access( pcm, hwParams, accessMode ) >= 0 ? "YES" : "NO" ) )); |
| 1999 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: device MMAP SND_PCM_ACCESS_MMAP_NONINTERLEAVED: %s\n", __FUNCTION__, ( alsa_snd_pcm_hw_params_test_access( pcm, hwParams, alternateAccessMode ) >= 0 ? "YES" : "NO" ) )); |
| 2000 | |
| 2001 | if( !self->canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. ) |
| 2002 | { |
| 2003 | accessMode = SND_PCM_ACCESS_RW_INTERLEAVEDcxx . . $ SND_PCM_ACCESS_RW_INTERLEAVED.; |
| 2004 | alternateAccessMode = SND_PCM_ACCESS_RW_NONINTERLEAVEDcxx . . $ SND_PCM_ACCESS_RW_NONINTERLEAVED.; |
| 2005 | } |
| 2006 | } |
| 2007 | else |
| 2008 | { |
| 2009 | accessMode = SND_PCM_ACCESS_MMAP_NONINTERLEAVEDcxx . . $ SND_PCM_ACCESS_MMAP_NONINTERLEAVED.; |
| 2010 | alternateAccessMode = SND_PCM_ACCESS_MMAP_INTERLEAVEDcxx . . $ SND_PCM_ACCESS_MMAP_INTERLEAVED.; |
| 2011 | |
| 2012 | /* test if MMAP supported */ |
| 2013 | self->canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. = alsa_snd_pcm_hw_params_test_accesscxx . . $ alsa_snd_pcm_hw_params_test_access.( pcm, hwParams, accessMode ) >= 0 || |
| 2014 | alsa_snd_pcm_hw_params_test_accesscxx . . $ alsa_snd_pcm_hw_params_test_access.( pcm, hwParams, alternateAccessMode ) >= 0; |
| 2015 | |
| 2016 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!((" %s: device MMAP SND_PCM_ACCESS_MMAP_NONINTERLEAVED: %s\n", __FUNCTION__, ( alsa_snd_pcm_hw_params_test_access( pcm, hwParams, accessMode ) >= 0 ? "YES" : "NO" ) )); |
| 2017 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: device MMAP SND_PCM_ACCESS_MMAP_INTERLEAVED: %s\n", __FUNCTION__, ( alsa_snd_pcm_hw_params_test_access( pcm, hwParams, alternateAccessMode ) >= 0 ? "YES" : "NO" ) )); |
| 2018 | |
| 2019 | if( !self->canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. ) |
| 2020 | { |
| 2021 | accessMode = SND_PCM_ACCESS_RW_NONINTERLEAVEDcxx . . $ SND_PCM_ACCESS_RW_NONINTERLEAVED.; |
| 2022 | alternateAccessMode = SND_PCM_ACCESS_RW_INTERLEAVEDcxx . . $ SND_PCM_ACCESS_RW_INTERLEAVED.; |
| 2023 | } |
| 2024 | } |
| 2025 | |
| 2026 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: device can MMAP: %s\n", __FUNCTION__, ( self->canMmap ? "YES" : "NO" ) )); |
| 2027 | |
| 2028 | /* If requested access mode fails, try alternate mode */ |
| 2029 | if( alsa_snd_pcm_hw_params_set_accesscxx . . $ alsa_snd_pcm_hw_params_set_access.( pcm, hwParams, accessMode ) < 0 ) |
| 2030 | { |
| 2031 | int err = 0; |
| 2032 | if( ( err = alsa_snd_pcm_hw_params_set_accesscxx . . $ alsa_snd_pcm_hw_params_set_access.( pcm, hwParams, alternateAccessMode )) < 0 ) |
| 2033 | { |
| 2034 | result = paUnanticipatedHostErrorcxx . . $ paUnanticipatedHostError.; |
| 2035 | PaUtil_SetLastHostErrorInfocxx . . $ PaUtil_SetLastHostErrorInfo(3000fca3c08738dd).( paALSAcxx . . $ paALSA., err, alsa_snd_strerrorcxx . . $ alsa_snd_strerror.( err ) ); |
| 2036 | goto error; |
| 2037 | } |
| 2038 | /* Flip mode */ |
| 2039 | self->hostInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#hostInterleaved. = !self->userInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#userInterleaved.; |
| 2040 | } |
| 2041 | |
| 2042 | /* Some specific hardware (reported: Audio8 DJ) can fail with assertion during this step. */ |
| 2043 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_format( pcm, hwParams, self->nativeFormat ), paUnanticipatedHostError ); |
| 2044 | |
| 2045 | if( ( result = SetApproximateSampleRatecxx . . $ SetApproximateSampleRate(95b810ef3c6fd091).( pcm, hwParams, sr )) != paUnanticipatedHostErrorcxx . . $ paUnanticipatedHostError. ) |
| 2046 | { |
| 2047 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( GetExactSampleRate( hwParams, &sr ), paUnanticipatedHostError ); |
| 2048 | if( result == paInvalidSampleRatecxx . . $ paInvalidSampleRate. ) /* From the SetApproximateSampleRate() call above */ |
| 2049 | { /* The sample rate was returned as 'out of tolerance' of the one requested */ |
| 2050 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Wanted %.3f, closest sample rate was %.3f\n", __FUNCTION__, sampleRate, sr )); |
| 2051 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( paInvalidSampleRate ); |
| 2052 | } |
| 2053 | } |
| 2054 | else |
| 2055 | { |
| 2056 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( paUnanticipatedHostError ); |
| 2057 | } |
| 2058 | |
| 2059 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_channels( pcm, hwParams, self->numHostChannels ), paInvalidChannelCount ); |
| 2060 | |
| 2061 | *sampleRate = sr; |
| 2062 | |
| 2063 | end: |
| 2064 | return result; |
| 2065 | |
| 2066 | error: |
| 2067 | /* No particular action */ |
| 2068 | goto end; |
| 2069 | } |
| 2070 | |
| 2071 | /** Finish the configuration of the component's ALSA device. |
| 2072 | * |
| 2073 | * As part of this method, the component's alsaBufferSize attribute will be set. |
| 2074 | * @param latency: The latency for this component. |
| 2075 | */ |
| 2076 | static PaErrorcxx . . $ PaError# PaAlsaStreamComponent_FinishConfigurecxx . . $ PaAlsaStreamComponent_FinishConfigure(453c8f9338324e42).( PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent# *self, snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t#* hwParams, |
| 2077 | const PaStreamParameterscxx . . $ PaStreamParameters# *params, int primeBuffers, double sampleRate, PaTimecxx . . $ PaTime#* latency ) |
| 2078 | { |
| 2079 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 2080 | snd_pcm_sw_params_tcxx . . $ snd_pcm_sw_params_t#* swParams; |
| 2081 | snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t# bufSz = 0; |
| 2082 | *latency = -1.; |
| 2083 | |
| 2084 | alsa_snd_pcm_sw_params_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:186:9`!( &swParams ); |
| 2085 | |
| 2086 | bufSz = params->suggestedLatencycxx . . $ PaStreamParameters#suggestedLatency. * sampleRate + self->framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod.; |
| 2087 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_buffer_size_near( self->pcm, hwParams, &bufSz ), paUnanticipatedHostError ); |
| 2088 | |
| 2089 | /* Set the parameters! */ |
| 2090 | { |
| 2091 | int r = alsa_snd_pcm_hw_paramscxx . . $ alsa_snd_pcm_hw_params.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., hwParams ); |
| 2092 | #ifdef PA_ENABLE_DEBUG_OUTPUT |
| 2093 | if( r < 0 ) |
| 2094 | { |
| 2095 | snd_output_t *output = NULL; |
| 2096 | alsa_snd_output_stdio_attach( &output, stderr, 0 ); |
| 2097 | alsa_snd_pcm_hw_params_dump( hwParams, output ); |
| 2098 | } |
| 2099 | #endif |
| 2100 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( r, paUnanticipatedHostError ); |
| 2101 | } |
| 2102 | if( alsa_snd_pcm_hw_params_get_buffer_sizecxx . . $ alsa_snd_pcm_hw_params_get_buffer_size. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 2103 | { |
| 2104 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_buffer_size( hwParams, &self->alsaBufferSize ), paUnanticipatedHostError ); |
| 2105 | } |
| 2106 | else |
| 2107 | { |
| 2108 | self->alsaBufferSizecxx . . $ $anonymous_type_c42756aa1fb35d76_1#alsaBufferSize. = bufSz; |
| 2109 | } |
| 2110 | |
| 2111 | /* Latency in seconds */ |
| 2112 | *latency = (self->alsaBufferSizecxx . . $ $anonymous_type_c42756aa1fb35d76_1#alsaBufferSize. - self->framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod.) / sampleRate; |
| 2113 | |
| 2114 | /* Now software parameters... */ |
| 2115 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_sw_params_current( self->pcm, swParams ), paUnanticipatedHostError ); |
| 2116 | |
| 2117 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_sw_params_set_start_threshold( self->pcm, swParams, self->framesPerPeriod ), paUnanticipatedHostError ); |
| 2118 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_sw_params_set_stop_threshold( self->pcm, swParams, self->alsaBufferSize ), paUnanticipatedHostError ); |
| 2119 | |
| 2120 | /* Silence buffer in the case of underrun */ |
| 2121 | if( !primeBuffers ) /* XXX: Make sense? */ |
| 2122 | { |
| 2123 | snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t# boundary; |
| 2124 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_sw_params_get_boundary( swParams, &boundary ), paUnanticipatedHostError ); |
| 2125 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_sw_params_set_silence_threshold( self->pcm, swParams, 0 ), paUnanticipatedHostError ); |
| 2126 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_sw_params_set_silence_size( self->pcm, swParams, boundary ), paUnanticipatedHostError ); |
| 2127 | } |
| 2128 | |
| 2129 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_sw_params_set_avail_min( self->pcm, swParams, self->framesPerPeriod ), paUnanticipatedHostError ); |
| 2130 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_sw_params_set_xfer_align( self->pcm, swParams, 1 ), paUnanticipatedHostError ); |
| 2131 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_sw_params_set_tstamp_mode( self->pcm, swParams, SND_PCM_TSTAMP_ENABLEcxx . . $ `external/portaudio/pa_linux_alsa.c:85:13`! ), paUnanticipatedHostError ); |
| 2132 | |
| 2133 | /* Set the parameters! */ |
| 2134 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_sw_params( self->pcm, swParams ), paUnanticipatedHostError ); |
| 2135 | |
| 2136 | error: |
| 2137 | return result; |
| 2138 | } |
| 2139 | |
| 2140 | static PaErrorcxx . . $ PaError# PaAlsaStream_Initializecxx . . $ PaAlsaStream_Initialize(f5a5d153a7c66770).( PaAlsaStreamcxx . . $ PaAlsaStream# *self, PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation# *alsaApi, const PaStreamParameterscxx . . $ PaStreamParameters# *inParams, |
| 2141 | const PaStreamParameterscxx . . $ PaStreamParameters# *outParams, double sampleRate, unsigned long framesPerUserBuffer, PaStreamCallbackcxx . . $ PaStreamCallback# callback, |
| 2142 | PaStreamFlagscxx . . $ PaStreamFlags# streamFlags, void *userData ) |
| 2143 | { |
| 2144 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 2145 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self ); |
| 2146 | |
| 2147 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( self, 0, sizeof( PaAlsaStreamcxx . . $ PaAlsaStream# ) ); |
| 2148 | |
| 2149 | if( NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! != callback ) |
| 2150 | { |
| 2151 | PaUtil_InitializeStreamRepresentationcxx . . $ PaUtil_InitializeStreamRepresentation(7f7193855de7d48b).( &self->streamRepresentationcxx . . $ PaAlsaStream#streamRepresentation., |
| 2152 | &alsaApi->callbackStreamInterfacecxx . . $ PaAlsaHostApiRepresentation#callbackStreamInterface., |
| 2153 | callback, userData ); |
| 2154 | self->callbackModecxx . . $ PaAlsaStream#callbackMode. = 1; |
| 2155 | } |
| 2156 | else |
| 2157 | { |
| 2158 | PaUtil_InitializeStreamRepresentationcxx . . $ PaUtil_InitializeStreamRepresentation(7f7193855de7d48b).( &self->streamRepresentationcxx . . $ PaAlsaStream#streamRepresentation., |
| 2159 | &alsaApi->blockingStreamInterfacecxx . . $ PaAlsaHostApiRepresentation#blockingStreamInterface., |
| 2160 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, userData ); |
| 2161 | } |
| 2162 | |
| 2163 | self->framesPerUserBuffercxx . . $ PaAlsaStream#framesPerUserBuffer. = framesPerUserBuffer; |
| 2164 | self->neverDropInputcxx . . $ PaAlsaStream#neverDropInput. = streamFlags & paNeverDropInputcxx . . $ `external/portaudio/portaudio.h:677:11`!; |
| 2165 | /* XXX: Ignore paPrimeOutputBuffersUsingStreamCallback until buffer priming is fully supported in pa_process.c */ |
| 2166 | /* |
| 2167 | if( outParams & streamFlags & paPrimeOutputBuffersUsingStreamCallback ) |
| 2168 | self->primeBuffers = 1; |
| 2169 | */ |
| 2170 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( &self->capturecxx . . $ PaAlsaStream#capture., 0, sizeof (PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent#) ); |
| 2171 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( &self->playbackcxx . . $ PaAlsaStream#playback., 0, sizeof (PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent#) ); |
| 2172 | if( inParams ) |
| 2173 | { |
| 2174 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_Initialize( &self->capture, alsaApi, inParams, StreamDirection_In, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! != callback ) ); |
| 2175 | } |
| 2176 | if( outParams ) |
| 2177 | { |
| 2178 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_Initialize( &self->playback, alsaApi, outParams, StreamDirection_Out, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! != callback ) ); |
| 2179 | } |
| 2180 | |
| 2181 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self->capture.nfds || self->playback.nfds ); |
| 2182 | |
| 2183 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( self->pfds = (struct pollfd*)PaUtil_AllocateMemory( ( self->capture.nfds + |
| 2184 | self->playback.nfds ) * sizeof( struct pollfd ) ), paInsufficientMemory ); |
| 2185 | |
| 2186 | PaUtil_InitializeCpuLoadMeasurercxx . . $ PaUtil_InitializeCpuLoadMeasurer(dc72d8645bcc5215).( &self->cpuLoadMeasurercxx . . $ PaAlsaStream#cpuLoadMeasurer., sampleRate ); |
| 2187 | ASSERT_CALL_cxx . . $ `external/portaudio/pa_linux_alsa.c:583:9`!( PaUnixMutex_Initialize( &self->stateMtx ), paNoError ); |
| 2188 | |
| 2189 | error: |
| 2190 | return result; |
| 2191 | } |
| 2192 | |
| 2193 | /** Free resources associated with stream, and eventually stream itself. |
| 2194 | * |
| 2195 | * Frees allocated memory, and terminates individual StreamComponents. |
| 2196 | */ |
| 2197 | static void PaAlsaStream_Terminatecxx . . $ PaAlsaStream_Terminate(e8e0d294f8fc0971).( PaAlsaStreamcxx . . $ PaAlsaStream# *self ) |
| 2198 | { |
| 2199 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self ); |
| 2200 | |
| 2201 | if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 2202 | { |
| 2203 | PaAlsaStreamComponent_Terminatecxx . . $ PaAlsaStreamComponent_Terminate(1b03962f3c64b779).( &self->capturecxx . . $ PaAlsaStream#capture. ); |
| 2204 | } |
| 2205 | if( self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 2206 | { |
| 2207 | PaAlsaStreamComponent_Terminatecxx . . $ PaAlsaStreamComponent_Terminate(1b03962f3c64b779).( &self->playbackcxx . . $ PaAlsaStream#playback. ); |
| 2208 | } |
| 2209 | |
| 2210 | PaUtil_FreeMemorycxx . . $ PaUtil_FreeMemory(5d22bdacc48458e8).( self->pfdscxx . . $ PaAlsaStream#pfds. ); |
| 2211 | ASSERT_CALL_cxx . . $ `external/portaudio/pa_linux_alsa.c:583:9`!( PaUnixMutex_Terminate( &self->stateMtx ), paNoError ); |
| 2212 | |
| 2213 | PaUtil_FreeMemorycxx . . $ PaUtil_FreeMemory(5d22bdacc48458e8).( self ); |
| 2214 | } |
| 2215 | |
| 2216 | /** Calculate polling timeout |
| 2217 | * |
| 2218 | * @param frames Time to wait |
| 2219 | * @return Polling timeout in milliseconds |
| 2220 | */ |
| 2221 | static int CalculatePollTimeoutcxx . . $ CalculatePollTimeout(c2605310b54a7632).( const PaAlsaStreamcxx . . $ PaAlsaStream# *stream, unsigned long frames ) |
| 2222 | { |
| 2223 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( stream->streamRepresentation.streamInfo.sampleRate > 0.0 ); |
| 2224 | /* Period in msecs, rounded up */ |
| 2225 | return (int)ceilcxx . . $ ceil(447c67c6676f75c3).( 1000 * frames / stream->streamRepresentationcxx . . $ PaAlsaStream#streamRepresentation..streamInfocxx . . $ PaUtilStreamRepresentation#streamInfo..sampleRatecxx . . $ PaStreamInfo#sampleRate. ); |
| 2226 | } |
| 2227 | |
| 2228 | /** Align value in backward direction. |
| 2229 | * |
| 2230 | * @param v: Value to align. |
| 2231 | * @param align: Alignment. |
| 2232 | */ |
| 2233 | static unsigned long PaAlsa_AlignBackwardcxx . . $ PaAlsa_AlignBackward(80bad76eed2d2579).(unsigned long v, unsigned long align) |
| 2234 | { |
| 2235 | return ( v - ( align ? v % align : 0 ) ); |
| 2236 | } |
| 2237 | |
| 2238 | /** Align value in forward direction. |
| 2239 | * |
| 2240 | * @param v: Value to align. |
| 2241 | * @param align: Alignment. |
| 2242 | */ |
| 2243 | static unsigned long PaAlsa_AlignForwardcxx . . $ PaAlsa_AlignForward(80bad76eed2d2579).(unsigned long v, unsigned long align) |
| 2244 | { |
| 2245 | unsigned long remainder = ( align ? ( v % align ) : 0); |
| 2246 | return ( remainder != 0 ? v + ( align - remainder ) : v ); |
| 2247 | } |
| 2248 | |
| 2249 | /** Get size of host buffer maintained from the number of user frames, sample rate and suggested latency. Minimum double buffering |
| 2250 | * is maintained to allow 100% CPU usage inside user callback. |
| 2251 | * |
| 2252 | * @param userFramesPerBuffer: User buffer size in number of frames. |
| 2253 | * @param suggestedLatency: User provided desired latency. |
| 2254 | * @param sampleRate: Sample rate. |
| 2255 | */ |
| 2256 | static unsigned long PaAlsa_GetFramesPerHostBuffercxx . . $ PaAlsa_GetFramesPerHostBuffer(159c02a17bce4e8c).(unsigned long userFramesPerBuffer, PaTimecxx . . $ PaTime# suggestedLatency, double sampleRate) |
| 2257 | { |
| 2258 | unsigned long frames = userFramesPerBuffer + PA_MAXcxx . . $ `external/portaudio/pa_unix_util.h:58:9`!( userFramesPerBuffer, (unsigned long)( suggestedLatency * sampleRate ) ); |
| 2259 | return frames; |
| 2260 | } |
| 2261 | |
| 2262 | /** Determine size per host buffer. |
| 2263 | * |
| 2264 | * During this method call, the component's framesPerPeriod attribute gets computed, and the corresponding period size |
| 2265 | * gets configured for the device. |
| 2266 | * @param accurate: If the configured period size is non-integer, this will be set to 0. |
| 2267 | */ |
| 2268 | static PaErrorcxx . . $ PaError# PaAlsaStreamComponent_DetermineFramesPerBuffercxx . . $ PaAlsaStreamComponent_DetermineFramesPerBuffer(65efe00106908ebd).( PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent#* self, const PaStreamParameterscxx . . $ PaStreamParameters#* params, |
| 2269 | unsigned long framesPerUserBuffer, double sampleRate, snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t#* hwParams, int* accurate ) |
| 2270 | { |
| 2271 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 2272 | unsigned long bufferSize, framesPerHostBuffer; |
| 2273 | int dir = 0; |
| 2274 | |
| 2275 | /* Calculate host buffer size */ |
| 2276 | bufferSize = PaAlsa_GetFramesPerHostBuffercxx . . $ PaAlsa_GetFramesPerHostBuffer(159c02a17bce4e8c).(framesPerUserBuffer, params->suggestedLatencycxx . . $ PaStreamParameters#suggestedLatency., sampleRate); |
| 2277 | |
| 2278 | /* Log */ |
| 2279 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: user-buffer (frames) = %lu\n", __FUNCTION__, framesPerUserBuffer )); |
| 2280 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: user-buffer (sec) = %f\n", __FUNCTION__, (double)(framesPerUserBuffer / sampleRate) )); |
| 2281 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: suggested latency (sec) = %f\n", __FUNCTION__, params->suggestedLatency )); |
| 2282 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: suggested host buffer (frames) = %lu\n", __FUNCTION__, bufferSize )); |
| 2283 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: suggested host buffer (sec) = %f\n", __FUNCTION__, (double)(bufferSize / sampleRate) )); |
| 2284 | |
| 2285 | #ifdef PA_ALSA_USE_OBSOLETE_HOST_BUFFER_CALC |
| 2286 | |
| 2287 | if( framesPerUserBuffer != paFramesPerBufferUnspecified ) |
| 2288 | { |
| 2289 | /* Preferably the host buffer size should be a multiple of the user buffer size */ |
| 2290 | |
| 2291 | if( bufferSize > framesPerUserBuffer ) |
| 2292 | { |
| 2293 | snd_pcm_uframes_t remainder = bufferSize % framesPerUserBuffer; |
| 2294 | if( remainder > framesPerUserBuffer / 2. ) |
| 2295 | bufferSize += framesPerUserBuffer - remainder; |
| 2296 | else |
| 2297 | bufferSize -= remainder; |
| 2298 | |
| 2299 | assert( bufferSize % framesPerUserBuffer == 0 ); |
| 2300 | } |
| 2301 | else if( framesPerUserBuffer % bufferSize != 0 ) |
| 2302 | { |
| 2303 | /* Find a good compromise between user specified latency and buffer size */ |
| 2304 | if( bufferSize > framesPerUserBuffer * .75 ) |
| 2305 | { |
| 2306 | bufferSize = framesPerUserBuffer; |
| 2307 | } |
| 2308 | else |
| 2309 | { |
| 2310 | snd_pcm_uframes_t newSz = framesPerUserBuffer; |
| 2311 | while( newSz / 2 >= bufferSize ) |
| 2312 | { |
| 2313 | if( framesPerUserBuffer % (newSz / 2) != 0 ) |
| 2314 | { |
| 2315 | /* No use dividing any further */ |
| 2316 | break; |
| 2317 | } |
| 2318 | newSz /= 2; |
| 2319 | } |
| 2320 | bufferSize = newSz; |
| 2321 | } |
| 2322 | |
| 2323 | assert( framesPerUserBuffer % bufferSize == 0 ); |
| 2324 | } |
| 2325 | } |
| 2326 | |
| 2327 | #endif |
| 2328 | |
| 2329 | { |
| 2330 | unsigned numPeriods = numPeriods_cxx . . $ numPeriods_., maxPeriods = 0, minPeriods = numPeriods_cxx . . $ numPeriods_.; |
| 2331 | |
| 2332 | /* It may be that the device only supports 2 periods for instance */ |
| 2333 | dir = 0; |
| 2334 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_periods_min( hwParams, &minPeriods, &dir ), paUnanticipatedHostError ); |
| 2335 | dir = 0; |
| 2336 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_periods_max( hwParams, &maxPeriods, &dir ), paUnanticipatedHostError ); |
| 2337 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( maxPeriods > 1 ); |
| 2338 | |
| 2339 | /* Clamp to min/max */ |
| 2340 | numPeriods = PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!(maxPeriods, PA_MAXcxx . . $ `external/portaudio/pa_unix_util.h:58:9`!(minPeriods, numPeriods)); |
| 2341 | |
| 2342 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: periods min = %lu, max = %lu, req = %lu \n", __FUNCTION__, minPeriods, maxPeriods, numPeriods )); |
| 2343 | |
| 2344 | #ifndef PA_ALSA_USE_OBSOLETE_HOST_BUFFER_CALC |
| 2345 | |
| 2346 | /* Calculate period size */ |
| 2347 | framesPerHostBuffer = (bufferSize / numPeriods); |
| 2348 | |
| 2349 | /* Align & test size */ |
| 2350 | if( framesPerUserBuffer != paFramesPerBufferUnspecifiedcxx . . $ `external/portaudio/portaudio.h:642:9`! ) |
| 2351 | { |
| 2352 | /* Align to user buffer size */ |
| 2353 | framesPerHostBuffer = PaAlsa_AlignForwardcxx . . $ PaAlsa_AlignForward(80bad76eed2d2579).(framesPerHostBuffer, framesPerUserBuffer); |
| 2354 | |
| 2355 | /* Test (borrowed from older implementation) */ |
| 2356 | if( framesPerHostBuffer < framesPerUserBuffer ) |
| 2357 | { |
| 2358 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( framesPerUserBuffer % framesPerHostBuffer == 0 ); |
| 2359 | if( alsa_snd_pcm_hw_params_test_period_sizecxx . . $ alsa_snd_pcm_hw_params_test_period_size.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., hwParams, framesPerHostBuffer, 0 ) < 0 ) |
| 2360 | { |
| 2361 | if( alsa_snd_pcm_hw_params_test_period_sizecxx . . $ alsa_snd_pcm_hw_params_test_period_size.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., hwParams, framesPerHostBuffer * 2, 0 ) == 0 ) |
| 2362 | framesPerHostBuffer *= 2; |
| 2363 | else if( alsa_snd_pcm_hw_params_test_period_sizecxx . . $ alsa_snd_pcm_hw_params_test_period_size.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., hwParams, framesPerHostBuffer / 2, 0 ) == 0 ) |
| 2364 | framesPerHostBuffer /= 2; |
| 2365 | } |
| 2366 | } |
| 2367 | else |
| 2368 | { |
| 2369 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( framesPerHostBuffer % framesPerUserBuffer == 0 ); |
| 2370 | if( alsa_snd_pcm_hw_params_test_period_sizecxx . . $ alsa_snd_pcm_hw_params_test_period_size.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., hwParams, framesPerHostBuffer, 0 ) < 0 ) |
| 2371 | { |
| 2372 | if( alsa_snd_pcm_hw_params_test_period_sizecxx . . $ alsa_snd_pcm_hw_params_test_period_size.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., hwParams, framesPerHostBuffer + framesPerUserBuffer, 0 ) == 0 ) |
| 2373 | framesPerHostBuffer += framesPerUserBuffer; |
| 2374 | else if( alsa_snd_pcm_hw_params_test_period_sizecxx . . $ alsa_snd_pcm_hw_params_test_period_size.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., hwParams, framesPerHostBuffer - framesPerUserBuffer, 0 ) == 0 ) |
| 2375 | framesPerHostBuffer -= framesPerUserBuffer; |
| 2376 | } |
| 2377 | } |
| 2378 | } |
| 2379 | #endif |
| 2380 | |
| 2381 | #ifdef PA_ALSA_USE_OBSOLETE_HOST_BUFFER_CALC |
| 2382 | |
| 2383 | if( framesPerUserBuffer != paFramesPerBufferUnspecified ) |
| 2384 | { |
| 2385 | /* Try to get a power-of-two of the user buffer size. */ |
| 2386 | framesPerHostBuffer = framesPerUserBuffer; |
| 2387 | if( framesPerHostBuffer < bufferSize ) |
| 2388 | { |
| 2389 | while( bufferSize / framesPerHostBuffer > numPeriods ) |
| 2390 | { |
| 2391 | framesPerHostBuffer *= 2; |
| 2392 | } |
| 2393 | /* One extra period is preferable to one less (should be more robust) */ |
| 2394 | if( bufferSize / framesPerHostBuffer < numPeriods ) |
| 2395 | { |
| 2396 | framesPerHostBuffer /= 2; |
| 2397 | } |
| 2398 | } |
| 2399 | else |
| 2400 | { |
| 2401 | while( bufferSize / framesPerHostBuffer < numPeriods ) |
| 2402 | { |
| 2403 | if( framesPerUserBuffer % ( framesPerHostBuffer / 2 ) != 0 ) |
| 2404 | { |
| 2405 | /* Can't be divided any further */ |
| 2406 | break; |
| 2407 | } |
| 2408 | framesPerHostBuffer /= 2; |
| 2409 | } |
| 2410 | } |
| 2411 | |
| 2412 | if( framesPerHostBuffer < framesPerUserBuffer ) |
| 2413 | { |
| 2414 | assert( framesPerUserBuffer % framesPerHostBuffer == 0 ); |
| 2415 | if( alsa_snd_pcm_hw_params_test_period_size( self->pcm, hwParams, framesPerHostBuffer, 0 ) < 0 ) |
| 2416 | { |
| 2417 | if( alsa_snd_pcm_hw_params_test_period_size( self->pcm, hwParams, framesPerHostBuffer * 2, 0 ) == 0 ) |
| 2418 | framesPerHostBuffer *= 2; |
| 2419 | else if( alsa_snd_pcm_hw_params_test_period_size( self->pcm, hwParams, framesPerHostBuffer / 2, 0 ) == 0 ) |
| 2420 | framesPerHostBuffer /= 2; |
| 2421 | } |
| 2422 | } |
| 2423 | else |
| 2424 | { |
| 2425 | assert( framesPerHostBuffer % framesPerUserBuffer == 0 ); |
| 2426 | if( alsa_snd_pcm_hw_params_test_period_size( self->pcm, hwParams, framesPerHostBuffer, 0 ) < 0 ) |
| 2427 | { |
| 2428 | if( alsa_snd_pcm_hw_params_test_period_size( self->pcm, hwParams, framesPerHostBuffer + framesPerUserBuffer, 0 ) == 0 ) |
| 2429 | framesPerHostBuffer += framesPerUserBuffer; |
| 2430 | else if( alsa_snd_pcm_hw_params_test_period_size( self->pcm, hwParams, framesPerHostBuffer - framesPerUserBuffer, 0 ) == 0 ) |
| 2431 | framesPerHostBuffer -= framesPerUserBuffer; |
| 2432 | } |
| 2433 | } |
| 2434 | } |
| 2435 | else |
| 2436 | { |
| 2437 | framesPerHostBuffer = bufferSize / numPeriods; |
| 2438 | } |
| 2439 | |
| 2440 | /* non-mmap mode needs a reasonably-sized buffer or it'll stutter */ |
| 2441 | if( !self->canMmap && framesPerHostBuffer < 2048 ) |
| 2442 | framesPerHostBuffer = 2048; |
| 2443 | #endif |
| 2444 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: suggested host buffer period = %lu \n", __FUNCTION__, framesPerHostBuffer )); |
| 2445 | } |
| 2446 | |
| 2447 | { |
| 2448 | /* Get min/max period sizes and adjust our chosen */ |
| 2449 | snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t# min = 0, max = 0, minmax_diff; |
| 2450 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_period_size_min( hwParams, &min, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ), paUnanticipatedHostError ); |
| 2451 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_period_size_max( hwParams, &max, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ), paUnanticipatedHostError ); |
| 2452 | minmax_diff = max - min; |
| 2453 | |
| 2454 | if( framesPerHostBuffer < min ) |
| 2455 | { |
| 2456 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: The determined period size (%lu) is less than minimum (%lu)\n", __FUNCTION__, framesPerHostBuffer, min )); |
| 2457 | framesPerHostBuffer = (( minmax_diff == 2 ) ? min + 1 : min ); |
| 2458 | } |
| 2459 | else if( framesPerHostBuffer > max ) |
| 2460 | { |
| 2461 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: The determined period size (%lu) is greater than maximum (%lu)\n", __FUNCTION__, framesPerHostBuffer, max )); |
| 2462 | framesPerHostBuffer = (( minmax_diff == 2 ) ? max - 1 : max ); |
| 2463 | } |
| 2464 | |
| 2465 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: device period minimum = %lu\n", __FUNCTION__, min )); |
| 2466 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: device period maximum = %lu\n", __FUNCTION__, max )); |
| 2467 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: host buffer period = %lu\n", __FUNCTION__, framesPerHostBuffer )); |
| 2468 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: host buffer period latency = %f\n", __FUNCTION__, (double)( framesPerHostBuffer / sampleRate ) )); |
| 2469 | |
| 2470 | /* Try setting period size */ |
| 2471 | dir = 0; |
| 2472 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_period_size_near( self->pcm, hwParams, &framesPerHostBuffer, &dir ), paUnanticipatedHostError ); |
| 2473 | if( dir != 0 ) |
| 2474 | { |
| 2475 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: The configured period size is non-integer.\n", __FUNCTION__, dir )); |
| 2476 | *accurate = 0; |
| 2477 | } |
| 2478 | } |
| 2479 | |
| 2480 | /* Set result */ |
| 2481 | self->framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod. = framesPerHostBuffer; |
| 2482 | |
| 2483 | error: |
| 2484 | return result; |
| 2485 | } |
| 2486 | |
| 2487 | /* We need to determine how many frames per host buffer (period) to use. Our |
| 2488 | * goals are to provide the best possible performance, but also to |
| 2489 | * honor the requested latency settings as closely as we can. Therefore this |
| 2490 | * decision is based on: |
| 2491 | * |
| 2492 | * - the period sizes that playback and/or capture support. The |
| 2493 | * host buffer size has to be one of these. |
| 2494 | * - the number of periods that playback and/or capture support. |
| 2495 | * |
| 2496 | * We want to make period_size*(num_periods-1) to be as close as possible |
| 2497 | * to latency*rate for both playback and capture. |
| 2498 | * |
| 2499 | * This method will determine suitable period sizes for capture and playback handles, and report the maximum number of |
| 2500 | * frames per host buffer. The latter is relevant, in case we should be so unfortunate that the period size differs |
| 2501 | * between capture and playback. If this should happen, the stream's hostBufferSizeMode attribute will be set to |
| 2502 | * paUtilBoundedHostBufferSize, because the best we can do is limit the size of individual host buffers to the upper |
| 2503 | * bound. The size of host buffers scheduled for processing should only matter if the user has specified a buffer size, |
| 2504 | * but when he/she does we must strive for an optimal configuration. By default we'll opt for a fixed host buffer size, |
| 2505 | * which should be fine if the period size is the same for capture and playback. In general, if there is a specified user |
| 2506 | * buffer size, this method tries it best to determine a period size which is a multiple of the user buffer size. |
| 2507 | * |
| 2508 | * The framesPerPeriod attributes of the individual capture and playback components of the stream are set to corresponding |
| 2509 | * values determined here. Since these should be reported as |
| 2510 | * |
| 2511 | * This is one of those blocks of code that will just take a lot of |
| 2512 | * refinement to be any good. |
| 2513 | * |
| 2514 | * In the full-duplex case it is possible that the routine was unable |
| 2515 | * to find a number of frames per buffer acceptable to both devices |
| 2516 | * TODO: Implement an algorithm to find the value closest to acceptance |
| 2517 | * by both devices, to minimize difference between period sizes? |
| 2518 | * |
| 2519 | * @param determinedFramesPerHostBuffer: The determined host buffer size. |
| 2520 | */ |
| 2521 | static PaErrorcxx . . $ PaError# PaAlsaStream_DetermineFramesPerBuffercxx . . $ PaAlsaStream_DetermineFramesPerBuffer(411b1cf855859765).( PaAlsaStreamcxx . . $ PaAlsaStream#* self, double sampleRate, const PaStreamParameterscxx . . $ PaStreamParameters#* inputParameters, |
| 2522 | const PaStreamParameterscxx . . $ PaStreamParameters#* outputParameters, unsigned long framesPerUserBuffer, snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t#* hwParamsCapture, |
| 2523 | snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t#* hwParamsPlayback, PaUtilHostBufferSizeModecxx . . $ PaUtilHostBufferSizeMode#* hostBufferSizeMode ) |
| 2524 | { |
| 2525 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 2526 | unsigned long framesPerHostBuffer = 0; |
| 2527 | int dir = 0; |
| 2528 | int accurate = 1; |
| 2529 | unsigned numPeriods = numPeriods_cxx . . $ numPeriods_.; |
| 2530 | |
| 2531 | if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. && self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 2532 | { |
| 2533 | if( framesPerUserBuffer == paFramesPerBufferUnspecifiedcxx . . $ `external/portaudio/portaudio.h:642:9`! ) |
| 2534 | { |
| 2535 | /* Come up with a common desired latency */ |
| 2536 | snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t# desiredBufSz, e, minPeriodSize, maxPeriodSize, optimalPeriodSize, periodSize, |
| 2537 | minCapture, minPlayback, maxCapture, maxPlayback; |
| 2538 | |
| 2539 | dir = 0; |
| 2540 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_period_size_min( hwParamsCapture, &minCapture, &dir ), paUnanticipatedHostError ); |
| 2541 | dir = 0; |
| 2542 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_period_size_min( hwParamsPlayback, &minPlayback, &dir ), paUnanticipatedHostError ); |
| 2543 | dir = 0; |
| 2544 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_period_size_max( hwParamsCapture, &maxCapture, &dir ), paUnanticipatedHostError ); |
| 2545 | dir = 0; |
| 2546 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_period_size_max( hwParamsPlayback, &maxPlayback, &dir ), paUnanticipatedHostError ); |
| 2547 | minPeriodSize = PA_MAXcxx . . $ `external/portaudio/pa_unix_util.h:58:9`!( minPlayback, minCapture ); |
| 2548 | maxPeriodSize = PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!( maxPlayback, maxCapture ); |
| 2549 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( minPeriodSize <= maxPeriodSize, paBadIODeviceCombination ); |
| 2550 | |
| 2551 | desiredBufSz = (snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t#)( PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!( outputParameters->suggestedLatency, inputParameters->suggestedLatency ) |
| 2552 | * sampleRate ); |
| 2553 | /* Clamp desiredBufSz */ |
| 2554 | { |
| 2555 | snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t# maxBufferSize; |
| 2556 | snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t# maxBufferSizeCapture, maxBufferSizePlayback; |
| 2557 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_buffer_size_max( hwParamsCapture, &maxBufferSizeCapture ), paUnanticipatedHostError ); |
| 2558 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_buffer_size_max( hwParamsPlayback, &maxBufferSizePlayback ), paUnanticipatedHostError ); |
| 2559 | maxBufferSize = PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!( maxBufferSizeCapture, maxBufferSizePlayback ); |
| 2560 | |
| 2561 | desiredBufSz = PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!( desiredBufSz, maxBufferSize ); |
| 2562 | } |
| 2563 | |
| 2564 | /* Find the closest power of 2 */ |
| 2565 | e = ilogbcxx . . $ ilogb(620b9ac44d2573a6).( minPeriodSize ); |
| 2566 | if( minPeriodSize & ( minPeriodSize - 1 ) ) |
| 2567 | e += 1; |
| 2568 | periodSize = (snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t#)powcxx . . $ pow(d8e7e0733fa41c87).( 2, e ); |
| 2569 | |
| 2570 | while( periodSize <= maxPeriodSize ) |
| 2571 | { |
| 2572 | if( alsa_snd_pcm_hw_params_test_period_sizecxx . . $ alsa_snd_pcm_hw_params_test_period_size.( self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., hwParamsPlayback, periodSize, 0 ) >= 0 && |
| 2573 | alsa_snd_pcm_hw_params_test_period_sizecxx . . $ alsa_snd_pcm_hw_params_test_period_size.( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., hwParamsCapture, periodSize, 0 ) >= 0 ) |
| 2574 | { |
| 2575 | /* OK! */ |
| 2576 | break; |
| 2577 | } |
| 2578 | |
| 2579 | periodSize *= 2; |
| 2580 | } |
| 2581 | |
| 2582 | optimalPeriodSize = PA_MAXcxx . . $ `external/portaudio/pa_unix_util.h:58:9`!( desiredBufSz / numPeriods, minPeriodSize ); |
| 2583 | optimalPeriodSize = PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!( optimalPeriodSize, maxPeriodSize ); |
| 2584 | |
| 2585 | /* Find the closest power of 2 */ |
| 2586 | e = ilogbcxx . . $ ilogb(620b9ac44d2573a6).( optimalPeriodSize ); |
| 2587 | if( optimalPeriodSize & (optimalPeriodSize - 1) ) |
| 2588 | e += 1; |
| 2589 | optimalPeriodSize = (snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t#)powcxx . . $ pow(d8e7e0733fa41c87).( 2, e ); |
| 2590 | |
| 2591 | while( optimalPeriodSize >= periodSize ) |
| 2592 | { |
| 2593 | if( alsa_snd_pcm_hw_params_test_period_sizecxx . . $ alsa_snd_pcm_hw_params_test_period_size.( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., hwParamsCapture, optimalPeriodSize, 0 ) |
| 2594 | >= 0 && alsa_snd_pcm_hw_params_test_period_sizecxx . . $ alsa_snd_pcm_hw_params_test_period_size.( self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., hwParamsPlayback, |
| 2595 | optimalPeriodSize, 0 ) >= 0 ) |
| 2596 | { |
| 2597 | break; |
| 2598 | } |
| 2599 | optimalPeriodSize /= 2; |
| 2600 | } |
| 2601 | |
| 2602 | if( optimalPeriodSize > periodSize ) |
| 2603 | periodSize = optimalPeriodSize; |
| 2604 | |
| 2605 | if( periodSize <= maxPeriodSize ) |
| 2606 | { |
| 2607 | /* Looks good, the periodSize _should_ be acceptable by both devices */ |
| 2608 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_period_size( self->capture.pcm, hwParamsCapture, periodSize, 0 ), |
| 2609 | paUnanticipatedHostError ); |
| 2610 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_period_size( self->playback.pcm, hwParamsPlayback, periodSize, 0 ), |
| 2611 | paUnanticipatedHostError ); |
| 2612 | self->capturecxx . . $ PaAlsaStream#capture..framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod. = self->playbackcxx . . $ PaAlsaStream#playback..framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod. = periodSize; |
| 2613 | framesPerHostBuffer = periodSize; |
| 2614 | } |
| 2615 | else |
| 2616 | { |
| 2617 | /* Unable to find a common period size, oh well */ |
| 2618 | optimalPeriodSize = PA_MAXcxx . . $ `external/portaudio/pa_unix_util.h:58:9`!( desiredBufSz / numPeriods, minPeriodSize ); |
| 2619 | optimalPeriodSize = PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!( optimalPeriodSize, maxPeriodSize ); |
| 2620 | |
| 2621 | self->capturecxx . . $ PaAlsaStream#capture..framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod. = optimalPeriodSize; |
| 2622 | dir = 0; |
| 2623 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_period_size_near( self->capture.pcm, hwParamsCapture, &self->capture.framesPerPeriod, &dir ), |
| 2624 | paUnanticipatedHostError ); |
| 2625 | self->playbackcxx . . $ PaAlsaStream#playback..framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod. = optimalPeriodSize; |
| 2626 | dir = 0; |
| 2627 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_period_size_near( self->playback.pcm, hwParamsPlayback, &self->playback.framesPerPeriod, &dir ), |
| 2628 | paUnanticipatedHostError ); |
| 2629 | framesPerHostBuffer = PA_MAXcxx . . $ `external/portaudio/pa_unix_util.h:58:9`!( self->capture.framesPerPeriod, self->playback.framesPerPeriod ); |
| 2630 | *hostBufferSizeMode = paUtilBoundedHostBufferSizecxx . . $ paUtilBoundedHostBufferSize.; |
| 2631 | } |
| 2632 | } |
| 2633 | else |
| 2634 | { |
| 2635 | /* We choose the simple route and determine a suitable number of frames per buffer for one component of |
| 2636 | * the stream, then we hope that this will work for the other component too (it should!). |
| 2637 | */ |
| 2638 | |
| 2639 | unsigned maxPeriods = 0; |
| 2640 | PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent#* first = &self->capturecxx . . $ PaAlsaStream#capture., * second = &self->playbackcxx . . $ PaAlsaStream#playback.; |
| 2641 | const PaStreamParameterscxx . . $ PaStreamParameters#* firstStreamParams = inputParameters; |
| 2642 | snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t#* firstHwParams = hwParamsCapture, * secondHwParams = hwParamsPlayback; |
| 2643 | |
| 2644 | dir = 0; |
| 2645 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_periods_max( hwParamsPlayback, &maxPeriods, &dir ), paUnanticipatedHostError ); |
| 2646 | if( maxPeriods < numPeriods ) |
| 2647 | { |
| 2648 | /* The playback component is trickier to get right, try that first */ |
| 2649 | first = &self->playbackcxx . . $ PaAlsaStream#playback.; |
| 2650 | second = &self->capturecxx . . $ PaAlsaStream#capture.; |
| 2651 | firstStreamParams = outputParameters; |
| 2652 | firstHwParams = hwParamsPlayback; |
| 2653 | secondHwParams = hwParamsCapture; |
| 2654 | } |
| 2655 | |
| 2656 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_DetermineFramesPerBuffer( first, firstStreamParams, framesPerUserBuffer, |
| 2657 | sampleRate, firstHwParams, &accurate ) ); |
| 2658 | |
| 2659 | second->framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod. = first->framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod.; |
| 2660 | dir = 0; |
| 2661 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_period_size_near( second->pcm, secondHwParams, &second->framesPerPeriod, &dir ), |
| 2662 | paUnanticipatedHostError ); |
| 2663 | if( self->capturecxx . . $ PaAlsaStream#capture..framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod. == self->playbackcxx . . $ PaAlsaStream#playback..framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod. ) |
| 2664 | { |
| 2665 | framesPerHostBuffer = self->capturecxx . . $ PaAlsaStream#capture..framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod.; |
| 2666 | } |
| 2667 | else |
| 2668 | { |
| 2669 | framesPerHostBuffer = PA_MAXcxx . . $ `external/portaudio/pa_unix_util.h:58:9`!( self->capture.framesPerPeriod, self->playback.framesPerPeriod ); |
| 2670 | *hostBufferSizeMode = paUtilBoundedHostBufferSizecxx . . $ paUtilBoundedHostBufferSize.; |
| 2671 | } |
| 2672 | } |
| 2673 | } |
| 2674 | else /* half-duplex is a slightly simpler case */ |
| 2675 | { |
| 2676 | if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 2677 | { |
| 2678 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_DetermineFramesPerBuffer( &self->capture, inputParameters, framesPerUserBuffer, |
| 2679 | sampleRate, hwParamsCapture, &accurate) ); |
| 2680 | framesPerHostBuffer = self->capturecxx . . $ PaAlsaStream#capture..framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod.; |
| 2681 | } |
| 2682 | else |
| 2683 | { |
| 2684 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self->playback.pcm ); |
| 2685 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_DetermineFramesPerBuffer( &self->playback, outputParameters, framesPerUserBuffer, |
| 2686 | sampleRate, hwParamsPlayback, &accurate ) ); |
| 2687 | framesPerHostBuffer = self->playbackcxx . . $ PaAlsaStream#playback..framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod.; |
| 2688 | } |
| 2689 | } |
| 2690 | |
| 2691 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( framesPerHostBuffer != 0, paInternalError ); |
| 2692 | self->maxFramesPerHostBuffercxx . . $ PaAlsaStream#maxFramesPerHostBuffer. = framesPerHostBuffer; |
| 2693 | |
| 2694 | if( !self->playbackcxx . . $ PaAlsaStream#playback..canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. || !accurate ) |
| 2695 | { |
| 2696 | /* Don't know the exact size per host buffer */ |
| 2697 | *hostBufferSizeMode = paUtilBoundedHostBufferSizecxx . . $ paUtilBoundedHostBufferSize.; |
| 2698 | /* Raise upper bound */ |
| 2699 | if( !accurate ) |
| 2700 | ++self->maxFramesPerHostBuffercxx . . $ PaAlsaStream#maxFramesPerHostBuffer.; |
| 2701 | } |
| 2702 | |
| 2703 | error: |
| 2704 | return result; |
| 2705 | } |
| 2706 | |
| 2707 | /** Set up ALSA stream parameters. |
| 2708 | * |
| 2709 | */ |
| 2710 | static PaErrorcxx . . $ PaError# PaAlsaStream_Configurecxx . . $ PaAlsaStream_Configure(18951d67557a4fda).( PaAlsaStreamcxx . . $ PaAlsaStream# *self, const PaStreamParameterscxx . . $ PaStreamParameters# *inParams, const PaStreamParameterscxx . . $ PaStreamParameters#* |
| 2711 | outParams, double sampleRate, unsigned long framesPerUserBuffer, double* inputLatency, double* outputLatency, |
| 2712 | PaUtilHostBufferSizeModecxx . . $ PaUtilHostBufferSizeMode#* hostBufferSizeMode ) |
| 2713 | { |
| 2714 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 2715 | double realSr = sampleRate; |
| 2716 | snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t#* hwParamsCapture, * hwParamsPlayback; |
| 2717 | |
| 2718 | alsa_snd_pcm_hw_params_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:171:9`!( &hwParamsCapture ); |
| 2719 | alsa_snd_pcm_hw_params_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:171:9`!( &hwParamsPlayback ); |
| 2720 | |
| 2721 | if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 2722 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_InitialConfigure( &self->capture, inParams, self->primeBuffers, hwParamsCapture, |
| 2723 | &realSr ) ); |
| 2724 | if( self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 2725 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_InitialConfigure( &self->playback, outParams, self->primeBuffers, hwParamsPlayback, |
| 2726 | &realSr ) ); |
| 2727 | |
| 2728 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_DetermineFramesPerBuffer( self, realSr, inParams, outParams, framesPerUserBuffer, |
| 2729 | hwParamsCapture, hwParamsPlayback, hostBufferSizeMode ) ); |
| 2730 | |
| 2731 | if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 2732 | { |
| 2733 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self->capture.framesPerPeriod != 0 ); |
| 2734 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_FinishConfigure( &self->capture, hwParamsCapture, inParams, self->primeBuffers, realSr, |
| 2735 | inputLatency ) ); |
| 2736 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Capture period size: %lu, latency: %f\n", __FUNCTION__, self->capture.framesPerPeriod, *inputLatency )); |
| 2737 | } |
| 2738 | if( self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 2739 | { |
| 2740 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self->playback.framesPerPeriod != 0 ); |
| 2741 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_FinishConfigure( &self->playback, hwParamsPlayback, outParams, self->primeBuffers, realSr, |
| 2742 | outputLatency ) ); |
| 2743 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Playback period size: %lu, latency: %f\n", __FUNCTION__, self->playback.framesPerPeriod, *outputLatency )); |
| 2744 | } |
| 2745 | |
| 2746 | /* Should be exact now */ |
| 2747 | self->streamRepresentationcxx . . $ PaAlsaStream#streamRepresentation..streamInfocxx . . $ PaUtilStreamRepresentation#streamInfo..sampleRatecxx . . $ PaStreamInfo#sampleRate. = realSr; |
| 2748 | |
| 2749 | /* this will cause the two streams to automatically start/stop/prepare in sync. |
| 2750 | * We only need to execute these operations on one of the pair. |
| 2751 | * A: We don't want to do this on a blocking stream. |
| 2752 | */ |
| 2753 | if( self->callbackModecxx . . $ PaAlsaStream#callbackMode. && self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. && self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 2754 | { |
| 2755 | int err = alsa_snd_pcm_linkcxx . . $ alsa_snd_pcm_link.( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ); |
| 2756 | if( err == 0 ) |
| 2757 | self->pcmsSyncedcxx . . $ PaAlsaStream#pcmsSynced. = 1; |
| 2758 | else |
| 2759 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Unable to sync pcms: %s\n", __FUNCTION__, alsa_snd_strerror( err ) )); |
| 2760 | } |
| 2761 | |
| 2762 | { |
| 2763 | unsigned long minFramesPerHostBuffer = PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!( self->capture.pcm ? self->capture.framesPerPeriod : ULONG_MAXcxx . . $ `<external>/67164224788392828/limits.h:135:9`!, |
| 2764 | self->playback.pcm ? self->playback.framesPerPeriod : ULONG_MAXcxx . . $ `<external>/67164224788392828/limits.h:135:9`! ); |
| 2765 | self->pollTimeoutcxx . . $ PaAlsaStream#pollTimeout. = CalculatePollTimeoutcxx . . $ CalculatePollTimeout(c2605310b54a7632).( self, minFramesPerHostBuffer ); /* Period in msecs, rounded up */ |
| 2766 | |
| 2767 | /* Time before watchdog unthrottles realtime thread == 1/4 of period time in msecs */ |
| 2768 | /* self->threading.throttledSleepTime = (unsigned long) (minFramesPerHostBuffer / sampleRate / 4 * 1000); */ |
| 2769 | } |
| 2770 | |
| 2771 | if( self->callbackModecxx . . $ PaAlsaStream#callbackMode. ) |
| 2772 | { |
| 2773 | /* If the user expects a certain number of frames per callback we will either have to rely on block adaption |
| 2774 | * (framesPerHostBuffer is not an integer multiple of framesPerPeriod) or we can simply align the number |
| 2775 | * of host buffer frames with what the user specified */ |
| 2776 | if( self->framesPerUserBuffercxx . . $ PaAlsaStream#framesPerUserBuffer. != paFramesPerBufferUnspecifiedcxx . . $ `external/portaudio/portaudio.h:642:9`! ) |
| 2777 | { |
| 2778 | /* self->alignFrames = 1; */ |
| 2779 | |
| 2780 | /* Unless the ratio between number of host and user buffer frames is an integer we will have to rely |
| 2781 | * on block adaption */ |
| 2782 | /* |
| 2783 | if( framesPerHostBuffer % framesPerPeriod != 0 || (self->capture.pcm && self->playback.pcm && |
| 2784 | self->capture.framesPerPeriod != self->playback.framesPerPeriod) ) |
| 2785 | self->useBlockAdaption = 1; |
| 2786 | else |
| 2787 | self->alignFrames = 1; |
| 2788 | */ |
| 2789 | } |
| 2790 | } |
| 2791 | |
| 2792 | error: |
| 2793 | return result; |
| 2794 | } |
| 2795 | |
| 2796 | static PaErrorcxx . . $ PaError# OpenStreamcxx . . $ OpenStream(dd932161c061c960).( struct PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation# *hostApi, |
| 2797 | PaStreamcxx . . $ PaStream#** s, |
| 2798 | const PaStreamParameterscxx . . $ PaStreamParameters# *inputParameters, |
| 2799 | const PaStreamParameterscxx . . $ PaStreamParameters# *outputParameters, |
| 2800 | double sampleRate, |
| 2801 | unsigned long framesPerBuffer, |
| 2802 | PaStreamFlagscxx . . $ PaStreamFlags# streamFlags, |
| 2803 | PaStreamCallbackcxx . . $ PaStreamCallback#* callback, |
| 2804 | void *userData ) |
| 2805 | { |
| 2806 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 2807 | PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation# *alsaHostApi = (PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation#*)hostApi; |
| 2808 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2809 | PaSampleFormatcxx . . $ PaSampleFormat# hostInputSampleFormat = 0, hostOutputSampleFormat = 0; |
| 2810 | PaSampleFormatcxx . . $ PaSampleFormat# inputSampleFormat = 0, outputSampleFormat = 0; |
| 2811 | int numInputChannels = 0, numOutputChannels = 0; |
| 2812 | PaTimecxx . . $ PaTime# inputLatency, outputLatency; |
| 2813 | /* Operate with fixed host buffer size by default, since other modes will invariably lead to block adaption */ |
| 2814 | /* XXX: Use Bounded by default? Output tends to get stuttery with Fixed ... */ |
| 2815 | PaUtilHostBufferSizeModecxx . . $ PaUtilHostBufferSizeMode# hostBufferSizeMode = paUtilFixedHostBufferSizecxx . . $ paUtilFixedHostBufferSize.; |
| 2816 | |
| 2817 | if( ( streamFlags & paPlatformSpecificFlagscxx . . $ `external/portaudio/portaudio.h:690:11`! ) != 0 ) |
| 2818 | return paInvalidFlagcxx . . $ paInvalidFlag.; |
| 2819 | |
| 2820 | if( inputParameters ) |
| 2821 | { |
| 2822 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( ValidateParameters( inputParameters, hostApi, StreamDirection_In ) ); |
| 2823 | |
| 2824 | numInputChannels = inputParameters->channelCountcxx . . $ PaStreamParameters#channelCount.; |
| 2825 | inputSampleFormat = inputParameters->sampleFormatcxx . . $ PaStreamParameters#sampleFormat.; |
| 2826 | } |
| 2827 | if( outputParameters ) |
| 2828 | { |
| 2829 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( ValidateParameters( outputParameters, hostApi, StreamDirection_Out ) ); |
| 2830 | |
| 2831 | numOutputChannels = outputParameters->channelCountcxx . . $ PaStreamParameters#channelCount.; |
| 2832 | outputSampleFormat = outputParameters->sampleFormatcxx . . $ PaStreamParameters#sampleFormat.; |
| 2833 | } |
| 2834 | |
| 2835 | /* XXX: Why do we support this anyway? */ |
| 2836 | if( framesPerBuffer == paFramesPerBufferUnspecifiedcxx . . $ `external/portaudio/portaudio.h:642:9`! && getenvcxx . . $ getenv(a8b8e32347182212).( "PA_ALSA_PERIODSIZE" ) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ) |
| 2837 | { |
| 2838 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Getting framesPerBuffer (Alsa period-size) from environment\n", __FUNCTION__ )); |
| 2839 | framesPerBuffer = atoicxx . . $ atoi(5c4306d8553b3696).( getenvcxx . . $ getenv(a8b8e32347182212).("PA_ALSA_PERIODSIZE") ); |
| 2840 | } |
| 2841 | |
| 2842 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( stream = (PaAlsaStream*)PaUtil_AllocateMemory( sizeof(PaAlsaStream) ), paInsufficientMemory ); |
| 2843 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, |
| 2844 | framesPerBuffer, callback, streamFlags, userData ) ); |
| 2845 | |
| 2846 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, |
| 2847 | &inputLatency, &outputLatency, &hostBufferSizeMode ) ); |
| 2848 | hostInputSampleFormat = stream->capturecxx . . $ PaAlsaStream#capture..hostSampleFormatcxx . . $ $anonymous_type_c42756aa1fb35d76_1#hostSampleFormat. | (!stream->capturecxx . . $ PaAlsaStream#capture..hostInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#hostInterleaved. ? paNonInterleavedcxx . . $ `external/portaudio/portaudio.h:495:9`! : 0); |
| 2849 | hostOutputSampleFormat = stream->playbackcxx . . $ PaAlsaStream#playback..hostSampleFormatcxx . . $ $anonymous_type_c42756aa1fb35d76_1#hostSampleFormat. | (!stream->playbackcxx . . $ PaAlsaStream#playback..hostInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#hostInterleaved. ? paNonInterleavedcxx . . $ `external/portaudio/portaudio.h:495:9`! : 0); |
| 2850 | |
| 2851 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaUtil_InitializeBufferProcessor( &stream->bufferProcessor, |
| 2852 | numInputChannels, inputSampleFormat, hostInputSampleFormat, |
| 2853 | numOutputChannels, outputSampleFormat, hostOutputSampleFormat, |
| 2854 | sampleRate, streamFlags, framesPerBuffer, stream->maxFramesPerHostBuffer, |
| 2855 | hostBufferSizeMode, callback, userData ) ); |
| 2856 | |
| 2857 | /* Ok, buffer processor is initialized, now we can deduce it's latency */ |
| 2858 | if( numInputChannels > 0 ) |
| 2859 | stream->streamRepresentationcxx . . $ PaAlsaStream#streamRepresentation..streamInfocxx . . $ PaUtilStreamRepresentation#streamInfo..inputLatencycxx . . $ PaStreamInfo#inputLatency. = inputLatency + (PaTimecxx . . $ PaTime#)( |
| 2860 | PaUtil_GetBufferProcessorInputLatencyFramescxx . . $ PaUtil_GetBufferProcessorInputLatencyFrames(a5da02a3b0f2cced).( &stream->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor. ) / sampleRate); |
| 2861 | if( numOutputChannels > 0 ) |
| 2862 | stream->streamRepresentationcxx . . $ PaAlsaStream#streamRepresentation..streamInfocxx . . $ PaUtilStreamRepresentation#streamInfo..outputLatencycxx . . $ PaStreamInfo#outputLatency. = outputLatency + (PaTimecxx . . $ PaTime#)( |
| 2863 | PaUtil_GetBufferProcessorOutputLatencyFramescxx . . $ PaUtil_GetBufferProcessorOutputLatencyFrames(a5da02a3b0f2cced).( &stream->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor. ) / sampleRate); |
| 2864 | |
| 2865 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Stream: framesPerBuffer = %lu, maxFramesPerHostBuffer = %lu, latency i=%f, o=%f\n", __FUNCTION__, framesPerBuffer, stream->maxFramesPerHostBuffer, stream->streamRepresentation.streamInfo.inputLatency, stream->streamRepresentation.streamInfo.outputLatency)); |
| 2866 | |
| 2867 | *s = (PaStreamcxx . . $ PaStream#*)stream; |
| 2868 | |
| 2869 | return result; |
| 2870 | |
| 2871 | error: |
| 2872 | if( stream ) |
| 2873 | { |
| 2874 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Stream in error, terminating\n", __FUNCTION__ )); |
| 2875 | PaAlsaStream_Terminatecxx . . $ PaAlsaStream_Terminate(e8e0d294f8fc0971).( stream ); |
| 2876 | } |
| 2877 | |
| 2878 | return result; |
| 2879 | } |
| 2880 | |
| 2881 | static PaErrorcxx . . $ PaError# CloseStreamcxx . . $ CloseStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream#* s ) |
| 2882 | { |
| 2883 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 2884 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream = (PaAlsaStreamcxx . . $ PaAlsaStream#*)s; |
| 2885 | |
| 2886 | PaUtil_TerminateBufferProcessorcxx . . $ PaUtil_TerminateBufferProcessor(ad694745b6b5e2b0).( &stream->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor. ); |
| 2887 | PaUtil_TerminateStreamRepresentationcxx . . $ PaUtil_TerminateStreamRepresentation(d99c7cce07513a60).( &stream->streamRepresentationcxx . . $ PaAlsaStream#streamRepresentation. ); |
| 2888 | |
| 2889 | PaAlsaStream_Terminatecxx . . $ PaAlsaStream_Terminate(e8e0d294f8fc0971).( stream ); |
| 2890 | |
| 2891 | return result; |
| 2892 | } |
| 2893 | |
| 2894 | static void SilenceBuffercxx . . $ SilenceBuffer(e8e0d294f8fc0971).( PaAlsaStreamcxx . . $ PaAlsaStream# *stream ) |
| 2895 | { |
| 2896 | const snd_pcm_channel_area_tcxx . . $ snd_pcm_channel_area_t# *areas; |
| 2897 | snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t# frames = (snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t#)alsa_snd_pcm_avail_updatecxx . . $ alsa_snd_pcm_avail_update.( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ), offset; |
| 2898 | |
| 2899 | alsa_snd_pcm_mmap_begincxx . . $ alsa_snd_pcm_mmap_begin.( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., &areas, &offset, &frames ); |
| 2900 | alsa_snd_pcm_areas_silencecxx . . $ alsa_snd_pcm_areas_silence.( areas, offset, stream->playbackcxx . . $ PaAlsaStream#playback..numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels., frames, stream->playbackcxx . . $ PaAlsaStream#playback..nativeFormatcxx . . $ $anonymous_type_c42756aa1fb35d76_1#nativeFormat. ); |
| 2901 | alsa_snd_pcm_mmap_commitcxx . . $ alsa_snd_pcm_mmap_commit.( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., offset, frames ); |
| 2902 | } |
| 2903 | |
| 2904 | /** Start/prepare pcm(s) for streaming. |
| 2905 | * |
| 2906 | * Depending on whether the stream is in callback or blocking mode, we will respectively start or simply |
| 2907 | * prepare the playback pcm. If the buffer has _not_ been primed, we will in callback mode prepare and |
| 2908 | * silence the buffer before starting playback. In blocking mode we simply prepare, as the playback will |
| 2909 | * be started automatically as the user writes to output. |
| 2910 | * |
| 2911 | * The capture pcm, however, will simply be prepared and started. |
| 2912 | */ |
| 2913 | static PaErrorcxx . . $ PaError# AlsaStartcxx . . $ AlsaStart(bf754e76938c308f).( PaAlsaStreamcxx . . $ PaAlsaStream# *stream, int priming ) |
| 2914 | { |
| 2915 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 2916 | |
| 2917 | if( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 2918 | { |
| 2919 | if( stream->callbackModecxx . . $ PaAlsaStream#callbackMode. ) |
| 2920 | { |
| 2921 | if( !priming ) |
| 2922 | { |
| 2923 | /* Buffer isn't primed, so prepare and silence */ |
| 2924 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_prepare( stream->playback.pcm ), paUnanticipatedHostError ); |
| 2925 | if( stream->playbackcxx . . $ PaAlsaStream#playback..canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. ) |
| 2926 | SilenceBuffercxx . . $ SilenceBuffer(e8e0d294f8fc0971).( stream ); |
| 2927 | } |
| 2928 | if( stream->playbackcxx . . $ PaAlsaStream#playback..canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. ) |
| 2929 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_start( stream->playback.pcm ), paUnanticipatedHostError ); |
| 2930 | } |
| 2931 | else |
| 2932 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_prepare( stream->playback.pcm ), paUnanticipatedHostError ); |
| 2933 | } |
| 2934 | if( stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. && !stream->pcmsSyncedcxx . . $ PaAlsaStream#pcmsSynced. ) |
| 2935 | { |
| 2936 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_prepare( stream->capture.pcm ), paUnanticipatedHostError ); |
| 2937 | /* For a blocking stream we want to start capture as well, since nothing will happen otherwise */ |
| 2938 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_start( stream->capture.pcm ), paUnanticipatedHostError ); |
| 2939 | } |
| 2940 | |
| 2941 | end: |
| 2942 | return result; |
| 2943 | error: |
| 2944 | goto end; |
| 2945 | } |
| 2946 | |
| 2947 | /** Utility function for determining if pcms are in running state. |
| 2948 | * |
| 2949 | */ |
| 2950 | #if 0 |
| 2951 | static int IsRunning( PaAlsaStream *stream ) |
| 2952 | { |
| 2953 | int result = 0; |
| 2954 | |
| 2955 | PA_ENSURE( PaUnixMutex_Lock( &stream->stateMtx ) ); |
| 2956 | if( stream->capture.pcm ) |
| 2957 | { |
| 2958 | snd_pcm_state_t capture_state = alsa_snd_pcm_state( stream->capture.pcm ); |
| 2959 | |
| 2960 | if( capture_state == SND_PCM_STATE_RUNNING || capture_state == SND_PCM_STATE_XRUN |
| 2961 | || capture_state == SND_PCM_STATE_DRAINING ) |
| 2962 | { |
| 2963 | result = 1; |
| 2964 | goto end; |
| 2965 | } |
| 2966 | } |
| 2967 | |
| 2968 | if( stream->playback.pcm ) |
| 2969 | { |
| 2970 | snd_pcm_state_t playback_state = alsa_snd_pcm_state( stream->playback.pcm ); |
| 2971 | |
| 2972 | if( playback_state == SND_PCM_STATE_RUNNING || playback_state == SND_PCM_STATE_XRUN |
| 2973 | || playback_state == SND_PCM_STATE_DRAINING ) |
| 2974 | { |
| 2975 | result = 1; |
| 2976 | goto end; |
| 2977 | } |
| 2978 | } |
| 2979 | |
| 2980 | end: |
| 2981 | ASSERT_CALL_( PaUnixMutex_Unlock( &stream->stateMtx ), paNoError ); |
| 2982 | return result; |
| 2983 | error: |
| 2984 | goto error; |
| 2985 | } |
| 2986 | #endif |
| 2987 | |
| 2988 | static PaErrorcxx . . $ PaError# StartStreamcxx . . $ StartStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *s ) |
| 2989 | { |
| 2990 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 2991 | PaAlsaStreamcxx . . $ PaAlsaStream#* stream = (PaAlsaStreamcxx . . $ PaAlsaStream#*)s; |
| 2992 | int streamStarted = 0; /* So we can know whether we need to take the stream down */ |
| 2993 | |
| 2994 | /* Ready the processor */ |
| 2995 | PaUtil_ResetBufferProcessorcxx . . $ PaUtil_ResetBufferProcessor(ad694745b6b5e2b0).( &stream->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor. ); |
| 2996 | |
| 2997 | /* Set now, so we can test for activity further down */ |
| 2998 | stream->isActivecxx . . $ PaAlsaStream#isActive. = 1; |
| 2999 | |
| 3000 | if( stream->callbackModecxx . . $ PaAlsaStream#callbackMode. ) |
| 3001 | { |
| 3002 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaUnixThread_New( &stream->thread, &CallbackThreadFunc, stream, 1., stream->rtSched ) ); |
| 3003 | } |
| 3004 | else |
| 3005 | { |
| 3006 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( AlsaStart( stream, 0 ) ); |
| 3007 | streamStarted = 1; |
| 3008 | } |
| 3009 | |
| 3010 | end: |
| 3011 | return result; |
| 3012 | error: |
| 3013 | if( streamStarted ) |
| 3014 | { |
| 3015 | AbortStreamcxx . . $ AbortStream(dedf1e9b1c614a07).( stream ); |
| 3016 | } |
| 3017 | stream->isActivecxx . . $ PaAlsaStream#isActive. = 0; |
| 3018 | |
| 3019 | goto end; |
| 3020 | } |
| 3021 | |
| 3022 | /** Stop PCM handle, either softly or abruptly. |
| 3023 | */ |
| 3024 | static PaErrorcxx . . $ PaError# AlsaStopcxx . . $ AlsaStop(bf754e76938c308f).( PaAlsaStreamcxx . . $ PaAlsaStream# *stream, int abort ) |
| 3025 | { |
| 3026 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3027 | /* XXX: alsa_snd_pcm_drain tends to lock up, avoid it until we find out more */ |
| 3028 | abort = 1; |
| 3029 | /* |
| 3030 | if( stream->capture.pcm && !strcmp( Pa_GetDeviceInfo( stream->capture.device )->name, |
| 3031 | "dmix" ) ) |
| 3032 | { |
| 3033 | abort = 1; |
| 3034 | } |
| 3035 | else if( stream->playback.pcm && !strcmp( Pa_GetDeviceInfo( stream->playback.device )->name, |
| 3036 | "dmix" ) ) |
| 3037 | { |
| 3038 | abort = 1; |
| 3039 | } |
| 3040 | */ |
| 3041 | |
| 3042 | if( abort ) |
| 3043 | { |
| 3044 | if( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3045 | { |
| 3046 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_drop( stream->playback.pcm ), paUnanticipatedHostError ); |
| 3047 | } |
| 3048 | if( stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. && !stream->pcmsSyncedcxx . . $ PaAlsaStream#pcmsSynced. ) |
| 3049 | { |
| 3050 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_drop( stream->capture.pcm ), paUnanticipatedHostError ); |
| 3051 | } |
| 3052 | |
| 3053 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Dropped frames\n", __FUNCTION__ )); |
| 3054 | } |
| 3055 | else |
| 3056 | { |
| 3057 | if( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3058 | { |
| 3059 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_nonblock( stream->playback.pcm, 0 ), paUnanticipatedHostError ); |
| 3060 | if( alsa_snd_pcm_draincxx . . $ alsa_snd_pcm_drain.( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) < 0 ) |
| 3061 | { |
| 3062 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Draining playback handle failed!\n", __FUNCTION__ )); |
| 3063 | } |
| 3064 | } |
| 3065 | if( stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. && !stream->pcmsSyncedcxx . . $ PaAlsaStream#pcmsSynced. ) |
| 3066 | { |
| 3067 | /* We don't need to retrieve any remaining frames */ |
| 3068 | if( alsa_snd_pcm_draincxx . . $ alsa_snd_pcm_drain.( stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) < 0 ) |
| 3069 | { |
| 3070 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Draining capture handle failed!\n", __FUNCTION__ )); |
| 3071 | } |
| 3072 | } |
| 3073 | } |
| 3074 | |
| 3075 | end: |
| 3076 | return result; |
| 3077 | error: |
| 3078 | goto end; |
| 3079 | } |
| 3080 | |
| 3081 | /** Stop or abort stream. |
| 3082 | * |
| 3083 | * If a stream is in callback mode we will have to inspect whether the background thread has |
| 3084 | * finished, or we will have to take it out. In either case we join the thread before |
| 3085 | * returning. In blocking mode, we simply tell ALSA to stop abruptly (abort) or finish |
| 3086 | * buffers (drain) |
| 3087 | * |
| 3088 | * Stream will be considered inactive (!PaAlsaStream::isActive) after a call to this function |
| 3089 | */ |
| 3090 | static PaErrorcxx . . $ PaError# RealStopcxx . . $ RealStop(bf754e76938c308f).( PaAlsaStreamcxx . . $ PaAlsaStream# *stream, int abort ) |
| 3091 | { |
| 3092 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3093 | |
| 3094 | /* First deal with the callback thread, cancelling and/or joining |
| 3095 | * it if necessary |
| 3096 | */ |
| 3097 | if( stream->callbackModecxx . . $ PaAlsaStream#callbackMode. ) |
| 3098 | { |
| 3099 | PaErrorcxx . . $ PaError# threadRes; |
| 3100 | stream->callbackAbortcxx . . $ PaAlsaStream#callbackAbort. = abort; |
| 3101 | |
| 3102 | if( !abort ) |
| 3103 | { |
| 3104 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "Stopping callback\n" )); |
| 3105 | } |
| 3106 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaUnixThread_Terminate( &stream->thread, !abort, &threadRes ) ); |
| 3107 | if( threadRes != paNoErrorcxx . . $ paNoError. ) |
| 3108 | { |
| 3109 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "Callback thread returned: %d\n", threadRes )); |
| 3110 | } |
| 3111 | #if 0 |
| 3112 | if( watchdogRes != paNoError ) |
| 3113 | PA_DEBUG(( "Watchdog thread returned: %d\n", watchdogRes )); |
| 3114 | #endif |
| 3115 | |
| 3116 | stream->callback_finishedcxx . . $ PaAlsaStream#callback_finished. = 0; |
| 3117 | } |
| 3118 | else |
| 3119 | { |
| 3120 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( AlsaStop( stream, abort ) ); |
| 3121 | } |
| 3122 | |
| 3123 | stream->isActivecxx . . $ PaAlsaStream#isActive. = 0; |
| 3124 | |
| 3125 | end: |
| 3126 | return result; |
| 3127 | |
| 3128 | error: |
| 3129 | goto end; |
| 3130 | } |
| 3131 | |
| 3132 | static PaErrorcxx . . $ PaError# StopStreamcxx . . $ StopStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *s ) |
| 3133 | { |
| 3134 | return RealStopcxx . . $ RealStop(bf754e76938c308f).( (PaAlsaStreamcxx . . $ PaAlsaStream# *) s, 0 ); |
| 3135 | } |
| 3136 | |
| 3137 | static PaErrorcxx . . $ PaError# AbortStreamcxx . . $ AbortStream(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *s ) |
| 3138 | { |
| 3139 | return RealStopcxx . . $ RealStop(bf754e76938c308f).( (PaAlsaStreamcxx . . $ PaAlsaStream# * ) s, 1 ); |
| 3140 | } |
| 3141 | |
| 3142 | /** The stream is considered stopped before StartStream, or AFTER a call to Abort/StopStream (callback |
| 3143 | * returning !paContinue is not considered) |
| 3144 | * |
| 3145 | */ |
| 3146 | static PaErrorcxx . . $ PaError# IsStreamStoppedcxx . . $ IsStreamStopped(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *s ) |
| 3147 | { |
| 3148 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream = (PaAlsaStreamcxx . . $ PaAlsaStream# *)s; |
| 3149 | |
| 3150 | /* callback_finished indicates we need to join callback thread (ie. in Abort/StopStream) */ |
| 3151 | return !IsStreamActivecxx . . $ IsStreamActive(dedf1e9b1c614a07).( s ) && !stream->callback_finishedcxx . . $ PaAlsaStream#callback_finished.; |
| 3152 | } |
| 3153 | |
| 3154 | static PaErrorcxx . . $ PaError# IsStreamActivecxx . . $ IsStreamActive(dedf1e9b1c614a07).( PaStreamcxx . . $ PaStream# *s ) |
| 3155 | { |
| 3156 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream = (PaAlsaStreamcxx . . $ PaAlsaStream#*)s; |
| 3157 | return stream->isActivecxx . . $ PaAlsaStream#isActive.; |
| 3158 | } |
| 3159 | |
| 3160 | static PaTimecxx . . $ PaTime# GetStreamTimecxx . . $ GetStreamTime(a405b17f82753acc).( PaStreamcxx . . $ PaStream# *s ) |
| 3161 | { |
| 3162 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream = (PaAlsaStreamcxx . . $ PaAlsaStream#*)s; |
| 3163 | |
| 3164 | snd_timestamp_tcxx . . $ snd_timestamp_t# timestamp; |
| 3165 | snd_pcm_status_tcxx . . $ snd_pcm_status_t#* status; |
| 3166 | alsa_snd_pcm_status_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:227:9`!( &status ); |
| 3167 | |
| 3168 | /* TODO: what if we have both? does it really matter? */ |
| 3169 | |
| 3170 | /* TODO: if running in callback mode, this will mean |
| 3171 | * libasound routines are being called from multiple threads. |
| 3172 | * need to verify that libasound is thread-safe. */ |
| 3173 | |
| 3174 | if( stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3175 | { |
| 3176 | alsa_snd_pcm_statuscxx . . $ alsa_snd_pcm_status.( stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., status ); |
| 3177 | } |
| 3178 | else if( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3179 | { |
| 3180 | alsa_snd_pcm_statuscxx . . $ alsa_snd_pcm_status.( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., status ); |
| 3181 | } |
| 3182 | |
| 3183 | alsa_snd_pcm_status_get_tstampcxx . . $ alsa_snd_pcm_status_get_tstamp.( status, ×tamp ); |
| 3184 | return timestamp.tv_seccxx . . $ timeval#tv_sec. + (PaTimecxx . . $ PaTime#)timestamp.tv_useccxx . . $ timeval#tv_usec. / 1e6; |
| 3185 | } |
| 3186 | |
| 3187 | static double GetStreamCpuLoadcxx . . $ GetStreamCpuLoad(a405b17f82753acc).( PaStreamcxx . . $ PaStream#* s ) |
| 3188 | { |
| 3189 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream = (PaAlsaStreamcxx . . $ PaAlsaStream#*)s; |
| 3190 | |
| 3191 | return PaUtil_GetCpuLoadcxx . . $ PaUtil_GetCpuLoad(6d83850f5e898215).( &stream->cpuLoadMeasurercxx . . $ PaAlsaStream#cpuLoadMeasurer. ); |
| 3192 | } |
| 3193 | |
| 3194 | /* Set the stream sample rate to a nominal value requested; allow only a defined tolerance range */ |
| 3195 | static int SetApproximateSampleRatecxx . . $ SetApproximateSampleRate(95b810ef3c6fd091).( snd_pcm_tcxx . . $ snd_pcm_t# *pcm, snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t# *hwParams, double sampleRate ) |
| 3196 | { |
| 3197 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3198 | unsigned int reqRate, setRate, deviation; |
| 3199 | |
| 3200 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( pcm && hwParams ); |
| 3201 | |
| 3202 | /* The Alsa sample rate is set by integer value; also the actual rate may differ */ |
| 3203 | reqRate = setRate = (unsigned int) sampleRate; |
| 3204 | |
| 3205 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_set_rate_near( pcm, hwParams, &setRate, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ), paUnanticipatedHostError ); |
| 3206 | /* The value actually set will be put in 'setRate' (may be way off); check the deviation as a proportion |
| 3207 | * of the requested-rate with reference to the max-deviate-ratio (larger values allow less deviation) */ |
| 3208 | deviation = abscxx . . $ abs(7864480464b09eea).( (int)setRate - (int)reqRate ); |
| 3209 | if( deviation > 0 && deviation * RATE_MAX_DEVIATE_RATIOcxx . . $ `external/portaudio/pa_linux_alsa.c:92:9`! > reqRate ) |
| 3210 | result = paInvalidSampleRatecxx . . $ paInvalidSampleRate.; |
| 3211 | |
| 3212 | end: |
| 3213 | return result; |
| 3214 | |
| 3215 | error: |
| 3216 | /* Log */ |
| 3217 | { |
| 3218 | unsigned int _min = 0, _max = 0; |
| 3219 | int _dir = 0; |
| 3220 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_rate_min( hwParams, &_min, &_dir ), paUnanticipatedHostError ); |
| 3221 | _dir = 0; |
| 3222 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_hw_params_get_rate_max( hwParams, &_max, &_dir ), paUnanticipatedHostError ); |
| 3223 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: SR min = %u, max = %u, req = %u\n", __FUNCTION__, _min, _max, reqRate )); |
| 3224 | } |
| 3225 | goto end; |
| 3226 | } |
| 3227 | |
| 3228 | /* Return exact sample rate in param sampleRate */ |
| 3229 | static int GetExactSampleRatecxx . . $ GetExactSampleRate(cb757e2e28b05fce).( snd_pcm_hw_params_tcxx . . $ snd_pcm_hw_params_t# *hwParams, double *sampleRate ) |
| 3230 | { |
| 3231 | unsigned int num, den = 1; |
| 3232 | int err; |
| 3233 | |
| 3234 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( hwParams ); |
| 3235 | |
| 3236 | err = alsa_snd_pcm_hw_params_get_rate_numdencxx . . $ alsa_snd_pcm_hw_params_get_rate_numden.( hwParams, &num, &den ); |
| 3237 | *sampleRate = (double) num / den; |
| 3238 | |
| 3239 | return err; |
| 3240 | } |
| 3241 | |
| 3242 | /* Utility functions for blocking/callback interfaces */ |
| 3243 | |
| 3244 | /* Atomic restart of stream (we don't want the intermediate state visible) */ |
| 3245 | static PaErrorcxx . . $ PaError# AlsaRestartcxx . . $ AlsaRestart(77d69498be53e9b5).( PaAlsaStreamcxx . . $ PaAlsaStream# *stream ) |
| 3246 | { |
| 3247 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3248 | |
| 3249 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaUnixMutex_Lock( &stream->stateMtx ) ); |
| 3250 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( AlsaStop( stream, 0 ) ); |
| 3251 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( AlsaStart( stream, 0 ) ); |
| 3252 | |
| 3253 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Restarted audio\n", __FUNCTION__ )); |
| 3254 | |
| 3255 | error: |
| 3256 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaUnixMutex_Unlock( &stream->stateMtx ) ); |
| 3257 | |
| 3258 | return result; |
| 3259 | } |
| 3260 | |
| 3261 | /** Recover from xrun state. |
| 3262 | * |
| 3263 | */ |
| 3264 | static PaErrorcxx . . $ PaError# PaAlsaStream_HandleXruncxx . . $ PaAlsaStream_HandleXrun(77d69498be53e9b5).( PaAlsaStreamcxx . . $ PaAlsaStream# *self ) |
| 3265 | { |
| 3266 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3267 | snd_pcm_status_tcxx . . $ snd_pcm_status_t# *st; |
| 3268 | PaTimecxx . . $ PaTime# now = PaUtil_GetTimecxx . . $ PaUtil_GetTime(31fa7155c10fdd13).(); |
| 3269 | snd_timestamp_tcxx . . $ snd_timestamp_t# t; |
| 3270 | int restartAlsa = 0; /* do not restart Alsa by default */ |
| 3271 | |
| 3272 | alsa_snd_pcm_status_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:227:9`!( &st ); |
| 3273 | |
| 3274 | if( self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3275 | { |
| 3276 | alsa_snd_pcm_statuscxx . . $ alsa_snd_pcm_status.( self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., st ); |
| 3277 | if( alsa_snd_pcm_status_get_statecxx . . $ alsa_snd_pcm_status_get_state.( st ) == SND_PCM_STATE_XRUNcxx . . $ SND_PCM_STATE_XRUN. ) |
| 3278 | { |
| 3279 | alsa_snd_pcm_status_get_trigger_tstampcxx . . $ alsa_snd_pcm_status_get_trigger_tstamp.( st, &t ); |
| 3280 | self->underruncxx . . $ PaAlsaStream#underrun. = now * 1000 - ( (PaTimecxx . . $ PaTime#)t.tv_seccxx . . $ timeval#tv_sec. * 1000 + (PaTimecxx . . $ PaTime#)t.tv_useccxx . . $ timeval#tv_usec. / 1000 ); |
| 3281 | |
| 3282 | if( !self->playbackcxx . . $ PaAlsaStream#playback..canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. ) |
| 3283 | { |
| 3284 | if( alsa_snd_pcm_recovercxx . . $ alsa_snd_pcm_recover.( self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., -EPIPEcxx . . $ `<external>/8987895939074593727/errno-base.h:36:9`!, 0 ) < 0 ) |
| 3285 | { |
| 3286 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: [playback] non-MMAP-PCM failed recovering from XRUN, will restart Alsa\n", __FUNCTION__ )); |
| 3287 | ++ restartAlsa; /* did not manage to recover */ |
| 3288 | } |
| 3289 | } |
| 3290 | else |
| 3291 | ++ restartAlsa; /* always restart MMAPed device */ |
| 3292 | } |
| 3293 | } |
| 3294 | if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3295 | { |
| 3296 | alsa_snd_pcm_statuscxx . . $ alsa_snd_pcm_status.( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., st ); |
| 3297 | if( alsa_snd_pcm_status_get_statecxx . . $ alsa_snd_pcm_status_get_state.( st ) == SND_PCM_STATE_XRUNcxx . . $ SND_PCM_STATE_XRUN. ) |
| 3298 | { |
| 3299 | alsa_snd_pcm_status_get_trigger_tstampcxx . . $ alsa_snd_pcm_status_get_trigger_tstamp.( st, &t ); |
| 3300 | self->overruncxx . . $ PaAlsaStream#overrun. = now * 1000 - ((PaTimecxx . . $ PaTime#) t.tv_seccxx . . $ timeval#tv_sec. * 1000 + (PaTimecxx . . $ PaTime#) t.tv_useccxx . . $ timeval#tv_usec. / 1000); |
| 3301 | |
| 3302 | if (!self->capturecxx . . $ PaAlsaStream#capture..canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap.) |
| 3303 | { |
| 3304 | if (alsa_snd_pcm_recovercxx . . $ alsa_snd_pcm_recover.( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., -EPIPEcxx . . $ `<external>/8987895939074593727/errno-base.h:36:9`!, 0 ) < 0) |
| 3305 | { |
| 3306 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: [capture] non-MMAP-PCM failed recovering from XRUN, will restart Alsa\n", __FUNCTION__ )); |
| 3307 | ++ restartAlsa; /* did not manage to recover */ |
| 3308 | } |
| 3309 | } |
| 3310 | else |
| 3311 | ++ restartAlsa; /* always restart MMAPed device */ |
| 3312 | } |
| 3313 | } |
| 3314 | |
| 3315 | if( restartAlsa ) |
| 3316 | { |
| 3317 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: restarting Alsa to recover from XRUN\n", __FUNCTION__ )); |
| 3318 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( AlsaRestart( self ) ); |
| 3319 | } |
| 3320 | |
| 3321 | end: |
| 3322 | return result; |
| 3323 | error: |
| 3324 | goto end; |
| 3325 | } |
| 3326 | |
| 3327 | /** Decide if we should continue polling for specified direction, eventually adjust the poll timeout. |
| 3328 | * |
| 3329 | */ |
| 3330 | static PaErrorcxx . . $ PaError# ContinuePollcxx . . $ ContinuePoll(5dfd4f36c17889fa).( const PaAlsaStreamcxx . . $ PaAlsaStream# *stream, StreamDirectioncxx . . $ StreamDirection# streamDir, int *pollTimeout, int *continuePoll ) |
| 3331 | { |
| 3332 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3333 | snd_pcm_sframes_tcxx . . $ snd_pcm_sframes_t# delay, margin; |
| 3334 | int err; |
| 3335 | const PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent# *component = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, *otherComponent = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 3336 | |
| 3337 | *continuePoll = 1; |
| 3338 | |
| 3339 | if( StreamDirection_Incxx . . $ StreamDirection_In. == streamDir ) |
| 3340 | { |
| 3341 | component = &stream->capturecxx . . $ PaAlsaStream#capture.; |
| 3342 | otherComponent = &stream->playbackcxx . . $ PaAlsaStream#playback.; |
| 3343 | } |
| 3344 | else |
| 3345 | { |
| 3346 | component = &stream->playbackcxx . . $ PaAlsaStream#playback.; |
| 3347 | otherComponent = &stream->capturecxx . . $ PaAlsaStream#capture.; |
| 3348 | } |
| 3349 | |
| 3350 | /* ALSA docs say that negative delay should indicate xrun, but in my experience alsa_snd_pcm_delay returns -EPIPE */ |
| 3351 | if( ( err = alsa_snd_pcm_delaycxx . . $ alsa_snd_pcm_delay.( otherComponent->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., &delay ) ) < 0 ) |
| 3352 | { |
| 3353 | if( err == -EPIPEcxx . . $ `<external>/8987895939074593727/errno-base.h:36:9`! ) |
| 3354 | { |
| 3355 | /* Xrun */ |
| 3356 | *continuePoll = 0; |
| 3357 | goto error; |
| 3358 | } |
| 3359 | |
| 3360 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( err, paUnanticipatedHostError ); |
| 3361 | } |
| 3362 | |
| 3363 | if( StreamDirection_Outcxx . . $ StreamDirection_Out. == streamDir ) |
| 3364 | { |
| 3365 | /* Number of eligible frames before capture overrun */ |
| 3366 | delay = otherComponent->alsaBufferSizecxx . . $ $anonymous_type_c42756aa1fb35d76_1#alsaBufferSize. - delay; |
| 3367 | } |
| 3368 | margin = delay - otherComponent->framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod. / 2; |
| 3369 | |
| 3370 | if( margin < 0 ) |
| 3371 | { |
| 3372 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Stopping poll for %s\n", __FUNCTION__, StreamDirection_In == streamDir ? "capture" : "playback" )); |
| 3373 | *continuePoll = 0; |
| 3374 | } |
| 3375 | else if( margin < otherComponent->framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod. ) |
| 3376 | { |
| 3377 | *pollTimeout = CalculatePollTimeoutcxx . . $ CalculatePollTimeout(c2605310b54a7632).( stream, margin ); |
| 3378 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Trying to poll again for %s frames, pollTimeout: %d\n", |
| 3379 | __FUNCTION__, StreamDirection_In == streamDir ? "capture" : "playback", *pollTimeout )); |
| 3380 | } |
| 3381 | |
| 3382 | error: |
| 3383 | return result; |
| 3384 | } |
| 3385 | |
| 3386 | /* Callback interface */ |
| 3387 | |
| 3388 | static void OnExitcxx . . $ OnExit(5d22bdacc48458e8).( void *data ) |
| 3389 | { |
| 3390 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream = (PaAlsaStreamcxx . . $ PaAlsaStream# *) data; |
| 3391 | |
| 3392 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( data ); |
| 3393 | |
| 3394 | PaUtil_ResetCpuLoadMeasurercxx . . $ PaUtil_ResetCpuLoadMeasurer(798ecf6f58992a18).( &stream->cpuLoadMeasurercxx . . $ PaAlsaStream#cpuLoadMeasurer. ); |
| 3395 | |
| 3396 | stream->callback_finishedcxx . . $ PaAlsaStream#callback_finished. = 1; /* Let the outside world know stream was stopped in callback */ |
| 3397 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Stopping ALSA handles\n", __FUNCTION__ )); |
| 3398 | AlsaStopcxx . . $ AlsaStop(bf754e76938c308f).( stream, stream->callbackAbortcxx . . $ PaAlsaStream#callbackAbort. ); |
| 3399 | |
| 3400 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Stoppage\n", __FUNCTION__ )); |
| 3401 | |
| 3402 | /* Eventually notify user all buffers have played */ |
| 3403 | if( stream->streamRepresentationcxx . . $ PaAlsaStream#streamRepresentation..streamFinishedCallbackcxx . . $ PaUtilStreamRepresentation#streamFinishedCallback. ) |
| 3404 | { |
| 3405 | stream->streamRepresentationcxx . . $ PaAlsaStream#streamRepresentation..streamFinishedCallbackcxx . . $ PaUtilStreamRepresentation#streamFinishedCallback.( stream->streamRepresentationcxx . . $ PaAlsaStream#streamRepresentation..userDatacxx . . $ PaUtilStreamRepresentation#userData. ); |
| 3406 | } |
| 3407 | stream->isActivecxx . . $ PaAlsaStream#isActive. = 0; |
| 3408 | } |
| 3409 | |
| 3410 | static void CalculateTimeInfocxx . . $ CalculateTimeInfo(4dd4135381d9e6d0).( PaAlsaStreamcxx . . $ PaAlsaStream# *stream, PaStreamCallbackTimeInfocxx . . $ PaStreamCallbackTimeInfo# *timeInfo ) |
| 3411 | { |
| 3412 | snd_pcm_status_tcxx . . $ snd_pcm_status_t# *capture_status, *playback_status; |
| 3413 | snd_timestamp_tcxx . . $ snd_timestamp_t# capture_timestamp, playback_timestamp; |
| 3414 | PaTimecxx . . $ PaTime# capture_time = 0., playback_time = 0.; |
| 3415 | |
| 3416 | alsa_snd_pcm_status_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:227:9`!( &capture_status ); |
| 3417 | alsa_snd_pcm_status_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:227:9`!( &playback_status ); |
| 3418 | |
| 3419 | if( stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3420 | { |
| 3421 | snd_pcm_sframes_tcxx . . $ snd_pcm_sframes_t# capture_delay; |
| 3422 | |
| 3423 | alsa_snd_pcm_statuscxx . . $ alsa_snd_pcm_status.( stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., capture_status ); |
| 3424 | alsa_snd_pcm_status_get_tstampcxx . . $ alsa_snd_pcm_status_get_tstamp.( capture_status, &capture_timestamp ); |
| 3425 | |
| 3426 | capture_time = capture_timestamp.tv_seccxx . . $ timeval#tv_sec. + |
| 3427 | ( (PaTimecxx . . $ PaTime#)capture_timestamp.tv_useccxx . . $ timeval#tv_usec. / 1000000.0 ); |
| 3428 | timeInfo->currentTimecxx . . $ PaStreamCallbackTimeInfo#currentTime. = capture_time; |
| 3429 | |
| 3430 | capture_delay = alsa_snd_pcm_status_get_delaycxx . . $ alsa_snd_pcm_status_get_delay.( capture_status ); |
| 3431 | timeInfo->inputBufferAdcTimecxx . . $ PaStreamCallbackTimeInfo#inputBufferAdcTime. = timeInfo->currentTimecxx . . $ PaStreamCallbackTimeInfo#currentTime. - |
| 3432 | (PaTimecxx . . $ PaTime#)capture_delay / stream->streamRepresentationcxx . . $ PaAlsaStream#streamRepresentation..streamInfocxx . . $ PaUtilStreamRepresentation#streamInfo..sampleRatecxx . . $ PaStreamInfo#sampleRate.; |
| 3433 | } |
| 3434 | if( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3435 | { |
| 3436 | snd_pcm_sframes_tcxx . . $ snd_pcm_sframes_t# playback_delay; |
| 3437 | |
| 3438 | alsa_snd_pcm_statuscxx . . $ alsa_snd_pcm_status.( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., playback_status ); |
| 3439 | alsa_snd_pcm_status_get_tstampcxx . . $ alsa_snd_pcm_status_get_tstamp.( playback_status, &playback_timestamp ); |
| 3440 | |
| 3441 | playback_time = playback_timestamp.tv_seccxx . . $ timeval#tv_sec. + |
| 3442 | ((PaTimecxx . . $ PaTime#)playback_timestamp.tv_useccxx . . $ timeval#tv_usec. / 1000000.0); |
| 3443 | |
| 3444 | if( stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) /* Full duplex */ |
| 3445 | { |
| 3446 | /* Hmm, we have both a playback and a capture timestamp. |
| 3447 | * Hopefully they are the same... */ |
| 3448 | if( fabscxx . . $ fabs(447c67c6676f75c3).( capture_time - playback_time ) > 0.01 ) |
| 3449 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "Capture time and playback time differ by %f\n", fabs( capture_time-playback_time ) )); |
| 3450 | } |
| 3451 | else |
| 3452 | timeInfo->currentTimecxx . . $ PaStreamCallbackTimeInfo#currentTime. = playback_time; |
| 3453 | |
| 3454 | playback_delay = alsa_snd_pcm_status_get_delaycxx . . $ alsa_snd_pcm_status_get_delay.( playback_status ); |
| 3455 | timeInfo->outputBufferDacTimecxx . . $ PaStreamCallbackTimeInfo#outputBufferDacTime. = timeInfo->currentTimecxx . . $ PaStreamCallbackTimeInfo#currentTime. + |
| 3456 | (PaTimecxx . . $ PaTime#)playback_delay / stream->streamRepresentationcxx . . $ PaAlsaStream#streamRepresentation..streamInfocxx . . $ PaUtilStreamRepresentation#streamInfo..sampleRatecxx . . $ PaStreamInfo#sampleRate.; |
| 3457 | } |
| 3458 | } |
| 3459 | |
| 3460 | /** Called after buffer processing is finished. |
| 3461 | * |
| 3462 | * A number of mmapped frames is committed, it is possible that an xrun has occurred in the meantime. |
| 3463 | * |
| 3464 | * @param numFrames The number of frames that has been processed |
| 3465 | * @param xrun Return whether an xrun has occurred |
| 3466 | */ |
| 3467 | static PaErrorcxx . . $ PaError# PaAlsaStreamComponent_EndProcessingcxx . . $ PaAlsaStreamComponent_EndProcessing(faa0451db8e0e202).( PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent# *self, unsigned long numFrames, int *xrun ) |
| 3468 | { |
| 3469 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3470 | int res = 0; |
| 3471 | |
| 3472 | /* @concern FullDuplex It is possible that only one direction is marked ready after polling, and processed |
| 3473 | * afterwards |
| 3474 | */ |
| 3475 | if( !self->readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. ) |
| 3476 | goto end; |
| 3477 | |
| 3478 | if( !self->canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. && StreamDirection_Outcxx . . $ StreamDirection_Out. == self->streamDircxx . . $ $anonymous_type_c42756aa1fb35d76_1#streamDir. ) |
| 3479 | { |
| 3480 | /* Play sound */ |
| 3481 | if( self->hostInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#hostInterleaved. ) |
| 3482 | res = alsa_snd_pcm_writeicxx . . $ alsa_snd_pcm_writei.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., self->nonMmapBuffercxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBuffer., numFrames ); |
| 3483 | else |
| 3484 | { |
| 3485 | void *bufs[self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels.]; |
| 3486 | int bufsize = alsa_snd_pcm_format_sizecxx . . $ alsa_snd_pcm_format_size.( self->nativeFormatcxx . . $ $anonymous_type_c42756aa1fb35d76_1#nativeFormat., self->framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod. + 1 ); |
| 3487 | unsigned char *buffer = self->nonMmapBuffercxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBuffer.; |
| 3488 | int i; |
| 3489 | for( i = 0; i < self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels.; ++i ) |
| 3490 | { |
| 3491 | bufs[i] = buffer; |
| 3492 | buffer += bufsize; |
| 3493 | } |
| 3494 | res = alsa_snd_pcm_writencxx . . $ alsa_snd_pcm_writen.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., bufs, numFrames ); |
| 3495 | } |
| 3496 | } |
| 3497 | |
| 3498 | if( self->canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. ) |
| 3499 | res = alsa_snd_pcm_mmap_commitcxx . . $ alsa_snd_pcm_mmap_commit.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., self->offsetcxx . . $ $anonymous_type_c42756aa1fb35d76_1#offset., numFrames ); |
| 3500 | |
| 3501 | if( res == -EPIPEcxx . . $ `<external>/8987895939074593727/errno-base.h:36:9`! || res == -ESTRPIPEcxx . . $ `<external>/17922322188510340118/errno.h:70:9`! ) |
| 3502 | { |
| 3503 | *xrun = 1; |
| 3504 | } |
| 3505 | else |
| 3506 | { |
| 3507 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( res, paUnanticipatedHostError ); |
| 3508 | } |
| 3509 | |
| 3510 | end: |
| 3511 | error: |
| 3512 | return result; |
| 3513 | } |
| 3514 | |
| 3515 | /* Extract buffer from channel area */ |
| 3516 | static unsigned char *ExtractAddresscxx . . $ ExtractAddress(77cd4362b12bf8b2).( const snd_pcm_channel_area_tcxx . . $ snd_pcm_channel_area_t# *area, snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t# offset ) |
| 3517 | { |
| 3518 | return (unsigned char *) area->addrcxx . . $ _snd_pcm_channel_area#addr. + ( area->firstcxx . . $ _snd_pcm_channel_area#first. + offset * area->stepcxx . . $ _snd_pcm_channel_area#step. ) / 8; |
| 3519 | } |
| 3520 | |
| 3521 | /** Do necessary adaption between user and host channels. |
| 3522 | * |
| 3523 | @concern ChannelAdaption Adapting between user and host channels can involve silencing unused channels and |
| 3524 | duplicating mono information if host outputs come in pairs. |
| 3525 | */ |
| 3526 | static PaErrorcxx . . $ PaError# PaAlsaStreamComponent_DoChannelAdaptioncxx . . $ PaAlsaStreamComponent_DoChannelAdaption(5a6eaebf402f29c5).( PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent# *self, PaUtilBufferProcessorcxx . . $ PaUtilBufferProcessor# *bp, int numFrames ) |
| 3527 | { |
| 3528 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3529 | unsigned char *p; |
| 3530 | int i; |
| 3531 | int unusedChans = self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels. - self->numUserChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numUserChannels.; |
| 3532 | unsigned char *src, *dst; |
| 3533 | int convertMono = ( self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels. % 2 ) == 0 && ( self->numUserChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numUserChannels. % 2 ) != 0; |
| 3534 | |
| 3535 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( StreamDirection_Out == self->streamDir ); |
| 3536 | |
| 3537 | if( self->hostInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#hostInterleaved. ) |
| 3538 | { |
| 3539 | int swidth = alsa_snd_pcm_format_sizecxx . . $ alsa_snd_pcm_format_size.( self->nativeFormatcxx . . $ $anonymous_type_c42756aa1fb35d76_1#nativeFormat., 1 ); |
| 3540 | unsigned char *buffer = self->canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. ? ExtractAddresscxx . . $ ExtractAddress(77cd4362b12bf8b2).( self->channelAreascxx . . $ $anonymous_type_c42756aa1fb35d76_1#channelAreas., self->offsetcxx . . $ $anonymous_type_c42756aa1fb35d76_1#offset. ) : self->nonMmapBuffercxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBuffer.; |
| 3541 | |
| 3542 | /* Start after the last user channel */ |
| 3543 | p = buffer + self->numUserChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numUserChannels. * swidth; |
| 3544 | |
| 3545 | if( convertMono ) |
| 3546 | { |
| 3547 | /* Convert the last user channel into stereo pair */ |
| 3548 | src = buffer + ( self->numUserChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numUserChannels. - 1 ) * swidth; |
| 3549 | for( i = 0; i < numFrames; ++i ) |
| 3550 | { |
| 3551 | dst = src + swidth; |
| 3552 | memcpycxx . . $ memcpy(cc817cb175f282d).( dst, src, swidth ); |
| 3553 | src += self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels. * swidth; |
| 3554 | } |
| 3555 | |
| 3556 | /* Don't touch the channel we just wrote to */ |
| 3557 | p += swidth; |
| 3558 | --unusedChans; |
| 3559 | } |
| 3560 | |
| 3561 | if( unusedChans > 0 ) |
| 3562 | { |
| 3563 | /* Silence unused output channels */ |
| 3564 | for( i = 0; i < numFrames; ++i ) |
| 3565 | { |
| 3566 | memsetcxx . . $ memset(d1de1e4fb215f1c6).( p, 0, swidth * unusedChans ); |
| 3567 | p += self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels. * swidth; |
| 3568 | } |
| 3569 | } |
| 3570 | } |
| 3571 | else |
| 3572 | { |
| 3573 | /* We extract the last user channel */ |
| 3574 | if( convertMono ) |
| 3575 | { |
| 3576 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_area_copy( self->channelAreas + self->numUserChannels, self->offset, self->channelAreas + |
| 3577 | ( self->numUserChannels - 1 ), self->offset, numFrames, self->nativeFormat ), paUnanticipatedHostError ); |
| 3578 | --unusedChans; |
| 3579 | } |
| 3580 | if( unusedChans > 0 ) |
| 3581 | { |
| 3582 | alsa_snd_pcm_areas_silencecxx . . $ alsa_snd_pcm_areas_silence.( self->channelAreascxx . . $ $anonymous_type_c42756aa1fb35d76_1#channelAreas. + ( self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels. - unusedChans ), self->offsetcxx . . $ $anonymous_type_c42756aa1fb35d76_1#offset., unusedChans, numFrames, |
| 3583 | self->nativeFormatcxx . . $ $anonymous_type_c42756aa1fb35d76_1#nativeFormat. ); |
| 3584 | } |
| 3585 | } |
| 3586 | |
| 3587 | error: |
| 3588 | return result; |
| 3589 | } |
| 3590 | |
| 3591 | static PaErrorcxx . . $ PaError# PaAlsaStream_EndProcessingcxx . . $ PaAlsaStream_EndProcessing(2d0e8f88e1a956e6).( PaAlsaStreamcxx . . $ PaAlsaStream# *self, unsigned long numFrames, int *xrunOccurred ) |
| 3592 | { |
| 3593 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3594 | int xrun = 0; |
| 3595 | |
| 3596 | if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3597 | { |
| 3598 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_EndProcessing( &self->capture, numFrames, &xrun ) ); |
| 3599 | } |
| 3600 | if( self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3601 | { |
| 3602 | if( self->playbackcxx . . $ PaAlsaStream#playback..numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels. > self->playbackcxx . . $ PaAlsaStream#playback..numUserChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numUserChannels. ) |
| 3603 | { |
| 3604 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_DoChannelAdaption( &self->playback, &self->bufferProcessor, numFrames ) ); |
| 3605 | } |
| 3606 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_EndProcessing( &self->playback, numFrames, &xrun ) ); |
| 3607 | } |
| 3608 | |
| 3609 | error: |
| 3610 | *xrunOccurred = xrun; |
| 3611 | return result; |
| 3612 | } |
| 3613 | |
| 3614 | /** Update the number of available frames. |
| 3615 | * |
| 3616 | */ |
| 3617 | static PaErrorcxx . . $ PaError# PaAlsaStreamComponent_GetAvailableFramescxx . . $ PaAlsaStreamComponent_GetAvailableFrames(c28f1d6e48bf463).( PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent# *self, unsigned long *numFrames, int *xrunOccurred ) |
| 3618 | { |
| 3619 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3620 | snd_pcm_sframes_tcxx . . $ snd_pcm_sframes_t# framesAvail = alsa_snd_pcm_avail_updatecxx . . $ alsa_snd_pcm_avail_update.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ); |
| 3621 | *xrunOccurred = 0; |
| 3622 | |
| 3623 | if( -EPIPEcxx . . $ `<external>/8987895939074593727/errno-base.h:36:9`! == framesAvail ) |
| 3624 | { |
| 3625 | *xrunOccurred = 1; |
| 3626 | framesAvail = 0; |
| 3627 | } |
| 3628 | else |
| 3629 | { |
| 3630 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( framesAvail, paUnanticipatedHostError ); |
| 3631 | } |
| 3632 | |
| 3633 | *numFrames = framesAvail; |
| 3634 | |
| 3635 | error: |
| 3636 | return result; |
| 3637 | } |
| 3638 | |
| 3639 | /** Fill in pollfd objects. |
| 3640 | */ |
| 3641 | static PaErrorcxx . . $ PaError# PaAlsaStreamComponent_BeginPollingcxx . . $ PaAlsaStreamComponent_BeginPolling(6401484dffe9db2a).( PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent#* self, struct pollfdcxx . . $ pollfd#* pfds ) |
| 3642 | { |
| 3643 | int nfds = alsa_snd_pcm_poll_descriptorscxx . . $ alsa_snd_pcm_poll_descriptors.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., pfds, self->nfdscxx . . $ $anonymous_type_c42756aa1fb35d76_1#nfds. ); |
| 3644 | /* If alsa returns anything else, like -EPIPE return */ |
| 3645 | if( nfds != self->nfdscxx . . $ $anonymous_type_c42756aa1fb35d76_1#nfds. ) |
| 3646 | { |
| 3647 | return paUnanticipatedHostErrorcxx . . $ paUnanticipatedHostError.; |
| 3648 | } |
| 3649 | self->readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. = 0; |
| 3650 | |
| 3651 | return paNoErrorcxx . . $ paNoError.; |
| 3652 | } |
| 3653 | |
| 3654 | /** Examine results from poll(). |
| 3655 | * |
| 3656 | * @param pfds pollfds to inspect |
| 3657 | * @param shouldPoll Should we continue to poll |
| 3658 | * @param xrun Has an xrun occurred |
| 3659 | */ |
| 3660 | static PaErrorcxx . . $ PaError# PaAlsaStreamComponent_EndPollingcxx . . $ PaAlsaStreamComponent_EndPolling(30902e159b78bb20).( PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent#* self, struct pollfdcxx . . $ pollfd#* pfds, int* shouldPoll, int* xrun ) |
| 3661 | { |
| 3662 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3663 | unsigned short revents; |
| 3664 | |
| 3665 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_poll_descriptors_revents( self->pcm, pfds, self->nfds, &revents ), paUnanticipatedHostError ); |
| 3666 | if( revents != 0 ) |
| 3667 | { |
| 3668 | if( revents & POLLERRcxx . . $ `<external>/17223861378049612178/poll.h:47:9`! ) |
| 3669 | { |
| 3670 | *xrun = 1; |
| 3671 | } |
| 3672 | else if( revents & POLLHUPcxx . . $ `<external>/17223861378049612178/poll.h:48:9`! ) |
| 3673 | { |
| 3674 | *xrun = 1; |
| 3675 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: revents has POLLHUP, processing as XRUN\n", __FUNCTION__ )); |
| 3676 | } |
| 3677 | else |
| 3678 | self->readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. = 1; |
| 3679 | |
| 3680 | *shouldPoll = 0; |
| 3681 | } |
| 3682 | else /* (A zero revent occurred) */ |
| 3683 | /* Work around an issue with Alsa older than 1.0.16 using some plugins (eg default with plug + dmix) where |
| 3684 | * POLLIN or POLLOUT are zeroed by Alsa-lib if _mmap_avail() is a few frames short of avail_min at period |
| 3685 | * boundary, possibly due to erratic dma interrupts at period boundary? Treat as a valid event. |
| 3686 | */ |
| 3687 | if( self->useReventFixcxx . . $ $anonymous_type_c42756aa1fb35d76_1#useReventFix. ) |
| 3688 | { |
| 3689 | self->readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. = 1; |
| 3690 | *shouldPoll = 0; |
| 3691 | } |
| 3692 | |
| 3693 | error: |
| 3694 | return result; |
| 3695 | } |
| 3696 | |
| 3697 | /** Return the number of available frames for this stream. |
| 3698 | * |
| 3699 | * @concern FullDuplex The minimum available for the two directions is calculated, it might be desirable to ignore |
| 3700 | * one direction however (not marked ready from poll), so this is controlled by queryCapture and queryPlayback. |
| 3701 | * |
| 3702 | * @param queryCapture Check available for capture |
| 3703 | * @param queryPlayback Check available for playback |
| 3704 | * @param available The returned number of frames |
| 3705 | * @param xrunOccurred Return whether an xrun has occurred |
| 3706 | */ |
| 3707 | static PaErrorcxx . . $ PaError# PaAlsaStream_GetAvailableFramescxx . . $ PaAlsaStream_GetAvailableFrames(977ce30c5628dff7).( PaAlsaStreamcxx . . $ PaAlsaStream# *self, int queryCapture, int queryPlayback, unsigned long |
| 3708 | *available, int *xrunOccurred ) |
| 3709 | { |
| 3710 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3711 | unsigned long captureFrames, playbackFrames; |
| 3712 | *xrunOccurred = 0; |
| 3713 | |
| 3714 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( queryCapture || queryPlayback ); |
| 3715 | |
| 3716 | if( queryCapture ) |
| 3717 | { |
| 3718 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self->capture.pcm ); |
| 3719 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_GetAvailableFrames( &self->capture, &captureFrames, xrunOccurred ) ); |
| 3720 | if( *xrunOccurred ) |
| 3721 | { |
| 3722 | goto end; |
| 3723 | } |
| 3724 | } |
| 3725 | if( queryPlayback ) |
| 3726 | { |
| 3727 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self->playback.pcm ); |
| 3728 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_GetAvailableFrames( &self->playback, &playbackFrames, xrunOccurred ) ); |
| 3729 | if( *xrunOccurred ) |
| 3730 | { |
| 3731 | goto end; |
| 3732 | } |
| 3733 | } |
| 3734 | |
| 3735 | if( queryCapture && queryPlayback ) |
| 3736 | { |
| 3737 | *available = PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!( captureFrames, playbackFrames ); |
| 3738 | /*PA_DEBUG(("capture: %lu, playback: %lu, combined: %lu\n", captureFrames, playbackFrames, *available));*/ |
| 3739 | } |
| 3740 | else if( queryCapture ) |
| 3741 | { |
| 3742 | *available = captureFrames; |
| 3743 | } |
| 3744 | else |
| 3745 | { |
| 3746 | *available = playbackFrames; |
| 3747 | } |
| 3748 | |
| 3749 | end: |
| 3750 | error: |
| 3751 | return result; |
| 3752 | } |
| 3753 | |
| 3754 | /** Wait for and report available buffer space from ALSA. |
| 3755 | * |
| 3756 | * Unless ALSA reports a minimum of frames available for I/O, we poll the ALSA filedescriptors for more. |
| 3757 | * Both of these operations can uncover xrun conditions. |
| 3758 | * |
| 3759 | * @concern Xruns Both polling and querying available frames can report an xrun condition. |
| 3760 | * |
| 3761 | * @param framesAvail Return the number of available frames |
| 3762 | * @param xrunOccurred Return whether an xrun has occurred |
| 3763 | */ |
| 3764 | static PaErrorcxx . . $ PaError# PaAlsaStream_WaitForFramescxx . . $ PaAlsaStream_WaitForFrames(a2847f9843e70ad8).( PaAlsaStreamcxx . . $ PaAlsaStream# *self, unsigned long *framesAvail, int *xrunOccurred ) |
| 3765 | { |
| 3766 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3767 | int pollPlayback = self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, pollCapture = self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 3768 | int pollTimeout = self->pollTimeoutcxx . . $ PaAlsaStream#pollTimeout.; |
| 3769 | int xrun = 0, timeouts = 0; |
| 3770 | int pollResults; |
| 3771 | |
| 3772 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self ); |
| 3773 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( framesAvail ); |
| 3774 | |
| 3775 | if( !self->callbackModecxx . . $ PaAlsaStream#callbackMode. ) |
| 3776 | { |
| 3777 | /* In blocking mode we will only wait if necessary */ |
| 3778 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_GetAvailableFrames( self, self->capture.pcm != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, self->playback.pcm != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 3779 | framesAvail, &xrun ) ); |
| 3780 | if( xrun ) |
| 3781 | { |
| 3782 | goto end; |
| 3783 | } |
| 3784 | |
| 3785 | if( *framesAvail > 0 ) |
| 3786 | { |
| 3787 | /* Mark pcms ready from poll */ |
| 3788 | if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3789 | self->capturecxx . . $ PaAlsaStream#capture..readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. = 1; |
| 3790 | if( self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3791 | self->playbackcxx . . $ PaAlsaStream#playback..readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. = 1; |
| 3792 | |
| 3793 | goto end; |
| 3794 | } |
| 3795 | } |
| 3796 | |
| 3797 | while( pollPlayback || pollCapture ) |
| 3798 | { |
| 3799 | int totalFds = 0; |
| 3800 | struct pollfdcxx . . $ pollfd# *capturePfds = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, *playbackPfds = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 3801 | |
| 3802 | #ifdef PTHREAD_CANCELEDcxx . . $ `<external>/14712363683955484316/pthread.h:182:9`! |
| 3803 | pthread_testcancelcxx . . $ pthread_testcancel(49f6e7a06ebc5aa8).(); |
| 3804 | #endif |
| 3805 | if( pollCapture ) |
| 3806 | { |
| 3807 | capturePfds = self->pfdscxx . . $ PaAlsaStream#pfds.; |
| 3808 | PaErrorcxx . . $ PaError# res = PaAlsaStreamComponent_BeginPollingcxx . . $ PaAlsaStreamComponent_BeginPolling(6401484dffe9db2a).( &self->capturecxx . . $ PaAlsaStream#capture., capturePfds ); |
| 3809 | if( res != paNoErrorcxx . . $ paNoError.) |
| 3810 | { |
| 3811 | xrun = 1; |
| 3812 | goto end; |
| 3813 | } |
| 3814 | totalFds += self->capturecxx . . $ PaAlsaStream#capture..nfdscxx . . $ $anonymous_type_c42756aa1fb35d76_1#nfds.; |
| 3815 | } |
| 3816 | if( pollPlayback ) |
| 3817 | { |
| 3818 | /* self->pfds is in effect an array of fds; if necessary, index past the capture fds */ |
| 3819 | playbackPfds = self->pfdscxx . . $ PaAlsaStream#pfds. + (pollCapture ? self->capturecxx . . $ PaAlsaStream#capture..nfdscxx . . $ $anonymous_type_c42756aa1fb35d76_1#nfds. : 0); |
| 3820 | PaErrorcxx . . $ PaError# res = PaAlsaStreamComponent_BeginPollingcxx . . $ PaAlsaStreamComponent_BeginPolling(6401484dffe9db2a).( &self->playbackcxx . . $ PaAlsaStream#playback., playbackPfds ); |
| 3821 | if( res != paNoErrorcxx . . $ paNoError.) |
| 3822 | { |
| 3823 | xrun = 1; |
| 3824 | goto end; |
| 3825 | } |
| 3826 | totalFds += self->playbackcxx . . $ PaAlsaStream#playback..nfdscxx . . $ $anonymous_type_c42756aa1fb35d76_1#nfds.; |
| 3827 | } |
| 3828 | |
| 3829 | #ifdef PTHREAD_CANCELEDcxx . . $ `<external>/14712363683955484316/pthread.h:182:9`! |
| 3830 | if( self->callbackModecxx . . $ PaAlsaStream#callbackMode. ) |
| 3831 | { |
| 3832 | /* To allow 'Abort' to terminate the callback thread, enable cancelability just for poll() (& disable after) */ |
| 3833 | pthread_setcancelstatecxx . . $ pthread_setcancelstate(ac48f4a6ffa9e770).( PTHREAD_CANCEL_ENABLEcxx . . $ `<external>/14712363683955484316/pthread.h:171:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ); |
| 3834 | } |
| 3835 | #endif |
| 3836 | |
| 3837 | pollResults = pollcxx . . $ poll(bc0744c797f613bd).( self->pfdscxx . . $ PaAlsaStream#pfds., totalFds, pollTimeout ); |
| 3838 | |
| 3839 | #ifdef PTHREAD_CANCELEDcxx . . $ `<external>/14712363683955484316/pthread.h:182:9`! |
| 3840 | if( self->callbackModecxx . . $ PaAlsaStream#callbackMode. ) |
| 3841 | { |
| 3842 | pthread_setcancelstatecxx . . $ pthread_setcancelstate(ac48f4a6ffa9e770).( PTHREAD_CANCEL_DISABLEcxx . . $ `<external>/14712363683955484316/pthread.h:173:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ); |
| 3843 | } |
| 3844 | #endif |
| 3845 | |
| 3846 | if( pollResults < 0 ) |
| 3847 | { |
| 3848 | /* XXX: Depend on preprocessor condition? */ |
| 3849 | if( errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EINTRcxx . . $ `<external>/8987895939074593727/errno-base.h:8:9`! ) |
| 3850 | { |
| 3851 | /* gdb */ |
| 3852 | Pa_Sleepcxx . . $ Pa_Sleep(1624ee8275b10bda).( 1 ); /* avoid hot loop */ |
| 3853 | continue; |
| 3854 | } |
| 3855 | |
| 3856 | /* TODO: Add macro for checking system calls */ |
| 3857 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( paInternalError ); |
| 3858 | } |
| 3859 | else if( pollResults == 0 ) |
| 3860 | { |
| 3861 | /* Suspended, paused or failed device can provide 0 poll results. To avoid deadloop in such situation |
| 3862 | * we simply run counter 'timeouts' which detects 0 poll result and accumulates. As soon as 2048 timouts (around 2 seconds) |
| 3863 | * are achieved we simply fail function with paTimedOut to notify waiting methods that device is not capable |
| 3864 | * of providing audio data anymore and needs some corresponding recovery action. |
| 3865 | * Note that 'timeouts' is reset to 0 if poll() managed to return non 0 results. |
| 3866 | */ |
| 3867 | |
| 3868 | /*PA_DEBUG(( "%s: poll == 0 results, timed out, %d times left\n", __FUNCTION__, 2048 - timeouts ));*/ |
| 3869 | ++ timeouts; |
| 3870 | if( timeouts > 1 ) /* sometimes device times out, but normally once, so we do not sleep any time */ |
| 3871 | { |
| 3872 | Pa_Sleepcxx . . $ Pa_Sleep(1624ee8275b10bda).( 1 ); /* avoid hot loop */ |
| 3873 | } |
| 3874 | /* not else ! */ |
| 3875 | if( timeouts >= 2048 ) /* audio device not working, shall return error to notify waiters */ |
| 3876 | { |
| 3877 | *framesAvail = 0; /* no frames available for processing */ |
| 3878 | xrun = 1; /* try recovering device */ |
| 3879 | |
| 3880 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: poll timed out\n", __FUNCTION__, timeouts )); |
| 3881 | goto end;/*PA_ENSURE( paTimedOut );*/ |
| 3882 | } |
| 3883 | } |
| 3884 | else if( pollResults > 0 ) |
| 3885 | { |
| 3886 | /* reset timouts counter */ |
| 3887 | timeouts = 0; |
| 3888 | |
| 3889 | /* check the return status of our pfds */ |
| 3890 | if( pollCapture ) |
| 3891 | { |
| 3892 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_EndPolling( &self->capture, capturePfds, &pollCapture, &xrun ) ); |
| 3893 | } |
| 3894 | if( pollPlayback ) |
| 3895 | { |
| 3896 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_EndPolling( &self->playback, playbackPfds, &pollPlayback, &xrun ) ); |
| 3897 | } |
| 3898 | if( xrun ) |
| 3899 | { |
| 3900 | break; |
| 3901 | } |
| 3902 | } |
| 3903 | |
| 3904 | /* @concern FullDuplex If only one of two pcms is ready we may want to compromise between the two. |
| 3905 | * If there is less than half a period's worth of samples left of frames in the other pcm's buffer we will |
| 3906 | * stop polling. |
| 3907 | */ |
| 3908 | if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. && self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3909 | { |
| 3910 | if( pollCapture && !pollPlayback ) |
| 3911 | { |
| 3912 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( ContinuePoll( self, StreamDirection_In, &pollTimeout, &pollCapture ) ); |
| 3913 | } |
| 3914 | else if( pollPlayback && !pollCapture ) |
| 3915 | { |
| 3916 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( ContinuePoll( self, StreamDirection_Out, &pollTimeout, &pollPlayback ) ); |
| 3917 | } |
| 3918 | } |
| 3919 | } |
| 3920 | |
| 3921 | if( !xrun ) |
| 3922 | { |
| 3923 | /* Get the number of available frames for the pcms that are marked ready. |
| 3924 | * @concern FullDuplex If only one direction is marked ready (from poll), the number of frames available for |
| 3925 | * the other direction is returned. Output is normally preferred over capture however, so capture frames may be |
| 3926 | * discarded to avoid overrun unless paNeverDropInput is specified. |
| 3927 | */ |
| 3928 | int captureReady = self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ? self->capturecxx . . $ PaAlsaStream#capture..readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. : 0, |
| 3929 | playbackReady = self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ? self->playbackcxx . . $ PaAlsaStream#playback..readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. : 0; |
| 3930 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_GetAvailableFrames( self, captureReady, playbackReady, framesAvail, &xrun ) ); |
| 3931 | |
| 3932 | if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. && self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3933 | { |
| 3934 | if( !self->playbackcxx . . $ PaAlsaStream#playback..readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. && !self->neverDropInputcxx . . $ PaAlsaStream#neverDropInput. ) |
| 3935 | { |
| 3936 | /* Drop input, a period's worth */ |
| 3937 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self->capture.ready ); |
| 3938 | PaAlsaStreamComponent_EndProcessingcxx . . $ PaAlsaStreamComponent_EndProcessing(faa0451db8e0e202).( &self->capturecxx . . $ PaAlsaStream#capture., PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!( self->capture.framesPerPeriod, |
| 3939 | *framesAvail ), &xrun ); |
| 3940 | *framesAvail = 0; |
| 3941 | self->capturecxx . . $ PaAlsaStream#capture..readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. = 0; |
| 3942 | } |
| 3943 | } |
| 3944 | else if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 3945 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self->capture.ready ); |
| 3946 | else |
| 3947 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self->playback.ready ); |
| 3948 | } |
| 3949 | |
| 3950 | end: |
| 3951 | error: |
| 3952 | if( xrun ) |
| 3953 | { |
| 3954 | /* Recover from the xrun state */ |
| 3955 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_HandleXrun( self ) ); |
| 3956 | *framesAvail = 0; |
| 3957 | } |
| 3958 | else |
| 3959 | { |
| 3960 | if( 0 != *framesAvail ) |
| 3961 | { |
| 3962 | /* If we're reporting frames eligible for processing, one of the handles better be ready */ |
| 3963 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( self->capture.ready || self->playback.ready, paInternalError ); |
| 3964 | } |
| 3965 | } |
| 3966 | *xrunOccurred = xrun; |
| 3967 | |
| 3968 | return result; |
| 3969 | } |
| 3970 | |
| 3971 | /** Register per-channel ALSA buffer information with buffer processor. |
| 3972 | * |
| 3973 | * Mmapped buffer space is acquired from ALSA, and registered with the buffer processor. Differences between the |
| 3974 | * number of host and user channels is taken into account. |
| 3975 | * |
| 3976 | * @param numFrames On entrance the number of requested frames, on exit the number of contiguously accessible frames. |
| 3977 | */ |
| 3978 | static PaErrorcxx . . $ PaError# PaAlsaStreamComponent_RegisterChannelscxx . . $ PaAlsaStreamComponent_RegisterChannels(326ab0e71bac442e).( PaAlsaStreamComponentcxx . . $ PaAlsaStreamComponent#* self, PaUtilBufferProcessorcxx . . $ PaUtilBufferProcessor#* bp, |
| 3979 | unsigned long* numFrames, int* xrun ) |
| 3980 | { |
| 3981 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 3982 | const snd_pcm_channel_area_tcxx . . $ snd_pcm_channel_area_t# *areas, *area; |
| 3983 | void (*setChannel)(PaUtilBufferProcessorcxx . . $ PaUtilBufferProcessor# *, unsigned int, void *, unsigned int) = |
| 3984 | StreamDirection_Incxx . . $ StreamDirection_In. == self->streamDircxx . . $ $anonymous_type_c42756aa1fb35d76_1#streamDir. ? PaUtil_SetInputChannelcxx . . $ PaUtil_SetInputChannel(ddd0edd67e9e2d45). : PaUtil_SetOutputChannelcxx . . $ PaUtil_SetOutputChannel(ddd0edd67e9e2d45).; |
| 3985 | unsigned char *buffer, *p; |
| 3986 | int i; |
| 3987 | unsigned long framesAvail; |
| 3988 | |
| 3989 | /* This _must_ be called before mmap_begin */ |
| 3990 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_GetAvailableFrames( self, &framesAvail, xrun ) ); |
| 3991 | if( *xrun ) |
| 3992 | { |
| 3993 | *numFrames = 0; |
| 3994 | goto end; |
| 3995 | } |
| 3996 | |
| 3997 | if( self->canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. ) |
| 3998 | { |
| 3999 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_mmap_begin( self->pcm, &areas, &self->offset, numFrames ), paUnanticipatedHostError ); |
| 4000 | /* @concern ChannelAdaption Buffer address is recorded so we can do some channel adaption later */ |
| 4001 | self->channelAreascxx . . $ $anonymous_type_c42756aa1fb35d76_1#channelAreas. = (snd_pcm_channel_area_tcxx . . $ snd_pcm_channel_area_t# *)areas; |
| 4002 | } |
| 4003 | else |
| 4004 | { |
| 4005 | unsigned int bufferSize = self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels. * alsa_snd_pcm_format_sizecxx . . $ alsa_snd_pcm_format_size.( self->nativeFormatcxx . . $ $anonymous_type_c42756aa1fb35d76_1#nativeFormat., *numFrames ); |
| 4006 | if( bufferSize > self->nonMmapBufferSizecxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBufferSize. ) |
| 4007 | { |
| 4008 | self->nonMmapBuffercxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBuffer. = realloccxx . . $ realloc(417ab160f6baadc6).( self->nonMmapBuffercxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBuffer., ( self->nonMmapBufferSizecxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBufferSize. = bufferSize ) ); |
| 4009 | if( !self->nonMmapBuffercxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBuffer. ) |
| 4010 | { |
| 4011 | result = paInsufficientMemorycxx . . $ paInsufficientMemory.; |
| 4012 | goto error; |
| 4013 | } |
| 4014 | } |
| 4015 | } |
| 4016 | |
| 4017 | if( self->hostInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#hostInterleaved. ) |
| 4018 | { |
| 4019 | int swidth = alsa_snd_pcm_format_sizecxx . . $ alsa_snd_pcm_format_size.( self->nativeFormatcxx . . $ $anonymous_type_c42756aa1fb35d76_1#nativeFormat., 1 ); |
| 4020 | |
| 4021 | p = buffer = self->canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. ? ExtractAddresscxx . . $ ExtractAddress(77cd4362b12bf8b2).( areas, self->offsetcxx . . $ $anonymous_type_c42756aa1fb35d76_1#offset. ) : self->nonMmapBuffercxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBuffer.; |
| 4022 | for( i = 0; i < self->numUserChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numUserChannels.; ++i ) |
| 4023 | { |
| 4024 | /* We're setting the channels up to userChannels, but the stride will be hostChannels samples */ |
| 4025 | setChannel( bp, i, p, self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels. ); |
| 4026 | p += swidth; |
| 4027 | } |
| 4028 | } |
| 4029 | else |
| 4030 | { |
| 4031 | if( self->canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. ) |
| 4032 | { |
| 4033 | for( i = 0; i < self->numUserChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numUserChannels.; ++i ) |
| 4034 | { |
| 4035 | area = areas + i; |
| 4036 | buffer = ExtractAddresscxx . . $ ExtractAddress(77cd4362b12bf8b2).( area, self->offsetcxx . . $ $anonymous_type_c42756aa1fb35d76_1#offset. ); |
| 4037 | setChannel( bp, i, buffer, 1 ); |
| 4038 | } |
| 4039 | } |
| 4040 | else |
| 4041 | { |
| 4042 | unsigned int buf_per_ch_size = self->nonMmapBufferSizecxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBufferSize. / self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels.; |
| 4043 | buffer = self->nonMmapBuffercxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBuffer.; |
| 4044 | for( i = 0; i < self->numUserChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numUserChannels.; ++i ) |
| 4045 | { |
| 4046 | setChannel( bp, i, buffer, 1 ); |
| 4047 | buffer += buf_per_ch_size; |
| 4048 | } |
| 4049 | } |
| 4050 | } |
| 4051 | |
| 4052 | if( !self->canMmapcxx . . $ $anonymous_type_c42756aa1fb35d76_1#canMmap. && StreamDirection_Incxx . . $ StreamDirection_In. == self->streamDircxx . . $ $anonymous_type_c42756aa1fb35d76_1#streamDir. ) |
| 4053 | { |
| 4054 | /* Read sound */ |
| 4055 | int res; |
| 4056 | if( self->hostInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#hostInterleaved. ) |
| 4057 | res = alsa_snd_pcm_readicxx . . $ alsa_snd_pcm_readi.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., self->nonMmapBuffercxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBuffer., *numFrames ); |
| 4058 | else |
| 4059 | { |
| 4060 | void *bufs[self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels.]; |
| 4061 | unsigned int buf_per_ch_size = self->nonMmapBufferSizecxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBufferSize. / self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels.; |
| 4062 | unsigned char *buffer = self->nonMmapBuffercxx . . $ $anonymous_type_c42756aa1fb35d76_1#nonMmapBuffer.; |
| 4063 | int i; |
| 4064 | for( i = 0; i < self->numHostChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numHostChannels.; ++i ) |
| 4065 | { |
| 4066 | bufs[i] = buffer; |
| 4067 | buffer += buf_per_ch_size; |
| 4068 | } |
| 4069 | res = alsa_snd_pcm_readncxx . . $ alsa_snd_pcm_readn.( self->pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm., bufs, *numFrames ); |
| 4070 | } |
| 4071 | if( res == -EPIPEcxx . . $ `<external>/8987895939074593727/errno-base.h:36:9`! || res == -ESTRPIPEcxx . . $ `<external>/17922322188510340118/errno.h:70:9`! ) |
| 4072 | { |
| 4073 | *xrun = 1; |
| 4074 | *numFrames = 0; |
| 4075 | } |
| 4076 | } |
| 4077 | |
| 4078 | end: |
| 4079 | error: |
| 4080 | return result; |
| 4081 | } |
| 4082 | |
| 4083 | /** Initiate buffer processing. |
| 4084 | * |
| 4085 | * ALSA buffers are registered with the PA buffer processor and the buffer size (in frames) set. |
| 4086 | * |
| 4087 | * @concern FullDuplex If both directions are being processed, the minimum amount of frames for the two directions is |
| 4088 | * calculated. |
| 4089 | * |
| 4090 | * @param numFrames On entrance the number of available frames, on exit the number of received frames |
| 4091 | * @param xrunOccurred Return whether an xrun has occurred |
| 4092 | */ |
| 4093 | static PaErrorcxx . . $ PaError# PaAlsaStream_SetUpBufferscxx . . $ PaAlsaStream_SetUpBuffers(a2847f9843e70ad8).( PaAlsaStreamcxx . . $ PaAlsaStream#* self, unsigned long* numFrames, int* xrunOccurred ) |
| 4094 | { |
| 4095 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 4096 | unsigned long captureFrames = ULONG_MAXcxx . . $ `<external>/67164224788392828/limits.h:135:9`!, playbackFrames = ULONG_MAXcxx . . $ `<external>/67164224788392828/limits.h:135:9`!, commonFrames = 0; |
| 4097 | int xrun = 0; |
| 4098 | |
| 4099 | if( *xrunOccurred ) |
| 4100 | { |
| 4101 | *numFrames = 0; |
| 4102 | return result; |
| 4103 | } |
| 4104 | /* If we got here at least one of the pcm's should be marked ready */ |
| 4105 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( self->capture.ready || self->playback.ready, paInternalError ); |
| 4106 | |
| 4107 | /* Extract per-channel ALSA buffer pointers and register them with the buffer processor. |
| 4108 | * It is possible that a direction is not marked ready however, because it is out of sync with the other. |
| 4109 | */ |
| 4110 | if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. && self->capturecxx . . $ PaAlsaStream#capture..readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. ) |
| 4111 | { |
| 4112 | captureFrames = *numFrames; |
| 4113 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_RegisterChannels( &self->capture, &self->bufferProcessor, &captureFrames, |
| 4114 | &xrun ) ); |
| 4115 | } |
| 4116 | if( self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. && self->playbackcxx . . $ PaAlsaStream#playback..readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. ) |
| 4117 | { |
| 4118 | playbackFrames = *numFrames; |
| 4119 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_RegisterChannels( &self->playback, &self->bufferProcessor, &playbackFrames, |
| 4120 | &xrun ) ); |
| 4121 | } |
| 4122 | if( xrun ) |
| 4123 | { |
| 4124 | /* Nothing more to do */ |
| 4125 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( 0 == commonFrames ); |
| 4126 | goto end; |
| 4127 | } |
| 4128 | |
| 4129 | commonFrames = PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!( captureFrames, playbackFrames ); |
| 4130 | /* assert( commonFrames <= *numFrames ); */ |
| 4131 | if( commonFrames > *numFrames ) |
| 4132 | { |
| 4133 | /* Hmmm ... how come there are more frames available than we requested!? Blah. */ |
| 4134 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Common available frames are reported to be more than number requested: %lu, %lu, callbackMode: %d\n", __FUNCTION__, |
| 4135 | commonFrames, *numFrames, self->callbackMode )); |
| 4136 | if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 4137 | { |
| 4138 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: captureFrames: %lu, capture.ready: %d\n", __FUNCTION__, captureFrames, self->capture.ready )); |
| 4139 | } |
| 4140 | if( self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 4141 | { |
| 4142 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: playbackFrames: %lu, playback.ready: %d\n", __FUNCTION__, playbackFrames, self->playback.ready )); |
| 4143 | } |
| 4144 | |
| 4145 | commonFrames = 0; |
| 4146 | goto end; |
| 4147 | } |
| 4148 | |
| 4149 | /* Inform PortAudio of the number of frames we got. |
| 4150 | * @concern FullDuplex We might be experiencing underflow in either end; if its an input underflow, we go on |
| 4151 | * with output. If its output underflow however, depending on the paNeverDropInput flag, we may want to simply |
| 4152 | * discard the excess input or call the callback with paOutputOverflow flagged. |
| 4153 | */ |
| 4154 | if( self->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 4155 | { |
| 4156 | if( self->capturecxx . . $ PaAlsaStream#capture..readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. ) |
| 4157 | { |
| 4158 | PaUtil_SetInputFrameCountcxx . . $ PaUtil_SetInputFrameCount(e404da6267a95ab).( &self->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor., commonFrames ); |
| 4159 | } |
| 4160 | else |
| 4161 | { |
| 4162 | /* We have input underflow */ |
| 4163 | PaUtil_SetNoInputcxx . . $ PaUtil_SetNoInput(ad694745b6b5e2b0).( &self->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor. ); |
| 4164 | } |
| 4165 | } |
| 4166 | if( self->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 4167 | { |
| 4168 | if( self->playbackcxx . . $ PaAlsaStream#playback..readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. ) |
| 4169 | { |
| 4170 | PaUtil_SetOutputFrameCountcxx . . $ PaUtil_SetOutputFrameCount(e404da6267a95ab).( &self->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor., commonFrames ); |
| 4171 | } |
| 4172 | else |
| 4173 | { |
| 4174 | /* We have output underflow, but keeping input data (paNeverDropInput) */ |
| 4175 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self->neverDropInput ); |
| 4176 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( self->capture.pcm != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ); |
| 4177 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Setting output buffers to NULL\n", __FUNCTION__ )); |
| 4178 | PaUtil_SetNoOutputcxx . . $ PaUtil_SetNoOutput(ad694745b6b5e2b0).( &self->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor. ); |
| 4179 | } |
| 4180 | } |
| 4181 | |
| 4182 | end: |
| 4183 | *numFrames = commonFrames; |
| 4184 | error: |
| 4185 | if( xrun ) |
| 4186 | { |
| 4187 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_HandleXrun( self ) ); |
| 4188 | *numFrames = 0; |
| 4189 | } |
| 4190 | *xrunOccurred = xrun; |
| 4191 | |
| 4192 | return result; |
| 4193 | } |
| 4194 | |
| 4195 | /** Callback thread's function. |
| 4196 | * |
| 4197 | * Roughly, the workflow can be described in the following way: The number of available frames that can be processed |
| 4198 | * directly is obtained from ALSA, we then request as much directly accessible memory as possible within this amount |
| 4199 | * from ALSA. The buffer memory is registered with the PA buffer processor and processing is carried out with |
| 4200 | * PaUtil_EndBufferProcessing. Finally, the number of processed frames is reported to ALSA. The processing can |
| 4201 | * happen in several iterations until we have consumed the known number of available frames (or an xrun is detected). |
| 4202 | */ |
| 4203 | static void *CallbackThreadFunccxx . . $ CallbackThreadFunc(9f162e79bfc6c74).( void *userData ) |
| 4204 | { |
| 4205 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 4206 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream = (PaAlsaStreamcxx . . $ PaAlsaStream#*) userData; |
| 4207 | PaStreamCallbackTimeInfocxx . . $ PaStreamCallbackTimeInfo# timeInfo = {0, 0, 0}; |
| 4208 | snd_pcm_sframes_tcxx . . $ snd_pcm_sframes_t# startThreshold = 0; |
| 4209 | int callbackResult = paContinuecxx . . $ paContinue.; |
| 4210 | PaStreamCallbackFlagscxx . . $ PaStreamCallbackFlags# cbFlags = 0; /* We might want to keep state across iterations */ |
| 4211 | int streamStarted = 0; |
| 4212 | |
| 4213 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( stream ); |
| 4214 | /* Not implemented */ |
| 4215 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( !stream->primeBuffers ); |
| 4216 | |
| 4217 | /* Execute OnExit when exiting */ |
| 4218 | pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!( &OnExit, stream ); |
| 4219 | #ifdef PTHREAD_CANCELEDcxx . . $ `<external>/14712363683955484316/pthread.h:182:9`! |
| 4220 | /* 'Abort' will use thread cancellation to terminate the callback thread, but the Alsa-lib functions |
| 4221 | * are NOT cancel-safe, (and can end up in an inconsistent state). So, disable cancelability for |
| 4222 | * the thread here, and just re-enable it for the poll() in PaAlsaStream_WaitForFrames(). */ |
| 4223 | pthread_testcancelcxx . . $ pthread_testcancel(49f6e7a06ebc5aa8).(); |
| 4224 | pthread_setcancelstatecxx . . $ pthread_setcancelstate(ac48f4a6ffa9e770).( PTHREAD_CANCEL_DISABLEcxx . . $ `<external>/14712363683955484316/pthread.h:173:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! ); |
| 4225 | #endif |
| 4226 | |
| 4227 | /* @concern StreamStart If the output is being primed the output pcm needs to be prepared, otherwise the |
| 4228 | * stream is started immediately. The latter involves signaling the waiting main thread. |
| 4229 | */ |
| 4230 | if( stream->primeBufferscxx . . $ PaAlsaStream#primeBuffers. ) |
| 4231 | { |
| 4232 | snd_pcm_sframes_tcxx . . $ snd_pcm_sframes_t# avail; |
| 4233 | |
| 4234 | if( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 4235 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_prepare( stream->playback.pcm ), paUnanticipatedHostError ); |
| 4236 | if( stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. && !stream->pcmsSyncedcxx . . $ PaAlsaStream#pcmsSynced. ) |
| 4237 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_prepare( stream->capture.pcm ), paUnanticipatedHostError ); |
| 4238 | |
| 4239 | /* We can't be certain that the whole ring buffer is available for priming, but there should be |
| 4240 | * at least one period */ |
| 4241 | avail = alsa_snd_pcm_avail_updatecxx . . $ alsa_snd_pcm_avail_update.( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ); |
| 4242 | startThreshold = avail - (avail % stream->playbackcxx . . $ PaAlsaStream#playback..framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod.); |
| 4243 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( startThreshold >= stream->playback.framesPerPeriod ); |
| 4244 | } |
| 4245 | else |
| 4246 | { |
| 4247 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaUnixThread_PrepareNotify( &stream->thread ) ); |
| 4248 | /* Buffer will be zeroed */ |
| 4249 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( AlsaStart( stream, 0 ) ); |
| 4250 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaUnixThread_NotifyParent( &stream->thread ) ); |
| 4251 | |
| 4252 | streamStarted = 1; |
| 4253 | } |
| 4254 | |
| 4255 | while( 1 ) |
| 4256 | { |
| 4257 | unsigned long framesAvail, framesGot; |
| 4258 | int xrun = 0; |
| 4259 | |
| 4260 | #ifdef PTHREAD_CANCELEDcxx . . $ `<external>/14712363683955484316/pthread.h:182:9`! |
| 4261 | pthread_testcancelcxx . . $ pthread_testcancel(49f6e7a06ebc5aa8).(); |
| 4262 | #endif |
| 4263 | |
| 4264 | /* @concern StreamStop if the main thread has requested a stop and the stream has not been effectively |
| 4265 | * stopped we signal this condition by modifying callbackResult (we'll want to flush buffered output). |
| 4266 | */ |
| 4267 | if( PaUnixThread_StopRequestedcxx . . $ PaUnixThread_StopRequested(8d04469c9f60d75).( &stream->threadcxx . . $ PaAlsaStream#thread. ) && paContinuecxx . . $ paContinue. == callbackResult ) |
| 4268 | { |
| 4269 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "Setting callbackResult to paComplete\n" )); |
| 4270 | callbackResult = paCompletecxx . . $ paComplete.; |
| 4271 | } |
| 4272 | |
| 4273 | if( paContinuecxx . . $ paContinue. != callbackResult ) |
| 4274 | { |
| 4275 | stream->callbackAbortcxx . . $ PaAlsaStream#callbackAbort. = ( paAbortcxx . . $ paAbort. == callbackResult ); |
| 4276 | if( stream->callbackAbortcxx . . $ PaAlsaStream#callbackAbort. || |
| 4277 | /** @concern BlockAdaption: Go on if adaption buffers are empty */ |
| 4278 | PaUtil_IsBufferProcessorOutputEmptycxx . . $ PaUtil_IsBufferProcessorOutputEmpty(46b4b6bccb6a2631).( &stream->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor. ) ) |
| 4279 | { |
| 4280 | goto end; |
| 4281 | } |
| 4282 | |
| 4283 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Flushing buffer processor\n", __FUNCTION__ )); |
| 4284 | /* There is still buffered output that needs to be processed */ |
| 4285 | } |
| 4286 | |
| 4287 | /* Wait for data to become available, this comes down to polling the ALSA file descriptors until we have |
| 4288 | * a number of available frames. |
| 4289 | */ |
| 4290 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_WaitForFrames( stream, &framesAvail, &xrun ) ); |
| 4291 | if( xrun ) |
| 4292 | { |
| 4293 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( 0 == framesAvail ); |
| 4294 | continue; |
| 4295 | |
| 4296 | /* XXX: Report xruns to the user? A situation is conceivable where the callback is never invoked due |
| 4297 | * to constant xruns, it might be desirable to notify the user of this. |
| 4298 | */ |
| 4299 | } |
| 4300 | |
| 4301 | /* Consume buffer space. Once we have a number of frames available for consumption we must retrieve the |
| 4302 | * mmapped buffers from ALSA, this is contiguously accessible memory however, so we may receive smaller |
| 4303 | * portions at a time than is available as a whole. Therefore we should be prepared to process several |
| 4304 | * chunks successively. The buffers are passed to the PA buffer processor. |
| 4305 | */ |
| 4306 | while( framesAvail > 0 ) |
| 4307 | { |
| 4308 | xrun = 0; |
| 4309 | |
| 4310 | /** @concern Xruns Under/overflows are to be reported to the callback */ |
| 4311 | if( stream->underruncxx . . $ PaAlsaStream#underrun. > 0.0 ) |
| 4312 | { |
| 4313 | cbFlags |= paOutputUnderflowcxx . . $ `external/portaudio/portaudio.h:736:9`!; |
| 4314 | stream->underruncxx . . $ PaAlsaStream#underrun. = 0.0; |
| 4315 | } |
| 4316 | if( stream->overruncxx . . $ PaAlsaStream#overrun. > 0.0 ) |
| 4317 | { |
| 4318 | cbFlags |= paInputOverflowcxx . . $ `external/portaudio/portaudio.h:730:9`!; |
| 4319 | stream->overruncxx . . $ PaAlsaStream#overrun. = 0.0; |
| 4320 | } |
| 4321 | if( stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. && stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) |
| 4322 | { |
| 4323 | /** @concern FullDuplex It's possible that only one direction is being processed to avoid an |
| 4324 | * under- or overflow, this should be reported correspondingly */ |
| 4325 | if( !stream->capturecxx . . $ PaAlsaStream#capture..readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. ) |
| 4326 | { |
| 4327 | cbFlags |= paInputUnderflowcxx . . $ `external/portaudio/portaudio.h:721:9`!; |
| 4328 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Input underflow\n", __FUNCTION__ )); |
| 4329 | } |
| 4330 | else if( !stream->playbackcxx . . $ PaAlsaStream#playback..readycxx . . $ $anonymous_type_c42756aa1fb35d76_1#ready. ) |
| 4331 | { |
| 4332 | cbFlags |= paOutputOverflowcxx . . $ `external/portaudio/portaudio.h:741:9`!; |
| 4333 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Output overflow\n", __FUNCTION__ )); |
| 4334 | } |
| 4335 | } |
| 4336 | |
| 4337 | #if 0 |
| 4338 | CallbackUpdate( &stream->threading ); |
| 4339 | #endif |
| 4340 | |
| 4341 | CalculateTimeInfocxx . . $ CalculateTimeInfo(4dd4135381d9e6d0).( stream, &timeInfo ); |
| 4342 | PaUtil_BeginBufferProcessingcxx . . $ PaUtil_BeginBufferProcessing(df016153b88db4c).( &stream->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor., &timeInfo, cbFlags ); |
| 4343 | cbFlags = 0; |
| 4344 | |
| 4345 | /* CPU load measurement should include processing activity external to the stream callback */ |
| 4346 | PaUtil_BeginCpuLoadMeasurementcxx . . $ PaUtil_BeginCpuLoadMeasurement(798ecf6f58992a18).( &stream->cpuLoadMeasurercxx . . $ PaAlsaStream#cpuLoadMeasurer. ); |
| 4347 | |
| 4348 | framesGot = framesAvail; |
| 4349 | if( paUtilFixedHostBufferSizecxx . . $ paUtilFixedHostBufferSize. == stream->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor..hostBufferSizeModecxx . . $ $anonymous_type_33f8fe5f0a49cfa7_1#hostBufferSizeMode. ) |
| 4350 | { |
| 4351 | /* We've committed to a fixed host buffer size, stick to that */ |
| 4352 | framesGot = framesGot >= stream->maxFramesPerHostBuffercxx . . $ PaAlsaStream#maxFramesPerHostBuffer. ? stream->maxFramesPerHostBuffercxx . . $ PaAlsaStream#maxFramesPerHostBuffer. : 0; |
| 4353 | } |
| 4354 | else |
| 4355 | { |
| 4356 | /* We've committed to an upper bound on the size of host buffers */ |
| 4357 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( paUtilBoundedHostBufferSize == stream->bufferProcessor.hostBufferSizeMode ); |
| 4358 | framesGot = PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!( framesGot, stream->maxFramesPerHostBuffer ); |
| 4359 | } |
| 4360 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_SetUpBuffers( stream, &framesGot, &xrun ) ); |
| 4361 | /* Check the host buffer size against the buffer processor configuration */ |
| 4362 | framesAvail -= framesGot; |
| 4363 | |
| 4364 | if( framesGot > 0 ) |
| 4365 | { |
| 4366 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( !xrun ); |
| 4367 | PaUtil_EndBufferProcessingcxx . . $ PaUtil_EndBufferProcessing(fd3913764679277b).( &stream->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor., &callbackResult ); |
| 4368 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_EndProcessing( stream, framesGot, &xrun ) ); |
| 4369 | } |
| 4370 | PaUtil_EndCpuLoadMeasurementcxx . . $ PaUtil_EndCpuLoadMeasurement(394649c2147554a2).( &stream->cpuLoadMeasurercxx . . $ PaAlsaStream#cpuLoadMeasurer., framesGot ); |
| 4371 | |
| 4372 | if( 0 == framesGot ) |
| 4373 | { |
| 4374 | /* Go back to polling for more frames */ |
| 4375 | break; |
| 4376 | } |
| 4377 | |
| 4378 | if( paContinuecxx . . $ paContinue. != callbackResult ) |
| 4379 | break; |
| 4380 | } |
| 4381 | } |
| 4382 | |
| 4383 | end: |
| 4384 | ; /* Hack to fix "label at end of compound statement" error caused by pthread_cleanup_pop(1) macro. */ |
| 4385 | /* Match pthread_cleanup_push */ |
| 4386 | pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!( 1 ); |
| 4387 | |
| 4388 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Thread %d exiting\n ", __FUNCTION__, pthread_self() )); |
| 4389 | PaUnixThreading_EXITcxx . . $ `external/portaudio/pa_unix_util.h:171:9`!( result ); |
| 4390 | |
| 4391 | error: |
| 4392 | PA_DEBUGcxx . . $ `external/portaudio/pa_debugprint.h:99:9`!(( "%s: Thread %d is canceled due to error %d\n ", __FUNCTION__, pthread_self(), result )); |
| 4393 | goto end; |
| 4394 | } |
| 4395 | |
| 4396 | /* Blocking interface */ |
| 4397 | |
| 4398 | static PaErrorcxx . . $ PaError# ReadStreamcxx . . $ ReadStream(c5040b39c98d43dd).( PaStreamcxx . . $ PaStream#* s, void *buffer, unsigned long frames ) |
| 4399 | { |
| 4400 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 4401 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream = (PaAlsaStreamcxx . . $ PaAlsaStream#*)s; |
| 4402 | unsigned long framesGot, framesAvail; |
| 4403 | void *userBuffer; |
| 4404 | snd_pcm_tcxx . . $ snd_pcm_t# *save = stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm.; |
| 4405 | |
| 4406 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( stream ); |
| 4407 | |
| 4408 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( stream->capture.pcm, paCanNotReadFromAnOutputOnlyStream ); |
| 4409 | |
| 4410 | /* Disregard playback */ |
| 4411 | stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 4412 | |
| 4413 | if( stream->overruncxx . . $ PaAlsaStream#overrun. > 0. ) |
| 4414 | { |
| 4415 | result = paInputOverflowedcxx . . $ paInputOverflowed.; |
| 4416 | stream->overruncxx . . $ PaAlsaStream#overrun. = 0.0; |
| 4417 | } |
| 4418 | |
| 4419 | if( stream->capturecxx . . $ PaAlsaStream#capture..userInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#userInterleaved. ) |
| 4420 | { |
| 4421 | userBuffer = buffer; |
| 4422 | } |
| 4423 | else |
| 4424 | { |
| 4425 | /* Copy channels into local array */ |
| 4426 | userBuffer = stream->capturecxx . . $ PaAlsaStream#capture..userBufferscxx . . $ $anonymous_type_c42756aa1fb35d76_1#userBuffers.; |
| 4427 | memcpycxx . . $ memcpy(cc817cb175f282d).( userBuffer, buffer, sizeof (void *) * stream->capturecxx . . $ PaAlsaStream#capture..numUserChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numUserChannels. ); |
| 4428 | } |
| 4429 | |
| 4430 | /* Start stream if in prepared state */ |
| 4431 | if( alsa_snd_pcm_statecxx . . $ alsa_snd_pcm_state.( stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) == SND_PCM_STATE_PREPAREDcxx . . $ SND_PCM_STATE_PREPARED. ) |
| 4432 | { |
| 4433 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_start( stream->capture.pcm ), paUnanticipatedHostError ); |
| 4434 | } |
| 4435 | |
| 4436 | while( frames > 0 ) |
| 4437 | { |
| 4438 | int xrun = 0; |
| 4439 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_WaitForFrames( stream, &framesAvail, &xrun ) ); |
| 4440 | framesGot = PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!( framesAvail, frames ); |
| 4441 | |
| 4442 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_SetUpBuffers( stream, &framesGot, &xrun ) ); |
| 4443 | if( framesGot > 0 ) |
| 4444 | { |
| 4445 | framesGot = PaUtil_CopyInputcxx . . $ PaUtil_CopyInput(5de04e6ef1a39085).( &stream->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor., &userBuffer, framesGot ); |
| 4446 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_EndProcessing( stream, framesGot, &xrun ) ); |
| 4447 | frames -= framesGot; |
| 4448 | } |
| 4449 | } |
| 4450 | |
| 4451 | end: |
| 4452 | stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. = save; |
| 4453 | return result; |
| 4454 | error: |
| 4455 | goto end; |
| 4456 | } |
| 4457 | |
| 4458 | static PaErrorcxx . . $ PaError# WriteStreamcxx . . $ WriteStream(72e086fd9bc8337a).( PaStreamcxx . . $ PaStream#* s, const void *buffer, unsigned long frames ) |
| 4459 | { |
| 4460 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 4461 | signed long err; |
| 4462 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream = (PaAlsaStreamcxx . . $ PaAlsaStream#*)s; |
| 4463 | snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t# framesGot, framesAvail; |
| 4464 | const void *userBuffer; |
| 4465 | snd_pcm_tcxx . . $ snd_pcm_t# *save = stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm.; |
| 4466 | |
| 4467 | assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!( stream ); |
| 4468 | |
| 4469 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( stream->playback.pcm, paCanNotWriteToAnInputOnlyStream ); |
| 4470 | |
| 4471 | /* Disregard capture */ |
| 4472 | stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 4473 | |
| 4474 | if( stream->underruncxx . . $ PaAlsaStream#underrun. > 0. ) |
| 4475 | { |
| 4476 | result = paOutputUnderflowedcxx . . $ paOutputUnderflowed.; |
| 4477 | stream->underruncxx . . $ PaAlsaStream#underrun. = 0.0; |
| 4478 | } |
| 4479 | |
| 4480 | if( stream->playbackcxx . . $ PaAlsaStream#playback..userInterleavedcxx . . $ $anonymous_type_c42756aa1fb35d76_1#userInterleaved. ) |
| 4481 | userBuffer = buffer; |
| 4482 | else /* Copy channels into local array */ |
| 4483 | { |
| 4484 | userBuffer = stream->playbackcxx . . $ PaAlsaStream#playback..userBufferscxx . . $ $anonymous_type_c42756aa1fb35d76_1#userBuffers.; |
| 4485 | memcpycxx . . $ memcpy(cc817cb175f282d).( (void *)userBuffer, buffer, sizeof (void *) * stream->playbackcxx . . $ PaAlsaStream#playback..numUserChannelscxx . . $ $anonymous_type_c42756aa1fb35d76_1#numUserChannels. ); |
| 4486 | } |
| 4487 | |
| 4488 | while( frames > 0 ) |
| 4489 | { |
| 4490 | int xrun = 0; |
| 4491 | snd_pcm_uframes_tcxx . . $ snd_pcm_uframes_t# hwAvail; |
| 4492 | |
| 4493 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_WaitForFrames( stream, &framesAvail, &xrun ) ); |
| 4494 | framesGot = PA_MINcxx . . $ `external/portaudio/pa_unix_util.h:57:9`!( framesAvail, frames ); |
| 4495 | |
| 4496 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_SetUpBuffers( stream, &framesGot, &xrun ) ); |
| 4497 | if( framesGot > 0 ) |
| 4498 | { |
| 4499 | framesGot = PaUtil_CopyOutputcxx . . $ PaUtil_CopyOutput(f7791ecebbb27bf1).( &stream->bufferProcessorcxx . . $ PaAlsaStream#bufferProcessor., &userBuffer, framesGot ); |
| 4500 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_EndProcessing( stream, framesGot, &xrun ) ); |
| 4501 | frames -= framesGot; |
| 4502 | } |
| 4503 | |
| 4504 | /* Start stream after one period of samples worth */ |
| 4505 | |
| 4506 | /* Frames residing in buffer */ |
| 4507 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( err = GetStreamWriteAvailable( stream ) ); |
| 4508 | framesAvail = err; |
| 4509 | hwAvail = stream->playbackcxx . . $ PaAlsaStream#playback..alsaBufferSizecxx . . $ $anonymous_type_c42756aa1fb35d76_1#alsaBufferSize. - framesAvail; |
| 4510 | |
| 4511 | if( alsa_snd_pcm_statecxx . . $ alsa_snd_pcm_state.( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ) == SND_PCM_STATE_PREPAREDcxx . . $ SND_PCM_STATE_PREPARED. && |
| 4512 | hwAvail >= stream->playbackcxx . . $ PaAlsaStream#playback..framesPerPeriodcxx . . $ $anonymous_type_c42756aa1fb35d76_1#framesPerPeriod. ) |
| 4513 | { |
| 4514 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( alsa_snd_pcm_start( stream->playback.pcm ), paUnanticipatedHostError ); |
| 4515 | } |
| 4516 | } |
| 4517 | |
| 4518 | end: |
| 4519 | stream->capturecxx . . $ PaAlsaStream#capture..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. = save; |
| 4520 | return result; |
| 4521 | error: |
| 4522 | goto end; |
| 4523 | } |
| 4524 | |
| 4525 | /* Return frames available for reading. In the event of an overflow, the capture pcm will be restarted */ |
| 4526 | static signed long GetStreamReadAvailablecxx . . $ GetStreamReadAvailable(72c1818a5177f981).( PaStreamcxx . . $ PaStream#* s ) |
| 4527 | { |
| 4528 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 4529 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream = (PaAlsaStreamcxx . . $ PaAlsaStream#*)s; |
| 4530 | unsigned long avail; |
| 4531 | int xrun; |
| 4532 | |
| 4533 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_GetAvailableFrames( &stream->capture, &avail, &xrun ) ); |
| 4534 | if( xrun ) |
| 4535 | { |
| 4536 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_HandleXrun( stream ) ); |
| 4537 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_GetAvailableFrames( &stream->capture, &avail, &xrun ) ); |
| 4538 | if( xrun ) |
| 4539 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( paInputOverflowed ); |
| 4540 | } |
| 4541 | |
| 4542 | return (signed long)avail; |
| 4543 | |
| 4544 | error: |
| 4545 | return result; |
| 4546 | } |
| 4547 | |
| 4548 | static signed long GetStreamWriteAvailablecxx . . $ GetStreamWriteAvailable(72c1818a5177f981).( PaStreamcxx . . $ PaStream#* s ) |
| 4549 | { |
| 4550 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 4551 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream = (PaAlsaStreamcxx . . $ PaAlsaStream#*)s; |
| 4552 | unsigned long avail; |
| 4553 | int xrun; |
| 4554 | |
| 4555 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStreamComponent_GetAvailableFrames( &stream->playback, &avail, &xrun ) ); |
| 4556 | if( xrun ) |
| 4557 | { |
| 4558 | snd_pcm_sframes_tcxx . . $ snd_pcm_sframes_t# savail; |
| 4559 | |
| 4560 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaAlsaStream_HandleXrun( stream ) ); |
| 4561 | savail = alsa_snd_pcm_avail_updatecxx . . $ alsa_snd_pcm_avail_update.( stream->playbackcxx . . $ PaAlsaStream#playback..pcmcxx . . $ $anonymous_type_c42756aa1fb35d76_1#pcm. ); |
| 4562 | |
| 4563 | /* savail should not contain -EPIPE now, since PaAlsaStream_HandleXrun will only prepare the pcm */ |
| 4564 | ENSURE_cxx . . $ `external/portaudio/pa_linux_alsa.c:565:9`!( savail, paUnanticipatedHostError ); |
| 4565 | |
| 4566 | avail = (unsigned long) savail; |
| 4567 | } |
| 4568 | |
| 4569 | return (signed long)avail; |
| 4570 | |
| 4571 | error: |
| 4572 | return result; |
| 4573 | } |
| 4574 | |
| 4575 | /* Extensions */ |
| 4576 | |
| 4577 | void PaAlsa_InitializeStreamInfocxx . . $ PaAlsa_InitializeStreamInfo(1887ca9b8000d8c).( PaAlsaStreamInfocxx . . $ PaAlsaStreamInfo# *info ) |
| 4578 | { |
| 4579 | info->sizecxx . . $ PaAlsaStreamInfo#size. = sizeof (PaAlsaStreamInfocxx . . $ PaAlsaStreamInfo#); |
| 4580 | info->hostApiTypecxx . . $ PaAlsaStreamInfo#hostApiType. = paALSAcxx . . $ paALSA.; |
| 4581 | info->versioncxx . . $ PaAlsaStreamInfo#version. = 1; |
| 4582 | info->deviceStringcxx . . $ PaAlsaStreamInfo#deviceString. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 4583 | } |
| 4584 | |
| 4585 | void PaAlsa_EnableRealtimeSchedulingcxx . . $ PaAlsa_EnableRealtimeScheduling(d0320739773070f2).( PaStreamcxx . . $ PaStream# *s, int enable ) |
| 4586 | { |
| 4587 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream = (PaAlsaStreamcxx . . $ PaAlsaStream# *) s; |
| 4588 | stream->rtSchedcxx . . $ PaAlsaStream#rtSched. = enable; |
| 4589 | } |
| 4590 | |
| 4591 | #if 0 |
| 4592 | void PaAlsa_EnableWatchdog( PaStream *s, int enable ) |
| 4593 | { |
| 4594 | PaAlsaStream *stream = (PaAlsaStream *) s; |
| 4595 | stream->thread.useWatchdog = enable; |
| 4596 | } |
| 4597 | #endif |
| 4598 | |
| 4599 | static PaErrorcxx . . $ PaError# GetAlsaStreamPointercxx . . $ GetAlsaStreamPointer(1ce5d00adc30dbf2).( PaStreamcxx . . $ PaStream#* s, PaAlsaStreamcxx . . $ PaAlsaStream#** stream ) |
| 4600 | { |
| 4601 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 4602 | PaUtilHostApiRepresentationcxx . . $ PaUtilHostApiRepresentation#* hostApi; |
| 4603 | PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation#* alsaHostApi; |
| 4604 | |
| 4605 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaUtil_ValidateStreamPointer( s ) ); |
| 4606 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( PaUtil_GetHostApiRepresentation( &hostApi, paALSA ) ); |
| 4607 | alsaHostApi = (PaAlsaHostApiRepresentationcxx . . $ PaAlsaHostApiRepresentation#*)hostApi; |
| 4608 | |
| 4609 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( PA_STREAM_REPcxx . . $ `external/portaudio/pa_stream.h:189:9`!( s )->streamInterface == &alsaHostApi->callbackStreamInterface |
| 4610 | || PA_STREAM_REPcxx . . $ `external/portaudio/pa_stream.h:189:9`!( s )->streamInterface == &alsaHostApi->blockingStreamInterface, |
| 4611 | paIncompatibleStreamHostApi ); |
| 4612 | |
| 4613 | *stream = (PaAlsaStreamcxx . . $ PaAlsaStream#*)s; |
| 4614 | error: |
| 4615 | return paNoErrorcxx . . $ paNoError.; |
| 4616 | } |
| 4617 | |
| 4618 | PaErrorcxx . . $ PaError# PaAlsa_GetStreamInputCardcxx . . $ PaAlsa_GetStreamInputCard(4d5d0fc07194c9a7).( PaStreamcxx . . $ PaStream#* s, int* card ) |
| 4619 | { |
| 4620 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream; |
| 4621 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 4622 | snd_pcm_info_tcxx . . $ snd_pcm_info_t#* pcmInfo; |
| 4623 | |
| 4624 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( GetAlsaStreamPointer( s, &stream ) ); |
| 4625 | |
| 4626 | /* XXX: More descriptive error? */ |
| 4627 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( stream->capture.pcm, paDeviceUnavailable ); |
| 4628 | |
| 4629 | alsa_snd_pcm_info_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:197:9`!( &pcmInfo ); |
| 4630 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( alsa_snd_pcm_info( stream->capture.pcm, pcmInfo ) ); |
| 4631 | *card = alsa_snd_pcm_info_get_cardcxx . . $ alsa_snd_pcm_info_get_card.( pcmInfo ); |
| 4632 | |
| 4633 | error: |
| 4634 | return result; |
| 4635 | } |
| 4636 | |
| 4637 | PaErrorcxx . . $ PaError# PaAlsa_GetStreamOutputCardcxx . . $ PaAlsa_GetStreamOutputCard(4d5d0fc07194c9a7).( PaStreamcxx . . $ PaStream#* s, int* card ) |
| 4638 | { |
| 4639 | PaAlsaStreamcxx . . $ PaAlsaStream# *stream; |
| 4640 | PaErrorcxx . . $ PaError# result = paNoErrorcxx . . $ paNoError.; |
| 4641 | snd_pcm_info_tcxx . . $ snd_pcm_info_t#* pcmInfo; |
| 4642 | |
| 4643 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( GetAlsaStreamPointer( s, &stream ) ); |
| 4644 | |
| 4645 | /* XXX: More descriptive error? */ |
| 4646 | PA_UNLESScxx . . $ `external/portaudio/pa_unix_util.h:70:9`!( stream->playback.pcm, paDeviceUnavailable ); |
| 4647 | |
| 4648 | alsa_snd_pcm_info_allocacxx . . $ `external/portaudio/pa_linux_alsa.c:197:9`!( &pcmInfo ); |
| 4649 | PA_ENSUREcxx . . $ `external/portaudio/pa_unix_util.h:83:9`!( alsa_snd_pcm_info( stream->playback.pcm, pcmInfo ) ); |
| 4650 | *card = alsa_snd_pcm_info_get_cardcxx . . $ alsa_snd_pcm_info_get_card.( pcmInfo ); |
| 4651 | |
| 4652 | error: |
| 4653 | return result; |
| 4654 | } |
| 4655 | |
| 4656 | PaErrorcxx . . $ PaError# PaAlsa_SetRetriesBusycxx . . $ PaAlsa_SetRetriesBusy(7864480464b09eea).( int retries ) |
| 4657 | { |
| 4658 | busyRetries_cxx . . $ busyRetries_. = retries; |
| 4659 | return paNoErrorcxx . . $ paNoError.; |
| 4660 | } |
| 4661 | #endif |