OpenShot Library | libopenshot-audio
0.2.0
juce_BufferedInputStream.h
1
2
/** @weakgroup juce_core-streams
3
* @{
4
*/
5
/*
6
==============================================================================
7
8
This file is part of the JUCE library.
9
Copyright (c) 2017 - ROLI Ltd.
10
11
JUCE is an open source library subject to commercial or open-source
12
licensing.
13
14
The code included in this file is provided under the terms of the ISC license
15
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
16
To use, copy, modify, and/or distribute this software for any purpose with or
17
without fee is hereby granted provided that the above copyright notice and
18
this permission notice appear in all copies.
19
20
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22
DISCLAIMED.
23
24
==============================================================================
25
*/
26
27
namespace
juce
28
{
29
30
//==============================================================================
31
/** Wraps another input stream, and reads from it using an intermediate buffer
32
33
If you're using an input stream such as a file input stream, and making lots of
34
small read accesses to it, it's probably sensible to wrap it in one of these,
35
so that the source stream gets accessed in larger chunk sizes, meaning less
36
work for the underlying stream.
37
38
@tags{Core}
39
*/
40
class
JUCE_API
BufferedInputStream
:
public
InputStream
41
{
42
public
:
43
//==============================================================================
44
/** Creates a BufferedInputStream from an input source.
45
46
@param sourceStream the source stream to read from
47
@param bufferSize the size of reservoir to use to buffer the source
48
@param deleteSourceWhenDestroyed whether the sourceStream that is passed in should be
49
deleted by this object when it is itself deleted.
50
*/
51
BufferedInputStream
(
InputStream
* sourceStream,
52
int
bufferSize,
53
bool
deleteSourceWhenDestroyed
);
54
55
/** Creates a BufferedInputStream from an input source.
56
57
@param sourceStream the source stream to read from - the source stream must not
58
be deleted until this object has been destroyed.
59
@param bufferSize the size of reservoir to use to buffer the source
60
*/
61
BufferedInputStream
(
InputStream
& sourceStream,
int
bufferSize);
62
63
/** Destructor.
64
65
This may also delete the source stream, if that option was chosen when the
66
buffered stream was created.
67
*/
68
~BufferedInputStream
()
override
;
69
70
71
//==============================================================================
72
/** Returns the next byte that would be read by a call to readByte() */
73
char
peekByte();
74
75
int64 getTotalLength()
override
;
76
int64 getPosition()
override
;
77
bool
setPosition (int64
newPosition
)
override
;
78
int
read (
void
*
destBuffer
,
int
maxBytesToRead
)
override
;
79
String
readString()
override
;
80
bool
isExhausted()
override
;
81
82
83
private
:
84
//==============================================================================
85
OptionalScopedPointer<InputStream>
source;
86
int
bufferSize;
87
int64 position, lastReadPos = 0, bufferStart, bufferOverlap = 128;
88
HeapBlock<char>
buffer;
89
bool
ensureBuffered();
90
91
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (
BufferedInputStream
)
92
};
93
94
}
// namespace juce
95
96
/** @}*/
juce::Array
Holds a resizable array of primitive or copy-by-value objects.
Definition
juce_Array.h:60
juce::BufferedInputStream
Wraps another input stream, and reads from it using an intermediate buffer.
Definition
juce_BufferedInputStream.h:41
juce::InputStream
The base class for streams that read data.
Definition
juce_InputStream.h:41
juce::String
The JUCE String class!
Definition
juce_String.h:43
JUCE_API
#define JUCE_API
This macro is added to all JUCE public class declarations.
Definition
juce_StandardHeader.h:143
juce_core
streams
juce_BufferedInputStream.h
Generated on Fri Sep 20 2024 04:11:05 for OpenShot Library | libopenshot-audio by
1.9.8