summaryrefslogtreecommitdiff
path: root/src/audio/sampman_oal.cpp
diff options
context:
space:
mode:
authorerorcun <erorcunerorcun@hotmail.com.tr>2021-06-25 05:06:38 +0300
committererorcun <erorcunerorcun@hotmail.com.tr>2021-06-26 16:24:23 +0300
commit107c4df69c0d72cb061d32e59e8cf8078193c87e (patch)
tree0de0ac78657f8d1f74e5fb3e0f93fffe80e8aa43 /src/audio/sampman_oal.cpp
parent53418409435ef601567dd3bb7831a5b34be98c59 (diff)
Multi-threaded audio streams
Under MULTITHREADED_AUDIO define.
Diffstat (limited to 'src/audio/sampman_oal.cpp')
-rw-r--r--src/audio/sampman_oal.cpp37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp
index 440e0927..cd2fa50a 100644
--- a/src/audio/sampman_oal.cpp
+++ b/src/audio/sampman_oal.cpp
@@ -34,6 +34,12 @@
#include "oal/oal_utils.h"
#include "oal/aldlist.h"
#include "oal/channel.h"
+
+#include <utility>
+#ifdef MULTITHREADED_AUDIO
+#include <mutex>
+#include <queue>
+#endif
#include "oal/stream.h"
#include "AudioManager.h"
@@ -521,7 +527,7 @@ _FindMP3s(void)
if (aStream[0] && aStream[0]->IsOpened())
{
total_ms = aStream[0]->GetLengthMS();
- delete aStream[0];
+ aStream[0]->Close();
aStream[0] = NULL;
OutputDebugString(fd.cFileName);
@@ -595,7 +601,7 @@ _FindMP3s(void)
if (aStream[0] && aStream[0]->IsOpened())
{
total_ms = aStream[0]->GetLengthMS();
- delete aStream[0];
+ aStream[0]->Close();
aStream[0] = NULL;
OutputDebugString(fd.cFileName);
@@ -655,7 +661,7 @@ _FindMP3s(void)
if (aStream[0] && aStream[0]->IsOpened())
{
total_ms = aStream[0]->GetLengthMS();
- delete aStream[0];
+ aStream[0]->Close();
aStream[0] = NULL;
OutputDebugString(fd.cFileName);
@@ -811,6 +817,7 @@ cSampleManager::Initialise(void)
return TRUE;
EFXInit();
+
CStream::Initialise();
{
@@ -971,7 +978,7 @@ cSampleManager::Initialise(void)
if ( aStream[0] && aStream[0]->IsOpened() )
{
uint32 tatalms = aStream[0]->GetLengthMS();
- delete aStream[0];
+ aStream[0]->Close();
aStream[0] = NULL;
nStreamLength[i] = tatalms;
@@ -1021,7 +1028,7 @@ cSampleManager::Initialise(void)
nStreamPan[i] = 63;
}
}
-
+
{
_bSampmanInitialised = TRUE;
@@ -1107,7 +1114,7 @@ cSampleManager::Terminate(void)
CStream *stream = aStream[i];
if (stream)
{
- delete stream;
+ stream->Close();
aStream[i] = NULL;
}
}
@@ -1688,7 +1695,7 @@ cSampleManager::PreloadStreamedFile(uint32 nFile, uint8 nStream)
{
if ( aStream[nStream] )
{
- delete aStream[nStream];
+ aStream[nStream]->Close();
aStream[nStream] = NULL;
}
@@ -1700,7 +1707,7 @@ cSampleManager::PreloadStreamedFile(uint32 nFile, uint8 nStream)
aStream[nStream] = stream;
if ( !stream->Setup() )
{
- delete stream;
+ stream->Close();
aStream[nStream] = NULL;
}
}
@@ -1747,7 +1754,7 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
if ( aStream[nStream] )
{
- delete aStream[nStream];
+ aStream[nStream]->Close();
aStream[nStream] = NULL;
}
if ( nFile == STREAMED_SOUND_RADIO_MP3_PLAYER )
@@ -1780,7 +1787,7 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
return TRUE;
} else {
- delete stream;
+ stream->Close();
aStream[nStream] = NULL;
}
return FALSE;
@@ -1805,7 +1812,7 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
_bIsMp3Active = TRUE;
return TRUE;
} else {
- delete aStream[nStream];
+ aStream[nStream]->Close();
aStream[nStream] = NULL;
}
// fall through, start playing from another song
@@ -1839,7 +1846,7 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
return TRUE;
} else {
- delete stream;
+ stream->Close();
aStream[nStream] = NULL;
}
return FALSE;
@@ -1861,7 +1868,7 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
#endif
return TRUE;
} else {
- delete aStream[nStream];
+ aStream[nStream]->Close();
aStream[nStream] = NULL;
}
@@ -1888,7 +1895,7 @@ cSampleManager::StartStreamedFile(uint32 nFile, uint32 nPos, uint8 nStream)
return TRUE;
} else {
- delete stream;
+ stream->Close();
aStream[nStream] = NULL;
}
return FALSE;
@@ -1903,7 +1910,7 @@ cSampleManager::StopStreamedFile(uint8 nStream)
if ( stream )
{
- delete stream;
+ stream->Close();
aStream[nStream] = NULL;
if ( nStream == 0 )