Apprendre
Télécharger
Communauté
Développement
Accueil
»
Apprendre
»
Documentation 2.0
»
SoundStream.hpp Source File
English
Faire un don
Documentation de SFML 2.0
Attention:
cette page se réfère à une ancienne version de SFML. Cliquez ici pour passer à la dernière version.
Main Page
Modules
Classes
Files
File List
sfml
sfml
include
SFML
Audio
SoundStream.hpp
1
2
//
3
// SFML - Simple and Fast Multimedia Library
4
// Copyright (C) 2007-2013 Laurent Gomila (laurent.gom@gmail.com)
5
//
6
// This software is provided 'as-is', without any express or implied warranty.
7
// In no event will the authors be held liable for any damages arising from the use of this software.
8
//
9
// Permission is granted to anyone to use this software for any purpose,
10
// including commercial applications, and to alter it and redistribute it freely,
11
// subject to the following restrictions:
12
//
13
// 1. The origin of this software must not be misrepresented;
14
// you must not claim that you wrote the original software.
15
// If you use this software in a product, an acknowledgment
16
// in the product documentation would be appreciated but is not required.
17
//
18
// 2. Altered source versions must be plainly marked as such,
19
// and must not be misrepresented as being the original software.
20
//
21
// 3. This notice may not be removed or altered from any source distribution.
22
//
24
25
#ifndef SFML_SOUNDSTREAM_HPP
26
#define SFML_SOUNDSTREAM_HPP
27
29
// Headers
31
#include <SFML/Audio/Export.hpp>
32
#include <SFML/Audio/SoundSource.hpp>
33
#include <SFML/System/Thread.hpp>
34
#include <SFML/System/Time.hpp>
35
#include <cstdlib>
36
37
38
namespace
sf
39
{
44
class
SFML_AUDIO_API
SoundStream
:
public
SoundSource
45
{
46
public
:
47
52
struct
Chunk
53
{
54
const
Int16*
samples
;
55
std::size_t
sampleCount
;
56
};
57
62
virtual
~
SoundStream
();
63
76
void
play();
77
87
void
pause();
88
99
void
stop();
100
109
unsigned
int
getChannelCount()
const
;
110
120
unsigned
int
getSampleRate()
const
;
121
128
Status
getStatus()
const
;
129
141
void
setPlayingOffset(
Time
timeOffset);
142
151
Time
getPlayingOffset()
const
;
152
166
void
setLoop(
bool
loop);
167
176
bool
getLoop()
const
;
177
178
protected
:
179
186
SoundStream
();
187
202
void
initialize(
unsigned
int
channelCount,
unsigned
int
sampleRate);
203
218
virtual
bool
onGetData(
Chunk
& data) = 0;
219
229
virtual
void
onSeek(
Time
timeOffset) = 0;
230
231
private
:
232
240
void
streamData();
241
255
bool
fillAndPushBuffer(
unsigned
int
bufferNum);
256
266
bool
fillQueue();
267
274
void
clearQueue();
275
276
enum
277
{
278
BufferCount = 3
279
};
280
282
// Member data
284
Thread
m_thread;
285
bool
m_isStreaming;
286
unsigned
int
m_buffers[BufferCount];
287
unsigned
int
m_channelCount;
288
unsigned
int
m_sampleRate;
289
Uint32 m_format;
290
bool
m_loop;
291
Uint64 m_samplesProcessed;
292
bool
m_endBuffers[BufferCount];
293
};
294
295
}
// namespace sf
296
297
298
#endif // SFML_SOUNDSTREAM_HPP
299
300