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
4f62eed9
Commit
4f62eed9
authored
Dec 29, 2016
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Misc. fixes for the OpenAL backend.
parent
516ff2e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
19 deletions
+26
-19
mini_al.h
mini_al.h
+26
-19
No files found.
mini_al.h
View file @
4f62eed9
...
@@ -4372,6 +4372,7 @@ static void mal_device_uninit__openal(mal_device* pDevice)
...
@@ -4372,6 +4372,7 @@ static void mal_device_uninit__openal(mal_device* pDevice)
{
{
mal_assert
(
pDevice
!=
NULL
);
mal_assert
(
pDevice
!=
NULL
);
((
MAL_LPALCMAKECONTEXTCURRENT
)
pDevice
->
pContext
->
openal
.
alcMakeContextCurrent
)(
NULL
);
((
MAL_LPALCDESTROYCONTEXT
)
pDevice
->
pContext
->
openal
.
alcDestroyContext
)(
pDevice
->
openal
.
pContextALC
);
((
MAL_LPALCDESTROYCONTEXT
)
pDevice
->
pContext
->
openal
.
alcDestroyContext
)(
pDevice
->
openal
.
pContextALC
);
if
(
pDevice
->
type
==
mal_device_type_playback
)
{
if
(
pDevice
->
type
==
mal_device_type_playback
)
{
...
@@ -4454,33 +4455,33 @@ static mal_result mal_device_init__openal(mal_context* pContext, mal_device_type
...
@@ -4454,33 +4455,33 @@ static mal_result mal_device_init__openal(mal_context* pContext, mal_device_type
return
MAL_FAILED_TO_INIT_BACKEND
;
return
MAL_FAILED_TO_INIT_BACKEND
;
}
}
// A context is only required for playback.
ALCcontext
*
pContextALC
=
((
MAL_LPALCCREATECONTEXT
)
pContext
->
openal
.
alcCreateContext
)(
pDeviceALC
,
NULL
);
ALCcontext
*
pContextALC
=
NULL
;
if
(
pContextALC
==
NULL
)
{
if
(
pDevice
->
type
==
mal_device_type_playback
)
{
if
(
pDevice
->
type
==
mal_device_type_playback
)
{
pContextALC
=
((
MAL_LPALCCREATECONTEXT
)
pContext
->
openal
.
alcCreateContext
)(
pDeviceALC
,
NULL
);
if
(
pContextALC
==
NULL
)
{
((
MAL_LPALCCLOSEDEVICE
)
pDevice
->
pContext
->
openal
.
alcCloseDevice
)(
pDeviceALC
);
((
MAL_LPALCCLOSEDEVICE
)
pDevice
->
pContext
->
openal
.
alcCloseDevice
)(
pDeviceALC
);
}
else
{
return
MAL_FAILED_TO_INIT_BACKEND
;
((
MAL_LPALCCAPTURECLOSEDEVICE
)
pDevice
->
pContext
->
openal
.
alcCaptureCloseDevice
)(
pDeviceALC
);
}
}
return
MAL_FAILED_TO_INIT_BACKEND
;
((
MAL_LPALCMAKECONTEXTCURRENT
)
pDevice
->
pContext
->
openal
.
alcMakeContextCurrent
)(
pContextALC
);
}
((
MAL_LPALCMAKECONTEXTCURRENT
)
pDevice
->
pContext
->
openal
.
alcMakeContextCurrent
)(
pContextALC
);
ALuint
sourceAL
;
ALuint
sourceAL
;
((
MAL_LPALGENSOURCES
)
pDevice
->
pContext
->
openal
.
alGenSources
)(
1
,
&
sourceAL
);
((
MAL_LPALGENSOURCES
)
pDevice
->
pContext
->
openal
.
alGenSources
)(
1
,
&
sourceAL
);
pDevice
->
openal
.
sourceAL
=
sourceAL
;
pDevice
->
openal
.
sourceAL
=
sourceAL
;
// We create the buffers, but only fill and queue them when the device is started.
// We create the buffers, but only fill and queue them when the device is started.
ALuint
buffersAL
[
MAL_MAX_PERIODS_OPENAL
];
ALuint
buffersAL
[
MAL_MAX_PERIODS_OPENAL
];
((
MAL_LPALGENBUFFERS
)
pDevice
->
pContext
->
openal
.
alGenBuffers
)(
pDevice
->
periods
,
buffersAL
);
((
MAL_LPALGENBUFFERS
)
pDevice
->
pContext
->
openal
.
alGenBuffers
)(
pDevice
->
periods
,
buffersAL
);
for
(
mal_uint32
i
=
0
;
i
<
pDevice
->
periods
;
++
i
)
{
for
(
mal_uint32
i
=
0
;
i
<
pDevice
->
periods
;
++
i
)
{
pDevice
->
openal
.
buffersAL
[
i
]
=
buffersAL
[
i
];
pDevice
->
openal
.
buffersAL
[
i
]
=
buffersAL
[
i
];
}
}
}
pDevice
->
internalChannels
=
channelsAL
;
pDevice
->
internalChannels
=
channelsAL
;
pDevice
->
openal
.
pDeviceALC
=
pDeviceALC
;
pDevice
->
openal
.
pContextALC
=
pContextALC
;
pDevice
->
openal
.
formatAL
=
formatAL
;
pDevice
->
openal
.
formatAL
=
formatAL
;
pDevice
->
openal
.
subBufferSizeInFrames
=
pDevice
->
bufferSizeInFrames
/
pDevice
->
periods
;
pDevice
->
openal
.
subBufferSizeInFrames
=
pDevice
->
bufferSizeInFrames
/
pDevice
->
periods
;
pDevice
->
openal
.
pIntermediaryBuffer
=
(
mal_uint8
*
)
mal_malloc
(
pDevice
->
openal
.
subBufferSizeInFrames
*
channelsAL
*
mal_get_sample_size_in_bytes
(
pDevice
->
format
));
pDevice
->
openal
.
pIntermediaryBuffer
=
(
mal_uint8
*
)
mal_malloc
(
pDevice
->
openal
.
subBufferSizeInFrames
*
channelsAL
*
mal_get_sample_size_in_bytes
(
pDevice
->
format
));
...
@@ -4502,6 +4503,8 @@ static mal_result mal_device__start_backend__openal(mal_device* pDevice)
...
@@ -4502,6 +4503,8 @@ static mal_result mal_device__start_backend__openal(mal_device* pDevice)
// When starting playback we want to ensure each buffer is filled and queued before playing the source.
// When starting playback we want to ensure each buffer is filled and queued before playing the source.
pDevice
->
openal
.
iNextBuffer
=
0
;
pDevice
->
openal
.
iNextBuffer
=
0
;
((
MAL_LPALCMAKECONTEXTCURRENT
)
pDevice
->
pContext
->
openal
.
alcMakeContextCurrent
)(
pDevice
->
openal
.
pContextALC
);
for
(
mal_uint32
i
=
0
;
i
<
pDevice
->
periods
;
++
i
)
{
for
(
mal_uint32
i
=
0
;
i
<
pDevice
->
periods
;
++
i
)
{
mal_device__read_frames_from_client
(
pDevice
,
pDevice
->
openal
.
subBufferSizeInFrames
,
pDevice
->
openal
.
pIntermediaryBuffer
);
mal_device__read_frames_from_client
(
pDevice
,
pDevice
->
openal
.
subBufferSizeInFrames
,
pDevice
->
openal
.
pIntermediaryBuffer
);
...
@@ -4525,6 +4528,7 @@ static mal_result mal_device__stop_backend__openal(mal_device* pDevice)
...
@@ -4525,6 +4528,7 @@ static mal_result mal_device__stop_backend__openal(mal_device* pDevice)
mal_assert
(
pDevice
!=
NULL
);
mal_assert
(
pDevice
!=
NULL
);
if
(
pDevice
->
type
==
mal_device_type_playback
)
{
if
(
pDevice
->
type
==
mal_device_type_playback
)
{
((
MAL_LPALCMAKECONTEXTCURRENT
)
pDevice
->
pContext
->
openal
.
alcMakeContextCurrent
)(
pDevice
->
openal
.
pContextALC
);
((
MAL_LPALSOURCESTOP
)
pDevice
->
pContext
->
openal
.
alSourceStop
)(
pDevice
->
openal
.
sourceAL
);
((
MAL_LPALSOURCESTOP
)
pDevice
->
pContext
->
openal
.
alSourceStop
)(
pDevice
->
openal
.
sourceAL
);
}
else
{
}
else
{
((
MAL_LPALCCAPTURESTOP
)
pDevice
->
pContext
->
openal
.
alcCaptureStop
)(
pDevice
->
openal
.
pDeviceALC
);
((
MAL_LPALCCAPTURESTOP
)
pDevice
->
pContext
->
openal
.
alcCaptureStop
)(
pDevice
->
openal
.
pDeviceALC
);
...
@@ -4546,13 +4550,15 @@ static mal_uint32 mal_device__get_available_frames__openal(mal_device* pDevice)
...
@@ -4546,13 +4550,15 @@ static mal_uint32 mal_device__get_available_frames__openal(mal_device* pDevice)
mal_assert
(
pDevice
!=
NULL
);
mal_assert
(
pDevice
!=
NULL
);
if
(
pDevice
->
type
==
mal_device_type_playback
)
{
if
(
pDevice
->
type
==
mal_device_type_playback
)
{
((
MAL_LPALCMAKECONTEXTCURRENT
)
pDevice
->
pContext
->
openal
.
alcMakeContextCurrent
)(
pDevice
->
openal
.
pContextALC
);
ALint
processedBufferCount
=
0
;
ALint
processedBufferCount
=
0
;
((
MAL_LPALGETSOURCEI
)
pDevice
->
pContext
->
openal
.
alGetSourcei
)(
pDevice
->
openal
.
sourceAL
,
AL_BUFFERS_PROCESSED
,
&
processedBufferCount
);
((
MAL_LPALGETSOURCEI
)
pDevice
->
pContext
->
openal
.
alGetSourcei
)(
pDevice
->
openal
.
sourceAL
,
AL_BUFFERS_PROCESSED
,
&
processedBufferCount
);
return
processedBufferCount
*
pDevice
->
openal
.
subBufferSizeInFrames
;
return
processedBufferCount
*
pDevice
->
openal
.
subBufferSizeInFrames
;
}
else
{
}
else
{
ALint
samplesAvailable
=
0
;
ALint
samplesAvailable
=
0
;
((
MAL_LPALCGETINTEGERV
)
pDevice
->
pContext
->
openal
.
alcGetIntegerv
)(
pDevice
->
openal
.
pDeviceALC
,
ALC_CAPTURE_SAMPLES
,
(
ALCsizei
)
sizeof
(
ALint
)
,
&
samplesAvailable
);
((
MAL_LPALCGETINTEGERV
)
pDevice
->
pContext
->
openal
.
alcGetIntegerv
)(
pDevice
->
openal
.
pDeviceALC
,
ALC_CAPTURE_SAMPLES
,
1
,
&
samplesAvailable
);
return
samplesAvailable
/
pDevice
->
channels
;
return
samplesAvailable
/
pDevice
->
channels
;
}
}
...
@@ -4604,6 +4610,7 @@ static mal_result mal_device__main_loop__openal(mal_device* pDevice)
...
@@ -4604,6 +4610,7 @@ static mal_result mal_device__main_loop__openal(mal_device* pDevice)
mal_device__read_frames_from_client
(
pDevice
,
framesToRead
,
pDevice
->
openal
.
pIntermediaryBuffer
);
mal_device__read_frames_from_client
(
pDevice
,
framesToRead
,
pDevice
->
openal
.
pIntermediaryBuffer
);
((
MAL_LPALCMAKECONTEXTCURRENT
)
pDevice
->
pContext
->
openal
.
alcMakeContextCurrent
)(
pDevice
->
openal
.
pContextALC
);
((
MAL_LPALSOURCEUNQUEUEBUFFERS
)
pDevice
->
pContext
->
openal
.
alSourceUnqueueBuffers
)(
pDevice
->
openal
.
sourceAL
,
1
,
&
bufferAL
);
((
MAL_LPALSOURCEUNQUEUEBUFFERS
)
pDevice
->
pContext
->
openal
.
alSourceUnqueueBuffers
)(
pDevice
->
openal
.
sourceAL
,
1
,
&
bufferAL
);
((
MAL_LPALBUFFERDATA
)
pDevice
->
pContext
->
openal
.
alBufferData
)(
bufferAL
,
pDevice
->
openal
.
formatAL
,
pDevice
->
openal
.
pIntermediaryBuffer
,
pDevice
->
openal
.
subBufferSizeInFrames
*
pDevice
->
internalChannels
*
mal_get_sample_size_in_bytes
(
pDevice
->
format
),
pDevice
->
sampleRate
);
((
MAL_LPALBUFFERDATA
)
pDevice
->
pContext
->
openal
.
alBufferData
)(
bufferAL
,
pDevice
->
openal
.
formatAL
,
pDevice
->
openal
.
pIntermediaryBuffer
,
pDevice
->
openal
.
subBufferSizeInFrames
*
pDevice
->
internalChannels
*
mal_get_sample_size_in_bytes
(
pDevice
->
format
),
pDevice
->
sampleRate
);
((
MAL_LPALSOURCEQUEUEBUFFERS
)
pDevice
->
pContext
->
openal
.
alSourceQueueBuffers
)(
pDevice
->
openal
.
sourceAL
,
1
,
&
bufferAL
);
((
MAL_LPALSOURCEQUEUEBUFFERS
)
pDevice
->
pContext
->
openal
.
alSourceQueueBuffers
)(
pDevice
->
openal
.
sourceAL
,
1
,
&
bufferAL
);
...
...
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