1 /* 2 __ 3 / _| 4 __ _ _ _ _ __ ___ _ __ __ _ | |_ ___ ___ ___ 5 / _` | | | | '__/ _ \| '__/ _` | | _/ _ \/ __/ __| 6 | (_| | |_| | | | (_) | | | (_| | | || (_) \__ \__ \ 7 \__,_|\__,_|_| \___/|_| \__,_| |_| \___/|___/___/ 8 9 Copyright (C) 2018-2019 Aurora Free Open Source Software. 10 Copyright (C) 2018-2019 Luís Ferreira <luis@aurorafoss.org> 11 12 This file is part of the Aurora Free Open Source Software. This 13 organization promote free and open source software that you can 14 redistribute and/or modify under the terms of the GNU Lesser General 15 Public License Version 3 as published by the Free Software Foundation or 16 (at your option) any later version approved by the Aurora Free Open Source 17 Software Organization. The license is available in the package root path 18 as 'LICENSE' file. Please review the following information to ensure the 19 GNU Lesser General Public License version 3 requirements will be met: 20 https://www.gnu.org/licenses/lgpl.html . 21 22 Alternatively, this file may be used under the terms of the GNU General 23 Public License version 3 or later as published by the Free Software 24 Foundation. Please review the following information to ensure the GNU 25 General Public License requirements will be met: 26 http://www.gnu.org/licenses/gpl-3.0.html. 27 28 NOTE: All products, services or anything associated to trademarks and 29 service marks used or referenced on this file are the property of their 30 respective companies/owners or its subsidiaries. Other names and brands 31 may be claimed as the property of others. 32 33 For more info about intellectual property visit: aurorafoss.org or 34 directly send an email to: contact (at) aurorafoss.org . 35 */ 36 37 module riverd.soundio.statfun; 38 39 import riverd.soundio.types; 40 41 extern(C) @nogc nothrow: 42 43 /// See also ::soundio_version_major, ::soundio_version_minor, ::soundio_version_patch 44 const(char)* soundio_version_string(); 45 /// See also ::soundio_version_string, ::soundio_version_minor, ::soundio_version_patch 46 int soundio_version_major(); 47 /// See also ::soundio_version_major, ::soundio_version_string, ::soundio_version_patch 48 int soundio_version_minor(); 49 /// See also ::soundio_version_major, ::soundio_version_minor, ::soundio_version_string 50 int soundio_version_patch(); 51 52 /// Create a SoundIo context. You may create multiple instances of this to 53 /// connect to multiple backends. Sets all fields to defaults. 54 /// Returns `NULL` if and only if memory could not be allocated. 55 /// See also ::soundio_destroy 56 SoundIo* soundio_create(); 57 void soundio_destroy(SoundIo* soundio); 58 59 /// Tries ::soundio_connect_backend on all available backends in order. 60 /// Possible errors: 61 /// * #SoundIoErrorInvalid - already connected 62 /// * #SoundIoErrorNoMem 63 /// * #SoundIoErrorSystemResources 64 /// * #SoundIoErrorNoSuchClient - when JACK returns `JackNoSuchClient` 65 /// See also ::soundio_disconnect 66 int soundio_connect(SoundIo* soundio); 67 /// Instead of calling ::soundio_connect you may call this function to try a 68 /// specific backend. 69 /// Possible errors: 70 /// * #SoundIoErrorInvalid - already connected or invalid backend parameter 71 /// * #SoundIoErrorNoMem 72 /// * #SoundIoErrorBackendUnavailable - backend was not compiled in 73 /// * #SoundIoErrorSystemResources 74 /// * #SoundIoErrorNoSuchClient - when JACK returns `JackNoSuchClient` 75 /// * #SoundIoErrorInitAudioBackend - requested `backend` is not active 76 /// * #SoundIoErrorBackendDisconnected - backend disconnected while connecting 77 /// See also ::soundio_disconnect 78 int soundio_connect_backend(SoundIo* soundio, SoundIoBackend backend); 79 void soundio_disconnect(SoundIo* soundio); 80 81 /// Get a string representation of a #SoundIoError 82 const(char)* soundio_strerror(int error); 83 /// Get a string representation of a #SoundIoBackend 84 const(char)* soundio_backend_name(SoundIoBackend backend); 85 86 /// Returns the number of available backends. 87 int soundio_backend_count(SoundIo* soundio); 88 /// get the available backend at the specified index 89 /// (0 <= index < ::soundio_backend_count) 90 SoundIoBackend soundio_get_backend(SoundIo* soundio, int index); 91 92 /// Returns whether libsoundio was compiled with backend. 93 bool soundio_have_backend(SoundIoBackend backend); 94 95 /// Atomically update information for all connected devices. Note that calling 96 /// this function merely flips a pointer; the actual work of collecting device 97 /// information is done elsewhere. It is performant to call this function many 98 /// times per second. 99 /// 100 /// When you call this, the following callbacks might be called: 101 /// * SoundIo::on_devices_change 102 /// * SoundIo::on_backend_disconnect 103 /// This is the only time those callbacks can be called. 104 /// 105 /// This must be called from the same thread as the thread in which you call 106 /// these functions: 107 /// * ::soundio_input_device_count 108 /// * ::soundio_output_device_count 109 /// * ::soundio_get_input_device 110 /// * ::soundio_get_output_device 111 /// * ::soundio_default_input_device_index 112 /// * ::soundio_default_output_device_index 113 /// 114 /// Note that if you do not care about learning about updated devices, you 115 /// might call this function only once ever and never call 116 /// ::soundio_wait_events. 117 void soundio_flush_events(SoundIo* soundio); 118 119 /// This function calls ::soundio_flush_events then blocks until another event 120 /// is ready or you call ::soundio_wakeup. Be ready for spurious wakeups. 121 void soundio_wait_events(SoundIo* soundio); 122 123 /// Makes ::soundio_wait_events stop blocking. 124 void soundio_wakeup(SoundIo* soundio); 125 126 /// If necessary you can manually trigger a device rescan. Normally you will 127 /// not ever have to call this function, as libsoundio listens to system events 128 /// for device changes and responds to them by rescanning devices and preparing 129 /// the new device information for you to be atomically replaced when you call 130 /// ::soundio_flush_events. However you might run into cases where you want to 131 /// force trigger a device rescan, for example if an ALSA device has a 132 /// SoundIoDevice::probe_error. 133 /// 134 /// After you call this you still have to use ::soundio_flush_events or 135 /// ::soundio_wait_events and then wait for the 136 /// SoundIo::on_devices_change callback. 137 /// 138 /// This can be called from any thread context except for 139 /// SoundIoOutStream::write_callback and SoundIoInStream::read_callback 140 void soundio_force_device_scan(SoundIo* soundio); 141 142 // Channel Layouts 143 144 /// Returns whether the channel count field and each channel id matches in 145 /// the supplied channel layouts. 146 bool soundio_channel_layout_equal(const(SoundIoChannelLayout)* a, const(SoundIoChannelLayout)* b); 147 148 const(char)* soundio_get_channel_name(SoundIoChannelId id); 149 /// Given UTF-8 encoded text which is the name of a channel such as 150 /// "Front Left", "FL", or "front-left", return the corresponding 151 /// SoundIoChannelId. Returns SoundIoChannelIdInvalid for no match. 152 SoundIoChannelId soundio_parse_channel_id(const(char)* str, int str_len); 153 154 /// Returns the number of builtin channel layouts. 155 int soundio_channel_layout_builtin_count(); 156 /// Returns a builtin channel layout. 0 <= `index` < ::soundio_channel_layout_builtin_count 157 /// 158 /// Although `index` is of type `int`, it should be a valid 159 /// #SoundIoChannelLayoutId enum value. 160 const(SoundIoChannelLayout)* soundio_channel_layout_get_builtin(int index); 161 162 /// Get the default builtin channel layout for the given number of channels. 163 const(SoundIoChannelLayout)* soundio_channel_layout_get_default(int channel_count); 164 165 /// Return the index of `channel` in `layout`, or `-1` if not found. 166 int soundio_channel_layout_find_channel(const(SoundIoChannelLayout)* layout, 167 SoundIoChannelId channel); 168 169 /// Populates the name field of layout if it matches a builtin one. 170 /// returns whether it found a match 171 bool soundio_channel_layout_detect_builtin(SoundIoChannelLayout* layout); 172 173 /// Iterates over preferred_layouts. Returns the first channel layout in 174 /// preferred_layouts which matches one of the channel layouts in 175 /// available_layouts. Returns NULL if none matches. 176 const(SoundIoChannelLayout)* soundio_best_matching_channel_layout(const(SoundIoChannelLayout)* preferred_layouts, 177 int preferred_layout_count, const(SoundIoChannelLayout)* available_layouts, 178 int available_layout_count); 179 180 /// Sorts by channel count, descending. 181 void soundio_sort_channel_layouts(SoundIoChannelLayout* layouts, int layout_count); 182 183 // Sample Formats 184 185 /// Returns -1 on invalid format. 186 int soundio_get_bytes_per_sample(SoundIoFormat format); 187 188 /// A frame is one sample per channel. 189 int soundio_get_bytes_per_frame(SoundIoFormat format, int channel_count); 190 191 /// Sample rate is the number of frames per second. 192 int soundio_get_bytes_per_second(SoundIoFormat format, int channel_count, int sample_rate); 193 194 /// Returns string representation of `format`. 195 const(char)* soundio_format_string(SoundIoFormat format); 196 197 // Devices 198 199 /// When you call ::soundio_flush_events, a snapshot of all device state is 200 /// saved and these functions merely access the snapshot data. When you want 201 /// to check for new devices, call ::soundio_flush_events. Or you can call 202 /// ::soundio_wait_events to block until devices change. If an error occurs 203 /// scanning devices in a background thread, SoundIo::on_backend_disconnect is called 204 /// with the error code. 205 206 /// Get the number of input devices. 207 /// Returns -1 if you never called ::soundio_flush_events. 208 int soundio_input_device_count(SoundIo* soundio); 209 /// Get the number of output devices. 210 /// Returns -1 if you never called ::soundio_flush_events. 211 int soundio_output_device_count(SoundIo* soundio); 212 213 /// Always returns a device. Call ::soundio_device_unref when done. 214 /// `index` must be 0 <= index < ::soundio_input_device_count 215 /// Returns NULL if you never called ::soundio_flush_events or if you provide 216 /// invalid parameter values. 217 SoundIoDevice* soundio_get_input_device(SoundIo* soundio, int index); 218 /// Always returns a device. Call ::soundio_device_unref when done. 219 /// `index` must be 0 <= index < ::soundio_output_device_count 220 /// Returns NULL if you never called ::soundio_flush_events or if you provide 221 /// invalid parameter values. 222 SoundIoDevice* soundio_get_output_device(SoundIo* soundio, int index); 223 224 /// returns the index of the default input device 225 /// returns -1 if there are no devices or if you never called 226 /// ::soundio_flush_events. 227 int soundio_default_input_device_index(SoundIo* soundio); 228 229 /// returns the index of the default output device 230 /// returns -1 if there are no devices or if you never called 231 /// ::soundio_flush_events. 232 int soundio_default_output_device_index(SoundIo* soundio); 233 234 /// Add 1 to the reference count of `device`. 235 void soundio_device_ref(SoundIoDevice* device); 236 /// Remove 1 to the reference count of `device`. Clean up if it was the last 237 /// reference. 238 void soundio_device_unref(SoundIoDevice* device); 239 240 /// Return `true` if and only if the devices have the same SoundIoDevice::id, 241 /// SoundIoDevice::is_raw, and SoundIoDevice::aim are the same. 242 bool soundio_device_equal(const(SoundIoDevice)* a, const(SoundIoDevice)* b); 243 244 /// Sorts channel layouts by channel count, descending. 245 void soundio_device_sort_channel_layouts(SoundIoDevice* device); 246 247 /// Convenience function. Returns whether `format` is included in the device's 248 /// supported formats. 249 bool soundio_device_supports_format(SoundIoDevice* device, SoundIoFormat format); 250 251 /// Convenience function. Returns whether `layout` is included in the device's 252 /// supported channel layouts. 253 bool soundio_device_supports_layout(SoundIoDevice* device, const(SoundIoChannelLayout)* layout); 254 255 /// Convenience function. Returns whether `sample_rate` is included in the 256 /// device's supported sample rates. 257 bool soundio_device_supports_sample_rate(SoundIoDevice* device, int sample_rate); 258 259 /// Convenience function. Returns the available sample rate nearest to 260 /// `sample_rate`, rounding up. 261 int soundio_device_nearest_sample_rate(SoundIoDevice* device, int sample_rate); 262 263 // Output Streams 264 /// Allocates memory and sets defaults. Next you should fill out the struct fields 265 /// and then call ::soundio_outstream_open. Sets all fields to defaults. 266 /// Returns `NULL` if and only if memory could not be allocated. 267 /// See also ::soundio_outstream_destroy 268 SoundIoOutStream* soundio_outstream_create(SoundIoDevice* device); 269 /// You may not call this function from the SoundIoOutStream::write_callback thread context. 270 void soundio_outstream_destroy(SoundIoOutStream* outstream); 271 272 /// After you call this function, SoundIoOutStream::software_latency is set to 273 /// the correct value. 274 /// 275 /// The next thing to do is call ::soundio_instream_start. 276 /// If this function returns an error, the outstream is in an invalid state and 277 /// you must call ::soundio_outstream_destroy on it. 278 /// 279 /// Possible errors: 280 /// * #SoundIoErrorInvalid 281 /// * SoundIoDevice::aim is not #SoundIoDeviceAimOutput 282 /// * SoundIoOutStream::format is not valid 283 /// * SoundIoOutStream::channel_count is greater than #SOUNDIO_MAX_CHANNELS 284 /// * #SoundIoErrorNoMem 285 /// * #SoundIoErrorOpeningDevice 286 /// * #SoundIoErrorBackendDisconnected 287 /// * #SoundIoErrorSystemResources 288 /// * #SoundIoErrorNoSuchClient - when JACK returns `JackNoSuchClient` 289 /// * #SoundIoErrorOpeningDevice 290 /// * #SoundIoErrorIncompatibleBackend - SoundIoOutStream::channel_count is 291 /// greater than the number of channels the backend can handle. 292 /// * #SoundIoErrorIncompatibleDevice - stream parameters requested are not 293 /// compatible with the chosen device. 294 int soundio_outstream_open(SoundIoOutStream* outstream); 295 296 /// After you call this function, SoundIoOutStream::write_callback will be called. 297 /// 298 /// This function might directly call SoundIoOutStream::write_callback. 299 /// 300 /// Possible errors: 301 /// * #SoundIoErrorStreaming 302 /// * #SoundIoErrorNoMem 303 /// * #SoundIoErrorSystemResources 304 /// * #SoundIoErrorBackendDisconnected 305 int soundio_outstream_start(SoundIoOutStream* outstream); 306 307 /// Call this function when you are ready to begin writing to the device buffer. 308 /// * `outstream` - (in) The output stream you want to write to. 309 /// * `areas` - (out) The memory addresses you can write data to, one per 310 /// channel. It is OK to modify the pointers if that helps you iterate. 311 /// * `frame_count` - (in/out) Provide the number of frames you want to write. 312 /// Returned will be the number of frames you can actually write, which is 313 /// also the number of frames that will be written when you call 314 /// ::soundio_outstream_end_write. The value returned will always be less 315 /// than or equal to the value provided. 316 /// It is your responsibility to call this function exactly as many times as 317 /// necessary to meet the `frame_count_min` and `frame_count_max` criteria from 318 /// SoundIoOutStream::write_callback. 319 /// You must call this function only from the SoundIoOutStream::write_callback thread context. 320 /// After calling this function, write data to `areas` and then call 321 /// ::soundio_outstream_end_write. 322 /// If this function returns an error, do not call ::soundio_outstream_end_write. 323 /// 324 /// Possible errors: 325 /// * #SoundIoErrorInvalid 326 /// * `*frame_count` <= 0 327 /// * `*frame_count` < `frame_count_min` or `*frame_count` > `frame_count_max` 328 /// * function called too many times without respecting `frame_count_max` 329 /// * #SoundIoErrorStreaming 330 /// * #SoundIoErrorUnderflow - an underflow caused this call to fail. You might 331 /// also get a SoundIoOutStream::underflow_callback, and you might not get 332 /// this error code when an underflow occurs. Unlike #SoundIoErrorStreaming, 333 /// the outstream is still in a valid state and streaming can continue. 334 /// * #SoundIoErrorIncompatibleDevice - in rare cases it might just now 335 /// be discovered that the device uses non-byte-aligned access, in which 336 /// case this error code is returned. 337 int soundio_outstream_begin_write(SoundIoOutStream* outstream, 338 SoundIoChannelArea** areas, int* frame_count); 339 340 /// Commits the write that you began with ::soundio_outstream_begin_write. 341 /// You must call this function only from the SoundIoOutStream::write_callback thread context. 342 /// 343 /// Possible errors: 344 /// * #SoundIoErrorStreaming 345 /// * #SoundIoErrorUnderflow - an underflow caused this call to fail. You might 346 /// also get a SoundIoOutStream::underflow_callback, and you might not get 347 /// this error code when an underflow occurs. Unlike #SoundIoErrorStreaming, 348 /// the outstream is still in a valid state and streaming can continue. 349 int soundio_outstream_end_write(SoundIoOutStream* outstream); 350 351 /// Clears the output stream buffer. 352 /// This function can be called from any thread. 353 /// This function can be called regardless of whether the outstream is paused 354 /// or not. 355 /// Some backends do not support clearing the buffer. On these backends this 356 /// function will return SoundIoErrorIncompatibleBackend. 357 /// Some devices do not support clearing the buffer. On these devices this 358 /// function might return SoundIoErrorIncompatibleDevice. 359 /// Possible errors: 360 /// 361 /// * #SoundIoErrorStreaming 362 /// * #SoundIoErrorIncompatibleBackend 363 /// * #SoundIoErrorIncompatibleDevice 364 int soundio_outstream_clear_buffer(SoundIoOutStream* outstream); 365 366 /// If the underlying backend and device support pausing, this pauses the 367 /// stream. SoundIoOutStream::write_callback may be called a few more times if 368 /// the buffer is not full. 369 /// Pausing might put the hardware into a low power state which is ideal if your 370 /// software is silent for some time. 371 /// This function may be called from any thread context, including 372 /// SoundIoOutStream::write_callback. 373 /// Pausing when already paused or unpausing when already unpaused has no 374 /// effect and returns #SoundIoErrorNone. 375 /// 376 /// Possible errors: 377 /// * #SoundIoErrorBackendDisconnected 378 /// * #SoundIoErrorStreaming 379 /// * #SoundIoErrorIncompatibleDevice - device does not support 380 /// pausing/unpausing. This error code might not be returned even if the 381 /// device does not support pausing/unpausing. 382 /// * #SoundIoErrorIncompatibleBackend - backend does not support 383 /// pausing/unpausing. 384 /// * #SoundIoErrorInvalid - outstream not opened and started 385 int soundio_outstream_pause(SoundIoOutStream* outstream, bool pause); 386 387 /// Obtain the total number of seconds that the next frame written after the 388 /// last frame written with ::soundio_outstream_end_write will take to become 389 /// audible. This includes both software and hardware latency. In other words, 390 /// if you call this function directly after calling ::soundio_outstream_end_write, 391 /// this gives you the number of seconds that the next frame written will take 392 /// to become audible. 393 /// 394 /// This function must be called only from within SoundIoOutStream::write_callback. 395 /// 396 /// Possible errors: 397 /// * #SoundIoErrorStreaming 398 int soundio_outstream_get_latency(SoundIoOutStream* outstream, double* out_latency); 399 400 // Input Streams 401 /// Allocates memory and sets defaults. Next you should fill out the struct fields 402 /// and then call ::soundio_instream_open. Sets all fields to defaults. 403 /// Returns `NULL` if and only if memory could not be allocated. 404 /// See also ::soundio_instream_destroy 405 SoundIoInStream* soundio_instream_create(SoundIoDevice* device); 406 /// You may not call this function from SoundIoInStream::read_callback. 407 void soundio_instream_destroy(SoundIoInStream* instream); 408 409 /// After you call this function, SoundIoInStream::software_latency is set to the correct 410 /// value. 411 /// The next thing to do is call ::soundio_instream_start. 412 /// If this function returns an error, the instream is in an invalid state and 413 /// you must call ::soundio_instream_destroy on it. 414 /// 415 /// Possible errors: 416 /// * #SoundIoErrorInvalid 417 /// * device aim is not #SoundIoDeviceAimInput 418 /// * format is not valid 419 /// * requested layout channel count > #SOUNDIO_MAX_CHANNELS 420 /// * #SoundIoErrorOpeningDevice 421 /// * #SoundIoErrorNoMem 422 /// * #SoundIoErrorBackendDisconnected 423 /// * #SoundIoErrorSystemResources 424 /// * #SoundIoErrorNoSuchClient 425 /// * #SoundIoErrorIncompatibleBackend 426 /// * #SoundIoErrorIncompatibleDevice 427 int soundio_instream_open(SoundIoInStream* instream); 428 429 /// After you call this function, SoundIoInStream::read_callback will be called. 430 /// 431 /// Possible errors: 432 /// * #SoundIoErrorBackendDisconnected 433 /// * #SoundIoErrorStreaming 434 /// * #SoundIoErrorOpeningDevice 435 /// * #SoundIoErrorSystemResources 436 int soundio_instream_start(SoundIoInStream* instream); 437 438 /// Call this function when you are ready to begin reading from the device 439 /// buffer. 440 /// * `instream` - (in) The input stream you want to read from. 441 /// * `areas` - (out) The memory addresses you can read data from. It is OK 442 /// to modify the pointers if that helps you iterate. There might be a "hole" 443 /// in the buffer. To indicate this, `areas` will be `NULL` and `frame_count` 444 /// tells how big the hole is in frames. 445 /// * `frame_count` - (in/out) - Provide the number of frames you want to read; 446 /// returns the number of frames you can actually read. The returned value 447 /// will always be less than or equal to the provided value. If the provided 448 /// value is less than `frame_count_min` from SoundIoInStream::read_callback this function 449 /// returns with #SoundIoErrorInvalid. 450 /// It is your responsibility to call this function no more and no fewer than the 451 /// correct number of times according to the `frame_count_min` and 452 /// `frame_count_max` criteria from SoundIoInStream::read_callback. 453 /// You must call this function only from the SoundIoInStream::read_callback thread context. 454 /// After calling this function, read data from `areas` and then use 455 /// ::soundio_instream_end_read` to actually remove the data from the buffer 456 /// and move the read index forward. ::soundio_instream_end_read should not be 457 /// called if the buffer is empty (`frame_count` == 0), but it should be called 458 /// if there is a hole. 459 /// 460 /// Possible errors: 461 /// * #SoundIoErrorInvalid 462 /// * `*frame_count` < `frame_count_min` or `*frame_count` > `frame_count_max` 463 /// * #SoundIoErrorStreaming 464 /// * #SoundIoErrorIncompatibleDevice - in rare cases it might just now 465 /// be discovered that the device uses non-byte-aligned access, in which 466 /// case this error code is returned. 467 int soundio_instream_begin_read(SoundIoInStream* instream, 468 SoundIoChannelArea** areas, int* frame_count); 469 /// This will drop all of the frames from when you called 470 /// ::soundio_instream_begin_read. 471 /// You must call this function only from the SoundIoInStream::read_callback thread context. 472 /// You must call this function only after a successful call to 473 /// ::soundio_instream_begin_read. 474 /// 475 /// Possible errors: 476 /// * #SoundIoErrorStreaming 477 int soundio_instream_end_read(SoundIoInStream* instream); 478 479 /// If the underyling device supports pausing, this pauses the stream and 480 /// prevents SoundIoInStream::read_callback from being called. Otherwise this returns 481 /// #SoundIoErrorIncompatibleDevice. 482 /// This function may be called from any thread. 483 /// Pausing when already paused or unpausing when already unpaused has no 484 /// effect and always returns #SoundIoErrorNone. 485 /// 486 /// Possible errors: 487 /// * #SoundIoErrorBackendDisconnected 488 /// * #SoundIoErrorStreaming 489 /// * #SoundIoErrorIncompatibleDevice - device does not support pausing/unpausing 490 int soundio_instream_pause(SoundIoInStream* instream, bool pause); 491 492 /// Obtain the number of seconds that the next frame of sound being 493 /// captured will take to arrive in the buffer, plus the amount of time that is 494 /// represented in the buffer. This includes both software and hardware latency. 495 /// 496 /// This function must be called only from within SoundIoInStream::read_callback. 497 /// 498 /// Possible errors: 499 /// * #SoundIoErrorStreaming 500 int soundio_instream_get_latency(SoundIoInStream* instream, double* out_latency); 501 502 /// `requested_capacity` in bytes. 503 /// Returns `NULL` if and only if memory could not be allocated. 504 /// Use ::soundio_ring_buffer_capacity to get the actual capacity, which might 505 /// be greater for alignment purposes. 506 /// See also ::soundio_ring_buffer_destroy 507 SoundIoRingBuffer* soundio_ring_buffer_create(SoundIo* soundio, int requested_capacity); 508 void soundio_ring_buffer_destroy(SoundIoRingBuffer* ring_buffer); 509 510 /// When you create a ring buffer, capacity might be more than the requested 511 /// capacity for alignment purposes. This function returns the actual capacity. 512 int soundio_ring_buffer_capacity(SoundIoRingBuffer* ring_buffer); 513 514 /// Do not write more than capacity. 515 char* soundio_ring_buffer_write_ptr(SoundIoRingBuffer* ring_buffer); 516 /// `count` in bytes. 517 void soundio_ring_buffer_advance_write_ptr(SoundIoRingBuffer* ring_buffer, int count); 518 519 /// Do not read more than capacity. 520 char* soundio_ring_buffer_read_ptr(SoundIoRingBuffer* ring_buffer); 521 /// `count` in bytes. 522 void soundio_ring_buffer_advance_read_ptr(SoundIoRingBuffer* ring_buffer, int count); 523 524 /// Returns how many bytes of the buffer is used, ready for reading. 525 int soundio_ring_buffer_fill_count(SoundIoRingBuffer* ring_buffer); 526 527 /// Returns how many bytes of the buffer is free, ready for writing. 528 int soundio_ring_buffer_free_count(SoundIoRingBuffer* ring_buffer); 529 530 /// Must be called by the writer. 531 void soundio_ring_buffer_clear(SoundIoRingBuffer* ring_buffer); 532