Commit Graph

530 Commits (8c7e06293fbe6d0ed1dd7dd0f424b9f1b6f92162)

Author SHA1 Message Date
Bret Curtis 07f75e1104 replace boost::shared_ptr in extern and components 8 years ago
Ewan Higgs 38a2de3c51 convert std::autor_ptr to std::unique_ptr, originally by Ewan Higgs and updated by Bret Curtis 8 years ago
MiroslavR d24bcbac15 Do not apply underwater effects to player's voice (Fixes #3850) 8 years ago
scrawl 5a939418fc Add missing avcodec_close (Fixes #3741) 8 years ago
Jules Blok e9d8ff532f OpenAL_Output: When a source is finished, rewind it instead of stopping it.
This works around a bug in the MacOS OpenAL implementation.
8 years ago
MiroslavR c34d85ffc2 Implement water sounds (Closes #451) 8 years ago
scrawl 530fb61ad0 Use OpenThreads instead of boost thread
This should allow OpenMW to work better with git versions of openscenegraph. OSG dev version 3.5.5 added the setting of thread affinity for the main thread. The problem is that in the boost/standard threading libraries, the affinity of a thread is inherited by any further threads launched from that thread, leading to these threads always running on the same core as the main thread unless you tell them not to.

With OpenThreads, the default affinity of a thread is none, no matter what parent thread it was launched from.

So, when using custom threading with OSG 3.6+, we have these options:
1. explicitely tell OSG to *not* set the thread affinity
or 2. explicitely set the thread affinity of additional threads created (possible with boost, but not possible with std::thread)
or 3. use OpenThreads
or 4. accept the suboptimal performance of non-OSG threads (in OpenMW's case the sound streaming & video threads) running on the same core as the main thread

This patch opts for 3.)

Reference: http://forum.openscenegraph.org/viewtopic.php?t=16158
8 years ago
scrawl 509e5dfe4d Include cleanup 9 years ago
scrawl 4699a8098b Include fix 9 years ago
scrawl 1739351b7a Remove now unused Sound_Decoder::rewind() 9 years ago
scrawl dc1b010cf0 Don't analyze the loudness for sounds that don't need it 9 years ago
scrawl 965aaebbdb Analyze the loudness data as the stream is decoded for playback
Instead of getting the loudness data for the whole file in advance, we now get it piece by piece as the sound is streamed.

The benefit is that we need to decode the audio just once instead of twice.

We no longer need to rewind() the stream when the first decoding is done, this should hopefully fix bug #3453 .
9 years ago
scrawl dfc2f3469a Don't play music if no playlist is set 9 years ago
scrawl 90a99991d1 Use empty() instead of !size() 9 years ago
scrawl 604b5d24e9 Use a ConstPtr in SoundManager 9 years ago
scrawl 4553db7b43 Merge pull request #861 from scrawl/soundcrash
Fix crash when running out of sound sources
9 years ago
scrawl 6a749e77f2 Fix crash when running out of sound sources 9 years ago
Chris Robinson cddea4a99c Start underwater sound after updating sounds
In between the startUpdate/finishUpdate calls, changes are deferred so that
they can happen all at once. This includes starting sounds, so when the
underwater sound is started it will be immediately checked to see if it's
playing. Since it's not yet playing, it'll be seen as stopped and get cleaned
up before ever playing.
9 years ago
Chris Robinson f47f0a996f Stop the object's old say sound before playing the new one 9 years ago
Chris Robinson 7fc2df153a Rename stopSound/stopStream to finishSound/finishStream
Since they're also used to clean up output resources, not just stopping.
9 years ago
Chris Robinson 808f701013 Use the actor's Head position for Say streams 9 years ago
Chris Robinson a00a4bce77 Avoid some unnecessary indirection 9 years ago
scrawl 1264651af7 Fix coverity defects 9 years ago
scrawl e69750905a Fix gcc warning about function casts 9 years ago
Chris Robinson c75303b652 Add an option to select and enable HRTF 9 years ago
scrawl 53158d29b1 stopSound crash fix 9 years ago
Marc Zinnschlag e0c9265148 Merge remote-tracking branch 'origin/master' 9 years ago
scrawl 86881bcf39 In first person mode, attach sound listener to the camera 9 years ago
Chris Robinson f19f1c47c8 Fix playing pending voices without a Ptr 9 years ago
Chris Robinson 2face3d0a9 Combine duplicate code 9 years ago
Chris Robinson 1407366e51 Use a premade SoundStream object for the output's streamSound functions 9 years ago
Chris Robinson 2ee3265b66 Use a premade Sound object for the output's playSound functions 9 years ago
Chris Robinson 53718a5ca0 Use a typedef for the sound instance handle 9 years ago
Chris Robinson 3a39a92b93 Keep track of audio tracks 9 years ago
Chris Robinson 2883cdba5c Initialize the Sound object before modifying the pitch variable 9 years ago
Chris Robinson a6db96b2d8 Update sound and stream parameters 9 years ago
Chris Robinson 4bd235284b Rename a couple members to avoid confusion 9 years ago
Chris Robinson 1ce3e7f5b9 Use a separate type for streams
They're basically the same, but it's to help avoid accidents with passing non-
streaming sounds to the stream functions, or vice-versa.
9 years ago
Chris Robinson 816015d6e6 Avoid inheriting from Sound for sound types 9 years ago
Alexander "Ace" Olofsson 24340bff95 Add a space 9 years ago
Alexander "Ace" Olofsson 6823298516 Different way to solve the type deduction issue 9 years ago
Alexander "Ace" Olofsson a69e751089 Revert "Fix windows builds"
This reverts commit b085c09f86.
9 years ago
Alexander "Ace" Olofsson b085c09f86 Fix windows builds
Can't instantiate a container (at least with MSVC) without knowing the exact size of the object being stored, forward-declares only work with pointers.
I couldn't see a simple way to remove the forward declare, so pointers and memory management it is.
9 years ago
Chris Robinson 4ee409af84 Load loudness data asynchronously
Currently abuses the output audio streams' background processing thread to do
the work, since there's no generalized threaded processing mechanism.
9 years ago
Chris Robinson 0f05ccf72a Use a non-recursive mutex and properly end the streaming thrread 9 years ago
Chris Robinson b5ed2e65f8 Add a method to get the sound stream delay
This helps avoid a lock during the movie player's read method, since it needs
to sync with the current playback position which would otherwise need to get
the movie decoder's current position.
9 years ago
Chris Robinson f3c035907c Rename Sound::update to Sound::applyUpdates 9 years ago
Chris Robinson 9568aa6a84 Use a condition variable to wake up the audio stream thread
This should make starting streams a bit more responsive, and allows us to do
more in it that really shouldn't wait for its next wake up.
9 years ago
Chris Robinson 4a078725d4 Play player voices locally 9 years ago
Chris Robinson 449eca4fb4 Properly mark streams as 2D or 3D 9 years ago
Chris Robinson 21bb2e9314 Use a deque for loudness buffers with a map lookup
Similar to Sound_Buffer, this allows individual Sound_Loudness objects to
retain a constant pointer when new ones are inserted on to the end.
9 years ago
Chris Robinson 5f8a09df97 Play player sounds (except footsteps) local to the listener 9 years ago
Chris Robinson 82f3651f81 Treat the sound offset as the offset in seconds 9 years ago
Chris Robinson 8b7587f9a6 Track whether a sound is 3D 9 years ago
Chris Robinson fc912b135f Avoid unnecessarily friending classes 9 years ago
Chris Robinson d4238a6d91 Add config options for the sound buffer cache size
The cache size is specified with a min/max range, intended to avoid constant
unloading once the limit is reached. This way, buffers can be unloaded down to
a reasonable mimimum, allowing some more buffers to be subsequently loaded
without causing more unloading.
9 years ago
Chris Robinson 8715add72f Store sound buffers in a deque that's filled in as needed
A deque allows existing Sound_Buffer references to remain valid as long as new
ones are back-inserted. These references can be used instead of indices.
9 years ago
Chris Robinson 8f08ca9cba Revert "Avoid unsafe sizeof(x)/sizeof(x[0]) constructs for array counting"
This reverts commit 0d4fea896c.
9 years ago
Chris Robinson 04f885d8cc Rename mReferences to mUses 9 years ago
Chris Robinson 0d4fea896c Avoid unsafe sizeof(x)/sizeof(x[0]) constructs for array counting 9 years ago
Chris Robinson a1bdb544db Avoid an unnecessary string copy 9 years ago
Chris Robinson aac903484c Remove a really unnecessary method 9 years ago
Chris Robinson 73448c72f6 Replace Play_NoTrack with playManualSound3D, and rename the latter 9 years ago
Chris Robinson caae305ddd Use a sorted list for unused buffers
Helps ensure the buffers being unloaded due to cache limits are not likely to
be needed anytime soon.
9 years ago
Chris Robinson 669b7a2295 Batch update changes together, when possible
Certain OpenAL implementations, including Rapture3D, Creative's hardware
drivers, and more recent versions of OpenAL Soft, can batch together changes so
that they all occur at once, avoiding potential discontinuities with one sound
being changed before another, or the listeenr being changed before sounds are.

On other implementaitons, this is a no-op and maintains existing behavior.
9 years ago
Chris Robinson ea70b0baee Don't store the buffer in the sound struct 9 years ago
Chris Robinson fd7d58fe7e Reset the sound handle back to null after unloading 9 years ago
Chris Robinson 4801661b34 Stop all sounds of the given id 9 years ago
Chris Robinson 8a69f676ec Remove some duplicate code 9 years ago
Chris Robinson 45628316f8 Remove an unnecessary check 9 years ago
Chris Robinson 574c1923fe Clear unused buffers after unloading them all 9 years ago
Chris Robinson 5ad772c3b3 Fix streaming sound time 9 years ago
Chris Robinson 3ce6aee98b Return a decoder from the loadVoice function 9 years ago
Chris Robinson 24f8c78fca Store sound buffer references by index instead of string 9 years ago
Chris Robinson f7218f5a25 Use proper mutex mechanisms and don't check al errors in the stream thread 9 years ago
Chris Robinson f9e18cd966 Prepare all Sound_Buffer objects when one is needed
This simply sets up the Sound record data to be used by the sound output. The
actual audio buffers, stored in the Sound_Handle, are still loaded on-demand.
9 years ago
Chris Robinson 6c3953766e Use separate lists for the sound name and its buffer
This should make sound lookup a bit more efficient, especially when an integer
ID can be used.
9 years ago
Chris Robinson fbfcc4050f Stream voice clips
Voices tend to be a bit long, and not individually replayed often. So it's
better to stream them instead of loading theminto a sound buffer. The loudness
data is very small, though, so that can be kept buffered indefinitely.
9 years ago
Chris Robinson eee6a19e31 Add a method to stream sounds in 3D 9 years ago
Chris Robinson f1a1dc8408 Pass relevant sound parameters to the OpenAL_SoundStream constructor 9 years ago
Chris Robinson 83721092f2 Refactor the audio streaming code to be a bit saner 9 years ago
Chris Robinson 16f72886e9 Use separate lists for openal sounds and streams 9 years ago
Chris Robinson 0f33f41d8d Actually unload sounds when running over 9 years ago
Chris Robinson 22a6811425 Limit the sound buffer cache to 15MB 9 years ago
Chris Robinson 0b2747098c Keep track of unused sound buffers 9 years ago
Chris Robinson 4073495070 Add some missing sound handling 9 years ago
Chris Robinson e362896817 Combine some duplicate code 9 years ago
Chris Robinson febc7b510a Remove an unneeded method 9 years ago
Chris Robinson 3fdc3c4ea9 Use a separate map for say sounds
Also restores lip movement
9 years ago
Chris Robinson 9d0018e1bc Reorder active sound data to make lookup by Ptr better 9 years ago
Chris Robinson 495e138907 Load sound loudness and store it with the Sound_Buffer
Still not used for say yet, though
9 years ago
Chris Robinson f4c22ec49e Hold a separate list for voice sound buffers
This fixes say. Ideally voices would be streamed, but the loudness/"lip" buffer
extraction should be separated from the buffer loading code.
9 years ago
Chris Robinson 4571218827 Load the sound as needed and pass it directly to the play methods
This breaks say sounds, loudness handling, and the cache limit. Fixes are
forthcoming.
9 years ago
Chris Robinson e2beefd8b5 Store info calculated from the ESM::Sound record 9 years ago
scrawl f08cfa19ea Fix SoundManager::isPlaying to consider multiple entries with the same Ptr/id
Now it returns true if *any* sounds matching the given Ptr and id are playing. The previous behaviour was causing problems with "zombie" sounds (sounds that have finished playing, but weren't removed from the map yet) making the isPlaying method return false even though there's another legitimately playing sound in the map.
9 years ago
Bret Curtis 3ea3d07d44 really purge libav 9 years ago
dteviot 77a1d947cc extracted MWMechanics::getPlayer() 10 years ago
scrawl cd2e6d4436 Move the __STDC_CONSTANT_MACROS define to cmakelists 10 years ago
scrawl 4bb3cbf0fb Remove last remains of Ogre 10 years ago
scrawl 84fd682e4e Fix for unnecessary exceptions when opening sounds
This would throw often during normal play, even though the throws are caught and ignored, can be annoying when the debugger is set to 'catch throw'.
10 years ago