From 5480f203d332ef54efe0ac73173f886475ff8997 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 10 Dec 2014 09:11:22 +0100 Subject: [PATCH] APE reader: style fixes. --- .../media/plugins/ape_reader/APEReader.cpp | 180 ++++++++++-------- 1 file changed, 105 insertions(+), 75 deletions(-) diff --git a/src/add-ons/media/plugins/ape_reader/APEReader.cpp b/src/add-ons/media/plugins/ape_reader/APEReader.cpp index 58d4a7fa95..33d179d880 100644 --- a/src/add-ons/media/plugins/ape_reader/APEReader.cpp +++ b/src/add-ons/media/plugins/ape_reader/APEReader.cpp @@ -1,59 +1,64 @@ +/* Copyright 2005-2009 SHINTA + * Distributed under the terms of the MIT license + */ + + #include -/*============================================================================*/ -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" -//------------------------------------------------------------------------------ -// BeOS -// C++ -// MAC #include "MACLib.h" -// Proj -//------------------------------------------------------------------------------ -//============================================================================== + + +static const char* kCopyrightString + = "Copyright " B_UTF8_COPYRIGHT " 2005-2009 by SHINTA"; + + TAPEReader::TAPEReader() - : SUPER() + : SUPER() { mDecodedData = NULL; mDecomp = NULL; Unset(); } -//------------------------------------------------------------------------------ + + TAPEReader::~TAPEReader() { } -//------------------------------------------------------------------------------ -status_t TAPEReader::AllocateCookie(int32 oStreamNumber, void** oCookie) + + +status_t +TAPEReader::AllocateCookie(int32 oStreamNumber, void** oCookie) { *oCookie = NULL; 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(1000); + return mDecomp->GetInfo(APE_DECOMPRESS_CURRENT_MS) + * static_cast(1000); } -//------------------------------------------------------------------------------ -status_t TAPEReader::FreeCookie(void* oCookie) + + +status_t +TAPEReader::FreeCookie(void* oCookie) { return B_OK; } -//------------------------------------------------------------------------------ -void TAPEReader::GetFileFormatInfo(media_file_format* oMFF) + + +void +TAPEReader::GetFileFormatInfo(media_file_format* oMFF) { oMFF->capabilities = media_file_format::B_READABLE | 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->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; @@ -93,14 +101,19 @@ status_t TAPEReader::GetNextChunk(void* oCookie, const void** oChunkBuffer, size oMediaHeader->file_pos = mPlayPos; 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 ) return LoadAPECheck(); - *oFrameCount = mDataSize/(mDecomp->GetInfo(APE_INFO_BITS_PER_SAMPLE)/8*mDecomp->GetInfo(APE_INFO_CHANNELS)); - *oDuration = mDecomp->GetInfo(APE_INFO_LENGTH_MS)*static_cast(1000); + *oFrameCount = mDataSize / (mDecomp->GetInfo(APE_INFO_BITS_PER_SAMPLE) / 8 + * mDecomp->GetInfo(APE_INFO_CHANNELS)); + *oDuration = mDecomp->GetInfo(APE_INFO_LENGTH_MS) + * static_cast(1000); // media_format oFormat->type = B_MEDIA_RAW_AUDIO; 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; return B_OK; } -//------------------------------------------------------------------------------ -status_t TAPEReader::LoadAPECheck() const + + +status_t +TAPEReader::LoadAPECheck() const { return mLoadAPECheck; } -//------------------------------------------------------------------------------ -status_t TAPEReader::ReadBlocks() + + +status_t +TAPEReader::ReadBlocks() { int aBlocksRead; int aRetVal = 0; - aRetVal = mDecomp->GetData(reinterpret_cast(mDecodedData), BLOCK_COUNT, &aBlocksRead); - if ( aRetVal != ERROR_SUCCESS ) { + aRetVal = mDecomp->GetData(reinterpret_cast(mDecodedData), + BLOCK_COUNT, &aBlocksRead); + if ( aRetVal != ERROR_SUCCESS ) return B_ERROR; - } + mPlayPos = 0; mReadPos = aBlocksRead*mDecomp->GetInfo(APE_INFO_BLOCK_ALIGN); mReadPosTotal += mReadPos; 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 ) { - *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 ) { - *frame = (*time)/1000*mDecomp->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS)/mDecomp->GetInfo(APE_DECOMPRESS_LENGTH_MS); - } else { + *frame = (*time)/1000*mDecomp->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS) + / mDecomp->GetInfo(APE_DECOMPRESS_LENGTH_MS); + printf("FindKeyFrame for time %Ld: %Ld\n", *time, *frame); + } else return B_ERROR; - } 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; - printf("Seek for time %Ld or frame %Ld\n",*time,*frame); if ( flags & B_MEDIA_SEEK_TO_FRAME ) { - aNewBlock = *frame; + printf("Seek to frame %Ld\n", *frame); + aNewBlock = *frame; } else if ( flags & B_MEDIA_SEEK_TO_TIME ) { - aNewBlock = (*time)/1000*mDecomp->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS)/mDecomp->GetInfo(APE_DECOMPRESS_LENGTH_MS); - } else { + printf("Seek for time %Ld\n", *time); + aNewBlock = (*time)/1000*mDecomp->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS) + / mDecomp->GetInfo(APE_DECOMPRESS_LENGTH_MS); + } else return B_ERROR; - } + mReadPosTotal = aNewBlock*mDecomp->GetInfo(APE_INFO_BLOCK_ALIGN); mDecomp->Seek(aNewBlock); ReadBlocks(); return B_OK; } -//------------------------------------------------------------------------------ -status_t TAPEReader::Sniff(int32* oStreamCount) + + +status_t +TAPEReader::Sniff(int32* oStreamCount) { Unset(); // prepare about file @@ -192,8 +218,10 @@ status_t TAPEReader::Sniff(int32* oStreamCount) *oStreamCount = 1; return B_OK; } -//------------------------------------------------------------------------------ -void TAPEReader::Unset() + + +void +TAPEReader::Unset() { mLoadAPECheck = B_NO_INIT; // about file @@ -207,25 +235,27 @@ void TAPEReader::Unset() mPlayPos = 0; delete [] mDecodedData; } -//------------------------------------------------------------------------------ -//============================================================================== + + TAPEReaderPlugin::TAPEReaderPlugin() { } -//------------------------------------------------------------------------------ + + TAPEReaderPlugin::~TAPEReaderPlugin() { } -//------------------------------------------------------------------------------ -Reader* TAPEReaderPlugin::NewReader() + + +Reader* +TAPEReaderPlugin::NewReader() { return new TAPEReader(); } -//------------------------------------------------------------------------------ -//============================================================================== -MediaPlugin* instantiate_plugin() + + +MediaPlugin* +instantiate_plugin() { return new TAPEReaderPlugin(); } -//------------------------------------------------------------------------------ -//==============================================================================