openshot-audio  0.1.6
juce_BufferingAudioFormatReader.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_BUFFERINGAUDIOFORMATREADER_H_INCLUDED
26 #define JUCE_BUFFERINGAUDIOFORMATREADER_H_INCLUDED
27 
28 //==============================================================================
36  private TimeSliceClient
37 {
38 public:
50  TimeSliceThread& timeSliceThread,
51  int samplesToBuffer);
52 
54 
60  void setReadTimeout (int timeoutMilliseconds) noexcept;
61 
62  bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer,
63  int64 startSampleInFile, int numSamples) override;
64 
65 private:
67  TimeSliceThread& thread;
68  int64 nextReadPosition;
69  const int numBlocks;
70  int timeoutMs;
71 
72  enum { samplesPerBlock = 32768 };
73 
74  struct BufferedBlock
75  {
76  BufferedBlock (AudioFormatReader& reader, int64 pos, int numSamples);
77 
78  Range<int64> range;
79  AudioSampleBuffer buffer;
80  };
81 
82  CriticalSection lock;
84 
85  BufferedBlock* getBlockContaining (int64 pos) const noexcept;
86  int useTimeSlice() override;
87  bool readNextBufferChunk();
88 
90 };
91 
92 
93 #endif // JUCE_BUFFERINGAUDIOFORMATREADER_H_INCLUDED
Definition: juce_AudioSampleBuffer.h:34
Definition: juce_TimeSliceThread.h:47
#define noexcept
Definition: juce_CompilerSupport.h:141
#define JUCE_API
Definition: juce_StandardHeader.h:139
Definition: juce_CriticalSection.h:47
Definition: juce_AudioFormatReader.h:38
long long int64
Definition: juce_MathsFunctions.h:60
Definition: juce_OwnedArray.h:55
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_TimeSliceThread.h:84
Definition: juce_BufferingAudioFormatReader.h:35
virtual bool readSamples(int **destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples)=0