mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-23 16:54:03 +02:00
Add some getters:
ma_device_get_format() ma_device_get_channels() ma_device_get_sample_rate() ma_device_get_internal_format() ma_device_get_internal_channels() ma_device_get_internal_sample_rate() ma_device_get_internal_channel_map()
This commit is contained in:
+318
-11
@@ -9379,6 +9379,84 @@ This should only be called in single-threaded mode. It should be called in a loo
|
|||||||
MA_API ma_result ma_device_step(ma_device* pDevice, ma_blocking_mode blockingMode);
|
MA_API ma_result ma_device_step(ma_device* pDevice, ma_blocking_mode blockingMode);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Retrieve the format of the device.
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
pDevice (in)
|
||||||
|
A pointer to the device whose format is being retrieved.
|
||||||
|
|
||||||
|
deviceType (in)
|
||||||
|
Either `ma_device_type_playback` or `ma_device_type_capture` specifying which side of the device whose format is being retrieved.
|
||||||
|
|
||||||
|
|
||||||
|
Return Value
|
||||||
|
------------
|
||||||
|
The public facing format of the device.
|
||||||
|
|
||||||
|
Will return `ma_format_unknown` if an invalid device or device type is specified.
|
||||||
|
|
||||||
|
|
||||||
|
Remarks
|
||||||
|
-------
|
||||||
|
Since the capture and playback sides can have different sample formats you need to use the `deviceType` parameter to discrimate between
|
||||||
|
the two. Use `ma_device_type_playback` for the playback side, or `ma_device_type_capture` for the capture side. You cannot use
|
||||||
|
`ma_device_type_duplex`. Doing so will result in `ma_format_unknown` being returned.
|
||||||
|
*/
|
||||||
|
MA_API ma_format ma_device_get_format(const ma_device* pDevice, ma_device_type deviceType);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Retrieve the channel count of the device.
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
pDevice (in)
|
||||||
|
A pointer to the device whose channel count is being retrieved.
|
||||||
|
|
||||||
|
deviceType (in)
|
||||||
|
Either `ma_device_type_playback` or `ma_device_type_capture` specifying which side of the device whose channel count is being retrieved.
|
||||||
|
|
||||||
|
|
||||||
|
Return Value
|
||||||
|
------------
|
||||||
|
The public facing channel count of the device.
|
||||||
|
|
||||||
|
Will return 0 if an invalid device or device type is specified.
|
||||||
|
|
||||||
|
|
||||||
|
Remarks
|
||||||
|
-------
|
||||||
|
Since the capture and playback sides can have different channel counts you need to use the `deviceType` parameter to discrimate between
|
||||||
|
the two. Use `ma_device_type_playback` for the playback side, or `ma_device_type_capture` for the capture side. You cannot use
|
||||||
|
`ma_device_type_duplex`. Doing so will result in 0 being returned.
|
||||||
|
*/
|
||||||
|
MA_API ma_uint32 ma_device_get_channels(const ma_device* pDevice, ma_device_type deviceType);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Retrieve the sample rate of the device.
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
pDevice (in)
|
||||||
|
A pointer to the device whose sample rate is being retrieved.
|
||||||
|
|
||||||
|
|
||||||
|
Return Value
|
||||||
|
------------
|
||||||
|
The public facing sample rate of the device.
|
||||||
|
|
||||||
|
|
||||||
|
Remarks
|
||||||
|
-------
|
||||||
|
Unlike the sample format, channel count and channel map, the sample rate is shared between the capture and playback sides of the device
|
||||||
|
which means a device type is not necessary.
|
||||||
|
*/
|
||||||
|
MA_API ma_uint32 ma_device_get_sample_rate(const ma_device* pDevice);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Retrieves the channel map of the device.
|
Retrieves the channel map of the device.
|
||||||
|
|
||||||
@@ -9398,11 +9476,133 @@ channelMapCap (in)
|
|||||||
The capacity of `pChannelMap`.
|
The capacity of `pChannelMap`.
|
||||||
|
|
||||||
|
|
||||||
|
Remarks
|
||||||
|
-------
|
||||||
|
Since the capture and playback sides can have different channel maps you need to use the `deviceType` parameter to discrimate between
|
||||||
|
the two. Use `ma_device_type_playback` for the playback side, or `ma_device_type_capture` for the capture side. You cannot use
|
||||||
|
`ma_device_type_duplex`. Doing so will result in a blank channel map being returned.
|
||||||
|
*/
|
||||||
|
MA_API void ma_device_get_channel_map(const ma_device* pDevice, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Retrieve the internal format of the device.
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
pDevice (in)
|
||||||
|
A pointer to the device whose internal format is being retrieved.
|
||||||
|
|
||||||
|
deviceType (in)
|
||||||
|
Either `ma_device_type_playback` or `ma_device_type_capture` specifying which side of the device whose internal format is being retrieved.
|
||||||
|
|
||||||
|
|
||||||
Return Value
|
Return Value
|
||||||
------------
|
------------
|
||||||
MA_SUCCESS if successful; any other error otherwise.
|
The internal format of the device.
|
||||||
|
|
||||||
|
Will return `ma_format_unknown` if an invalid device or device type is specified.
|
||||||
|
|
||||||
|
|
||||||
|
Remarks
|
||||||
|
-------
|
||||||
|
This would usually only be called by backends. A normal program should almost never need to call this.
|
||||||
|
|
||||||
|
Since the capture and playback sides can have different sample formats you need to use the `deviceType` parameter to discrimate between
|
||||||
|
the two. Use `ma_device_type_playback` for the playback side, or `ma_device_type_capture` for the capture side. You cannot use
|
||||||
|
`ma_device_type_duplex`. Doing so will result in `ma_format_unknown` being returned.
|
||||||
*/
|
*/
|
||||||
MA_API ma_result ma_device_get_channel_map(const ma_device* pDevice, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap);
|
MA_API ma_format ma_device_get_internal_format(const ma_device* pDevice, ma_device_type deviceType);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Retrieve the internal channel count of the device.
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
pDevice (in)
|
||||||
|
A pointer to the device whose internal channel count is being retrieved.
|
||||||
|
|
||||||
|
deviceType (in)
|
||||||
|
Either `ma_device_type_playback` or `ma_device_type_capture` specifying which side of the device whose internal channel count is being retrieved.
|
||||||
|
|
||||||
|
|
||||||
|
Return Value
|
||||||
|
------------
|
||||||
|
The internal channel count of the device.
|
||||||
|
|
||||||
|
Will return 0 if an invalid device or device type is specified.
|
||||||
|
|
||||||
|
|
||||||
|
Remarks
|
||||||
|
-------
|
||||||
|
This would usually only be called by backends. A normal program should almost never need to call this.
|
||||||
|
|
||||||
|
Since the capture and playback sides can have different channel counts you need to use the `deviceType` parameter to discrimate between
|
||||||
|
the two. Use `ma_device_type_playback` for the playback side, or `ma_device_type_capture` for the capture side. You cannot use
|
||||||
|
`ma_device_type_duplex`. Doing so will result in 0 being returned.
|
||||||
|
*/
|
||||||
|
MA_API ma_uint32 ma_device_get_internal_channels(const ma_device* pDevice, ma_device_type deviceType);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Retrieve the internal sample rate of the device.
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
pDevice (in)
|
||||||
|
A pointer to the device whose sample rate is being retrieved.
|
||||||
|
|
||||||
|
deviceType (in)
|
||||||
|
Either `ma_device_type_playback` or `ma_device_type_capture` specifying which side of the device whose internal sample rate is being retrieved.
|
||||||
|
|
||||||
|
|
||||||
|
Return Value
|
||||||
|
------------
|
||||||
|
The internal sample rate of the device.
|
||||||
|
|
||||||
|
Will return 0 if an invalid device or device type is specified.
|
||||||
|
|
||||||
|
|
||||||
|
Remarks
|
||||||
|
-------
|
||||||
|
This would usually only be called by backends. A normal program should almost never need to call this.
|
||||||
|
|
||||||
|
Since the capture and playback sides can have different internal sample rates you need to use the `deviceType` parameter to discrimate
|
||||||
|
between the two. Use `ma_device_type_playback` for the playback side, or `ma_device_type_capture` for the capture side. You cannot use
|
||||||
|
`ma_device_type_duplex`. Doing so will result in 0 being returned.
|
||||||
|
*/
|
||||||
|
MA_API ma_uint32 ma_device_get_internal_sample_rate(const ma_device* pDevice, ma_device_type deviceType);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Retrieves the internal channel map of the device.
|
||||||
|
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
pDevice (in)
|
||||||
|
A pointer to the device whose internal channel map is being retrieved.
|
||||||
|
|
||||||
|
deviceType (in)
|
||||||
|
Either `ma_device_type_playback` or `ma_device_type_capture` specifying which side of the device whose internal channel map is being retrieved.
|
||||||
|
|
||||||
|
pChannelMap (out)
|
||||||
|
A pointer to the buffer that will receive the internal channel map.
|
||||||
|
|
||||||
|
channelMapCap (in)
|
||||||
|
The capacity of `pChannelMap`.
|
||||||
|
|
||||||
|
|
||||||
|
Remarks
|
||||||
|
-------
|
||||||
|
This would usually only be called by backends. A normal program should almost never need to call this.
|
||||||
|
|
||||||
|
Since the capture and playback sides can have different channel maps you need to use the `deviceType` parameter to discrimate between
|
||||||
|
the two. Use `ma_device_type_playback` for the playback side, or `ma_device_type_capture` for the capture side. You cannot use
|
||||||
|
`ma_device_type_duplex`. Doing so will result in a blank channel map being returned.
|
||||||
|
*/
|
||||||
|
MA_API void ma_device_get_internal_channel_map(const ma_device* pDevice, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -49487,20 +49687,127 @@ MA_API ma_result ma_device_step(ma_device* pDevice, ma_blocking_mode blockingMod
|
|||||||
return MA_SUCCESS;
|
return MA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
MA_API ma_result ma_device_get_channel_map(const ma_device* pDevice, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap)
|
MA_API ma_format ma_device_get_format(const ma_device* pDevice, ma_device_type deviceType)
|
||||||
{
|
{
|
||||||
if (pDevice == NULL || pChannelMap == NULL) {
|
if (pDevice == NULL) {
|
||||||
return MA_INVALID_ARGS;
|
return ma_format_unknown;
|
||||||
}
|
|
||||||
|
|
||||||
if (deviceType == ma_device_type_duplex) {
|
|
||||||
return MA_INVALID_ARGS; /* Don't know if the playback or capture side is being requested. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deviceType == ma_device_type_playback) {
|
if (deviceType == ma_device_type_playback) {
|
||||||
return ma_data_converter_get_input_channel_map(&pDevice->playback.converter, pChannelMap, channelMapCap);
|
return pDevice->playback.converter.formatIn;
|
||||||
} else {
|
} else {
|
||||||
return ma_data_converter_get_output_channel_map(&pDevice->capture.converter, pChannelMap, channelMapCap);
|
return pDevice->capture.converter.formatOut;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MA_API ma_uint32 ma_device_get_channels(const ma_device* pDevice, ma_device_type deviceType)
|
||||||
|
{
|
||||||
|
if (pDevice == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceType == ma_device_type_playback) {
|
||||||
|
return pDevice->playback.converter.channelsIn;
|
||||||
|
} else {
|
||||||
|
return pDevice->capture.converter.channelsOut;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MA_API ma_uint32 ma_device_get_sample_rate(const ma_device* pDevice)
|
||||||
|
{
|
||||||
|
if (pDevice == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pDevice->type == ma_device_type_playback) {
|
||||||
|
return pDevice->playback.converter.sampleRateIn;
|
||||||
|
} else {
|
||||||
|
return pDevice->capture.converter.sampleRateOut;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MA_API void ma_device_get_channel_map(const ma_device* pDevice, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap)
|
||||||
|
{
|
||||||
|
if (pChannelMap == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap);
|
||||||
|
|
||||||
|
if (pDevice == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceType == ma_device_type_duplex) {
|
||||||
|
return; /* Don't know if the playback or capture side is being requested. */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceType == ma_device_type_playback) {
|
||||||
|
ma_data_converter_get_input_channel_map(&pDevice->playback.converter, pChannelMap, channelMapCap);
|
||||||
|
} else {
|
||||||
|
ma_data_converter_get_output_channel_map(&pDevice->capture.converter, pChannelMap, channelMapCap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MA_API ma_format ma_device_get_internal_format(const ma_device* pDevice, ma_device_type deviceType)
|
||||||
|
{
|
||||||
|
if (pDevice == NULL) {
|
||||||
|
return ma_format_unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceType == ma_device_type_playback) {
|
||||||
|
return pDevice->playback.converter.formatOut;
|
||||||
|
} else {
|
||||||
|
return pDevice->capture.converter.formatIn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MA_API ma_uint32 ma_device_get_internal_channels(const ma_device* pDevice, ma_device_type deviceType)
|
||||||
|
{
|
||||||
|
if (pDevice == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceType == ma_device_type_playback) {
|
||||||
|
return pDevice->playback.converter.channelsOut;
|
||||||
|
} else {
|
||||||
|
return pDevice->capture.converter.channelsIn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MA_API ma_uint32 ma_device_get_internal_sample_rate(const ma_device* pDevice, ma_device_type deviceType)
|
||||||
|
{
|
||||||
|
if (pDevice == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceType == ma_device_type_playback) {
|
||||||
|
return pDevice->playback.converter.sampleRateOut;
|
||||||
|
} else {
|
||||||
|
return pDevice->capture.converter.sampleRateIn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MA_API void ma_device_get_internal_channel_map(const ma_device* pDevice, ma_device_type deviceType, ma_channel* pChannelMap, size_t channelMapCap)
|
||||||
|
{
|
||||||
|
if (pChannelMap == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MA_ZERO_MEMORY(pChannelMap, sizeof(*pChannelMap) * channelMapCap);
|
||||||
|
|
||||||
|
if (pDevice == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceType == ma_device_type_duplex) {
|
||||||
|
return; /* Don't know if the playback or capture side is being requested. */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceType == ma_device_type_playback) {
|
||||||
|
ma_data_converter_get_output_channel_map(&pDevice->playback.converter, pChannelMap, channelMapCap);
|
||||||
|
} else {
|
||||||
|
ma_data_converter_get_input_channel_map(&pDevice->capture.converter, pChannelMap, channelMapCap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user