Class: FMOD::Sound::OpenState
- Inherits:
-
Object
- Object
- FMOD::Sound::OpenState
- Defined in:
- lib/fmod/sound.rb
Overview
Contains the state a sound is in after Core::Mode::NON_BLOCKING has been used to open it, or the state of the streaming buffer.
When a sound is opened with Core::Mode::NON_BLOCKING, it is opened and prepared in the background, or asynchronously. This allows the main application to execute without stalling on audio loads. This function will describe the state of the asynchronous load routine i.e. whether it has succeeded, failed or is still in progress.
If #starving? is true
, then you will most likely hear a stuttering/repeating sound as the decode buffer loops on itself and replays old data. You can detect buffer under-run and use something like ChannelControl#mute to keep it quiet until it is not starving any more.
Constant Summary collapse
- READY =
Opened and ready to play.
0
- LOADING =
Initial load in progress.
1
- ERROR =
Failed to open - file not found, out of memory etc.
2
- CONNECTING =
Connecting to remote host (internet sounds only).
3
- BUFFERING =
Buffering data.
4
- SEEKING =
Seeking to subsound and re-flushing stream buffer.
5
- PLAYING =
Ready and playing, but not possible to release at this time without stalling the main thread.
6
- SET_POSITION =
Seeking within a stream to a different position.
7
Instance Attribute Summary collapse
-
#buffered ⇒ Float
readonly
The percentage of the file buffer filled progress of a stream.
-
#state ⇒ Integer
readonly
The open state of a sound.
Instance Method Summary collapse
-
#busy? ⇒ Boolean
The disk busy state of a sound.
-
#initialize(state, buffered, busy, starving) ⇒ OpenState
constructor
private
A new instance of OpenState.
-
#starving? ⇒ Boolean
The starving state of a sound.
Constructor Details
#initialize(state, buffered, busy, starving) ⇒ OpenState
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of OpenState.
100 101 102 |
# File 'lib/fmod/sound.rb', line 100 def initialize(state, buffered, busy, starving) @state, @buffered, @busy, @starving = state, buffered, busy, starving end |
Instance Attribute Details
#buffered ⇒ Float (readonly)
Returns the percentage of the file buffer filled progress of a stream.
81 82 83 |
# File 'lib/fmod/sound.rb', line 81 def buffered @buffered end |
#state ⇒ Integer (readonly)
Returns the open state of a sound.
Will be one of the following:
76 77 78 |
# File 'lib/fmod/sound.rb', line 76 def state @state end |
Instance Method Details
#busy? ⇒ Boolean
The disk busy state of a sound.
87 88 89 |
# File 'lib/fmod/sound.rb', line 87 def busy? @busy != 0 end |
#starving? ⇒ Boolean
The starving state of a sound.
95 96 97 |
# File 'lib/fmod/sound.rb', line 95 def starving? @starving != 0 end |