APE reader: style fixes.
This commit is contained in:
@@ -1,25 +1,18 @@
|
|||||||
|
/* Copyright 2005-2009 SHINTA
|
||||||
|
* Distributed under the terms of the MIT license
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
|
|
||||||
/*============================================================================*/
|
|
||||||
const char* gAppName = "APE (Monkey's Audio) reader";
|
|
||||||
const char* gAppVer = "Ver 1.13";
|
|
||||||
const char* gCright = "Copyright " B_UTF8_COPYRIGHT " 2005-2009 by SHINTA";
|
|
||||||
const char* gAppSignature = "application/x-vnd.SHINTA-MediaKitAPEReader";
|
|
||||||
/*============================================================================*/
|
|
||||||
|
|
||||||
/*=== Memo =====================================================================
|
|
||||||
==============================================================================*/
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#include "APEReader.h"
|
#include "APEReader.h"
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// BeOS
|
|
||||||
// C++
|
|
||||||
// MAC
|
|
||||||
#include "MACLib.h"
|
#include "MACLib.h"
|
||||||
// Proj
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
//==============================================================================
|
static const char* kCopyrightString
|
||||||
|
= "Copyright " B_UTF8_COPYRIGHT " 2005-2009 by SHINTA";
|
||||||
|
|
||||||
|
|
||||||
TAPEReader::TAPEReader()
|
TAPEReader::TAPEReader()
|
||||||
: SUPER()
|
: SUPER()
|
||||||
{
|
{
|
||||||
@@ -27,33 +20,45 @@ TAPEReader::TAPEReader()
|
|||||||
mDecomp = NULL;
|
mDecomp = NULL;
|
||||||
Unset();
|
Unset();
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
TAPEReader::~TAPEReader()
|
TAPEReader::~TAPEReader()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t TAPEReader::AllocateCookie(int32 oStreamNumber, void** oCookie)
|
|
||||||
|
status_t
|
||||||
|
TAPEReader::AllocateCookie(int32 oStreamNumber, void** oCookie)
|
||||||
{
|
{
|
||||||
*oCookie = NULL;
|
*oCookie = NULL;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
const char* TAPEReader::Copyright()
|
|
||||||
|
const char*
|
||||||
|
TAPEReader::Copyright()
|
||||||
{
|
{
|
||||||
return gCright;
|
return kCopyrightString;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
bigtime_t TAPEReader::CurrentTime() const
|
|
||||||
|
bigtime_t
|
||||||
|
TAPEReader::CurrentTime() const
|
||||||
{
|
{
|
||||||
return mDecomp->GetInfo(APE_DECOMPRESS_CURRENT_MS)*static_cast<bigtime_t>(1000);
|
return mDecomp->GetInfo(APE_DECOMPRESS_CURRENT_MS)
|
||||||
|
* static_cast<bigtime_t>(1000);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t TAPEReader::FreeCookie(void* oCookie)
|
|
||||||
|
status_t
|
||||||
|
TAPEReader::FreeCookie(void* oCookie)
|
||||||
{
|
{
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void TAPEReader::GetFileFormatInfo(media_file_format* oMFF)
|
|
||||||
|
void
|
||||||
|
TAPEReader::GetFileFormatInfo(media_file_format* oMFF)
|
||||||
{
|
{
|
||||||
oMFF->capabilities = media_file_format::B_READABLE
|
oMFF->capabilities = media_file_format::B_READABLE
|
||||||
| media_file_format::B_PERFECTLY_SEEKABLE
|
| media_file_format::B_PERFECTLY_SEEKABLE
|
||||||
@@ -67,8 +72,11 @@ void TAPEReader::GetFileFormatInfo(media_file_format* oMFF)
|
|||||||
strcpy(oMFF->short_name, MIME_TYPE_APE_SHORT_DESCRIPTION);
|
strcpy(oMFF->short_name, MIME_TYPE_APE_SHORT_DESCRIPTION);
|
||||||
strcpy(oMFF->file_extension, MIME_TYPE_APE_EXTENSION);
|
strcpy(oMFF->file_extension, MIME_TYPE_APE_EXTENSION);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t TAPEReader::GetNextChunk(void* oCookie, const void** oChunkBuffer, size_t* oChunkSize, media_header* oMediaHeader)
|
|
||||||
|
status_t
|
||||||
|
TAPEReader::GetNextChunk(void* oCookie, const void** oChunkBuffer,
|
||||||
|
size_t* oChunkSize, media_header* oMediaHeader)
|
||||||
{
|
{
|
||||||
int64 aOutSize;
|
int64 aOutSize;
|
||||||
|
|
||||||
@@ -93,14 +101,19 @@ status_t TAPEReader::GetNextChunk(void* oCookie, const void** oChunkBuffer, size
|
|||||||
oMediaHeader->file_pos = mPlayPos;
|
oMediaHeader->file_pos = mPlayPos;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t TAPEReader::GetStreamInfo(void* oCookie, int64* oFrameCount, bigtime_t* oDuration, media_format* oFormat,
|
|
||||||
const void** oInfoBuffer, size_t* oInfoSize)
|
status_t
|
||||||
|
TAPEReader::GetStreamInfo(void* oCookie, int64* oFrameCount,
|
||||||
|
bigtime_t* oDuration, media_format* oFormat, const void** oInfoBuffer,
|
||||||
|
size_t* oInfoSize)
|
||||||
{
|
{
|
||||||
if ( LoadAPECheck() != B_OK )
|
if ( LoadAPECheck() != B_OK )
|
||||||
return LoadAPECheck();
|
return LoadAPECheck();
|
||||||
*oFrameCount = mDataSize/(mDecomp->GetInfo(APE_INFO_BITS_PER_SAMPLE)/8*mDecomp->GetInfo(APE_INFO_CHANNELS));
|
*oFrameCount = mDataSize / (mDecomp->GetInfo(APE_INFO_BITS_PER_SAMPLE) / 8
|
||||||
*oDuration = mDecomp->GetInfo(APE_INFO_LENGTH_MS)*static_cast<bigtime_t>(1000);
|
* mDecomp->GetInfo(APE_INFO_CHANNELS));
|
||||||
|
*oDuration = mDecomp->GetInfo(APE_INFO_LENGTH_MS)
|
||||||
|
* static_cast<bigtime_t>(1000);
|
||||||
// media_format
|
// media_format
|
||||||
oFormat->type = B_MEDIA_RAW_AUDIO;
|
oFormat->type = B_MEDIA_RAW_AUDIO;
|
||||||
oFormat->u.raw_audio.frame_rate = mDecomp->GetInfo(APE_INFO_SAMPLE_RATE);
|
oFormat->u.raw_audio.frame_rate = mDecomp->GetInfo(APE_INFO_SAMPLE_RATE);
|
||||||
@@ -116,63 +129,76 @@ status_t TAPEReader::GetStreamInfo(void* oCookie, int64* oFrameCount, bigtime_t*
|
|||||||
oInfoSize = NULL;
|
oInfoSize = NULL;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t TAPEReader::LoadAPECheck() const
|
|
||||||
|
status_t
|
||||||
|
TAPEReader::LoadAPECheck() const
|
||||||
{
|
{
|
||||||
return mLoadAPECheck;
|
return mLoadAPECheck;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t TAPEReader::ReadBlocks()
|
|
||||||
|
status_t
|
||||||
|
TAPEReader::ReadBlocks()
|
||||||
{
|
{
|
||||||
int aBlocksRead;
|
int aBlocksRead;
|
||||||
int aRetVal = 0;
|
int aRetVal = 0;
|
||||||
|
|
||||||
aRetVal = mDecomp->GetData(reinterpret_cast<char*>(mDecodedData), BLOCK_COUNT, &aBlocksRead);
|
aRetVal = mDecomp->GetData(reinterpret_cast<char*>(mDecodedData),
|
||||||
if ( aRetVal != ERROR_SUCCESS ) {
|
BLOCK_COUNT, &aBlocksRead);
|
||||||
|
if ( aRetVal != ERROR_SUCCESS )
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
|
||||||
mPlayPos = 0;
|
mPlayPos = 0;
|
||||||
mReadPos = aBlocksRead*mDecomp->GetInfo(APE_INFO_BLOCK_ALIGN);
|
mReadPos = aBlocksRead*mDecomp->GetInfo(APE_INFO_BLOCK_ALIGN);
|
||||||
mReadPosTotal += mReadPos;
|
mReadPosTotal += mReadPos;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
status_t TAPEReader::FindKeyFrame(void* cookie, uint32 flags,
|
|
||||||
int64* frame, bigtime_t* time)
|
status_t
|
||||||
|
TAPEReader::FindKeyFrame(void* cookie, uint32 flags, int64* frame,
|
||||||
|
bigtime_t* time)
|
||||||
{
|
{
|
||||||
printf("FindKeyFrame for time %Ld or frame %Ld\n",*time,*frame);
|
|
||||||
if ( flags & B_MEDIA_SEEK_TO_FRAME ) {
|
if ( flags & B_MEDIA_SEEK_TO_FRAME ) {
|
||||||
*time = *frame * 1000 / mDecomp->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS) * mDecomp->GetInfo(APE_DECOMPRESS_LENGTH_MS);
|
*time = *frame * 1000 / mDecomp->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS)
|
||||||
|
* mDecomp->GetInfo(APE_DECOMPRESS_LENGTH_MS);
|
||||||
|
printf("FindKeyFrame for frame %Ld: %Ld\n", *frame, *time);
|
||||||
} else if ( flags & B_MEDIA_SEEK_TO_TIME ) {
|
} else if ( flags & B_MEDIA_SEEK_TO_TIME ) {
|
||||||
*frame = (*time)/1000*mDecomp->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS)/mDecomp->GetInfo(APE_DECOMPRESS_LENGTH_MS);
|
*frame = (*time)/1000*mDecomp->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS)
|
||||||
} else {
|
/ mDecomp->GetInfo(APE_DECOMPRESS_LENGTH_MS);
|
||||||
|
printf("FindKeyFrame for time %Ld: %Ld\n", *time, *frame);
|
||||||
|
} else
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t TAPEReader::Seek(void *cookie, uint32 flags,
|
|
||||||
int64 *frame, bigtime_t *time)
|
status_t
|
||||||
|
TAPEReader::Seek(void *cookie, uint32 flags, int64 *frame, bigtime_t *time)
|
||||||
{
|
{
|
||||||
int32 aNewBlock;
|
int32 aNewBlock;
|
||||||
|
|
||||||
printf("Seek for time %Ld or frame %Ld\n",*time,*frame);
|
|
||||||
if ( flags & B_MEDIA_SEEK_TO_FRAME ) {
|
if ( flags & B_MEDIA_SEEK_TO_FRAME ) {
|
||||||
|
printf("Seek to frame %Ld\n", *frame);
|
||||||
aNewBlock = *frame;
|
aNewBlock = *frame;
|
||||||
} else if ( flags & B_MEDIA_SEEK_TO_TIME ) {
|
} else if ( flags & B_MEDIA_SEEK_TO_TIME ) {
|
||||||
aNewBlock = (*time)/1000*mDecomp->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS)/mDecomp->GetInfo(APE_DECOMPRESS_LENGTH_MS);
|
printf("Seek for time %Ld\n", *time);
|
||||||
} else {
|
aNewBlock = (*time)/1000*mDecomp->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS)
|
||||||
|
/ mDecomp->GetInfo(APE_DECOMPRESS_LENGTH_MS);
|
||||||
|
} else
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
|
||||||
mReadPosTotal = aNewBlock*mDecomp->GetInfo(APE_INFO_BLOCK_ALIGN);
|
mReadPosTotal = aNewBlock*mDecomp->GetInfo(APE_INFO_BLOCK_ALIGN);
|
||||||
mDecomp->Seek(aNewBlock);
|
mDecomp->Seek(aNewBlock);
|
||||||
ReadBlocks();
|
ReadBlocks();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
status_t TAPEReader::Sniff(int32* oStreamCount)
|
|
||||||
|
status_t
|
||||||
|
TAPEReader::Sniff(int32* oStreamCount)
|
||||||
{
|
{
|
||||||
Unset();
|
Unset();
|
||||||
// prepare about file
|
// prepare about file
|
||||||
@@ -192,8 +218,10 @@ status_t TAPEReader::Sniff(int32* oStreamCount)
|
|||||||
*oStreamCount = 1;
|
*oStreamCount = 1;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void TAPEReader::Unset()
|
|
||||||
|
void
|
||||||
|
TAPEReader::Unset()
|
||||||
{
|
{
|
||||||
mLoadAPECheck = B_NO_INIT;
|
mLoadAPECheck = B_NO_INIT;
|
||||||
// about file
|
// about file
|
||||||
@@ -207,25 +235,27 @@ void TAPEReader::Unset()
|
|||||||
mPlayPos = 0;
|
mPlayPos = 0;
|
||||||
delete [] mDecodedData;
|
delete [] mDecodedData;
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
//==============================================================================
|
|
||||||
TAPEReaderPlugin::TAPEReaderPlugin()
|
TAPEReaderPlugin::TAPEReaderPlugin()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
TAPEReaderPlugin::~TAPEReaderPlugin()
|
TAPEReaderPlugin::~TAPEReaderPlugin()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
Reader* TAPEReaderPlugin::NewReader()
|
|
||||||
|
Reader*
|
||||||
|
TAPEReaderPlugin::NewReader()
|
||||||
{
|
{
|
||||||
return new TAPEReader();
|
return new TAPEReader();
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
//==============================================================================
|
|
||||||
MediaPlugin* instantiate_plugin()
|
MediaPlugin*
|
||||||
|
instantiate_plugin()
|
||||||
{
|
{
|
||||||
return new TAPEReaderPlugin();
|
return new TAPEReaderPlugin();
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
//==============================================================================
|
|
||||||
|
|||||||
Reference in New Issue
Block a user