openMSX
SDLSoundDriver.hh
Go to the documentation of this file.
1 #ifndef SDLSOUNDDRIVER_HH
2 #define SDLSOUNDDRIVER_HH
3 
4 #include "SoundDriver.hh"
5 #include "SDLSurfacePtr.hh"
6 #include "MemBuffer.hh"
7 #include <SDL.h>
8 
9 namespace openmsx {
10 
11 class Reactor;
12 
13 class SDLSoundDriver final : public SoundDriver
14 {
15 public:
16  SDLSoundDriver(const SDLSoundDriver&) = delete;
18 
19  SDLSoundDriver(Reactor& reactor, unsigned wantedFreq, unsigned samples);
20  ~SDLSoundDriver() override;
21 
22  void mute() override;
23  void unmute() override;
24 
25  [[nodiscard]] unsigned getFrequency() const override;
26  [[nodiscard]] unsigned getSamples() const override;
27 
28  void uploadBuffer(float* buffer, unsigned len) override;
29 
30 private:
31  void reInit();
32  [[nodiscard]] unsigned getBufferFilled() const;
33  [[nodiscard]] unsigned getBufferFree() const;
34  static void audioCallbackHelper(void* userdata, uint8_t* strm, int len);
35  void audioCallback(float* stream, unsigned len);
36 
37 private:
38  Reactor& reactor;
39  SDL_AudioDeviceID deviceID;
40  MemBuffer<float> mixBuffer;
41  unsigned mixBufferSize;
42  unsigned frequency;
43  unsigned fragmentSize;
44  unsigned readIdx, writeIdx;
45  bool muted;
47 };
48 
49 } // namespace openmsx
50 
51 #endif
Contains the main loop of openMSX.
Definition: Reactor.hh:68
void unmute() override
Unmute the sound system.
void mute() override
Mute the sound system.
unsigned getFrequency() const override
Returns the actual sample frequency.
SDLSoundDriver(const SDLSoundDriver &)=delete
void uploadBuffer(float *buffer, unsigned len) override
unsigned getSamples() const override
Get the number of samples that should be created 'per fragment'.
SDLSoundDriver & operator=(const SDLSoundDriver &)=delete
This file implemented 3 utility functions:
Definition: Autofire.cc:9