mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 04:52:32 +00:00
Updated the libmpg123 decoder plugin. It compiles and works again.
This commit is contained in:
parent
93af3d1447
commit
5fc36a17d1
@ -36,9 +36,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#define STREAM_FEED_SIZE 2048 * 2
|
||||
#define DEBUG 0
|
||||
#define MPG123_DECODER_DEBUG 0
|
||||
|
||||
#if DEBUG > 0
|
||||
#if MPG123_DECODER_DEBUG > 0
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
@ -67,9 +67,17 @@ void Mpg123Decoder::Destroy() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
double Mpg123Decoder::GetDuration() {
|
||||
if (this->decoder) {
|
||||
return (double) mpg123_length(this->decoder) / (double) this->sampleRate;
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double Mpg123Decoder::SetPosition(double second) {
|
||||
off_t seekToFileOffset = 0;
|
||||
off_t seekToSampleOffset = second * (double)this->sampleRate;
|
||||
off_t seekToSampleOffset = (off_t) (second * (double)this->sampleRate);
|
||||
off_t *indexOffset = 0;
|
||||
off_t indexSet = 0;
|
||||
size_t indexFill = 0;
|
||||
@ -136,7 +144,7 @@ bool Mpg123Decoder::GetBuffer(IBuffer *buffer) {
|
||||
break;
|
||||
|
||||
case MPG123_NEW_FORMAT: {
|
||||
#if DEBUG > 0
|
||||
#if MPG123_DECODER_DEBUG > 0
|
||||
int encoding = 0;
|
||||
|
||||
mpg123_getformat(
|
||||
@ -165,8 +173,7 @@ bool Mpg123Decoder::Feed() {
|
||||
if (this->fileStream) {
|
||||
unsigned char buffer[STREAM_FEED_SIZE];
|
||||
|
||||
long long bytesRead =
|
||||
this->fileStream->Read(&buffer, STREAM_FEED_SIZE);
|
||||
long bytesRead = this->fileStream->Read(&buffer, STREAM_FEED_SIZE);
|
||||
|
||||
if (bytesRead) {
|
||||
if (mpg123_feed(this->decoder, buffer, bytesRead) == MPG123_OK) {
|
||||
|
@ -48,6 +48,7 @@ class Mpg123Decoder : public musik::core::sdk::IDecoder {
|
||||
virtual double SetPosition(double seconds);
|
||||
virtual bool GetBuffer(musik::core::sdk::IBuffer *buffer);
|
||||
virtual void Destroy();
|
||||
virtual double GetDuration();
|
||||
|
||||
private:
|
||||
bool Feed();
|
||||
|
@ -42,6 +42,12 @@
|
||||
|
||||
using namespace musik::core::sdk;
|
||||
|
||||
inline bool endsWith(const std::string& s, const std::string& suffix) {
|
||||
return
|
||||
s.size() >= suffix.size() &&
|
||||
s.rfind(suffix) == (s.size() - suffix.size());
|
||||
}
|
||||
|
||||
Mpg123DecoderFactory::Mpg123DecoderFactory() {
|
||||
mpg123_init();
|
||||
}
|
||||
@ -62,7 +68,7 @@ bool Mpg123DecoderFactory::CanHandle(const char* type) const {
|
||||
std::string str(type);
|
||||
std::transform(str.begin(), str.end(), str.begin(), tolower);
|
||||
|
||||
if (musik::sdk::endsWith(str, ".mp3") ||
|
||||
if (endsWith(str, ".mp3") ||
|
||||
str.find("audio/mpeg3") != std::string::npos ||
|
||||
str.find("audio/x-mpeg-3") != std::string::npos ||
|
||||
str.find("audio/mp3") != std::string::npos)
|
||||
|
@ -14,18 +14,18 @@
|
||||
<ProjectGuid>{04118CC2-DE10-4627-A695-2219428C7D59}</ProjectGuid>
|
||||
<RootNamespace>mpg123decoder</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
|
@ -53,6 +53,11 @@ class Mpg123Plugin : public musik::core::sdk::IPlugin {
|
||||
virtual const char* Name() { return "mpg123 IDecoder"; }
|
||||
virtual const char* Version() { return "0.4"; }
|
||||
virtual const char* Author() { return "Daniel Önnerby, clangen"; }
|
||||
virtual const char* Guid() { return "89f705c4-50ae-4577-9cc2-09bb94f341a8"; }
|
||||
virtual bool Configurable() { return false; }
|
||||
virtual void Configure() { }
|
||||
virtual void Reload() { }
|
||||
virtual int SdkVersion() { return musik::core::sdk::SdkVersion; }
|
||||
};
|
||||
|
||||
extern "C" DLLEXPORT musik::core::sdk::IPlugin* GetPlugin() {
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <core/sdk/config.h>
|
||||
#include <core/sdk/constants.h>
|
||||
#include <math.h>
|
||||
|
||||
#ifdef WIN32
|
||||
|
Loading…
Reference in New Issue
Block a user