SDL_migration.cocci: migrate audio api 1.2

This commit is contained in:
Sylvain 2023-01-12 15:00:31 +01:00 committed by Sylvain Becker
parent 2ec9a20204
commit 3b2e9d98df
1 changed files with 56 additions and 0 deletions

View File

@ -31,6 +31,62 @@
// So this file is a set of many semantic patches, mostly independant.
@ rule_audio_open @
expression e1, e2;
@@
- SDL_OpenAudio(e1, e2)
+ (g_audio_id = SDL_OpenAudioDevice(NULL, 0, e1, e2, 0)) > 0 ? 0 : -1
@ depends on rule_audio_open @
@@
{
+ /* FIXME MIGRATION: maybe move this to a global scope ? */
+ SDL_AudioDeviceID g_audio_id = -1;
...
SDL_OpenAudioDevice(...)
...
}
@@
@@
- SDL_LockAudio()
+ SDL_LockAudioDevice(g_audio_id)
@@
@@
- SDL_UnlockAudio()
+ SDL_UnlockAudioDevice(g_audio_id)
@@
@@
- SDL_CloseAudio(void)
+ SDL_CloseAudioDevice(g_audio_id)
@@
expression e;
@@
- SDL_PauseAudio(e)
+ e == SDL_TRUE ? SDL_PauseAudioDevice(g_audio_id) : SDL_PlayAudioDevice(g_audio_id)
@@
@@
- SDL_GetAudioStatus()
+ SDL_GetAudioDeviceStatus(g_audio_id)
@@
@@
- SDL_GetQueuedAudioSize(1)
+ SDL_GetQueuedAudioSize(g_audio_id)
@@
expression e1, e2;
@@
- SDL_QueueAudio(1, e1, e2)
+ SDL_QueueAudio(g_audio_id, e1, e2)
// SDL_EventState() - replaced with SDL_SetEventEnabled()
@@
expression e1;