diff options
| author | crueter <crueter@eden-emu.dev> | 2025-08-04 04:50:14 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2025-08-04 04:50:14 +0200 |
| commit | 51b170b470ed587f99a7c2a773e4464687f0d07a (patch) | |
| tree | 4c03c510cfb17a5f5d6233df490d78f06dcfa7f7 /externals/oboe/samples/parselib/src/main/cpp | |
| parent | 04e5e6453875ffa5c79cdb421a29bc19985b1049 (diff) | |
[cmake] refactor: Use CPM over submodules (#143)
Transfers the majority of submodules and large externals to CPM, using source archives rather than full Git clones. Not only does this save massive amounts of clone and configure time, but dependencies are grabbed on-demand rather than being required by default. Additionally, CPM will (generally) automatically search for system dependencies, though certain dependencies have options to control this.
Testing shows gains ranging from 5x to 10x in terms of overall clone/configure time.
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/143
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Diffstat (limited to 'externals/oboe/samples/parselib/src/main/cpp')
18 files changed, 0 insertions, 1152 deletions
diff --git a/externals/oboe/samples/parselib/src/main/cpp/CMakeLists.txt b/externals/oboe/samples/parselib/src/main/cpp/CMakeLists.txt deleted file mode 100644 index d9ed9d5bb4..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -# For more information about using CMake with Android Studio, read the
-# documentation: https://d.android.com/studio/projects/add-native-code.html
-
-# Sets the minimum version of CMake required to build the native library.
-cmake_minimum_required(VERSION 3.4.1)
-
-#PROJECT(wavlib C CXX)
-
-#message("CMAKE_CURRENT_LIST_DIR = " ${CMAKE_CURRENT_LIST_DIR})
-
-#message("HOME is " ${HOME})
-
-# SET(NDK "")
-#message("NDK is " ${NDK})
-
-# compiler flags
-# -mhard-float -D_NDK_MATH_NO_SOFTFP=1
-#SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mhard-float -D_NDK_MATH_NO_SOFTFP=1" )
-
-# Set the path to the Oboe library directory
-set (OBOE_DIR ../../../../../)
-message("OBOE_DIR = " + ${OBOE_DIR})
-
-#add_subdirectory(${OBOE_DIR} ./oboe-bin)
-
-# include folders
-include_directories(
- ${OBOE_DIR}/include
- ${CMAKE_CURRENT_LIST_DIR}
- ../../../../shared)
-
-# Creates and names a library, sets it as either STATIC
-# or SHARED, and provides the relative paths to its source code.
-# You can define multiple libraries, and CMake builds them for you.
-# Gradle automatically packages shared libraries with your APK.
-
-add_library( # Sets the name of the library.
- parselib
-
- # Sets the library as a static library.
- STATIC
-
- # Provides a relative path to your source file(s).
- # stream
- ${CMAKE_CURRENT_LIST_DIR}/stream/FileInputStream.cpp
- ${CMAKE_CURRENT_LIST_DIR}/stream/InputStream.cpp
- ${CMAKE_CURRENT_LIST_DIR}/stream/MemInputStream.cpp
- # wav
- ${CMAKE_CURRENT_LIST_DIR}/wav/AudioEncoding.cpp
- ${CMAKE_CURRENT_LIST_DIR}/wav/WavChunkHeader.cpp
- ${CMAKE_CURRENT_LIST_DIR}/wav/WavFmtChunkHeader.cpp
- ${CMAKE_CURRENT_LIST_DIR}/wav/WavRIFFChunkHeader.cpp
- ${CMAKE_CURRENT_LIST_DIR}/wav/WavStreamReader.cpp)
-
-# Specifies libraries CMake should link to your target library. You
-# can link multiple libraries, such as libraries you define in this
-# build script, prebuilt third-party libraries, or system libraries.
-
-target_link_libraries( # Specifies the target library.
- parselib
-
- # Links the target library to the log library
- # included in the NDK.
- log)
diff --git a/externals/oboe/samples/parselib/src/main/cpp/stream/FileInputStream.cpp b/externals/oboe/samples/parselib/src/main/cpp/stream/FileInputStream.cpp deleted file mode 100644 index 186b9b16a8..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/stream/FileInputStream.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <unistd.h>
-
-#include "FileInputStream.h"
-
-namespace parselib {
-
-int32_t FileInputStream::read(void *buff, int32_t numBytes) {
- return ::read(mFH, buff, numBytes);
-}
-
-int32_t FileInputStream::peek(void *buff, int32_t numBytes) {
- int32_t numRead = ::read(mFH, buff, numBytes);
- ::lseek(mFH, -numBytes, SEEK_CUR);
- return numRead;
-}
-
-void FileInputStream::advance(int32_t numBytes) {
- if (numBytes > 0) {
- ::lseek(mFH, numBytes, SEEK_CUR);
- }
-}
-
-int32_t FileInputStream::getPos() {
- return ::lseek(mFH, 0L, SEEK_CUR);
-}
-
-void FileInputStream::setPos(int32_t pos) {
- if (pos > 0) {
- ::lseek(mFH, pos, SEEK_SET);
- }
-}
-
-} /* namespace parselib */
diff --git a/externals/oboe/samples/parselib/src/main/cpp/stream/FileInputStream.h b/externals/oboe/samples/parselib/src/main/cpp/stream/FileInputStream.h deleted file mode 100644 index 95c9afa1bd..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/stream/FileInputStream.h +++ /dev/null @@ -1,49 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef _IO_STREAM_FILEINPUTSTREAM_H_
-#define _IO_STREAM_FILEINPUTSTREAM_H_
-
-#include "InputStream.h"
-
-namespace parselib {
-
-/**
- * A concrete implementation of InputStream for a file data source
- */
-class FileInputStream : public InputStream {
-public:
- /** constructor. Caller is presumed to have opened the file with (at least) read permission */
- FileInputStream(int fh) : mFH(fh) {}
- virtual ~FileInputStream() {}
-
- virtual int32_t read(void *buff, int32_t numBytes);
-
- virtual int32_t peek(void *buff, int32_t numBytes);
-
- virtual void advance(int32_t numBytes);
-
- virtual int32_t getPos();
-
- virtual void setPos(int32_t pos);
-
-private:
- /** File handle of the data file to read from */
- int mFH;
-};
-
-} // namespace parselib
-
-#endif // _IO_STREAM_FILEINPUTSTREAM_H_
diff --git a/externals/oboe/samples/parselib/src/main/cpp/stream/InputStream.cpp b/externals/oboe/samples/parselib/src/main/cpp/stream/InputStream.cpp deleted file mode 100644 index 747a401013..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/stream/InputStream.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "InputStream.h"
-
-namespace parselib {
-
-// All of the methods of InputStream are pure virtual
-
-} /* namespace wavlib */
diff --git a/externals/oboe/samples/parselib/src/main/cpp/stream/InputStream.h b/externals/oboe/samples/parselib/src/main/cpp/stream/InputStream.h deleted file mode 100644 index f9089d8ff9..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/stream/InputStream.h +++ /dev/null @@ -1,63 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef _IO_STREAM_INPUTSTREAM_H_
-#define _IO_STREAM_INPUTSTREAM_H_
-
-#include <cstdint>
-
-namespace parselib {
-
-/**
- * An interface declaration for a stream of bytes. Concrete implements for File and Memory Buffers
- */
-class InputStream {
-public:
- InputStream() {}
- virtual ~InputStream() {}
-
- /**
- * Retrieve the specified number of bytes and advance the read position.
- * Returns: The number of bytes actually retrieved. May be less than requested
- * if attempt to read beyond the end of the stream.
- */
- virtual int32_t read(void *buff, int32_t numBytes) = 0;
-
- /**
- * Retrieve the specified number of bytes. DOES NOT advance the read position.
- * Returns: The number of bytes actually retrieved. May be less than requested
- * if attempt to read beyond the end of the stream.
- */
- virtual int32_t peek(void *buff, int32_t numBytes) = 0;
-
- /**
- * Moves the read position forward the (positive) number of bytes specified.
- */
- virtual void advance(int32_t numBytes) = 0;
-
- /**
- * Returns the read position of the stream
- */
- virtual int32_t getPos() = 0;
-
- /**
- * Sets the read position of the stream to the 0 or positive position.
- */
- virtual void setPos(int32_t pos) = 0;
-};
-
-} // namespace parselib
-
-#endif // _IO_STREAM_INPUTSTREAM_H_
diff --git a/externals/oboe/samples/parselib/src/main/cpp/stream/MemInputStream.cpp b/externals/oboe/samples/parselib/src/main/cpp/stream/MemInputStream.cpp deleted file mode 100644 index 37d5a151bb..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/stream/MemInputStream.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <algorithm>
-#include <string.h>
-
-#include "MemInputStream.h"
-
-namespace parselib {
-
-int32_t MemInputStream::read(void *buff, int32_t numBytes) {
- int32_t numAvail = mBufferLen - mPos;
- numBytes = std::min(numBytes, numAvail);
-
- peek(buff, numBytes);
- mPos += numBytes;
- return numBytes;
-}
-
-int32_t MemInputStream::peek(void *buff, int32_t numBytes) {
- int32_t numAvail = mBufferLen - mPos;
- numBytes = std::min(numBytes, numAvail);
- memcpy(buff, mBuffer + mPos, numBytes);
- return numBytes;
-}
-
-void MemInputStream::advance(int32_t numBytes) {
- if (numBytes > 0) {
- int32_t numAvail = mBufferLen - mPos;
- mPos += std::min(numAvail, numBytes);
- }
-}
-
-int32_t MemInputStream::getPos() {
- return mPos;
-}
-
-void MemInputStream::setPos(int32_t pos) {
- if (pos > 0) {
- if (pos < mBufferLen) {
- mPos = pos;
- } else {
- mPos = mBufferLen - 1;
- }
- }
-}
-
-} // namespace parselib
diff --git a/externals/oboe/samples/parselib/src/main/cpp/stream/MemInputStream.h b/externals/oboe/samples/parselib/src/main/cpp/stream/MemInputStream.h deleted file mode 100644 index 9608c106ff..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/stream/MemInputStream.h +++ /dev/null @@ -1,55 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef _IO_STREAM_MEMINPUTSTREAM_H_
-#define _IO_STREAM_MEMINPUTSTREAM_H_
-
-#include "InputStream.h"
-
-namespace parselib {
-
-/**
- * A concrete implementation of InputStream for a memory buffer data source
- */
-class MemInputStream : public InputStream {
-public:
- /** constructor. Caller is presumed to have allocated and filled the memory buffer */
- MemInputStream(unsigned char *buff, int32_t len) : mBuffer(buff), mBufferLen(len), mPos(0) {}
- virtual ~MemInputStream() {}
-
- virtual int32_t read(void *buff, int32_t numBytes);
-
- virtual int32_t peek(void *buff, int32_t numBytes);
-
- virtual void advance(int32_t numBytes);
-
- virtual int32_t getPos();
-
- virtual void setPos(int32_t pos);
-
-private:
- /** Points to the data buffer to stream from. */
- unsigned char *mBuffer;
-
- /** Total number of bytes in the memory buffer */
- int32_t mBufferLen;
-
- /** The index of the next byte to read */
- int32_t mPos;
-};
-
-} // namespace parselib
-
-#endif // _IO_STREAM_MEMINPUTSTREAM_H_
diff --git a/externals/oboe/samples/parselib/src/main/cpp/wav/AudioEncoding.cpp b/externals/oboe/samples/parselib/src/main/cpp/wav/AudioEncoding.cpp deleted file mode 100644 index 3da041ab79..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/wav/AudioEncoding.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "AudioEncoding.h"
-
-namespace parselib {
-
-} // namespace wavlib
diff --git a/externals/oboe/samples/parselib/src/main/cpp/wav/AudioEncoding.h b/externals/oboe/samples/parselib/src/main/cpp/wav/AudioEncoding.h deleted file mode 100644 index 0a510739fa..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/wav/AudioEncoding.h +++ /dev/null @@ -1,36 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef _IO_WAV_AUDIOFORMAT_H_
-#define _IO_WAV_AUDIOFORMAT_H_
-
-namespace parselib {
-
-/**
- * Definitions for Audio Encodings in WAV files.
- */
-class AudioEncoding {
-public:
- static const int INVALID = -1;
- static const int PCM_16 = 0;
- static const int PCM_8 = 1;
- static const int PCM_IEEEFLOAT = 2;
- static const int PCM_24 = 3;
- static const int PCM_32 = 4;
-};
-
-} // namespace parselib
-
-#endif // _IO_WAV_AUDIOFORMAT_H_
diff --git a/externals/oboe/samples/parselib/src/main/cpp/wav/WavChunkHeader.cpp b/externals/oboe/samples/parselib/src/main/cpp/wav/WavChunkHeader.cpp deleted file mode 100644 index b10d85c874..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/wav/WavChunkHeader.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "stream/InputStream.h"
-
-#include "WavChunkHeader.h"
-
-namespace parselib {
-
-const RiffID WavChunkHeader::RIFFID_DATA = makeRiffID('d', 'a', 't', 'a');
-
-void WavChunkHeader::read(InputStream *stream) {
- stream->read(&mChunkId, sizeof(mChunkId));
- stream->read(&mChunkSize, sizeof(mChunkSize));
-}
-
-} // namespace parselib
diff --git a/externals/oboe/samples/parselib/src/main/cpp/wav/WavChunkHeader.h b/externals/oboe/samples/parselib/src/main/cpp/wav/WavChunkHeader.h deleted file mode 100644 index 07f6333d97..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/wav/WavChunkHeader.h +++ /dev/null @@ -1,50 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef _IO_WAV_WAVCHUNKHEADER_H_
-#define _IO_WAV_WAVCHUNKHEADER_H_
-
-#include "WavTypes.h"
-
-namespace parselib {
-
-class InputStream;
-
-/**
- * Superclass for all RIFF chunks. Handles the chunk ID and chunk size.
- * Concrete subclasses include chunks for 'RIFF' and 'fmt ' chunks.
- */
-class WavChunkHeader {
-public:
- static const RiffID RIFFID_DATA;
-
- RiffID mChunkId;
- RiffInt32 mChunkSize;
-
- WavChunkHeader() : mChunkId(0), mChunkSize(0) {}
-
- WavChunkHeader(RiffID chunkId) : mChunkId(chunkId), mChunkSize(0) {}
-
- /**
- * Reads the contents of the chunk. In this class, just the ID and size fields.
- * When implemented in a concrete subclass, that implementation MUST call this (super) method
- * as the first step. It may then read the fields specific to that chunk type.
- */
- virtual void read(InputStream *stream);
-};
-
-} // namespace parselib
-
-#endif // _IO_WAV_WAVCHUNKHEADER_H_
diff --git a/externals/oboe/samples/parselib/src/main/cpp/wav/WavFmtChunkHeader.cpp b/externals/oboe/samples/parselib/src/main/cpp/wav/WavFmtChunkHeader.cpp deleted file mode 100644 index 233e93334c..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/wav/WavFmtChunkHeader.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <android/log.h>
-
-#include "stream/InputStream.h"
-
-#include "WavFmtChunkHeader.h"
-
-static const char *TAG = "WavFmtChunkHeader";
-
-namespace parselib {
-
-const RiffID WavFmtChunkHeader::RIFFID_FMT = makeRiffID('f', 'm', 't', ' ');
-
-WavFmtChunkHeader::WavFmtChunkHeader() : WavChunkHeader(RIFFID_FMT) {
- mEncodingId = ENCODING_PCM;
- mNumChannels = 0;
- mSampleRate = 0;
- mAveBytesPerSecond = 0;
- mBlockAlign = 0;
- mSampleSize = 0;
- mExtraBytes = 0;
-}
-
-WavFmtChunkHeader::WavFmtChunkHeader(RiffID tag) : WavChunkHeader(tag) {
- mEncodingId = ENCODING_PCM;
- mNumChannels = 0;
- mSampleRate = 0;
- mAveBytesPerSecond = 0;
- mBlockAlign = 0;
- mSampleSize = 0;
- mExtraBytes = 0;
-}
-
-void WavFmtChunkHeader::normalize() {
- if (mEncodingId == ENCODING_PCM || mEncodingId == ENCODING_IEEE_FLOAT) {
- mBlockAlign = (short) (mNumChannels * (mSampleSize / 8));
- mAveBytesPerSecond = mSampleRate * mBlockAlign;
- mExtraBytes = 0;
- } else {
- //hmmm....
- }
-}
-
-void WavFmtChunkHeader::read(InputStream *stream) {
- WavChunkHeader::read(stream);
- stream->read(&mEncodingId, sizeof(mEncodingId));
- stream->read(&mNumChannels, sizeof(mNumChannels));
- stream->read(&mSampleRate, sizeof(mSampleRate));
- stream->read(&mAveBytesPerSecond, sizeof(mAveBytesPerSecond));
- stream->read(&mBlockAlign, sizeof(mBlockAlign));
- stream->read(&mSampleSize, sizeof(mSampleSize));
-
- if (mEncodingId != ENCODING_PCM && mEncodingId != ENCODING_IEEE_FLOAT) {
- // only read this if NOT PCM
- stream->read(&mExtraBytes, sizeof(mExtraBytes));
- } else {
- mExtraBytes = (short) (mChunkSize - 16);
- }
-}
-
-} // namespace parselib
diff --git a/externals/oboe/samples/parselib/src/main/cpp/wav/WavFmtChunkHeader.h b/externals/oboe/samples/parselib/src/main/cpp/wav/WavFmtChunkHeader.h deleted file mode 100644 index ab4d478dd3..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/wav/WavFmtChunkHeader.h +++ /dev/null @@ -1,56 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef _IO_WAV_WAVFMTCHUNKHEADER_H_
-#define _IO_WAV_WAVFMTCHUNKHEADER_H_
-
-#include "WavChunkHeader.h"
-
-class InputStream;
-
-namespace parselib {
-
-/**
- * Encapsulates a WAV file 'fmt ' chunk.
- */
-class WavFmtChunkHeader : public WavChunkHeader {
-public:
- static const RiffID RIFFID_FMT;
-
- // Microsoft Encoding IDs
- static const short ENCODING_PCM = 1;
- static const short ENCODING_ADPCM = 2; // Microsoft ADPCM Format
- static const short ENCODING_IEEE_FLOAT = 3; // samples from -1.0 -> 1.0
-
- RiffInt16 mEncodingId; /** Microsoft WAV encoding ID (see above) */
- RiffInt16 mNumChannels;
- RiffInt32 mSampleRate;
- RiffInt32 mAveBytesPerSecond;
- RiffInt16 mBlockAlign;
- RiffInt16 mSampleSize;
- RiffInt16 mExtraBytes;
-
- WavFmtChunkHeader();
-
- WavFmtChunkHeader(RiffID tag);
-
- void normalize();
-
- void read(InputStream *stream);
-};
-
-} // namespace parselib
-
-#endif // _IO_WAV_WAVFMTCHUNKHEADER_H_
diff --git a/externals/oboe/samples/parselib/src/main/cpp/wav/WavRIFFChunkHeader.cpp b/externals/oboe/samples/parselib/src/main/cpp/wav/WavRIFFChunkHeader.cpp deleted file mode 100644 index 27c8e6382c..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/wav/WavRIFFChunkHeader.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "WavRIFFChunkHeader.h"
-#include "stream/InputStream.h"
-
-namespace parselib {
-
-const RiffID WavRIFFChunkHeader::RIFFID_RIFF = makeRiffID('R', 'I', 'F', 'F');
-const RiffID WavRIFFChunkHeader::RIFFID_WAVE = makeRiffID('W', 'A', 'V', 'E');
-
-WavRIFFChunkHeader::WavRIFFChunkHeader() : WavChunkHeader(RIFFID_RIFF) {
- mFormatId = RIFFID_WAVE;
-}
-
-WavRIFFChunkHeader::WavRIFFChunkHeader(RiffID tag) : WavChunkHeader(tag) {
- mFormatId = RIFFID_WAVE;
-}
-
-void WavRIFFChunkHeader::read(InputStream *stream) {
- WavChunkHeader::read(stream);
- stream->read(&mFormatId, sizeof(mFormatId));
-}
-
-} // namespace parselib
diff --git a/externals/oboe/samples/parselib/src/main/cpp/wav/WavRIFFChunkHeader.h b/externals/oboe/samples/parselib/src/main/cpp/wav/WavRIFFChunkHeader.h deleted file mode 100644 index f9e6af03e2..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/wav/WavRIFFChunkHeader.h +++ /dev/null @@ -1,42 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef _IO_WAV_WAVRIFFCHUNKHEADER_H_
-#define _IO_WAV_WAVRIFFCHUNKHEADER_H_
-
-#include "WavChunkHeader.h"
-
-namespace parselib {
-
-class InputStream;
-
-class WavRIFFChunkHeader : public WavChunkHeader {
-public:
- static const RiffID RIFFID_RIFF;
-
- static const RiffID RIFFID_WAVE;
-
- RiffID mFormatId;
-
- WavRIFFChunkHeader();
-
- WavRIFFChunkHeader(RiffID tag);
-
- virtual void read(InputStream *stream);
-};
-
-} // namespace parselib
-
-#endif // _IO_WAV_WAVRIFFCHUNKHEADER_H_
diff --git a/externals/oboe/samples/parselib/src/main/cpp/wav/WavStreamReader.cpp b/externals/oboe/samples/parselib/src/main/cpp/wav/WavStreamReader.cpp deleted file mode 100644 index ba59c9ee94..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/wav/WavStreamReader.cpp +++ /dev/null @@ -1,319 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <algorithm>
-#include <string.h>
-
-#include <android/log.h>
-
-#include "stream/InputStream.h"
-
-#include "AudioEncoding.h"
-#include "WavRIFFChunkHeader.h"
-#include "WavFmtChunkHeader.h"
-#include "WavChunkHeader.h"
-#include "WavStreamReader.h"
-
-static const char *TAG = "WavStreamReader";
-
-static constexpr int kConversionBufferFrames = 16;
-
-namespace parselib {
-
-WavStreamReader::WavStreamReader(InputStream *stream) {
- mStream = stream;
-
- mWavChunk = nullptr;
- mFmtChunk = nullptr;
- mDataChunk = nullptr;
-
- mAudioDataStartPos = -1;
-}
-
-int WavStreamReader::getSampleEncoding() {
- if (mFmtChunk->mEncodingId == WavFmtChunkHeader::ENCODING_PCM) {
- switch (mFmtChunk->mSampleSize) {
- case 8:
- return AudioEncoding::PCM_8;
-
- case 16:
- return AudioEncoding::PCM_16;
-
- case 24:
- return AudioEncoding::PCM_24;
-
- case 32:
- return AudioEncoding::PCM_32;
-
- default:
- return AudioEncoding::INVALID;
- }
- } else if (mFmtChunk->mEncodingId == WavFmtChunkHeader::ENCODING_IEEE_FLOAT) {
- return AudioEncoding::PCM_IEEEFLOAT;
- }
-
- return AudioEncoding::INVALID;
-}
-
-void WavStreamReader::parse() {
- RiffID tag;
-
- while (true) {
- int numRead = mStream->peek(&tag, sizeof(tag));
- if (numRead <= 0) {
- break; // done
- }
-
-// char *tagStr = (char *) &tag;
-// __android_log_print(ANDROID_LOG_INFO, TAG, "[%c%c%c%c]",
-// tagStr[0], tagStr[1], tagStr[2], tagStr[3]);
-
- std::shared_ptr<WavChunkHeader> chunk = nullptr;
- if (tag == WavRIFFChunkHeader::RIFFID_RIFF) {
- chunk = mWavChunk = std::make_shared<WavRIFFChunkHeader>(WavRIFFChunkHeader(tag));
- mWavChunk->read(mStream);
- } else if (tag == WavFmtChunkHeader::RIFFID_FMT) {
- chunk = mFmtChunk = std::make_shared<WavFmtChunkHeader>(WavFmtChunkHeader(tag));
- mFmtChunk->read(mStream);
- } else if (tag == WavChunkHeader::RIFFID_DATA) {
- chunk = mDataChunk = std::make_shared<WavChunkHeader>(WavChunkHeader(tag));
- mDataChunk->read(mStream);
- // We are now positioned at the start of the audio data.
- mAudioDataStartPos = mStream->getPos();
- mStream->advance(mDataChunk->mChunkSize);
- } else {
- chunk = std::make_shared<WavChunkHeader>(WavChunkHeader(tag));
- chunk->read(mStream);
- mStream->advance(chunk->mChunkSize); // skip the body
- }
-
- mChunkMap[tag] = chunk;
- }
-
- if (mDataChunk != 0) {
- mStream->setPos(mAudioDataStartPos);
- }
-}
-
-// Data access
-void WavStreamReader::positionToAudio() {
- if (mDataChunk != 0) {
- mStream->setPos(mAudioDataStartPos);
- }
-}
-
-/**
- * Read and convert samples in PCM8 format to float
- */
-int WavStreamReader::getDataFloat_PCM8(float *buff, int numFrames) {
- int numChannels = mFmtChunk->mNumChannels;
-
- int buffOffset = 0;
- int totalFramesRead = 0;
-
- static constexpr int kSampleSize = sizeof(u_int8_t);
- static constexpr float kSampleFullScale = (float)0x80;
- static constexpr float kInverseScale = 1.0f / kSampleFullScale;
-
- u_int8_t readBuff[kConversionBufferFrames * numChannels];
- int framesLeft = numFrames;
- while (framesLeft > 0) {
- int framesThisRead = std::min(framesLeft, kConversionBufferFrames);
- //__android_log_print(ANDROID_LOG_INFO, TAG, "read(%d)", framesThisRead);
- int numFramesRead =
- mStream->read(readBuff, framesThisRead * kSampleSize * numChannels) /
- (kSampleSize * numChannels);
- totalFramesRead += numFramesRead;
-
- // Convert & Scale
- for (int offset = 0; offset < numFramesRead * numChannels; offset++) {
- // PCM8 is unsigned, so we need to make it signed before scaling/converting
- buff[buffOffset++] = ((float) readBuff[offset] - kSampleFullScale)
- * kInverseScale;
- }
-
- if (numFramesRead < framesThisRead) {
- break; // none left
- }
-
- framesLeft -= framesThisRead;
- }
-
- return totalFramesRead;
-}
-
-/**
- * Read and convert samples in PCM16 format to float
- */
-int WavStreamReader::getDataFloat_PCM16(float *buff, int numFrames) {
- int numChannels = mFmtChunk->mNumChannels;
-
- int buffOffset = 0;
- int totalFramesRead = 0;
-
- static constexpr int kSampleSize = sizeof(int16_t);
- static constexpr float kSampleFullScale = (float) 0x8000;
- static constexpr float kInverseScale = 1.0f / kSampleFullScale;
-
- int16_t readBuff[kConversionBufferFrames * numChannels];
- int framesLeft = numFrames;
- while (framesLeft > 0) {
- int framesThisRead = std::min(framesLeft, kConversionBufferFrames);
- //__android_log_print(ANDROID_LOG_INFO, TAG, "read(%d)", framesThisRead);
- int numFramesRead =
- mStream->read(readBuff, framesThisRead * kSampleSize * numChannels) /
- (kSampleSize * numChannels);
- totalFramesRead += numFramesRead;
-
- // Convert & Scale
- for (int offset = 0; offset < numFramesRead * numChannels; offset++) {
- buff[buffOffset++] = (float) readBuff[offset] * kInverseScale;
- }
-
- if (numFramesRead < framesThisRead) {
- break; // none left
- }
-
- framesLeft -= framesThisRead;
- }
-
- return totalFramesRead;
-}
-
-/**
- * Read and convert samples in PCM24 format to float
- */
-int WavStreamReader::getDataFloat_PCM24(float *buff, int numFrames) {
- int numChannels = mFmtChunk->mNumChannels;
- int numSamples = numFrames * numChannels;
-
- static constexpr float kSampleFullScale = (float) 0x80000000;
- static constexpr float kInverseScale = 1.0f / kSampleFullScale;
-
- uint8_t buffer[3];
- for(int sampleIndex = 0; sampleIndex < numSamples; sampleIndex++) {
- if (mStream->read(buffer, 3) < 3) {
- break; // no more data
- }
- int32_t sample = (buffer[0] << 8) | (buffer[1] << 16) | (buffer[2] << 24);
- buff[sampleIndex] = (float)sample * kInverseScale;
- }
-
- return numFrames;
-}
-
-/**
- * Read and convert samples in Float32 format to float
- */
-int WavStreamReader::getDataFloat_Float32(float *buff, int numFrames) {
- // Turns out that WAV Float32 is just Android floats
- int numChannels = mFmtChunk->mNumChannels;
-
- return mStream->read(buff, numFrames * sizeof(float) * numChannels) /
- (sizeof(float) * numChannels);
-}
-
-/**
- * Read and convert samples in PCM32 format to float
- */
-int WavStreamReader::getDataFloat_PCM32(float *buff, int numFrames) {
- int numChannels = mFmtChunk->mNumChannels;
-
- int buffOffset = 0;
- int totalFramesRead = 0;
-
- static constexpr int kSampleSize = sizeof(int32_t);
- static constexpr float kSampleFullScale = (float) 0x80000000;
- static constexpr float kInverseScale = 1.0f / kSampleFullScale;
-
- int32_t readBuff[kConversionBufferFrames * numChannels];
- int framesLeft = numFrames;
- while (framesLeft > 0) {
- int framesThisRead = std::min(framesLeft, kConversionBufferFrames);
- //__android_log_print(ANDROID_LOG_INFO, TAG, "read(%d)", framesThisRead);
- int numFramesRead =
- mStream->read(readBuff, framesThisRead * kSampleSize* numChannels) /
- (kSampleSize * numChannels);
- totalFramesRead += numFramesRead;
-
- // convert & Scale
- for (int offset = 0; offset < numFramesRead * numChannels; offset++) {
- buff[buffOffset++] = (float) readBuff[offset] * kInverseScale;
- }
-
- if (numFramesRead < framesThisRead) {
- break; // none left
- }
-
- framesLeft -= framesThisRead;
- }
-
- return totalFramesRead;
-}
-
-int WavStreamReader::getDataFloat(float *buff, int numFrames) {
- // __android_log_print(ANDROID_LOG_INFO, TAG, "getData(%d)", numFrames);
-
- if (mDataChunk == nullptr || mFmtChunk == nullptr) {
- return ERR_INVALID_STATE;
- }
-
- int numFramesRead = 0;
- switch (mFmtChunk->mSampleSize) {
- case 8:
- numFramesRead = getDataFloat_PCM8(buff, numFrames);
- break;
-
- case 16:
- numFramesRead = getDataFloat_PCM16(buff, numFrames);
- break;
-
- case 24:
- if (mFmtChunk->mEncodingId == WavFmtChunkHeader::ENCODING_PCM) {
- numFramesRead = getDataFloat_PCM24(buff, numFrames);
- } else {
- __android_log_print(ANDROID_LOG_INFO, TAG, "invalid encoding:%d mSampleSize:%d",
- mFmtChunk->mEncodingId, mFmtChunk->mSampleSize);
- }
- break;
-
- case 32:
- if (mFmtChunk->mEncodingId == WavFmtChunkHeader::ENCODING_PCM) {
- numFramesRead = getDataFloat_PCM32(buff, numFrames);
- } else if (mFmtChunk->mEncodingId == WavFmtChunkHeader::ENCODING_IEEE_FLOAT) {
- numFramesRead = getDataFloat_Float32(buff, numFrames);
- } else {
- __android_log_print(ANDROID_LOG_INFO, TAG, "invalid encoding:%d mSampleSize:%d",
- mFmtChunk->mEncodingId, mFmtChunk->mSampleSize);
- }
- break;
-
- default:
- __android_log_print(ANDROID_LOG_INFO, TAG, "invalid encoding:%d mSampleSize:%d",
- mFmtChunk->mEncodingId, mFmtChunk->mSampleSize);
- return ERR_INVALID_FORMAT;
- }
-
- // Zero out any unread frames
- if (numFramesRead < numFrames) {
- int numChannels = getNumChannels();
- memset(buff + (numFramesRead * numChannels), 0,
- (numFrames - numFramesRead) * sizeof(buff[0]) * numChannels);
- }
-
- return numFramesRead;
-}
-
-} // namespace parselib
diff --git a/externals/oboe/samples/parselib/src/main/cpp/wav/WavStreamReader.h b/externals/oboe/samples/parselib/src/main/cpp/wav/WavStreamReader.h deleted file mode 100644 index 1f7ee12f97..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/wav/WavStreamReader.h +++ /dev/null @@ -1,89 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef _IO_WAV_WAVSTREAMREADER_H_
-#define _IO_WAV_WAVSTREAMREADER_H_
-
-#include <map>
-
-#include "AudioEncoding.h"
-#include "WavRIFFChunkHeader.h"
-#include "WavFmtChunkHeader.h"
-
-/*
- * WAV format documentation can be found:
- * http://soundfile.sapp.org/doc/WaveFormat/
- * https://web.archive.org/web/20090417165828/http://www.kk.iij4u.or.jp/~kondo/wave/mpidata.txt
- */
-namespace parselib {
-
-class InputStream;
-
-class WavStreamReader {
-public:
- WavStreamReader(InputStream *stream);
-
- int getSampleRate() { return mFmtChunk->mSampleRate; }
-
- int getNumSampleFrames() {
- return mDataChunk->mChunkSize / (mFmtChunk->mSampleSize / 8) / mFmtChunk->mNumChannels;
- }
-
- int getNumChannels() { return mFmtChunk != 0 ? mFmtChunk->mNumChannels : 0; }
-
- int getSampleEncoding();
-
- int getBitsPerSample() { return mFmtChunk->mSampleSize; }
-
- void parse();
-
- // Data access
- void positionToAudio();
-
- static constexpr int ERR_INVALID_FORMAT = -1;
- static constexpr int ERR_INVALID_STATE = -2;
-
- int getDataFloat(float *buff, int numFrames);
-
- // int getData16(short *buff, int numFramees);
-
-protected:
- InputStream *mStream;
-
- std::shared_ptr<WavRIFFChunkHeader> mWavChunk;
- std::shared_ptr<WavFmtChunkHeader> mFmtChunk;
- std::shared_ptr<WavChunkHeader> mDataChunk;
-
- long mAudioDataStartPos;
-
- std::map<RiffID, std::shared_ptr<WavChunkHeader>> mChunkMap;
-
-private:
- /*
- * Individual Format Readers/Converters
- */
- int getDataFloat_PCM8(float *buff, int numFrames);
-
- int getDataFloat_PCM16(float *buff, int numFrames);
-
- int getDataFloat_PCM24(float *buff, int numFrames);
-
- int getDataFloat_Float32(float *buff, int numFrames);
- int getDataFloat_PCM32(float *buff, int numFrames);
-};
-
-} // namespace parselib
-
-#endif // _IO_WAV_WAVSTREAMREADER_H_
diff --git a/externals/oboe/samples/parselib/src/main/cpp/wav/WavTypes.h b/externals/oboe/samples/parselib/src/main/cpp/wav/WavTypes.h deleted file mode 100644 index 89af7cda3b..0000000000 --- a/externals/oboe/samples/parselib/src/main/cpp/wav/WavTypes.h +++ /dev/null @@ -1,38 +0,0 @@ -/*
- * Copyright 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#ifndef __WAVTYPES_H__
-#define __WAVTYPES_H__
-
-namespace parselib {
-
-/*
- * Declarations for various (cross-platform) WAV-specific data types.
- */
-typedef unsigned int RiffID; // A "four character code" (i.e. FOURCC)
-typedef int RiffInt32; // A 32-bit signed integer
-typedef short RiffInt16; // A 16-bit signed integer
-
-/*
- * Packs the specified characters into a 32-bit value in accordance with the Microsoft
- * FOURCC specification.
- */
-inline RiffID makeRiffID(char a, char b, char c, char d) {
- return ((RiffID)d << 24) | ((RiffID)c << 16) | ((RiffID)b << 8) | (RiffID)a;
-}
-
-} // namespace parselib
-
-#endif /* __WAVTYPES_H__ */
|
