summaryrefslogtreecommitdiffstats
path: root/src/core/CdStreamPosix.cpp
diff options
context:
space:
mode:
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);
}