|
#pragma once
#include "buffers.hpp"
#include "WAOutModule.hpp"
#include "ASIO SDK/common/asio.h"
namespace WinAMP
{
namespace OutModule
{
////////////////////////////////////////////////////////////////////////////////
//
// Writer
// ------
//
// Wraps a buffer dedicated for a single ASIO output sample type as well as
// additional data and functionality required for WinAMP interaction (mainly the
// the write callback used for transforming the input data into the output
// format).
//
////////////////////////////////////////////////////////////////////////////////
class Writer
{
public:
MultiChannelBuffer & buffer () { return buffer_ ; }
MultiChannelBuffer const & buffer () const { return const_cast<Writer &>( *this ).buffer() ; }
WAOutModule::WriteCallback callback () const { assert( writeCallback_ ); return writeCallback_; }
size_t outputBytesPerSample () const { return outputBytesPerSample_ ; }
ASIOSampleType outputSampleType () const { return outputSampleType_ ; }
int write ( char * const buffer, int const bufferLength ) const { return callback()( buffer, bufferLength ) ; }
int writtenTimeInMilliseconds() const;
bool setUpForIOParameters( int inputBitsPerSecond, size_t outputSampleRate );
typedef int (Writer::*unspecified_bool_type)() const;
operator unspecified_bool_type() const { return writeCallback_ ? &Writer::writtenTimeInMilliseconds : 0; }
private: // WriterForASIOSampleType private interface.
template <ASIOSampleType> friend class WriterForASIOSampleType;
Writer( ASIOSampleType, size_t outputBytesPerSample );
private: // Non copyable.
Writer ( Writer const & );
void operator=( Writer const & );
private:
MultiChannelBuffer buffer_ ;
WAOutModule::WriteCallback writeCallback_ ;
size_t outputSampleRate_ ;
ASIOSampleType const outputSampleType_ ;
size_t const outputBytesPerSample_;
};
Writer & getOutputSampleTypeWriter( ASIOSampleType );
Writer const & getReadersWriter ( MultiChannelBuffer::Reader const & );
} // namespace OutModule
} // namespace WinAMP
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.