our_dick/include/audio/channel.hpp

75 lines
1.8 KiB
C++

/**
This file is a part of our_dick
Copyright (C) 2021 rexy712
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OUR_DICK_AUDIO_CHANNEL_HPP
#define OUR_DICK_AUDIO_CHANNEL_HPP
#include <cstdlib> //size_t
#include "mixdata.hpp"
#include "impl/channel.hpp"
namespace sfx{
//needs to be thread safe, lock free, and avoid false sharing
class channel
{
private:
impl::channel* m_impl;
public:
using native_chunk = impl::channel::chunk;
public:
channel(impl::channel& c);
channel(const channel& c) = default;
channel(channel&& c) = default;
~channel(void) = default;
channel& operator=(const channel&) = default;
channel& operator=(channel&&) = default;
void resize_buffer(size_t newsize);
template<size_t Size>
void play(const mixrawdata<Size>& m);
template<size_t Size>
bool try_play(const mixrawdata<Size>& m);
void pause(void);
void resume(void);
void stop(void);
bool is_paused(void)const;
bool is_playing(void)const;
bool is_stopped(void)const;
};
template<size_t Size>
void channel::play(const mixrawdata<Size>& m){
m_impl->play(m);
}
template<size_t Size>
bool channel::try_play(const mixrawdata<Size>& m){
return m_impl->try_play(m);
}
}
#endif