1 //============================================================================ 2 // 3 // SSSS tt lll lll 4 // SS SS tt ll ll 5 // SS tttttt eeee ll ll aaaa 6 // SSSS tt ee ee ll ll aa 7 // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" 8 // SS SS tt ee ll ll aa aa 9 // SSSS ttt eeeee llll llll aaaaa 10 // 11 // Copyright (c) 1995-2021 by Bradford W. Mott, Stephen Anthony 12 // and the Stella Team 13 // 14 // See the file "License.txt" for information on usage and redistribution of 15 // this file, and for a DISCLAIMER OF ALL WARRANTIES. 16 //============================================================================ 17 18 #ifdef SOUND_SUPPORT 19 20 #ifndef SOUND_LIBRETRO_HXX 21 #define SOUND_LIBRETRO_HXX 22 23 class OSystem; 24 class AudioQueue; 25 class EmulationTiming; 26 class AudioSettings; 27 28 #include "bspf.hxx" 29 #include "Sound.hxx" 30 31 /** 32 This class implements the sound API for LIBRETRO. 33 34 @author Stephen Anthony and Christian Speckner (DirtyHairy) 35 */ 36 class SoundLIBRETRO : public Sound 37 { 38 public: 39 /** 40 Create a new sound object. The init method must be invoked before 41 using the object. 42 */ 43 SoundLIBRETRO(OSystem& osystem, AudioSettings& audioSettings); 44 ~SoundLIBRETRO() override; 45 46 public: 47 /** 48 Initializes the sound device. This must be called before any 49 calls are made to derived methods. 50 */ 51 void open(shared_ptr<AudioQueue> audioQueue, 52 EmulationTiming* emulationTiming) override; 53 54 /** 55 Should be called to close the sound device. Once called the sound 56 device can be started again using the open method. 57 */ 58 void close() override; 59 60 /** 61 Empties the playback buffer. 62 63 @param stream Output audio buffer 64 @param samples Number of audio samples read 65 */ 66 void dequeue(Int16* stream, uInt32* samples); 67 68 protected: 69 ////////////////////////////////////////////////////////////////////// 70 // Most methods here aren't used at all. See Sound class for 71 // description, if needed. 72 ////////////////////////////////////////////////////////////////////// 73 setEnabled(bool enable)74 void setEnabled(bool enable) override { } queryHardware(VariantList & devices)75 void queryHardware(VariantList& devices) override { } setVolume(uInt32 percent)76 void setVolume(uInt32 percent) override { } adjustVolume(int direction=+1)77 void adjustVolume(int direction = +1) override { } mute(bool state)78 bool mute(bool state) override { return !myIsInitializedFlag; } toggleMute()79 bool toggleMute() override { return !myIsInitializedFlag; } about() const80 string about() const override { return ""; } 81 82 private: 83 // Indicates if the sound device was successfully initialized 84 bool myIsInitializedFlag{false}; 85 86 shared_ptr<AudioQueue> myAudioQueue; 87 88 EmulationTiming* myEmulationTiming{nullptr}; 89 90 Int16* myCurrentFragment{nullptr}; 91 bool myUnderrun{false}; 92 93 AudioSettings& myAudioSettings; 94 95 private: 96 // Following constructors and assignment operators not supported 97 SoundLIBRETRO() = delete; 98 SoundLIBRETRO(const SoundLIBRETRO&) = delete; 99 SoundLIBRETRO(SoundLIBRETRO&&) = delete; 100 SoundLIBRETRO& operator=(const SoundLIBRETRO&) = delete; 101 SoundLIBRETRO& operator=(SoundLIBRETRO&&) = delete; 102 }; 103 104 #endif 105 106 #endif // SOUND_SUPPORT 107