summaryrefslogtreecommitdiffstats
path: root/src/core/CdStreamPosix.cpp
diff options
context:
space:
mode:
authorerorcun <erorcunerorcun@hotmail.com.tr>2021-01-27 16:26:08 +0100
committererorcun <erorcunerorcun@hotmail.com.tr>2021-01-27 20:19:00 +0100
commitab939e059b4263fec4e26425bce6a12ecf88d2e6 (patch)
tree72be40877a6cb4e37962552bf3df3c88c9860974 /src/core/CdStreamPosix.cpp
parentfix fix (diff)
downloadre3-ab939e059b4263fec4e26425bce6a12ecf88d2e6.tar
re3-ab939e059b4263fec4e26425bce6a12ecf88d2e6.tar.gz
re3-ab939e059b4263fec4e26425bce6a12ecf88d2e6.tar.bz2
re3-ab939e059b4263fec4e26425bce6a12ecf88d2e6.tar.lz
re3-ab939e059b4263fec4e26425bce6a12ecf88d2e6.tar.xz
re3-ab939e059b4263fec4e26425bce6a12ecf88d2e6.tar.zst
re3-ab939e059b4263fec4e26425bce6a12ecf88d2e6.zip
Diffstat (limited to 'src/core/CdStreamPosix.cpp')
-rw-r--r--src/core/CdStreamPosix.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/core/CdStreamPosix.cpp b/src/core/CdStreamPosix.cpp
index 0854d850..8a27665a 100644
--- a/src/core/CdStreamPosix.cpp
+++ b/src/core/CdStreamPosix.cpp
@@ -21,9 +21,9 @@
#define CDDEBUG(f, ...) debug ("%s: " f "\n", "cdvd_stream", ## __VA_ARGS__)
#define CDTRACE(f, ...) printf("%s: " f "\n", "cdvd_stream", ## __VA_ARGS__)
-// #define ONE_THREAD_PER_CHANNEL // Don't use if you're not on SSD/Flash. (Also you may want to benefit from this via using all channels in Streaming.cpp)
-
+#ifdef FLUSHABLE_STREAMING
bool flushStream[MAX_CDCHANNELS];
+#endif
struct CdReadInfo
{
@@ -99,6 +99,7 @@ CdStreamInitThread(void)
ASSERT(0);
return;
}
+
#ifdef ONE_THREAD_PER_CHANNEL
sprintf(semName,"/semaphore_start%d",i);
gpReadInfo[i].pStartSemaphore = sem_open(semName, O_CREAT, 0644, 1);
@@ -245,10 +246,12 @@ CdStreamRead(int32 channel, void *buffer, uint32 offset, uint32 size)
if ( pChannel->nSectorsToRead != 0 || pChannel->bReading ) {
if (pChannel->hFile == hImage - 1 && pChannel->nSectorOffset == _GET_OFFSET(offset) && pChannel->nSectorsToRead >= size)
return STREAM_SUCCESS;
-
+#ifdef FLUSHABLE_STREAMING
flushStream[channel] = 1;
CdStreamSync(channel);
- //return STREAM_NONE;
+#else
+ return STREAM_NONE;
+#endif
}
pChannel->hFile = hImage - 1;
@@ -316,34 +319,34 @@ CdStreamSync(int32 channel)
CdReadInfo *pChannel = &gpReadInfo[channel];
ASSERT( pChannel != nil );
+#ifdef FLUSHABLE_STREAMING
if (flushStream[channel]) {
-#ifdef ONE_THREAD_PER_CHANNEL
pChannel->nSectorsToRead = 0;
+#ifdef ONE_THREAD_PER_CHANNEL
pthread_kill(pChannel->pChannelThread, SIGUSR1);
if (pChannel->bReading) {
pChannel->bLocked = true;
- while (pChannel->bLocked)
- sem_wait(pChannel->pDoneSemaphore);
- }
#else
- pChannel->nSectorsToRead = 0;
if (pChannel->bReading) {
pChannel->bLocked = true;
pthread_kill(_gCdStreamThread, SIGUSR1);
+#endif
while (pChannel->bLocked)
sem_wait(pChannel->pDoneSemaphore);
}
-#endif
pChannel->bReading = false;
flushStream[channel] = false;
return STREAM_NONE;
}
+#endif
if ( pChannel->nSectorsToRead != 0 )
{
pChannel->bLocked = true;
- while (pChannel->bLocked)
+ while (pChannel->bLocked && pChannel->nSectorsToRead != 0){
sem_wait(pChannel->pDoneSemaphore);
+ }
+ pChannel->bLocked = false;
}
pChannel->bReading = false;
@@ -447,7 +450,7 @@ void *CdStreamThread(void *param)
if ( pChannel->bLocked )
{
pChannel->bLocked = 0;
- sem_post(pChannel->pDoneSemaphore);
+ sem_post(pChannel->pDoneSemaphore);
}
pChannel->bReading = false;
}
@@ -524,7 +527,9 @@ void
CdStreamRemoveImages(void)
{
for ( int32 i = 0; i < gNumChannels; i++ ) {
+#ifdef FLUSHABLE_STREAMING
flushStream[i] = 1;
+#endif
CdStreamSync(i);
}