ScummVM API documentation
audio.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef PSP_AUDIO_H
23 #define PSP_AUDIO_H
24 
25 #include "backends/platform/psp/thread.h"
26 
27 class PspAudio : public PspThreadable {
28 public:
29  enum {
30  NUM_BUFFERS = 2,
31  FREQUENCY = 44100 /* only frequency we allow */
32  };
33  typedef void (* callbackFunc)(void *userData, byte *samples, int len); // audio callback to call
34  PspAudio() : _pspChannel(0),
35  _numOfChannels(0), _numOfSamples(0), _callback(0),
36  _bufferToPlay(0), _bufferToFill(0),
37  _init(false), _paused(true) {
38  for (int i=0; i<NUM_BUFFERS; i++)
39  _buffers[i] = 0;
40  }
41  ~PspAudio() { close(); }
42  bool playBuffer();
43  void nextBuffer(int &bufferIdx);
44  bool open(uint32 freq, uint32 numOfChannels, uint32 numOfSamples, callbackFunc callback, void *userData);
45  void close();
46  uint32 getFrequency() { return FREQUENCY; }
47  void pause() { _paused = true; }
48  void unpause() { _paused = false; }
49  virtual void threadFunction(); // actual audio thread
50 
51 private:
52  int _pspChannel; // chosen hardware output channel
53  uint32 _numOfChannels; // 1 for mono; 2 for stereo
54  uint32 _numOfSamples;
55  callbackFunc _callback; // the callback to call between outputting audio
56  void *_userData; // userData to send with callback
57  byte *_buffers[NUM_BUFFERS];
58  int _bufferToPlay; // the next buffer to output
59  int _bufferToFill;
60  int _bufferSize;
61  bool _init; // flag for initialization
62  bool _paused;
63 };
64 
65 #endif /* PSP_AUDIO_H */
Definition: audio.h:27
Definition: thread.h:29