mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
Minor changes to osaudio.
This commit is contained in:
@@ -240,6 +240,17 @@ I'm looking for feedback on the following:
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
Support far pointers on relevant platforms (DOS, in particular). The version of this file
|
||||||
|
distributed with an operating system wouldn't need this because they would just have an
|
||||||
|
OS-specific version of this file, but as a reference it's useful to use far pointers here.
|
||||||
|
*/
|
||||||
|
#if defined(__MSDOS__) || defined(_MSDOS) || defined(__DOS__)
|
||||||
|
#define OSAUDIO_FAR far
|
||||||
|
#else
|
||||||
|
#define OSAUDIO_FAR
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct _osaudio_t* osaudio_t;
|
typedef struct _osaudio_t* osaudio_t;
|
||||||
typedef struct osaudio_config_t osaudio_config_t;
|
typedef struct osaudio_config_t osaudio_config_t;
|
||||||
typedef struct osaudio_id_t osaudio_id_t;
|
typedef struct osaudio_id_t osaudio_id_t;
|
||||||
@@ -508,7 +519,7 @@ Use osaudio_get_avail() to determine how much data can be written without blocki
|
|||||||
|
|
||||||
Returns 0 on success, < 0 on failure.
|
Returns 0 on success, < 0 on failure.
|
||||||
*/
|
*/
|
||||||
osaudio_result_t osaudio_write(osaudio_t audio, const void* data, unsigned int frame_count);
|
osaudio_result_t osaudio_write(osaudio_t audio, const void OSAUDIO_FAR* data, unsigned int frame_count);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Reads audio data from the device.
|
Reads audio data from the device.
|
||||||
@@ -524,7 +535,7 @@ Use osaudio_get_avail() to determine how much data can be read without blocking.
|
|||||||
|
|
||||||
Returns 0 on success, < 0 on failure.
|
Returns 0 on success, < 0 on failure.
|
||||||
*/
|
*/
|
||||||
osaudio_result_t osaudio_read(osaudio_t audio, void* data, unsigned int frame_count);
|
osaudio_result_t osaudio_read(osaudio_t audio, void OSAUDIO_FAR* data, unsigned int frame_count);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Drains the device.
|
Drains the device.
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ static ma_format osaudio_format_to_miniaudio(osaudio_format_t format)
|
|||||||
switch (format)
|
switch (format)
|
||||||
{
|
{
|
||||||
case OSAUDIO_FORMAT_F32: return ma_format_f32;
|
case OSAUDIO_FORMAT_F32: return ma_format_f32;
|
||||||
|
case OSAUDIO_FORMAT_U8: return ma_format_u8;
|
||||||
case OSAUDIO_FORMAT_S16: return ma_format_s16;
|
case OSAUDIO_FORMAT_S16: return ma_format_s16;
|
||||||
case OSAUDIO_FORMAT_S24: return ma_format_s24;
|
case OSAUDIO_FORMAT_S24: return ma_format_s24;
|
||||||
case OSAUDIO_FORMAT_S32: return ma_format_s32;
|
case OSAUDIO_FORMAT_S32: return ma_format_s32;
|
||||||
@@ -82,6 +83,7 @@ static osaudio_format_t osaudio_format_from_miniaudio(ma_format format)
|
|||||||
switch (format)
|
switch (format)
|
||||||
{
|
{
|
||||||
case ma_format_f32: return OSAUDIO_FORMAT_F32;
|
case ma_format_f32: return OSAUDIO_FORMAT_F32;
|
||||||
|
case ma_format_u8: return OSAUDIO_FORMAT_U8;
|
||||||
case ma_format_s16: return OSAUDIO_FORMAT_S16;
|
case ma_format_s16: return OSAUDIO_FORMAT_S16;
|
||||||
case ma_format_s24: return OSAUDIO_FORMAT_S24;
|
case ma_format_s24: return OSAUDIO_FORMAT_S24;
|
||||||
case ma_format_s32: return OSAUDIO_FORMAT_S32;
|
case ma_format_s32: return OSAUDIO_FORMAT_S32;
|
||||||
@@ -887,7 +889,7 @@ osaudio_result_t osaudio_pause(osaudio_t audio)
|
|||||||
ma_atomic_bool32_set(&audio->isPaused, MA_TRUE);
|
ma_atomic_bool32_set(&audio->isPaused, MA_TRUE);
|
||||||
|
|
||||||
/* No need to stop the device if it's not active. */
|
/* No need to stop the device if it's not active. */
|
||||||
if (ma_atomic_bool32_get(&audio->isActive) == MA_FALSE) {
|
if (ma_atomic_bool32_get(&audio->isActive)) {
|
||||||
result = osaudio_result_from_miniaudio(ma_device_stop(&audio->device));
|
result = osaudio_result_from_miniaudio(ma_device_stop(&audio->device));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user