Line data Source code
1 : /* 2 : * Copyright (C) 2004-2024 Savoir-faire Linux Inc. 3 : * 4 : * Inspired by tonegenerator of 5 : * Laurielle Lea <laurielle.lea@savoirfairelinux.com> (2004) 6 : * Inspired by ringbuffer of Audacity Project 7 : * 8 : * This program is free software: you can redistribute it and/or modify 9 : * it under the terms of the GNU General Public License as published by 10 : * the Free Software Foundation, either version 3 of the License, or 11 : * (at your option) any later version. 12 : * 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. 17 : * 18 : * You should have received a copy of the GNU General Public License 19 : * along with this program. If not, see <https://www.gnu.org/licenses/>. 20 : */ 21 : #pragma once 22 : 23 : #include <stdexcept> 24 : #include "audio/audioloop.h" 25 : 26 : namespace jami { 27 : 28 : class AudioFileException : public std::runtime_error 29 : { 30 : public: 31 58 : AudioFileException(const std::string& str) 32 58 : : std::runtime_error("AudioFile: AudioFileException occurred: " + str) 33 58 : {} 34 : }; 35 : 36 : /** 37 : * @brief Abstract interface for file readers 38 : */ 39 : class AudioFile : public AudioLoop 40 : { 41 : public: 42 : AudioFile(const std::string& filepath, unsigned int sampleRate, AVSampleFormat sampleFormat); 43 : 44 0 : std::string getFilePath() const { return filepath_; } 45 : 46 : protected: 47 : /** The absolute path to the sound file */ 48 : std::string filepath_; 49 : 50 : private: 51 : // override 52 : void onBufferFinish(); 53 : unsigned updatePlaybackScale_; 54 : }; 55 : 56 : } // namespace jami