@@ -1414,6 +1414,82 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetAudioStreamOutputChannelMap(SDL_AudioStr
1414
1414
*/
1415
1415
extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamData (SDL_AudioStream * stream , const void * buf , int len );
1416
1416
1417
+ /**
1418
+ * A callback that fires for completed SDL_PutAudioStreamDataNoCopy() data.
1419
+ *
1420
+ * When using SDL_PutAudioStreamDataNoCopy() to provide data to an
1421
+ * SDL_AudioStream, it's not safe to dispose of the data until the stream
1422
+ * has completely consumed it. Often times it's difficult to know exactly
1423
+ * when this has happened.
1424
+ *
1425
+ * This callback fires once when the stream no longer needs the buffer,
1426
+ * allowing the app to easily free or reuse it.
1427
+ *
1428
+ * \param userdata an opaque pointer provided by the app for their personal
1429
+ * use.
1430
+ * \param buf the pointer provided to SDL_PutAudioStreamDataNoCopy().
1431
+ * \param buflen the size of buffer, in bytes, provided to
1432
+ * SDL_PutAudioStreamDataNoCopy().
1433
+ *
1434
+ * \threadsafety This callbacks may run from any thread, so if you need to
1435
+ * protect shared data, you should use SDL_LockAudioStream to
1436
+ * serialize access; this lock will be held before your callback
1437
+ * is called, so your callback does not need to manage the lock
1438
+ * explicitly.
1439
+ *
1440
+ * \since This datatype is available since SDL 3.4.0.
1441
+ *
1442
+ * \sa SDL_SetAudioStreamGetCallback
1443
+ * \sa SDL_SetAudioStreamPutCallback
1444
+ */
1445
+ typedef void (SDLCALL * SDL_AudioStreamDataCompleteCallback )(void * userdata , const void * buf , int buflen );
1446
+
1447
+ /**
1448
+ * Add constant data to the stream.
1449
+ *
1450
+ * Unlike SDL_PutAudioStreamData(), this function does not make a copy of the
1451
+ * provided data, instead storing the provided pointer. This means that the
1452
+ * put operation does not need to allocate and copy the data, but the original
1453
+ * data must remain available until the stream is done with it, either by
1454
+ * being read from the stream in its entirety, or a call to
1455
+ * SDL_ClearAudioStream() or SDL_DestroyAudioStream().
1456
+ *
1457
+ * The data must match the format/channels/samplerate specified in the latest
1458
+ * call to SDL_SetAudioStreamFormat, or the format specified when creating the
1459
+ * stream if it hasn't been changed.
1460
+ *
1461
+ * An optional callback may be provided, which is called when the stream no
1462
+ * longer needs the data. Once this callback fires, the stream will not
1463
+ * access the data again.
1464
+ *
1465
+ * Note that there is still an allocation to store tracking information,
1466
+ * so this function is more efficient for larger blocks of data. If you're
1467
+ * planning to put a few samples at a time, it will be more efficient to use
1468
+ * SDL_PutAudioStreamData(), which allocates and buffers in blocks.
1469
+ *
1470
+ * \param stream the stream the audio data is being added to.
1471
+ * \param buf a pointer to the audio data to add.
1472
+ * \param len the number of bytes to write to the stream.
1473
+ * \param callback the callback function to call when the data is no longer
1474
+ * needed by the stream. May be NULL.
1475
+ * \param userdata an opaque pointer provided to the callback for its own
1476
+ * personal use.
1477
+ * \returns true on success or false on failure; call SDL_GetError() for more
1478
+ * information.
1479
+ *
1480
+ * \threadsafety It is safe to call this function from any thread, but if the
1481
+ * stream has a callback set, the caller might need to manage
1482
+ * extra locking.
1483
+ *
1484
+ * \since This function is available since SDL 3.4.0.
1485
+ *
1486
+ * \sa SDL_ClearAudioStream
1487
+ * \sa SDL_FlushAudioStream
1488
+ * \sa SDL_GetAudioStreamData
1489
+ * \sa SDL_GetAudioStreamQueued
1490
+ */
1491
+ extern SDL_DECLSPEC bool SDLCALL SDL_PutAudioStreamDataNoCopy (SDL_AudioStream * stream , const void * buf , int len , SDL_AudioStreamDataCompleteCallback callback , void * userdata );
1492
+
1417
1493
/**
1418
1494
* Add data to the stream with each channel in a separate array.
1419
1495
*
0 commit comments