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
d3f17c22
Commit
d3f17c22
authored
Oct 25, 2016
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OpenSL|ES: Add untested work for capture support.
parent
f540e10f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
4 deletions
+57
-4
mini_al.h
mini_al.h
+57
-4
No files found.
mini_al.h
View file @
d3f17c22
...
@@ -3102,8 +3102,46 @@ static mal_result mal_device_init__sles(mal_device* pDevice, mal_device_type typ
...
@@ -3102,8 +3102,46 @@ static mal_result mal_device_init__sles(mal_device* pDevice, mal_device_type typ
return
mal_post_error
(
pDevice
,
"Failed to register buffer queue callback."
,
MAL_NO_BACKEND
);
return
mal_post_error
(
pDevice
,
"Failed to register buffer queue callback."
,
MAL_NO_BACKEND
);
}
}
}
else
{
}
else
{
// Implement me.
SLDataLocator_IODevice
locatorDevice
;
return
MAL_NO_BACKEND
;
locatorDevice
.
locatorType
=
SL_DATALOCATOR_IODEVICE
;
locatorDevice
.
deviceType
=
SL_IODEVICE_AUDIOINPUT
;
locatorDevice
.
deviceID
=
(
pDeviceID
==
NULL
)
?
SL_DEFAULTDEVICEID_AUDIOINPUT
:
pDeviceID
->
id32
;
locatorDevice
.
device
=
NULL
;
SLDataSource
source
;
source
.
pLocator
=
&
locatorDevice
;
source
.
pFormat
=
NULL
;
SLDataSink
sink
;
sink
.
pLocator
=
&
queue
;
sink
.
pFormat
=
&
pcm
;
const
SLInterfaceID
itfIDs1
[]
=
{
SL_IID_ANDROIDSIMPLEBUFFERQUEUE
};
const
SLboolean
itfIDsRequired1
[]
=
{
SL_BOOLEAN_TRUE
};
if
((
*
g_malEngineSL
)
->
CreateAudioRecorder
(
g_malEngineSL
,
(
SLObjectItf
*
)
&
pDevice
->
sles
.
pAudioRecorderObj
,
&
source
,
&
sink
,
1
,
itfIDs1
,
itfIDsRequired1
)
!=
SL_RESULT_SUCCESS
)
{
mal_device_uninit__sles
(
pDevice
);
return
mal_post_error
(
pDevice
,
"Failed to create audio recorder."
,
MAL_NO_BACKEND
);
}
if
(
MAL_SLES_OBJ
(
pDevice
->
sles
.
pAudioRecorderObj
)
->
Realize
((
SLObjectItf
)
pDevice
->
sles
.
pAudioRecorderObj
,
SL_BOOLEAN_FALSE
)
!=
SL_RESULT_SUCCESS
)
{
mal_device_uninit__sles
(
pDevice
);
return
mal_post_error
(
pDevice
,
"Failed to realize audio recorder."
,
MAL_NO_BACKEND
);
}
if
(
MAL_SLES_OBJ
(
pDevice
->
sles
.
pAudioRecorderObj
)
->
GetInterface
((
SLObjectItf
)
pDevice
->
sles
.
pAudioRecorderObj
,
SL_IID_RECORD
,
&
pDevice
->
sles
.
pAudioRecorder
)
!=
SL_RESULT_SUCCESS
)
{
mal_device_uninit__sles
(
pDevice
);
return
mal_post_error
(
pDevice
,
"Failed to retrieve SL_IID_RECORD interface."
,
MAL_NO_BACKEND
);
}
if
(
MAL_SLES_OBJ
(
pDevice
->
sles
.
pAudioRecorderObj
)
->
GetInterface
((
SLObjectItf
)
pDevice
->
sles
.
pAudioRecorderObj
,
SL_IID_ANDROIDSIMPLEBUFFERQUEUE
,
&
pDevice
->
sles
.
pBufferQueue
)
!=
SL_RESULT_SUCCESS
)
{
mal_device_uninit__sles
(
pDevice
);
return
mal_post_error
(
pDevice
,
"Failed to retrieve SL_IID_ANDROIDSIMPLEBUFFERQUEUE interface."
,
MAL_NO_BACKEND
);
}
if
(
MAL_SLES_BUFFERQUEUE
(
pDevice
->
sles
.
pBufferQueue
)
->
RegisterCallback
((
SLAndroidSimpleBufferQueueItf
)
pDevice
->
sles
.
pBufferQueue
,
mal_buffer_queue_callback__sles_android
,
pDevice
)
!=
SL_RESULT_SUCCESS
)
{
mal_device_uninit__sles
(
pDevice
);
return
mal_post_error
(
pDevice
,
"Failed to register buffer queue callback."
,
MAL_NO_BACKEND
);
}
}
}
size_t
bufferSizeInBytes
=
pDevice
->
bufferSizeInFrames
*
pDevice
->
channels
*
mal_get_sample_size_in_bytes
(
pDevice
->
format
);
size_t
bufferSizeInBytes
=
pDevice
->
bufferSizeInFrames
*
pDevice
->
channels
*
mal_get_sample_size_in_bytes
(
pDevice
->
format
);
...
@@ -3160,7 +3198,19 @@ static mal_result mal_device__start_backend__sles(mal_device* pDevice)
...
@@ -3160,7 +3198,19 @@ static mal_result mal_device__start_backend__sles(mal_device* pDevice)
}
}
}
}
}
else
{
}
else
{
// TODO: Implement me.
SLresult
resultSL
=
MAL_SLES_RECORD
(
pDevice
->
sles
.
pAudioRecorder
)
->
SetRecordState
((
SLRecordItf
)
pDevice
->
sles
.
pAudioRecorder
,
SL_RECORDSTATE_RECORDING
);
if
(
resultSL
!=
SL_RESULT_SUCCESS
)
{
return
MAL_FAILED_TO_START_BACKEND_DEVICE
;
}
size_t
periodSizeInBytes
=
pDevice
->
sles
.
periodSizeInFrames
*
pDevice
->
channels
*
mal_get_sample_size_in_bytes
(
pDevice
->
format
);
for
(
mal_uint32
iPeriod
=
0
;
iPeriod
<
pDevice
->
periods
;
++
iPeriod
)
{
resultSL
=
MAL_SLES_BUFFERQUEUE
(
pDevice
->
sles
.
pBufferQueue
)
->
Enqueue
((
SLAndroidSimpleBufferQueueItf
)
pDevice
->
sles
.
pBufferQueue
,
pDevice
->
sles
.
pBuffer
+
(
periodSizeInBytes
*
iPeriod
),
periodSizeInBytes
);
if
(
resultSL
!=
SL_RESULT_SUCCESS
)
{
SLresult
resultSL
=
MAL_SLES_RECORD
(
pDevice
->
sles
.
pAudioRecorder
)
->
SetRecordState
((
SLRecordItf
)
pDevice
->
sles
.
pAudioRecorder
,
SL_RECORDSTATE_STOPPED
);
return
MAL_FAILED_TO_START_BACKEND_DEVICE
;
}
}
}
}
return
MAL_SUCCESS
;
return
MAL_SUCCESS
;
...
@@ -3176,7 +3226,10 @@ static mal_result mal_device__stop_backend__sles(mal_device* pDevice)
...
@@ -3176,7 +3226,10 @@ static mal_result mal_device__stop_backend__sles(mal_device* pDevice)
return
MAL_FAILED_TO_STOP_BACKEND_DEVICE
;
return
MAL_FAILED_TO_STOP_BACKEND_DEVICE
;
}
}
}
else
{
}
else
{
// TODO: Implement me.
SLresult
resultSL
=
MAL_SLES_RECORD
(
pDevice
->
sles
.
pAudioRecorder
)
->
SetRecordState
((
SLRecordItf
)
pDevice
->
sles
.
pAudioRecorder
,
SL_RECORDSTATE_STOPPED
);
if
(
resultSL
!=
SL_RESULT_SUCCESS
)
{
return
MAL_FAILED_TO_STOP_BACKEND_DEVICE
;
}
}
}
// Make sure any queued buffers are cleared.
// Make sure any queued buffers are cleared.
...
...
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