Sound pause/unpause Magic API functions...

...plus documenting them.
...plus using them in new "Comic Dots" Magic tool.
This commit is contained in:
Bill Kendrick 2024-09-17 22:11:32 -07:00
parent 143b50733c
commit d94e85e26e
33 changed files with 723 additions and 129 deletions

View file

@ -127,6 +127,16 @@ typedef struct magic_api_t {
loudest) */
void (*playsound)(Mix_Chunk *, int, int);
/* Asks Tux Paint whether a sound is currently being played (by 'playsound()') */
int (*playingsound)(void);
/* Asks Tux Paint to pause the sound being played by 'playsound()' */
void (*pausesound)(void);
/* Asks Tux Paint to resume (unpause) the sound being played by
'playsound()' (if any) */
void (*unpausesound)(void);
/* Asks Tux Paint to stop playing the sound played by 'playsound()' */
void (*stopsound)(void);

View file

@ -2295,6 +2295,9 @@ static int magic_sort(const void *a, const void *b);
Mix_Chunk *magic_current_snd_ptr;
static void magic_playsound(Mix_Chunk * snd, int left_right, int up_down);
static int magic_playingsound(void);
static void magic_pausesound(void);
static void magic_unpausesound(void);
static void magic_stopsound(void);
static void magic_line_func(void *mapi,
int which, SDL_Surface * canvas,
@ -21729,6 +21732,9 @@ static void load_magic_plugins(void)
magic_api_struct->xorpixel = magic_xorpixel;
magic_api_struct->line = magic_line_func;
magic_api_struct->playsound = magic_playsound;
magic_api_struct->playingsound = magic_playingsound;
magic_api_struct->pausesound = magic_pausesound;
magic_api_struct->unpausesound = magic_unpausesound;
magic_api_struct->stopsound = magic_stopsound;
magic_api_struct->special_notify = special_notify;
magic_api_struct->button_down = magic_button_down;
@ -22403,6 +22409,29 @@ static void magic_playsound(Mix_Chunk * snd, int left_right, int up_down)
#endif
}
static int magic_playingsound(void)
{
#ifndef NOSOUND
int is_playing;
is_playing = Mix_Playing(0);
return is_playing;
#endif
}
static void magic_pausesound(void)
{
#ifndef NOSOUND
return Mix_Pause(0);
#endif
}
static void magic_unpausesound(void)
{
#ifndef NOSOUND
return Mix_Resume(0);
#endif
}
/**
* FIXME
*/