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

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

Issue 389623002: Add a block based Audio FIFO. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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 // This class is thread-unsafe. 17 // This class is thread-unsafe.
18 class MEDIA_EXPORT AudioFifo { 18 class MEDIA_EXPORT AudioFifo {
19 public: 19 public:
20 // Creates a new AudioFifo and allocates |channels| of length |frames|. 20 // Creates a new AudioFifo and allocates |channels| of length |frames|.
21 AudioFifo(int channels, int frames); 21 AudioFifo(int channels, int frames);
22 virtual ~AudioFifo(); 22 virtual ~AudioFifo();
23 23
24 static void GetSizes(int pos, int max_size, int in_size, int* size,
25 int* wrap_size);
26 static int UpdatePos(int pos, int step, int max_size);
27
24 // Pushes all audio channel data from |source| to the FIFO. 28 // Pushes all audio channel data from |source| to the FIFO.
25 // Push() will crash if the allocated space is insufficient. 29 // Push() will crash if the allocated space is insufficient.
26 void Push(const AudioBus* source); 30 void Push(const AudioBus* source);
27 31
28 // Consumes |frames_to_consume| audio frames from the FIFO and copies 32 // Consumes |frames_to_consume| audio frames from the FIFO and copies
29 // them to |destination| starting at position |start_frame|. 33 // them to |destination| starting at position |start_frame|.
30 // Consume() will crash if the FIFO does not contain |frames_to_consume| 34 // Consume() will crash if the FIFO does not contain |frames_to_consume|
31 // frames or if there is insufficient space in |destination| to store the 35 // frames or if there is insufficient space in |destination| to store the
32 // frames. 36 // frames.
33 void Consume(AudioBus* destination, int start_frame, int frames_to_consume); 37 void Consume(AudioBus* destination, int start_frame, int frames_to_consume);
(...skipping 23 matching lines...) Expand all
57 61
58 // Current write position. 62 // Current write position.
59 int write_pos_; 63 int write_pos_;
60 64
61 DISALLOW_COPY_AND_ASSIGN(AudioFifo); 65 DISALLOW_COPY_AND_ASSIGN(AudioFifo);
62 }; 66 };
63 67
64 } // namespace media 68 } // namespace media
65 69
66 #endif // MEDIA_BASE_AUDIO_FIFO_H_ 70 #endif // MEDIA_BASE_AUDIO_FIFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698