Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: TThread vs CPU usage?

  1. #11

    TThread vs CPU usage?

    Yea, I was trying to say he was right to use a double buffer. Something happen (error message of some sort) and I then was not able to edit the post.... arrrg. I am doing polling too. I think you can enable a callback in DirectSound, but I've not yet had a chance to look into it. The polling has been working fine me. The Sleep seems to work good. The value that I came up with works well based on the buffer size. Smaller then this for the buffer size that I use then sound starts to overlap, larger then too much latency.
    Jarrod Davis
    Technical Director @ Piradyne Games

  2. #12

    TThread vs CPU usage?

    Actually, if you use OpenAL, there IS a way to check for buffer's state. Here is very good lesson how to do streaming in C++:

    http://www.devmaster.net/articles/op...ls/lesson8.php

    Pay special attention to function ogg_stream::update()
    blog: http://alexionne.blogspot.com/

  3. #13

    TThread vs CPU usage?

    sleep is good, don't worry
    From brazil (:

    Pascal pownz!

  4. #14

    TThread vs CPU usage?

    Sleep(Time > 0) may cause the thread to sleep for to long due to the window times of the scheduler (16ms on win if i'm not misstaken), a way that quake used that works really well even for unthreaded applications is:

    [pascal]
    UpdateTime:= GetCurrentTime;
    repeat
    Sleep(0);

    CurentTime:= GetCurrentTime;
    until CurentTime- UpdateTime >= UpdateTime;
    [/pascal][/pascal]
    Amnoxx

    Oh, and this code appears to be an approximate replacement for return(random() & 0x01);

    Phoenix Wiki
    http://www.phoenixlib.net/

    Phoenix Forum
    http://www.pascalgamedevelopment.com/viewforum.php?f=71

  5. #15

    TThread vs CPU usage?

    Quote Originally Posted by Andreaz
    Sleep(Time > 0) may cause the thread to sleep for to long due to the window times of the scheduler (16ms on win if i'm not misstaken), a way that quake used that works really well even for unthreaded applications is:

    [pascal]
    UpdateTime:= GetCurrentTime;
    repeat
    Sleep(0);

    CurentTime:= GetCurrentTime;
    until CurentTime- UpdateTime >= UpdateTime;
    [/pascal][/pascal]
    it's precise but eats the cpu instead
    From brazil (:

    Pascal pownz!

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •