1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
//-------------------------------------------------------------------------
// This class encapsulates an OggFLAC stream. Only the functions
// needed by the alsaplayer flac plugin are implemented.
//
// Copyright (c) 2002 by Drew Hess <dhess@bothan.net>
//
/* This file is part of AlsaPlayer.
*
* AlsaPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* AlsaPlayer 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
//-------------------------------------------------------------------------
#ifndef _OGG_FLAC_STREAM_H_
#define _OGG_FLAC_STREAM_H_
#include <string>
#include "reader.h"
#include "FlacStream.h"
extern "C"
{
#include <OggFLAC/stream_decoder.h>
}
#undef DEBUG
namespace Flac
{
class FlacEngine;
class FlacTag;
class OggFlacStream : public FlacStream
{
public:
//-----------------------------------------------------------------
// Return true if we think name points to a valid OggFLAC stream.
//-----------------------------------------------------------------
static bool isOggFlacStream (const std::string & name);
public:
//---------------------------------------------------------------
// Constructor & destructor. The reader_type f belongs to the
// OggFlacStream after construction, and it will be closed upon
// deletion of the OggFlacStream object. If reportErrors is
// false, the object will squelch all alsaplayer_error messages.
// This is particularly useful when attempting to open streams
// to determine whether they're OggFLAC streams.
//---------------------------------------------------------------
OggFlacStream (const std::string & name,
reader_type * f,
bool reportErrors = true);
virtual ~OggFlacStream ();
//--------------------------------------------------------
// See FlacStream.h for a description of these functions.
//--------------------------------------------------------
virtual bool open ();
virtual bool processOneBlock ();
//----------------------------------------
// Seeks are unsupported. Returns false.
//----------------------------------------
virtual bool seekAbsolute (FLAC__uint64 sample);
private:
//-----------------------------------------------------------------
// The flac metadata callback. It's called as a side effect of the
// open method. It'll be called once for each metadata block in
// the flac stream. To check its success, look at _mcbSuccess.
//-----------------------------------------------------------------
static void metaCallBack (const OggFLAC__StreamDecoder * decoder,
const FLAC__StreamMetadata * md,
void * cilent_data);
static FLAC__StreamDecoderWriteStatus
writeCallBack (const OggFLAC__StreamDecoder * decoder,
const FLAC__Frame * block,
const FLAC__int32 * const buffer[],
void * client_data);
static FLAC__StreamDecoderReadStatus
readCallBack (const OggFLAC__StreamDecoder * decoder,
FLAC__byte buffer[],
size_t * bytes,
void * client_data);
static void errCallBack (const OggFLAC__StreamDecoder * decoder,
FLAC__StreamDecoderErrorStatus status,
void * client_data);
private:
OggFlacStream ();
private:
OggFLAC__StreamDecoder * _decoder;
}; // class OggFlacStream
//----------------
// Inline methods.
//----------------
inline bool
OggFlacStream::seekAbsolute (FLAC__uint64 sample)
{
return false;
}
inline
OggFlacStream::OggFlacStream ()
: _decoder (0)
{
}
} // namespace Flac
#endif // _OGG_FLAC_STREAM_H_
|