Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load audio asychronously (fix #4880) #2928

Closed
wants to merge 9 commits into from
Closed

Commits on Jan 27, 2021

  1. Configuration menu
    Copy the full SHA
    ac69ecc View commit details
    Browse the repository at this point in the history
  2. Remove DEFAULT_DECODER macros

    elsid committed Jan 27, 2021
    Configuration menu
    Copy the full SHA
    66cbcd1 View commit details
    Browse the repository at this point in the history
  3. Remove DEFAULT_OUTPUT macros

    elsid committed Jan 27, 2021
    Configuration menu
    Copy the full SHA
    0e1618e View commit details
    Browse the repository at this point in the history
  4. Move Sound_Decoder::mResourceMgr into FFmpeg_Decoder

    It's used only there.
    elsid committed Jan 27, 2021
    Configuration menu
    Copy the full SHA
    5136610 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    b533582 View commit details
    Browse the repository at this point in the history
  6. Split volume into volume factor and SFX volume

    Volume factor is passed as an argument when engine logic requires to play
    sound. SFX volume is loaded from ESM file. These values are not available
    at the same time and can change independently. With asynchronous sound loading
    SFX volume becomes available when access to the volume factor argument is lost
    therefore need to keep it as a separate field.
    elsid committed Jan 27, 2021
    Configuration menu
    Copy the full SHA
    a5b6eb5 View commit details
    Browse the repository at this point in the history
  7. Create audio decoders asychronously

    To avoid initial file read from disk in the main thread. Use deadline to avoid
    noticable delay in actors speech start. This changed affects only voices and
    music. Sounds are not affected by this change.
    
    Decoder initialization requires to open file to read headers that leads to
    read from disk. This operation is performed by a separated thread via
    SceneUtil::WorkQueue. Created and initialized decoders are stored into
    a map file name -> decoder. Other data required to play voice stored into
    SoundManager state and used each update from the main thread to try to start
    playing voices and music when corresponding decoder is available. If it's
    not available play is delayed until next frame. When deadline to create
    decoder is reached main thread stops and waits until that decoder is created.
    elsid committed Jan 27, 2021
    Configuration menu
    Copy the full SHA
    9a6dc79 View commit details
    Browse the repository at this point in the history
  8. Load sounds asynchronously

    To avoid initial file read from disk in the main thread. Use deadline to avoid
    noticable delay in actors speech start. This changed affects only sounds.
    
    Sounds are played more often than voices and music. There is a pool of created
    and initialized sound buffers that allows to play it from memory. When sound
    buffer initially requested openwm has to created decoder, read headers and
    potentially read all data. Initial request for sound buffer is performed in
    a separate thread via SceneUtil::WorkQueue. Created buffers are stored into
    a pool. If required sound buffer is present in the pool separate thread is
    not used. Other data required to play sound is stored SoundManager state and
    used each update from the main thread to try to start playing sounds when
    corresponding sound buffer is available. If it's not available play is delayed
    until the next frame. When deadline to load sound is reached main thread stops
    and waits until sound is loaded and added into the pool.
    elsid committed Jan 27, 2021
    Configuration menu
    Copy the full SHA
    491d9d6 View commit details
    Browse the repository at this point in the history
  9. Add bug #4880 to changelog

    elsid committed Jan 27, 2021
    Configuration menu
    Copy the full SHA
    d9e34fc View commit details
    Browse the repository at this point in the history