Fix "no remove aqua speed" bug when player leaves the water
[ryzomcore.git] / nel / src / sound / driver / dsound / buffer_dsound.h
blobfed09c413e1244ce047e405911c93e602c3acfb2
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef NL_BUFFER_DSOUND_H
18 #define NL_BUFFER_DSOUND_H
20 #include "nel/sound/driver/buffer.h"
22 namespace NLSOUND {
24 /**
25 * Buffer for the DSound implementation of the audio driver.
27 * A buffer represents a sound file loaded in RAM.
29 * \author Peter Hanappe, Olivier Cado
30 * \author Nevrax France
31 * \date 2002
33 class CBufferDSound : public IBuffer
35 public:
36 /// Constructor
37 CBufferDSound();
39 /// Destructor
40 virtual ~CBufferDSound();
42 /// Return a pointer to the sample data
43 inline const uint8 *getData() const { return _Data; }
45 /** Preset the name of the buffer. Used for async loading to give a name
46 * before the buffer is effectivly loaded.
47 * If the name after loading of the buffer doesn't match the preset name,
48 * the load will assert.
50 virtual void setName(NLMISC::TStringId bufferName);
51 /// Return the name of this buffer
52 virtual NLMISC::TStringId getName() const;
54 /// Set the sample format. (channels = 1, 2, ...; bitsPerSample = 8, 16; frequency = samples per second, 44100, ...)
55 virtual void setFormat(TBufferFormat format, uint8 channels, uint8 bitsPerSample, uint32 frequency);
56 /// Return the sample format information.
57 virtual void getFormat(TBufferFormat &format, uint8 &channels, uint8 &bitsPerSample, uint32 &frequency) const;
58 /// Set the storage mode of this buffer, call before filling this buffer. Storage mode is always software if OptionSoftwareBuffer is enabled. Default is auto.
59 virtual void setStorageMode(TStorageMode storageMode = IBuffer::StorageAuto);
60 /// Get the storage mode of this buffer.
61 virtual TStorageMode getStorageMode();
63 /// Get a writable pointer to the buffer of specified size. Use capacity to specify the required bytes. Returns NULL in case of failure. It is only guaranteed that the original data is still available when using StorageSoftware and the specified size is not larger than the size specified in the last lock. Call setStorageMode() and setFormat() first.
64 virtual uint8 *lock(uint capacity);
65 /// Notify that you are done writing to this buffer, so it can be copied over to hardware if needed. Set size to the number of bytes actually written to the buffer. Returns true if ok.
66 virtual bool unlock(uint size);
67 /// Copy the data with specified size into the buffer. A readable local copy is only guaranteed when OptionLocalBufferCopy is set. Returns true if ok.
68 virtual bool fill(const uint8 *src, uint size);
70 /// Return the size of the buffer, in bytes.
71 virtual uint getSize() const;
72 /// Return the duration (in ms) of the sample in the buffer.
73 virtual float getDuration() const;
74 /// Return true if the buffer is stereo (multi-channel), false if mono.
75 virtual bool isStereo() const;
76 /// Return true if the buffer is loaded. Used for async load/unload.
77 virtual bool isBufferLoaded() const;
79 private:
80 NLMISC::TStringId _Name;
81 /// The sample data in this buffer.
82 uint8 *_Data;
83 /// The capacity of the buffer
84 uint _Capacity;
85 /// The size of the data in the buffer
86 uint _Size;
87 TSampleFormat _Format;
88 uint _Freq;
90 #if USE_LOCDEFER
91 LPDIRECTSOUNDBUFFER _SecondaryBuffer;
92 LPDIRECTSOUND3DBUFFER _3DBuffer;
93 #endif
98 } // NLSOUND
101 #endif // NL_BUFFER_DSOUND_H