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
82911b25
Commit
82911b25
authored
Apr 25, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WinMM: Add support for retrieving detailed device info.
parent
5b069848
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
64 deletions
+118
-64
mini_al.h
mini_al.h
+118
-64
No files found.
mini_al.h
View file @
82911b25
...
@@ -6511,6 +6511,9 @@ mal_result mal_context_get_device_info__dsound(mal_context* pContext, mal_device
...
@@ -6511,6 +6511,9 @@ mal_result mal_context_get_device_info__dsound(mal_context* pContext, mal_device
pDeviceInfo->formats[0] = mal_format_s24;
pDeviceInfo->formats[0] = mal_format_s24;
} else if (bitsPerSample == 32) {
} else if (bitsPerSample == 32) {
pDeviceInfo->formats[0] = mal_format_s32;
pDeviceInfo->formats[0] = mal_format_s32;
} else {
mal_IDirectSoundCapture_Release(pDirectSoundCapture);
return MAL_FORMAT_NOT_SUPPORTED;
}
}
mal_IDirectSoundCapture_Release(pDirectSoundCapture);
mal_IDirectSoundCapture_Release(pDirectSoundCapture);
...
@@ -7197,6 +7200,86 @@ typedef struct
...
@@ -7197,6 +7200,86 @@ typedef struct
GUID NameGuid;
GUID NameGuid;
} MAL_WAVECAPSA;
} MAL_WAVECAPSA;
mal_result mal_get_best_info_from_formats_flags__winmm(DWORD dwFormats, WORD channels, WORD* pBitsPerSample, DWORD* pSampleRate)
{
if (pBitsPerSample) {
*pBitsPerSample = 0;
}
if (pSampleRate) {
*pSampleRate = 0;
}
WORD bitsPerSample = 0;
DWORD sampleRate = 0;
if (channels == 1) {
bitsPerSample = 16;
if ((dwFormats & WAVE_FORMAT_48M16) != 0) {
sampleRate = 48000;
} else if ((dwFormats & WAVE_FORMAT_44M16) != 0) {
sampleRate = 44100;
} else if ((dwFormats & WAVE_FORMAT_2M16) != 0) {
sampleRate = 22050;
} else if ((dwFormats & WAVE_FORMAT_1M16) != 0) {
sampleRate = 11025;
} else if ((dwFormats & WAVE_FORMAT_96M16) != 0) {
sampleRate = 96000;
} else {
bitsPerSample = 8;
if ((dwFormats & WAVE_FORMAT_48M08) != 0) {
sampleRate = 48000;
} else if ((dwFormats & WAVE_FORMAT_44M08) != 0) {
sampleRate = 44100;
} else if ((dwFormats & WAVE_FORMAT_2M08) != 0) {
sampleRate = 22050;
} else if ((dwFormats & WAVE_FORMAT_1M08) != 0) {
sampleRate = 11025;
} else if ((dwFormats & WAVE_FORMAT_96M08) != 0) {
sampleRate = 96000;
} else {
return MAL_FORMAT_NOT_SUPPORTED;
}
}
} else {
bitsPerSample = 16;
if ((dwFormats & WAVE_FORMAT_48S16) != 0) {
sampleRate = 48000;
} else if ((dwFormats & WAVE_FORMAT_44S16) != 0) {
sampleRate = 44100;
} else if ((dwFormats & WAVE_FORMAT_2S16) != 0) {
sampleRate = 22050;
} else if ((dwFormats & WAVE_FORMAT_1S16) != 0) {
sampleRate = 11025;
} else if ((dwFormats & WAVE_FORMAT_96S16) != 0) {
sampleRate = 96000;
} else {
bitsPerSample = 8;
if ((dwFormats & WAVE_FORMAT_48S08) != 0) {
sampleRate = 48000;
} else if ((dwFormats & WAVE_FORMAT_44S08) != 0) {
sampleRate = 44100;
} else if ((dwFormats & WAVE_FORMAT_2S08) != 0) {
sampleRate = 22050;
} else if ((dwFormats & WAVE_FORMAT_1S08) != 0) {
sampleRate = 11025;
} else if ((dwFormats & WAVE_FORMAT_96S08) != 0) {
sampleRate = 96000;
} else {
return MAL_FORMAT_NOT_SUPPORTED;
}
}
}
if (pBitsPerSample) {
*pBitsPerSample = bitsPerSample;
}
if (pSampleRate) {
*pSampleRate = sampleRate;
}
return MAL_SUCCESS;
}
mal_result mal_context_get_device_info_from_WAVECAPS(mal_context* pContext, MAL_WAVECAPSA* pCaps, mal_device_info* pDeviceInfo)
mal_result mal_context_get_device_info_from_WAVECAPS(mal_context* pContext, MAL_WAVECAPSA* pCaps, mal_device_info* pDeviceInfo)
{
{
mal_assert(pContext != NULL);
mal_assert(pContext != NULL);
...
@@ -7260,6 +7343,31 @@ mal_result mal_context_get_device_info_from_WAVECAPS(mal_context* pContext, MAL_
...
@@ -7260,6 +7343,31 @@ mal_result mal_context_get_device_info_from_WAVECAPS(mal_context* pContext, MAL_
}
}
}
}
WORD bitsPerSample;
DWORD sampleRate;
mal_result result = mal_get_best_info_from_formats_flags__winmm(pCaps->dwFormats, pCaps->wChannels, &bitsPerSample, &sampleRate);
if (result != MAL_SUCCESS) {
return result;
}
pDeviceInfo->minChannels = pCaps->wChannels;
pDeviceInfo->maxChannels = pCaps->wChannels;
pDeviceInfo->minSampleRate = sampleRate;
pDeviceInfo->maxSampleRate = sampleRate;
pDeviceInfo->formatCount = 1;
if (bitsPerSample == 8) {
pDeviceInfo->formats[0] = mal_format_u8;
} else if (bitsPerSample == 16) {
pDeviceInfo->formats[0] = mal_format_s16;
} else if (bitsPerSample == 24) {
pDeviceInfo->formats[0] = mal_format_s24;
} else if (bitsPerSample == 32) {
pDeviceInfo->formats[0] = mal_format_s32;
} else {
return MAL_FORMAT_NOT_SUPPORTED;
}
return MAL_SUCCESS;
return MAL_SUCCESS;
}
}
...
@@ -7521,66 +7629,12 @@ mal_result mal_device_init__winmm(mal_context* pContext, mal_device_type type, m
...
@@ -7521,66 +7629,12 @@ mal_result mal_device_init__winmm(mal_context* pContext, mal_device_type type, m
goto on_error;
goto on_error;
}
}
if
(
wChannels
==
1
)
{
wf.nChannels = wChannels;
wf
.
nChannels
=
1
;
wf
.
wBitsPerSample
=
16
;
mal_result result = mal_get_best_info_from_formats_flags__winmm(dwFormats, wChannels, &wf.wBitsPerSample, &wf.nSamplesPerSec);
if
((
dwFormats
&
WAVE_FORMAT_48M16
)
!=
0
)
{
if (result != MAL_SUCCESS) {
wf
.
nSamplesPerSec
=
48000
;
errorMsg = "[WinMM] Could not find appropriate format for internal device.", errorCode = result;
}
else
if
((
dwFormats
&
WAVE_FORMAT_44M16
)
!=
0
)
{
goto on_error;
wf
.
nSamplesPerSec
=
44100
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_2M16
)
!=
0
)
{
wf
.
nSamplesPerSec
=
22050
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_1M16
)
!=
0
)
{
wf
.
nSamplesPerSec
=
11025
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_96M16
)
!=
0
)
{
wf
.
nSamplesPerSec
=
96000
;
}
else
{
wf
.
wBitsPerSample
=
8
;
if
((
dwFormats
&
WAVE_FORMAT_48M08
)
!=
0
)
{
wf
.
nSamplesPerSec
=
48000
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_44M08
)
!=
0
)
{
wf
.
nSamplesPerSec
=
44100
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_2M08
)
!=
0
)
{
wf
.
nSamplesPerSec
=
22050
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_1M08
)
!=
0
)
{
wf
.
nSamplesPerSec
=
11025
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_96M08
)
!=
0
)
{
wf
.
nSamplesPerSec
=
96000
;
}
else
{
errorMsg
=
"[WinMM] Could not find appropriate format for internal device."
,
errorCode
=
MAL_FORMAT_NOT_SUPPORTED
;
goto
on_error
;
}
}
}
else
{
wf
.
nChannels
=
2
;
wf
.
wBitsPerSample
=
16
;
if
((
dwFormats
&
WAVE_FORMAT_48S16
)
!=
0
)
{
wf
.
nSamplesPerSec
=
48000
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_44S16
)
!=
0
)
{
wf
.
nSamplesPerSec
=
44100
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_2S16
)
!=
0
)
{
wf
.
nSamplesPerSec
=
22050
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_1S16
)
!=
0
)
{
wf
.
nSamplesPerSec
=
11025
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_96S16
)
!=
0
)
{
wf
.
nSamplesPerSec
=
96000
;
}
else
{
wf
.
wBitsPerSample
=
8
;
if
((
dwFormats
&
WAVE_FORMAT_48S08
)
!=
0
)
{
wf
.
nSamplesPerSec
=
48000
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_44S08
)
!=
0
)
{
wf
.
nSamplesPerSec
=
44100
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_2S08
)
!=
0
)
{
wf
.
nSamplesPerSec
=
22050
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_1S08
)
!=
0
)
{
wf
.
nSamplesPerSec
=
11025
;
}
else
if
((
dwFormats
&
WAVE_FORMAT_96S08
)
!=
0
)
{
wf
.
nSamplesPerSec
=
96000
;
}
else
{
errorMsg
=
"[WinMM] Could not find appropriate format for internal device."
,
errorCode
=
MAL_FORMAT_NOT_SUPPORTED
;
goto
on_error
;
}
}
}
}
wf.nBlockAlign = (wf.nChannels * wf.wBitsPerSample) / 8;
wf.nBlockAlign = (wf.nChannels * wf.wBitsPerSample) / 8;
...
@@ -7596,14 +7650,14 @@ mal_result mal_device_init__winmm(mal_context* pContext, mal_device_type type, m
...
@@ -7596,14 +7650,14 @@ mal_result mal_device_init__winmm(mal_context* pContext, mal_device_type type, m
if (type == mal_device_type_playback) {
if (type == mal_device_type_playback) {
MMRESULT
result
=
((
MAL_PFN_waveOutOpen
)
pContext
->
winmm
.
waveOutOpen
)((
LPHWAVEOUT
)
&
pDevice
->
winmm
.
hDevice
,
winMMDeviceID
,
&
wf
,
(
DWORD_PTR
)
pDevice
->
winmm
.
hEvent
,
(
DWORD_PTR
)
pDevice
,
CALLBACK_EVENT
|
WAVE_ALLOWSYNC
);
MMRESULT result
MM
= ((MAL_PFN_waveOutOpen)pContext->winmm.waveOutOpen)((LPHWAVEOUT)&pDevice->winmm.hDevice, winMMDeviceID, &wf, (DWORD_PTR)pDevice->winmm.hEvent, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC);
if
(
result
!=
MMSYSERR_NOERROR
)
{
if (result
MM
!= MMSYSERR_NOERROR) {
errorMsg = "[WinMM] Failed to open playback device.", errorCode = MAL_FAILED_TO_OPEN_BACKEND_DEVICE;
errorMsg = "[WinMM] Failed to open playback device.", errorCode = MAL_FAILED_TO_OPEN_BACKEND_DEVICE;
goto on_error;
goto on_error;
}
}
} else {
} else {
MMRESULT
result
=
((
MAL_PFN_waveInOpen
)
pDevice
->
pContext
->
winmm
.
waveInOpen
)((
LPHWAVEIN
)
&
pDevice
->
winmm
.
hDevice
,
winMMDeviceID
,
&
wf
,
(
DWORD_PTR
)
pDevice
->
winmm
.
hEvent
,
(
DWORD_PTR
)
pDevice
,
CALLBACK_EVENT
|
WAVE_ALLOWSYNC
);
MMRESULT result
MM
= ((MAL_PFN_waveInOpen)pDevice->pContext->winmm.waveInOpen)((LPHWAVEIN)&pDevice->winmm.hDevice, winMMDeviceID, &wf, (DWORD_PTR)pDevice->winmm.hEvent, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC);
if
(
result
!=
MMSYSERR_NOERROR
)
{
if (result
MM
!= MMSYSERR_NOERROR) {
errorMsg = "[WinMM] Failed to open capture device.", errorCode = MAL_FAILED_TO_OPEN_BACKEND_DEVICE;
errorMsg = "[WinMM] Failed to open capture device.", errorCode = MAL_FAILED_TO_OPEN_BACKEND_DEVICE;
goto on_error;
goto on_error;
}
}
...
...
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