Commit 24167ba3 authored by David Reid's avatar David Reid

API CHANGE: Remove the device type and ID from mal_device_init/_ex().

parent 661115f1
This diff is collapsed.
...@@ -56,12 +56,18 @@ void on_send_to_device__dithered(mal_device* pDevice, void* pOutput, const void* ...@@ -56,12 +56,18 @@ void on_send_to_device__dithered(mal_device* pDevice, void* pOutput, const void*
int do_dithering_test() int do_dithering_test()
{ {
mal_device_config config = mal_device_config_init(mal_format_f32, 1, 0, on_send_to_device__original, NULL); mal_device_config config;
mal_device device; mal_device device;
mal_result result; mal_result result;
config = mal_device_config_init(mal_device_type_playback);
config.format = mal_format_f32;
config.channels = 1;
config.sampleRate = 0;
config.dataCallback = on_send_to_device__original;
// We first play the sound the way it's meant to be played. // We first play the sound the way it's meant to be played.
result = mal_device_init(NULL, mal_device_type_playback, NULL, &config, &device); result = mal_device_init(NULL, &config, &device);
if (result != MAL_SUCCESS) { if (result != MAL_SUCCESS) {
return -1; return -1;
} }
...@@ -106,9 +112,11 @@ int do_dithering_test() ...@@ -106,9 +112,11 @@ int do_dithering_test()
return -3; return -3;
} }
config = mal_device_config_init(converterOutConfig.formatOut, 1, 0, on_send_to_device__dithered, &converterOut);
result = mal_device_init(NULL, mal_device_type_playback, NULL, &config, &device); config.dataCallback = on_send_to_device__dithered;
config.pUserData = &converterOut;
result = mal_device_init(NULL, &config, &device);
if (result != MAL_SUCCESS) { if (result != MAL_SUCCESS) {
return -1; return -1;
} }
......
...@@ -14,7 +14,7 @@ void on_stop(mal_device* pDevice) ...@@ -14,7 +14,7 @@ void on_stop(mal_device* pDevice)
printf("STOPPED\n"); printf("STOPPED\n");
} }
void data_callback(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 frameCount) void on_data(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 frameCount)
{ {
(void)pInput; /* Not used yet. */ (void)pInput; /* Not used yet. */
...@@ -54,15 +54,16 @@ int main(int argc, char** argv) ...@@ -54,15 +54,16 @@ int main(int argc, char** argv)
mal_sine_wave_init(0.25, 400, 44100, &sineWave); mal_sine_wave_init(0.25, 400, 44100, &sineWave);
mal_device_config config = mal_device_config_init_default(data_callback, NULL); mal_device_config config = mal_device_config_init(mal_device_type_playback);
config.format = mal_format_f32; config.format = mal_format_f32;
config.channels = 2; config.channels = 2;
config.sampleRate = 44100; config.sampleRate = 44100;
config.onStopCallback = on_stop; config.dataCallback = on_data;
config.stopCallback = on_stop;
config.bufferSizeInFrames = 16384*4; config.bufferSizeInFrames = 16384*4;
mal_device device; mal_device device;
result = mal_device_init_ex(&backend, 1, NULL, mal_device_type_playback, NULL, &config, &device); result = mal_device_init_ex(&backend, 1, NULL, &config, &device);
if (result != MAL_SUCCESS) { if (result != MAL_SUCCESS) {
printf("Failed to initialize device.\n"); printf("Failed to initialize device.\n");
return result; return result;
......
...@@ -2254,6 +2254,8 @@ void on_send__playback_test(mal_device* pDevice, void* pOutput, const void* pInp ...@@ -2254,6 +2254,8 @@ void on_send__playback_test(mal_device* pDevice, void* pOutput, const void* pInp
} }
} }
#endif #endif
(void)pInput;
} }
void on_stop__playback_test(mal_device* pDevice) void on_stop__playback_test(mal_device* pDevice)
...@@ -2284,14 +2286,17 @@ int do_playback_test(mal_backend backend) ...@@ -2284,14 +2286,17 @@ int do_playback_test(mal_backend backend)
printf(" Opening Device... "); printf(" Opening Device... ");
{ {
mal_context_config contextConfig = mal_context_config_init(on_log); mal_context_config contextConfig = mal_context_config_init(on_log);
mal_device_config deviceConfig = mal_device_config_init_default(on_send__playback_test, &callbackData); mal_device_config deviceConfig = mal_device_config_init(mal_device_type_playback);
deviceConfig.onStopCallback = on_stop__playback_test; deviceConfig.pUserData = &callbackData;
deviceConfig.dataCallback = on_send__playback_test;
deviceConfig.stopCallback = on_stop__playback_test;
#if defined(__EMSCRIPTEN__) #if defined(__EMSCRIPTEN__)
deviceConfig.format = mal_format_f32; deviceConfig.format = mal_format_f32;
#endif #endif
result = mal_device_init_ex(&backend, 1, &contextConfig, mal_device_type_playback, NULL, &deviceConfig, &device); result = mal_device_init_ex(&backend, 1, &contextConfig, &deviceConfig, &device);
if (result == MAL_SUCCESS) { if (result == MAL_SUCCESS) {
printf("Done\n"); printf("Done\n");
} else { } else {
......
...@@ -351,21 +351,21 @@ ...@@ -351,21 +351,21 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="mal_stop.c"> <ClCompile Include="mal_stop.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="mal_test_0.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="mal_test_0.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="mal_test_0.cpp"> <ClCompile Include="mal_test_0.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment