Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
1301af97
Commit
1301af97
authored
Oct 15, 2016
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up.
parent
58989ea1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
79 deletions
+39
-79
mini_al.h
mini_al.h
+39
-79
No files found.
mini_al.h
View file @
1301af97
...
...
@@ -45,8 +45,8 @@
// - DirectSound has _bad_ latency compared to other backends. In my testing, a fragment size of 1024 frames
// is too small, but a size of 2048 seems to work.
#ifndef
dr_m
al_h
#define
dr_m
al_h
#ifndef
mini_
al_h
#define
mini_
al_h
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -121,22 +121,22 @@ typedef void* mal_ptr;
typedef
int
mal_result
;
#define MAL_SUCCESS 0
#define MAL_ERROR -1
#define MAL_ERROR -1
// A generic error.
#define MAL_INVALID_ARGS -2
#define MAL_OUT_OF_MEMORY -3
#define MAL_
NO_BACKEND -16
#define MAL_
DEVICE_BUSY -32 // The device is already in the middle of something.
#define MAL_DEVICE_
NOT_INITIALIZED -33 // Trying to do something on an uninitialized device.
#define MAL_DEVICE_
ALREADY_STARTED -1
7
#define MAL_DEVICE_ALREADY_START
ING -1
8
#define MAL_DEVICE_ALREADY_ST
OPPED -1
9
#define MAL_DEVICE_ALREADY_STOPP
ING -2
0
#define MAL_
FAILED_TO_INIT_BACKEND -2
1
#define MAL_F
ORMAT_NOT_SUPPORTED -2
2
#define MAL_FAILED_TO_
READ_DATA_FROM_CLIENT -2
3
#define MAL_FAILED_TO_
START_BACKEND_DEVICE -2
4
#define MAL_FAILED_TO_ST
OP_BACKEND_DEVICE -2
5
#define MAL_FAILED_TO_
MAP_DEVICE_BUFFER -2
6
#define MAL_
FORMAT_NOT_SUPPORTED -4
#define MAL_
NO_BACKEND -5
#define MAL_DEVICE_
BUSY -6
#define MAL_DEVICE_
NOT_INITIALIZED -
7
#define MAL_DEVICE_ALREADY_START
ED -
8
#define MAL_DEVICE_ALREADY_ST
ARTING -
9
#define MAL_DEVICE_ALREADY_STOPP
ED -1
0
#define MAL_
DEVICE_ALREADY_STOPPING -1
1
#define MAL_F
AILED_TO_MAP_DEVICE_BUFFER -1
2
#define MAL_FAILED_TO_
INIT_BACKEND -1
3
#define MAL_FAILED_TO_
READ_DATA_FROM_CLIENT -1
4
#define MAL_FAILED_TO_ST
ART_BACKEND_DEVICE -1
5
#define MAL_FAILED_TO_
STOP_BACKEND_DEVICE -1
6
typedef
struct
mal_device
mal_device
;
...
...
@@ -281,7 +281,7 @@ mal_result mal_enumerate_devices(mal_device_type type, mal_uint32* pCount, mal_d
// - MAL_FAILED_TO_INIT_BACKEND
// There was a backend-specific error during initialization.
//
// Thread Safety:
SAFE
// Thread Safety:
???
// This API is thread safe so long as the application does not try to use the device object before
// this call has returned.
//
...
...
@@ -302,7 +302,7 @@ mal_result mal_device_init(mal_device* pDevice, mal_device_type type, mal_device
// - MAL_DEVICE_NOT_INITIALIZED
// The device is not currently or was never initialized.
//
// Thread Safety:
UNSAFE
// Thread Safety:
???
// This API shouldn't crash in a multi-threaded environment, but results are undefined if an application
// attempts to do something with the device at the same time as uninitializing.
//
...
...
@@ -311,7 +311,9 @@ mal_result mal_device_init(mal_device* pDevice, mal_device_type type, mal_device
// to destroy internal objects like the backend-specific objects and the background thread.
void
mal_device_uninit
(
mal_device
*
pDevice
);
// Sets the callback to use when the application has receives data from the device.
// Sets the callback to use when the application has received data from the device.
//
// The fragment size specified at initialization time controls the sample count.
//
// Thread Safety: SAFE
// This API is implemented as a simple atomic assignment.
...
...
@@ -322,6 +324,11 @@ void mal_device_set_recv_callback(mal_device* pDevice, mal_recv_proc proc);
// Sets the callback to use when the application needs to send data to the device for playback.
//
// Note that the implementation of this callback must copy over as many samples as is available. The
// return value specifies how many samples were written to the output buffer. The backend will fill
// any leftover samples with silence. The fragment size specified at initialization time controls the
// number of samples the device will request.
//
// Thread Safety: SAFE
// This API is implemented as a simple atomic assignment.
//
...
...
@@ -351,6 +358,12 @@ void mal_device_set_send_callback(mal_device* pDevice, mal_send_proc proc);
// applications.
// - MAL_DEVICE_ALREADY_STARTED
// The device is already started.
// - MAL_FAILED_TO_READ_DATA_FROM_CLIENT
// Failed to read the initial chunk of audio data from the client. This initial chunk of data is
// required so that the device has valid audio data as soon as it starts playing. This will never
// be returned for capture devices.
// - MAL_FAILED_TO_START_BACKEND_DEVICE
// There was a backend-specific error starting the device.
//
// Thread Safety: SAFE
//
...
...
@@ -375,6 +388,8 @@ mal_result mal_device_start(mal_device* pDevice);
// applications.
// - MAL_DEVICE_ALREADY_STOPPED
// The device is already stopped.
// - MAL_FAILED_TO_STOP_BACKEND_DEVICE
// There was a backend-specific error stopping the device.
//
// Thread Safety: SAFE
//
...
...
@@ -417,7 +432,7 @@ mal_uint32 mal_get_sample_size_in_bytes(mal_format format);
#ifdef __cplusplus
}
#endif
#endif //
dr_m
al_h
#endif //
mini_
al_h
///////////////////////////////////////////////////////////////////////////////
...
...
@@ -815,61 +830,6 @@ mal_bool32 mal_event_signal(mal_event* pEvent)
}
#if 0
mal_bool32 mal_semaphore_create(mal_semaphore* pSemaphore, int initialValue)
{
if (pSemaphore == NULL) return MAL_FALSE;
#ifdef MAL_WIN32
return mal_semaphore_create__win32(pSemaphore, initialValue);
#endif
#ifdef MAL_POSIX
return mal_semaphore_create__posix(pSemaphore, initialValue);
#endif
}
void mal_semaphore_delete(mal_semaphore* pSemaphore)
{
if (pSemaphore == NULL) return;
#ifdef MAL_WIN32
mal_semaphore_delete__win32(pSemaphore);
#endif
#ifdef MAL_POSIX
mal_semaphore_delete__posix(pSemaphore);
#endif
}
mal_bool32 mal_semaphore_wait(mal_semaphore* pSemaphore)
{
if (pSemaphore == NULL) return MAL_FALSE;
#ifdef MAL_WIN32
return mal_semaphore_wait__win32(pSemaphore);
#endif
#ifdef MAL_POSIX
return mal_semaphore_wait__posix(pSemaphore);
#endif
}
mal_bool32 mal_semaphore_release(mal_semaphore* pSemaphore)
{
if (pSemaphore == NULL) return MAL_FALSE;
#ifdef MAL_WIN32
return mal_semaphore_release__win32(pSemaphore);
#endif
#ifdef MAL_POSIX
return mal_semaphore_release__posix(pSemaphore);
#endif
}
#endif
// A helper function for reading sample data from the client. Returns the number of samples read from the client. Remaining samples
// are filled with silence.
...
...
@@ -1041,6 +1001,7 @@ static BOOL CALLBACK mal_enum_devices_callback__dsound(LPGUID lpGuid, LPCSTR lpc
if
(
pData
->
pInfo
!=
NULL
)
{
if
(
pData
->
infoCount
>
0
)
{
mal_zero_object
(
pData
->
pInfo
);
mal_strncpy_s
(
pData
->
pInfo
->
description
,
sizeof
(
pData
->
pInfo
->
description
),
lpcstrDescription
,
(
size_t
)
-
1
);
if
(
lpGuid
!=
NULL
)
{
...
...
@@ -2389,7 +2350,6 @@ mal_uint32 mal_get_sample_size_in_bytes(mal_format format)
// TODO
// ====
// - More error codes
// - Logging
// - Profiling. Need to measure mal_device_start() and mal_device_stop() in particular. One of the two seems to be taking a bit
// longer than it should.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment