Re: [PATCH] Hang when moving between editing marks
Commit Message
Klaus Schmidinger wrote:
> Sebastian Frei wrote:
>
>> I applied the patch, but it doesn't work as good as the sched_yield
>> "patch".
>>
>> Now it takes between 3 and 8 seconds when moving or jumping between
>> cutmarks, with the sched_yield this was possible instantly.
>
>
> What happens if you put a
>
> cCondWait::SleepMs(1);
>
> instead of the sched_yield()?
> Maybe Reinhards remark about putting the sleep() outside of the locked area
> is the key...
>
> Klaus
Here's another suggestion (line numbers may be a little off).
The only difference to Reinhard's patch is that the sleep is done
outside the locked area.
Klaus
Comments
>
> Here's another suggestion (line numbers may be a little off).
> The only difference to Reinhard's patch is that the sleep is done
> outside the locked area.
>
> Klaus
>
>
>
> --- dvbplayer.c 2005/01/14 14:00:56 1.30
> +++ dvbplayer.c 2005/05/08 14:40:48
> @@ -370,9 +372,14 @@
>
> nonBlockingFileReader = new cNonBlockingFileReader;
> int Length = 0;
> + bool Sleep = false;
>
> running = true;
> while (running && (NextFile() || readIndex >= 0 ||
> ringBuffer->Available() || !DeviceFlush(100))) { + if (Sleep) {
> + cCondWait::SleepMs(3); // this keeps the CPU load low
> + Sleep = false;
> + }
> cPoller Poller;
> if (DevicePoll(Poller, 100)) {
>
> @@ -380,8 +387,8 @@
>
> // Read the next frame from the file:
>
> - if (!readFrame && (replayFile >= 0 || readIndex >= 0)) {
> - if (playMode != pmStill) {
> + if (playMode != pmStill && playMode != pmPause) {
> + if (!readFrame && (replayFile >= 0 || readIndex >= 0)) {
> if (!nonBlockingFileReader->Reading()) {
> if (playMode == pmFast || (playMode == pmSlow &&
> playDir == pdBackward)) { uchar FileNumber;
> @@ -438,16 +445,16 @@
> break;
> }
> }
> - else
> - cCondWait::SleepMs(3); // this keeps the CPU load low
> - }
>
> - // Store the frame in the buffer:
> + // Store the frame in the buffer:
>
> - if (readFrame) {
> - if (ringBuffer->Put(readFrame))
> - readFrame = NULL;
> + if (readFrame) {
> + if (ringBuffer->Put(readFrame))
> + readFrame = NULL;
> + }
> }
> + else
> + Sleep = true;
>
> // Get the next frame from the buffer:
>
This works too.
S.
@@ -370,9 +372,14 @@
nonBlockingFileReader = new cNonBlockingFileReader;
int Length = 0;
+ bool Sleep = false;
running = true;
while (running && (NextFile() || readIndex >= 0 || ringBuffer->Available() || !DeviceFlush(100))) {
+ if (Sleep) {
+ cCondWait::SleepMs(3); // this keeps the CPU load low
+ Sleep = false;
+ }
cPoller Poller;
if (DevicePoll(Poller, 100)) {
@@ -380,8 +387,8 @@
// Read the next frame from the file:
- if (!readFrame && (replayFile >= 0 || readIndex >= 0)) {
- if (playMode != pmStill) {
+ if (playMode != pmStill && playMode != pmPause) {
+ if (!readFrame && (replayFile >= 0 || readIndex >= 0)) {
if (!nonBlockingFileReader->Reading()) {
if (playMode == pmFast || (playMode == pmSlow && playDir == pdBackward)) {
uchar FileNumber;
@@ -438,16 +445,16 @@
break;
}
}
- else
- cCondWait::SleepMs(3); // this keeps the CPU load low
- }
- // Store the frame in the buffer:
+ // Store the frame in the buffer:
- if (readFrame) {
- if (ringBuffer->Put(readFrame))
- readFrame = NULL;
+ if (readFrame) {
+ if (ringBuffer->Put(readFrame))
+ readFrame = NULL;
+ }
}
+ else
+ Sleep = true;
// Get the next frame from the buffer: