URY playd
C++ minimalist audio player
sndfile.hpp
Go to the documentation of this file.
1 // This file is part of playd.
2 // playd is licensed under the MIT licence: see LICENSE.txt.
3 
10 #ifndef PLAYD_AUDIO_SOURCE_SNDFILE_HPP
11 #define PLAYD_AUDIO_SOURCE_SNDFILE_HPP
12 #ifdef WITH_SNDFILE
13 
14 #include <cstdint>
15 #include <string>
16 #include <vector>
17 
18 #include <sndfile.h>
19 
20 #include "../audio_source.hpp"
21 #include "../sample_formats.hpp"
22 
24 class SndfileAudioSource : public AudioSource
25 {
26 public:
33  SndfileAudioSource(const std::string &path);
34 
36  ~SndfileAudioSource();
37 
38  DecodeResult Decode() override;
39  std::uint64_t Seek(std::uint64_t position) override;
40 
41  std::uint8_t ChannelCount() const override;
42  std::uint32_t SampleRate() const override;
43  SampleFormat OutputSampleFormat() const override;
44 
45 private:
46  SF_INFO info;
47  SNDFILE *file;
48 
49  std::vector<int32_t> buffer;
50 };
51 
52 #endif // WITH_SNDFILE
53 #endif // PLAYD_AUDIO_SOURCE_SNDFILE_HPP
virtual DecodeResult Decode()=0
Performs a round of decoding.
An object responsible for decoding an audio file.
virtual std::uint8_t ChannelCount() const =0
Returns the channel count.
virtual SampleFormat OutputSampleFormat() const =0
Returns the output sample format.
virtual std::uint64_t Seek(std::uint64_t position)=0
Seeks to the given position, in samples.
virtual std::uint32_t SampleRate() const =0
Returns the sample rate.
SampleFormat
Sample formats available in playd.