Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YGOPRO-520DIY
ygopro
Commits
27315f2f
Commit
27315f2f
authored
Mar 31, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix sound conflict
parent
d405b636
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
14 deletions
+35
-14
gframe/sound_manager.cpp
gframe/sound_manager.cpp
+34
-12
gframe/sound_manager.h
gframe/sound_manager.h
+1
-2
No files found.
gframe/sound_manager.cpp
View file @
27315f2f
...
...
@@ -36,7 +36,6 @@ bool SoundManager::Init() {
}
engineConfig
.
pResourceManager
=
&
resourceManager
;
#endif
playingSoundEffect
=
FALSE
;
if
(
ma_engine_init
(
&
engineConfig
,
&
engineSound
)
!=
MA_SUCCESS
||
ma_engine_init
(
&
engineConfig
,
&
engineMusic
)
!=
MA_SUCCESS
)
{
return
false
;
}
else
{
...
...
@@ -90,21 +89,41 @@ void SoundManager::PlaySound(char* sound) {
#ifdef YGOPRO_USE_AUDIO
if
(
!
mainGame
->
chkEnableSound
->
isChecked
())
return
;
#ifdef YGOPRO_USE_MINIAUDIO
StopSound
();
SetSoundVolume
(
mainGame
->
gameConf
.
sound_volume
);
playingSoundEffect
=
TRUE
;
#ifdef YGOPRO_USE_MINIAUDIO
ma_sound
*
usingSoundEffectPointer
=
nullptr
;
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
if
(
playingSoundEffect
[
i
]
&&
!
ma_sound_is_playing
(
playingSoundEffect
[
i
]))
{
ma_sound_uninit
(
playingSoundEffect
[
i
]);
if
(
usingSoundEffectPointer
)
{
free
(
playingSoundEffect
[
i
]);
playingSoundEffect
[
i
]
=
nullptr
;
printf
(
"free sound %d
\n
"
,
i
);
}
else
{
usingSoundEffectPointer
=
playingSoundEffect
[
i
];
printf
(
"reusing sound %d
\n
"
,
i
);
}
}
if
(
!
playingSoundEffect
[
i
]
&&
!
usingSoundEffectPointer
)
{
usingSoundEffectPointer
=
playingSoundEffect
[
i
]
=
(
ma_sound
*
)
malloc
(
sizeof
(
ma_sound
));
printf
(
"alloc sound %d
\n
"
,
i
);
}
}
if
(
!
usingSoundEffectPointer
)
{
// force to stop the first sound
usingSoundEffectPointer
=
playingSoundEffect
[
0
];
ma_sound_uninit
(
usingSoundEffectPointer
);
}
#ifdef _WIN32
wchar_t
sound_w
[
1024
];
BufferIO
::
DecodeUTF8
(
sound
,
sound_w
);
ma_sound_init_from_file_w
(
&
engineSound
,
sound_w
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
&
soundEffect
);
ma_sound_init_from_file_w
(
&
engineSound
,
sound_w
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
usingSoundEffectPointer
);
#else
ma_sound_init_from_file
(
&
engineSound
,
sound
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
&
soundEffect
);
ma_sound_init_from_file
(
&
engineSound
,
sound
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
usingSoundEffectPointer
);
#endif
ma_sound_start
(
&
soundEffect
);
ma_sound_start
(
usingSoundEffectPointer
);
#endif
#ifdef YGOPRO_USE_IRRKLANG
SetSoundVolume
(
mainGame
->
gameConf
.
sound_volume
);
engineSound
->
play2D
(
soundPath
);
#endif
#endif
...
...
@@ -358,10 +377,13 @@ void SoundManager::StopBGM() {
}
void
SoundManager
::
StopSound
()
{
#ifdef YGOPRO_USE_MINIAUDIO
if
(
!
playingSoundEffect
)
return
;
playingSoundEffect
=
FALSE
;
ma_sound_uninit
(
&
soundEffect
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
if
(
playingSoundEffect
[
i
])
{
ma_sound_uninit
(
playingSoundEffect
[
i
]);
free
(
playingSoundEffect
[
i
]);
playingSoundEffect
[
i
]
=
nullptr
;
}
}
#endif
#ifdef YGOPRO_USE_IRRKLANG
engineSound
->
stopAllSounds
();
...
...
gframe/sound_manager.h
View file @
27315f2f
...
...
@@ -29,8 +29,7 @@ private:
ma_engine
engineMusic
;
ma_sound
soundBGM
;
char
currentPlayingMusic
[
1024
]{};
ma_sound
soundEffect
;
char
playingSoundEffect
;
ma_sound
*
playingSoundEffect
[
10
]{};
#endif
#ifdef YGOPRO_USE_IRRKLANG
irrklang
::
ISoundEngine
*
engineSound
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment