4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_AUDIO_PCM_PLAYER_HPP
25 #define XCSOAR_AUDIO_PCM_PLAYER_HPP
28 #include "Thread/Mutex.hpp"
29 #include "SLES/Object.hpp"
30 #include "SLES/Play.hpp"
31 #include "SLES/AndroidSimpleBufferQueue.hpp"
41 * An audio player that plays synthesized 16 bit mono PCM data. It is
42 * being fed by a #PCMSynthesiser object that gets called when more
43 * PCM samples are needed.
48 PCMSynthesiser
*synthesiser
;
52 SLES::Object engine_object
;
54 SLES::Object mix_object
;
56 SLES::Object play_object
;
58 SLES::AndroidSimpleBufferQueue queue
;
61 * This mutex protects the attributes "next" and "filled". It is
62 * only needed while playback is launched, when the initial buffers
63 * are being enqueued in the caller thread, while another thread may
64 * invoke the registered callback.
69 * The index of the next buffer to be enqueued.
74 * Does the "next" buffer already contain synthesised samples? This
75 * can happen when PCMSynthesiser::Synthesise() has been called, but
76 * the OpenSL/ES buffer queue was full. The buffer will then be
82 * An array of buffers. It's one more than being managed by
83 * OpenSL/ES, and the one not enqueued (see attribute #next) will be
86 int16_t buffers
[3][4096];
99 * @param synthesiser a PCMSynthesiser instance that will be used to
100 * generate sound; the caller is responsible for releasing it (not
101 * before playback is stopped)
103 bool Start(PCMSynthesiser
&synthesiser
, unsigned sample_rate
);
106 * Stop playback and close the audio device. This method is
115 void Synthesise(void *buffer
, size_t n
);