OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 26 matching lines...) Expand all Loading... |
37 : m_provider(audioProvider), | 37 : m_provider(audioProvider), |
38 m_fifo(numberOfChannels, fifoLength), | 38 m_fifo(numberOfChannels, fifoLength), |
39 m_providerSize(providerSize), | 39 m_providerSize(providerSize), |
40 m_tempBus(AudioBus::create(numberOfChannels, providerSize)) {} | 40 m_tempBus(AudioBus::create(numberOfChannels, providerSize)) {} |
41 | 41 |
42 void AudioPullFIFO::consume(AudioBus* destination, size_t framesToConsume) { | 42 void AudioPullFIFO::consume(AudioBus* destination, size_t framesToConsume) { |
43 if (!destination) | 43 if (!destination) |
44 return; | 44 return; |
45 | 45 |
46 if (framesToConsume > m_fifo.framesInFifo()) { | 46 if (framesToConsume > m_fifo.framesInFifo()) { |
47 // We don't have enough data in the FIFO to fulfill the request. Ask for mor
e data. | 47 // We don't have enough data in the FIFO to fulfill the request. Ask for |
| 48 // more data. |
48 fillBuffer(framesToConsume - m_fifo.framesInFifo()); | 49 fillBuffer(framesToConsume - m_fifo.framesInFifo()); |
49 } | 50 } |
50 | 51 |
51 m_fifo.consume(destination, framesToConsume); | 52 m_fifo.consume(destination, framesToConsume); |
52 } | 53 } |
53 | 54 |
54 void AudioPullFIFO::fillBuffer(size_t numberOfFrames) { | 55 void AudioPullFIFO::fillBuffer(size_t numberOfFrames) { |
55 // Keep asking the provider to give us data until we have received at least |n
umberOfFrames| of | 56 // Keep asking the provider to give us data until we have received at least |
56 // data. Stuff the data into the FIFO. | 57 // |numberOfFrames| of data. Stuff the data into the FIFO. |
57 size_t framesProvided = 0; | 58 size_t framesProvided = 0; |
58 | 59 |
59 while (framesProvided < numberOfFrames) { | 60 while (framesProvided < numberOfFrames) { |
60 m_provider.provideInput(m_tempBus.get(), m_providerSize); | 61 m_provider.provideInput(m_tempBus.get(), m_providerSize); |
61 | 62 |
62 m_fifo.push(m_tempBus.get()); | 63 m_fifo.push(m_tempBus.get()); |
63 | 64 |
64 framesProvided += m_providerSize; | 65 framesProvided += m_providerSize; |
65 } | 66 } |
66 } | 67 } |
67 | 68 |
68 } // namespace blink | 69 } // namespace blink |
OLD | NEW |