Compare commits
10 Commits
c421c16cd3
...
c64ae3c2f0
| Author | SHA1 | Date | |
|---|---|---|---|
|
c64ae3c2f0
|
|||
| 7d7d8b6291 | |||
| ba50d482c0 | |||
| be0443e468 | |||
|
|
16d8c5a0ce | ||
|
|
aeadb2285f | ||
|
|
6168450fd7 | ||
|
|
7e1f433b1d | ||
|
|
703d33110f | ||
|
|
82b49e9102 |
82
.gitea/workflows/build.yml
Normal file
82
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
name: Build bannertool
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-linux:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Install Tools
|
||||||
|
run: |
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y build-essential make cmake zip \
|
||||||
|
gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \
|
||||||
|
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \
|
||||||
|
gcc-x86-64-linux-gnu g++-x86-64-linux-gnu \
|
||||||
|
gcc-i686-linux-gnu g++-i686-linux-gnu \
|
||||||
|
gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64
|
||||||
|
- name: Download Cross-Build
|
||||||
|
run: git clone https://dev.npid7.de/tobid7/cross-build
|
||||||
|
- name: Build Targets
|
||||||
|
run: |
|
||||||
|
declare -A TARGETS=(
|
||||||
|
["linux-i386"]="-DCMAKE_TOOLCHAIN_FILE=cross-build/cmake/linux-i386.cmake"
|
||||||
|
["linux-x86_64"]="-DCMAKE_TOOLCHAIN_FILE=cross-build/cmake/linux-x86_64.cmake"
|
||||||
|
["linux-armhf"]="-DCMAKE_TOOLCHAIN_FILE=cross-build/cmake/linux-armhf.cmake"
|
||||||
|
["linux-aarch64"]="-DCMAKE_TOOLCHAIN_FILE=cross-build/cmake/linux-aarch64.cmake"
|
||||||
|
["windows-x86_64"]="-DCMAKE_TOOLCHAIN_FILE=cross-build/cmake/windows-mingw-x86_64.cmake"
|
||||||
|
)
|
||||||
|
|
||||||
|
for name in "${!TARGETS[@]}"; do
|
||||||
|
cmake ${TARGETS[$name]} -DCMAKE_INSTALL_PREFIX=bin-$name -B build-$name .
|
||||||
|
cmake --build build-$name --parallel
|
||||||
|
cmake --install build-$name
|
||||||
|
mkdir -p artifacts/$name
|
||||||
|
cp -r bin-$name/* artifacts/$name/
|
||||||
|
done
|
||||||
|
build-macos:
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cmake -DCMAKE_INSTALL_PREFIX=bin-macos-universal -DCMAKE_OSX_ARCHITECURE="x86_64;arm64" -B build .
|
||||||
|
cmake --build build
|
||||||
|
cmake --install build
|
||||||
|
cp -r bin-macos-universal/* artifacts/macos-universal/
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [build-linux, build-macos]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Prepare Files
|
||||||
|
run: |
|
||||||
|
mkdir -p release_files
|
||||||
|
for d in artifacts/*; do
|
||||||
|
name=$(basename "$d")
|
||||||
|
zip -r "release_files/$name.zip" "$d"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Get Date
|
||||||
|
run: echo "TAG_NAME=v$(date -u +'%Y%m%d-%H%M%S')" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Upload to Gitea
|
||||||
|
uses: akkuman/gitea-release-action@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.TOKEN }}
|
||||||
|
prerelease: true
|
||||||
|
name: "Dev build ${{ env.TAG_NAME }}"
|
||||||
|
tag_name: ${{ env.TAG_NAME }}
|
||||||
|
body: |
|
||||||
|
**Automated build**
|
||||||
|
Commit: ${{ github.sha }}
|
||||||
|
Triggered by: ${{ github.actor }}
|
||||||
|
files: release_files/*.zip
|
||||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,6 +1,2 @@
|
|||||||
.idea
|
.idea
|
||||||
cmake-build-debug
|
cmake-build-debug
|
||||||
CMakeLists.txt
|
|
||||||
|
|
||||||
build
|
|
||||||
output
|
|
||||||
|
|||||||
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -1,4 +0,0 @@
|
|||||||
[submodule "buildtools"]
|
|
||||||
path = buildtools
|
|
||||||
url = git://github.com/Steveice10/buildtools
|
|
||||||
shallow = true
|
|
||||||
42
CMakeLists.txt
Normal file
42
CMakeLists.txt
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
|
project(bannertool)
|
||||||
|
|
||||||
|
# add definition for alloca
|
||||||
|
# otherwise stb_vorbis fails
|
||||||
|
if(MSVC)
|
||||||
|
add_compile_definitions(alloca=_alloca)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# define version
|
||||||
|
set(VERSION_MAJOR "1")
|
||||||
|
set(VERSION_MINOR "2")
|
||||||
|
set(VERSION_MICRO "0")
|
||||||
|
|
||||||
|
# Add executable
|
||||||
|
add_executable(bannertool
|
||||||
|
source/cmd.cpp
|
||||||
|
source/main.cpp
|
||||||
|
source/pc/stb_image.c
|
||||||
|
source/pc/stb_vorbis.c
|
||||||
|
source/pc/wav.cpp
|
||||||
|
source/3ds/cbmd.cpp
|
||||||
|
source/3ds/cwav.cpp
|
||||||
|
source/3ds/lz11.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# set include dirs
|
||||||
|
target_include_directories(bannertool PUBLIC
|
||||||
|
source
|
||||||
|
source/3ds
|
||||||
|
source/pc
|
||||||
|
)
|
||||||
|
|
||||||
|
# define VERSION
|
||||||
|
target_compile_definitions(bannertool PUBLIC
|
||||||
|
-DVERSION_MAJOR=${VERSION_MAJOR}
|
||||||
|
-DVERSION_MINOR=${VERSION_MINOR}
|
||||||
|
-DVERSION_MICRO=${VERSION_MICRO}
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS bannertool DESTINATION bin)
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
Copyright (C) 2024-2025 tobid7
|
||||||
Copyright (C) 2015-2017 Steveice10
|
Copyright (C) 2015-2017 Steveice10
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|||||||
39
Makefile
39
Makefile
@@ -1,39 +0,0 @@
|
|||||||
# TARGET #
|
|
||||||
|
|
||||||
TARGET := NATIVE
|
|
||||||
LIBRARY := 0
|
|
||||||
|
|
||||||
ifeq ($(TARGET),$(filter $(TARGET),3DS WIIU))
|
|
||||||
ifeq ($(strip $(DEVKITPRO)),)
|
|
||||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro")
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
# COMMON CONFIGURATION #
|
|
||||||
|
|
||||||
NAME := bannertool
|
|
||||||
|
|
||||||
BUILD_DIR := build
|
|
||||||
OUTPUT_DIR := output
|
|
||||||
INCLUDE_DIRS := include
|
|
||||||
SOURCE_DIRS := source
|
|
||||||
|
|
||||||
EXTRA_OUTPUT_FILES :=
|
|
||||||
|
|
||||||
LIBRARY_DIRS :=
|
|
||||||
LIBRARIES :=
|
|
||||||
|
|
||||||
BUILD_FLAGS := -Wno-unused-function
|
|
||||||
BUILD_FLAGS_CC :=
|
|
||||||
BUILD_FLAGS_CXX :=
|
|
||||||
RUN_FLAGS :=
|
|
||||||
|
|
||||||
VERSION_PARTS := $(subst ., ,$(shell git describe --tags --abbrev=0))
|
|
||||||
|
|
||||||
VERSION_MAJOR := $(word 1, $(VERSION_PARTS))
|
|
||||||
VERSION_MINOR := $(word 2, $(VERSION_PARTS))
|
|
||||||
VERSION_MICRO := $(word 3, $(VERSION_PARTS))
|
|
||||||
|
|
||||||
# INTERNAL #
|
|
||||||
|
|
||||||
include buildtools/make_base
|
|
||||||
@@ -1,3 +1,11 @@
|
|||||||
# bannertool
|
# bannertool
|
||||||
|
|
||||||
A tool for creating 3DS banners.
|
A tool for creating 3DS banners.
|
||||||
|
|
||||||
|
## How to build (Using Docker)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker build -t bannertool-builder .
|
||||||
|
docker run --name bannertool-builder bannertool-builder
|
||||||
|
docker cp bannertool-builder:/bannertool/output/bannertool.zip .
|
||||||
|
```
|
||||||
|
|||||||
Submodule buildtools deleted from 4524b3a324
@@ -113,11 +113,14 @@ void* lz11_compress(u32* size, void* input, u32 inputSize) {
|
|||||||
|
|
||||||
if(compressedLength % 4 != 0) {
|
if(compressedLength % 4 != 0) {
|
||||||
u32 padLength = 4 - (compressedLength % 4);
|
u32 padLength = 4 - (compressedLength % 4);
|
||||||
u8 pad[padLength];
|
// Small patch to prevent msvc error
|
||||||
|
u8* pad = new u8[padLength];
|
||||||
memset(pad, 0, (size_t) padLength);
|
memset(pad, 0, (size_t) padLength);
|
||||||
|
|
||||||
ss.write((char*) pad, padLength);
|
ss.write((char*) pad, padLength);
|
||||||
compressedLength += padLength;
|
compressedLength += padLength;
|
||||||
|
// Need to delete as not dynamic
|
||||||
|
delete[] pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* buf = malloc((size_t) compressedLength);
|
void* buf = malloc((size_t) compressedLength);
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
u8 gameRatings[SMDH_NUM_RATING_SLOTS];
|
u8 gameRatings[SMDH_NUM_RATING_SLOTS];
|
||||||
u32 regionLock;
|
u32 regionLock;
|
||||||
u8 matchMakerId[0xC];
|
u32 matchMakerId;
|
||||||
|
u64 matchMakerBitId;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
u16 eulaVersion;
|
u16 eulaVersion;
|
||||||
u16 reserved1;
|
u16 reserved1;
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <codecvt>
|
||||||
|
#include <locale>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -21,18 +23,20 @@ typedef enum {
|
|||||||
RGBA4444
|
RGBA4444
|
||||||
} PixelFormat;
|
} PixelFormat;
|
||||||
|
|
||||||
static void utf8_to_utf16(u16* dst, const char* src, size_t maxLen) {
|
static void utf8_to_utf16(u16* dst, const std::string& src, size_t maxLen) {
|
||||||
if(maxLen == 0) {
|
if(maxLen == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t n = 0;
|
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> converter;
|
||||||
while(src[n]) {
|
std::u16string str16 = converter.from_bytes(src.data());
|
||||||
dst[n] = (u16) src[n];
|
|
||||||
if(n++ >= maxLen) {
|
size_t copyLen = str16.length() * sizeof(char16_t);
|
||||||
return;
|
if(copyLen > maxLen) {
|
||||||
}
|
copyLen = maxLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memcpy(dst, str16.data(), copyLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* read_file(u32* size, const std::string& file) {
|
static void* read_file(u32* size, const std::string& file) {
|
||||||
@@ -504,6 +508,7 @@ static void cmd_print_info(const std::string& command) {
|
|||||||
printf(" -f/--flags: Optional. Flags to apply to the SMDH file.\n");
|
printf(" -f/--flags: Optional. Flags to apply to the SMDH file.\n");
|
||||||
printf(" Valid flags: visible, autoboot, allow3d, requireeula, autosave, extendedbanner, ratingrequired, savedata, recordusage, nosavebackups, new3ds.\n");
|
printf(" Valid flags: visible, autoboot, allow3d, requireeula, autosave, extendedbanner, ratingrequired, savedata, recordusage, nosavebackups, new3ds.\n");
|
||||||
printf(" -mmid/--matchmakerid: Optional. Match maker ID of the SMDH.\n");
|
printf(" -mmid/--matchmakerid: Optional. Match maker ID of the SMDH.\n");
|
||||||
|
printf(" -mmbid/--matchmakerbitid: Optional. Match maker BIT ID of the SMDH.\n");
|
||||||
printf(" -ev/--eulaversion: Optional. Version of the EULA required to be accepted before launching.\n");
|
printf(" -ev/--eulaversion: Optional. Version of the EULA required to be accepted before launching.\n");
|
||||||
printf(" -obf/--optimalbannerframe: Optional. Optimal frame of the accompanying banner.\n");
|
printf(" -obf/--optimalbannerframe: Optional. Optimal frame of the accompanying banner.\n");
|
||||||
printf(" -spid/--streetpassid: Optional. Streetpass ID of the SMDH.\n");
|
printf(" -spid/--streetpassid: Optional. Streetpass ID of the SMDH.\n");
|
||||||
@@ -642,9 +647,9 @@ int cmd_process_command(int argc, char* argv[]) {
|
|||||||
longTitleFound = longTitleFound || !currLongTitle.empty();
|
longTitleFound = longTitleFound || !currLongTitle.empty();
|
||||||
publisherFound = publisherFound || !currPublisher.empty();
|
publisherFound = publisherFound || !currPublisher.empty();
|
||||||
|
|
||||||
utf8_to_utf16(smdh.titles[i].shortTitle, currShortTitle.c_str(), sizeof(smdh.titles[i].shortTitle) / 2);
|
utf8_to_utf16(smdh.titles[i].shortTitle, currShortTitle, sizeof(smdh.titles[i].shortTitle) / 2);
|
||||||
utf8_to_utf16(smdh.titles[i].longTitle, currLongTitle.c_str(), sizeof(smdh.titles[i].longTitle) / 2);
|
utf8_to_utf16(smdh.titles[i].longTitle, currLongTitle, sizeof(smdh.titles[i].longTitle) / 2);
|
||||||
utf8_to_utf16(smdh.titles[i].publisher, currPublisher.c_str(), sizeof(smdh.titles[i].publisher) / 2);
|
utf8_to_utf16(smdh.titles[i].publisher, currPublisher, sizeof(smdh.titles[i].publisher) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!shortTitleFound || !longTitleFound || !publisherFound) {
|
if(!shortTitleFound || !longTitleFound || !publisherFound) {
|
||||||
@@ -709,12 +714,12 @@ int cmd_process_command(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 matchMakerId = (u64) atoll(cmd_find_arg(args, "mmid", "matchmakerid", "0").c_str());
|
smdh.settings.matchMakerId = (u32) atoi(cmd_find_arg(args, "mmid", "matchmakerid", "0").c_str());
|
||||||
memcpy(smdh.settings.matchMakerId, &matchMakerId, 0xC);
|
smdh.settings.matchMakerBitId = (u64) atoll(cmd_find_arg(args, "mmbid", "matchmakerbitid", "0").c_str());
|
||||||
|
|
||||||
smdh.settings.eulaVersion = (u16) atoi(cmd_find_arg(args, "ev", "eulaversion", "0").c_str());
|
smdh.settings.eulaVersion = (u16) atoi(cmd_find_arg(args, "ev", "eulaversion", "0").c_str());
|
||||||
smdh.settings.optimalBannerFrame = (u32) atoll(cmd_find_arg(args, "obf", "optimalbannerframe", "0").c_str());
|
smdh.settings.optimalBannerFrame = (u32) atoi(cmd_find_arg(args, "obf", "optimalbannerframe", "0").c_str());
|
||||||
smdh.settings.streetpassId = (u32) atoll(cmd_find_arg(args, "spid", "streetpassid", "0").c_str());
|
smdh.settings.streetpassId = (u32) atoi(cmd_find_arg(args, "spid", "streetpassid", "0").c_str());
|
||||||
|
|
||||||
smdh.settings.gameRatings[SMDH_RATING_CERO] = (u8) atoi(cmd_find_arg(args, "cer", "cero", "0").c_str());
|
smdh.settings.gameRatings[SMDH_RATING_CERO] = (u8) atoi(cmd_find_arg(args, "cer", "cero", "0").c_str());
|
||||||
smdh.settings.gameRatings[SMDH_RATING_ESRB] = (u8) atoi(cmd_find_arg(args, "er", "esrb", "0").c_str());
|
smdh.settings.gameRatings[SMDH_RATING_ESRB] = (u8) atoi(cmd_find_arg(args, "er", "esrb", "0").c_str());
|
||||||
@@ -731,8 +736,8 @@ int cmd_process_command(int argc, char* argv[]) {
|
|||||||
const std::string input = cmd_find_arg(args, "i", "input", "");
|
const std::string input = cmd_find_arg(args, "i", "input", "");
|
||||||
const std::string output = cmd_find_arg(args, "o", "output", "");
|
const std::string output = cmd_find_arg(args, "o", "output", "");
|
||||||
std::string loop = cmd_find_arg(args, "l", "loop", "false");
|
std::string loop = cmd_find_arg(args, "l", "loop", "false");
|
||||||
u32 loopStartFrame = (u32) atol(cmd_find_arg(args, "s", "loopstartframe", "0").c_str());
|
u32 loopStartFrame = (u32) atoi(cmd_find_arg(args, "s", "loopstartframe", "0").c_str());
|
||||||
u32 loopEndFrame = (u32) atol(cmd_find_arg(args, "e", "loopendframe", "0").c_str());
|
u32 loopEndFrame = (u32) atoi(cmd_find_arg(args, "e", "loopendframe", "0").c_str());
|
||||||
if(input.empty() || output.empty()) {
|
if(input.empty() || output.empty()) {
|
||||||
cmd_missing_args(command);
|
cmd_missing_args(command);
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "wav.h"
|
#include "wav.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -45,7 +46,7 @@ WAV* wav_read(FILE* fd) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char error[128] = {'\0'};
|
std::string error = "";
|
||||||
bool riff = false;
|
bool riff = false;
|
||||||
bool fmt = false;
|
bool fmt = false;
|
||||||
bool data = false;
|
bool data = false;
|
||||||
@@ -54,23 +55,23 @@ WAV* wav_read(FILE* fd) {
|
|||||||
memset(&context, 0, sizeof(context));
|
memset(&context, 0, sizeof(context));
|
||||||
context.fd = fd;
|
context.fd = fd;
|
||||||
|
|
||||||
while(strlen(error) == 0 && (!riff || !fmt || !data) && wav_next_chunk(&context)) {
|
while(error.empty() && (!riff || !fmt || !data) && wav_next_chunk(&context)) {
|
||||||
if(memcmp(context.currChunk.chunkId, "RIFF", 4) == 0) {
|
if(memcmp(context.currChunk.chunkId, "RIFF", 4) == 0) {
|
||||||
riff = true;
|
riff = true;
|
||||||
|
|
||||||
char format[4];
|
char format[4];
|
||||||
if(wav_read_chunk_data(&context, format, sizeof(format))) {
|
if(wav_read_chunk_data(&context, format, sizeof(format))) {
|
||||||
if(memcmp(format, "WAVE", sizeof(format)) != 0) {
|
if(memcmp(format, "WAVE", sizeof(format)) != 0) {
|
||||||
strncpy(error, "ERROR: RIFF file is not of WAVE format", sizeof(error));
|
error = "ERROR: RIFF file is not of WAVE format";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
strncpy(error, "ERROR: Failed to read RIFF chunk data", sizeof(error));
|
error = "ERROR: Failed to read RIFF chunk data";
|
||||||
}
|
}
|
||||||
} else if(memcmp(context.currChunk.chunkId, "fmt ", 4) == 0) {
|
} else if(memcmp(context.currChunk.chunkId, "fmt ", 4) == 0) {
|
||||||
fmt = true;
|
fmt = true;
|
||||||
|
|
||||||
if(!wav_read_chunk_data(&context, &wav->format, sizeof(WavFormatChunk))) {
|
if(!wav_read_chunk_data(&context, &wav->format, sizeof(WavFormatChunk))) {
|
||||||
strncpy(error, "ERROR: Failed to read fmt chunk data", sizeof(error));
|
error = "ERROR: Failed to read fmt chunk data";
|
||||||
}
|
}
|
||||||
} else if(memcmp(context.currChunk.chunkId, "data", 4) == 0) {
|
} else if(memcmp(context.currChunk.chunkId, "data", 4) == 0) {
|
||||||
data = true;
|
data = true;
|
||||||
@@ -79,15 +80,15 @@ WAV* wav_read(FILE* fd) {
|
|||||||
wav->data.data = (u8*) malloc(wav->data.size);
|
wav->data.data = (u8*) malloc(wav->data.size);
|
||||||
if(wav->data.data != NULL) {
|
if(wav->data.data != NULL) {
|
||||||
if(!wav_read_chunk_data(&context, wav->data.data, wav->data.size)) {
|
if(!wav_read_chunk_data(&context, wav->data.data, wav->data.size)) {
|
||||||
strncpy(error, "ERROR: Failed to read data chunk data", sizeof(error));
|
error = "ERROR: Failed to read data chunk data";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
strncpy(error, "ERROR: Could not allocate memory for WAV samples", sizeof(error));
|
error = "ERROR: Could not allocate memory for WAV samples";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strlen(error) == 0 && (!riff || !fmt || !data)) {
|
if(error.empty() && (!riff || !fmt || !data)) {
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
stream << "ERROR: Missing one or more WAV chunks: ";
|
stream << "ERROR: Missing one or more WAV chunks: ";
|
||||||
|
|
||||||
@@ -111,16 +112,16 @@ WAV* wav_read(FILE* fd) {
|
|||||||
stream << "data";
|
stream << "data";
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(error, stream.str().c_str(), sizeof(error));
|
error = stream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strlen(error) > 0) {
|
if(!error.empty()) {
|
||||||
wav_free(wav);
|
wav_free(wav);
|
||||||
|
|
||||||
if(errno != 0) {
|
if(errno != 0) {
|
||||||
perror(error);
|
perror(error.c_str());
|
||||||
} else {
|
} else {
|
||||||
printf("%s.\n", error);
|
printf("%s.\n", error.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user