Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: media/base/audio_fifo.h

Issue 10918098: Introduce AudioOutputResampler for browser side resampling. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: First draft! Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_AUDIO_FIFO_H_ 5 #ifndef MEDIA_BASE_AUDIO_FIFO_H_
6 #define MEDIA_BASE_AUDIO_FIFO_H_ 6 #define MEDIA_BASE_AUDIO_FIFO_H_
7 7
8 #include "media/base/audio_bus.h" 8 #include "media/base/audio_bus.h"
9 #include "media/base/media_export.h" 9 #include "media/base/media_export.h"
10 10
11 namespace media { 11 namespace media {
12 12
13 // First-in first-out container for AudioBus elements. 13 // First-in first-out container for AudioBus elements.
14 // The maximum number of audio frames in the FIFO is set at construction and 14 // The maximum number of audio frames in the FIFO is set at construction and
15 // can not be extended dynamically. The allocated memory is utilized as a 15 // can not be extended dynamically. The allocated memory is utilized as a
16 // ring buffer. 16 // ring buffer.
17 class MEDIA_EXPORT AudioFifo { 17 class MEDIA_EXPORT AudioFifo {
18 public: 18 public:
19 // Creates a new AudioFifo and allocates |channels| of length |frames|. 19 // Creates a new AudioFifo and allocates |channels| of length |frames|.
20 AudioFifo(int channels, int frames); 20 AudioFifo(int channels, int frames);
21 virtual ~AudioFifo(); 21 virtual ~AudioFifo();
22 22
23 // Pushes all audio channel data from |source| to the FIFO. 23 // Pushes all audio channel data from |source| to the FIFO.
24 // Returns false if the allocated space is not sufficient. Partial data is 24 // Returns false if the allocated space is not sufficient. Partial data is
25 // not written to the FIFO for this overflow case. 25 // not written to the FIFO for this overflow case.
26 bool Push(const AudioBus* source); 26 bool Push(const AudioBus* source, int frames);
27 27
28 // Consumes |frames_to_consume| audio frames from the FIFO and copies 28 // Consumes |frames_to_consume| audio frames from the FIFO and copies
29 // them to |destination|. 29 // them to |destination|.
30 // Returns false if the FIFO does not contain |frames_to_consume| frames 30 // Returns false if the FIFO does not contain |frames_to_consume| frames
31 // or if there is not sufficient space in |destination| to store the frames. 31 // or if there is not sufficient space in |destination| to store the frames.
32 bool Consume(AudioBus* destination, int frames_to_consume); 32 bool Consume(AudioBus* destination, int start_frame, int frames_to_consume);
33 33
34 // Empties the FIFO without deallocating any memory. 34 // Empties the FIFO without deallocating any memory.
35 void Clear(); 35 void Clear();
36 36
37 // Number of actual audio bus frames in the FIFO. 37 // Number of actual audio bus frames in the FIFO.
38 int frames_in_fifo() const { return frames_in_fifo_; } 38 int frames_in_fifo() const { return frames_in_fifo_; }
39 39
40 private: 40 private:
41 int max_frames() const { return max_frames_in_fifo_; } 41 int max_frames() const { return max_frames_in_fifo_; }
42 42
(...skipping 12 matching lines...) Expand all
55 55
56 // Current write position. 56 // Current write position.
57 int write_pos_; 57 int write_pos_;
58 58
59 DISALLOW_COPY_AND_ASSIGN(AudioFifo); 59 DISALLOW_COPY_AND_ASSIGN(AudioFifo);
60 }; 60 };
61 61
62 } // namespace media 62 } // namespace media
63 63
64 #endif // MEDIA_BASE_AUDIO_FIFO_H_ 64 #endif // MEDIA_BASE_AUDIO_FIFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698