sfxStream.h

Engine/source/sfx/sfxStream.h

More...

Classes:

class

The base sound data streaming interface.

Public Typedefs

SFXStreamRef 

Detailed Description

Public Typedefs

typedef ThreadSafeRef< SFXStream > SFXStreamRef 
 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2012 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#ifndef _SFXSTREAM_H_
25#define _SFXSTREAM_H_
26
27#ifndef _THREADSAFEREFCOUNT_H_
28#  include "platform/threads/threadSafeRefCount.h"
29#endif
30#ifndef _SFXCOMMON_H_
31#  include "sfx/sfxCommon.h"
32#endif
33#ifndef _TSTREAM_H_
34#  include "core/stream/tStream.h"
35#endif
36
37
38/// The base sound data streaming interface.
39///
40/// @note Streams that support seeking should implement the IPositionable<U32> interface.
41/// @note Since SFXStreams are byte streams, all offset/size information is in bytes and
42///   not in number of samples.
43class SFXStream : public ThreadSafeRefCount< SFXStream >,
44                  public IInputStream< U8 >,
45                  public IResettable
46{
47   public:
48
49      typedef void Parent;
50
51      /// Destructor.
52      virtual ~SFXStream() {}
53
54      /// Make a copy of this stream with its own private state, so
55      /// new independent read() operations can be issued on the same
56      /// data stream.
57      ///
58      /// @return Returns a copy of the stream or NULL.
59      virtual SFXStream* clone() const { return NULL; }
60
61      /// The format of the data in the stream.
62      virtual const SFXFormat& getFormat() const = 0;
63
64      /// The number of samples in the data stream.
65      virtual U32 getSampleCount() const = 0;
66
67      /// The data size in bytes of the decompressed PCM data.
68      virtual U32 getDataLength() const = 0;
69
70      /// The length of the sound in milliseconds.
71      virtual U32 getDuration() const = 0;
72
73      /// Returns true if we've reached the end of the stream.
74      virtual bool isEOS() const = 0;
75
76      /// Resets the stream to restart reading data from the begining.
77      virtual void reset() = 0;
78
79      /// Reads data from the stream and decompresses it into PCM samples.
80      ///
81      /// @param length Number of bytes to read.
82      virtual U32 read( U8 *buffer, U32 length ) = 0;
83};
84
85typedef ThreadSafeRef< SFXStream> SFXStreamRef;
86
87#endif // _SFXSTREAM_H_
88