-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
open audio device as needed to avoid potentional conflicts.
- Loading branch information
Showing
1 changed file
with
9 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,17 @@ Now: EBK21 [email protected] | |
************************************/ | ||
|
||
#include <obs-module.h> | ||
#include <obs-frontend-api/obs-frontend-api.h> | ||
#include <obs-frontend-api.h> | ||
#include <thread> | ||
#include <atomic> | ||
#include <sstream> | ||
#include <mutex> | ||
|
||
extern "C" | ||
{ | ||
#include "SDL.h" | ||
#include "SDL_thread.h" | ||
#include "SDL_mixer.h" | ||
#include <SDL2/SDL.h> | ||
#include <SDL2/SDL_thread.h> | ||
#include <SDL2/SDL_mixer.h> | ||
}; | ||
|
||
std::mutex audioMutex; | ||
|
@@ -56,7 +56,6 @@ void obs_module_unload(void) | |
{ | ||
ps_sto_Thread.join(); | ||
} | ||
Mix_CloseAudio(); | ||
SDL_Quit(); | ||
return; | ||
} | ||
|
@@ -81,6 +80,10 @@ void play_clip(const char *filepath) | |
{ | ||
Mix_Music* music; | ||
audioMutex.lock(); | ||
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 1, 1024)!=0) { | ||
audioMutex.unlock(); | ||
return; | ||
} | ||
if(! (music = Mix_LoadMUS(filepath))) { | ||
audioMutex.unlock(); | ||
return; | ||
|
@@ -91,6 +94,7 @@ void play_clip(const char *filepath) | |
SDL_Delay(1); | ||
} | ||
Mix_FreeMusic(music); | ||
Mix_CloseAudio(); | ||
audioMutex.unlock(); | ||
return; | ||
} | ||
|
@@ -208,7 +212,6 @@ void obsstudio_srbeep_frontend_event_callback(enum obs_frontend_event event, voi | |
|
||
bool obs_module_load(void) | ||
{ | ||
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 1, 1024); | ||
obs_frontend_add_event_callback(obsstudio_srbeep_frontend_event_callback, 0); | ||
return true; | ||
} |