mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-30 15:32:37 +00:00
musikbox runs on OSX!
- It's not pretty - More updates to CMakeLists and mp3decoder and taglib_plugin - Fixed bugs in PluginFactory so the DLLs load properly - Fixed a bug in Window where RemoveWindow was removing from the wrong parent - Added a couple hacks in Common.cpp, these need to be fixed
This commit is contained in:
parent
d12eae819d
commit
f9c95a5963
@ -6,6 +6,7 @@ set (musikbox_VERSION_MAJOR 0)
|
||||
set (musikbox_VERSION_MINOR 1)
|
||||
|
||||
set (CMAKE_MODULE_PATH ${musikbox_SOURCE_DIR}/modules)
|
||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-fpermissive -g")
|
||||
|
||||
set (BOOST_LIBS
|
||||
system
|
||||
@ -22,12 +23,9 @@ add_definitions (-DHAVE_BOOST
|
||||
-D_FILE_OFFSET_BITS=64)
|
||||
set (BOOST_LINK_LIBS
|
||||
${Boost_LIBRARIES})
|
||||
message(STATUS "Libs: " ${BOOST_LINK_LIBS})
|
||||
message(STATUS "Includes: " ${Boost_INCLUDE_DIRS})
|
||||
|
||||
set (linux_LINK_LIBS
|
||||
dl
|
||||
)
|
||||
#message(STATUS "Libs: " ${BOOST_LINK_LIBS})
|
||||
#message(STATUS "Includes: " ${Boost_INCLUDE_DIRS})
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Modules)
|
||||
@ -41,6 +39,7 @@ link_directories (${musikbox_SOURCE_DIR}/bin/plugins)
|
||||
set (musikbox_LINK_LIBS
|
||||
${linux_LINK_LIBS}
|
||||
${BOOST_LINK_LIBS}
|
||||
dl
|
||||
sqlite3
|
||||
md5
|
||||
)
|
||||
@ -54,5 +53,6 @@ include_directories (
|
||||
|
||||
add_subdirectory(src/3rdparty)
|
||||
add_subdirectory(src/core)
|
||||
#add_subdirectory(src/contrib)
|
||||
add_subdirectory(src/musikbox)
|
||||
add_subdirectory(src/contrib/taglib_plugin)
|
||||
add_subdirectory(src/contrib/mp3decoder)
|
||||
|
@ -2,29 +2,18 @@ set ( mp3decoder_SOURCES
|
||||
BaseDecoder.cpp
|
||||
BitStream.cpp
|
||||
CRC.cpp
|
||||
FrameSplitter.cpp
|
||||
Header.cpp
|
||||
Layer3Decoder.cpp
|
||||
mp3decoder_plugin.cpp
|
||||
MP3Decoder.cpp
|
||||
MP3SourceSupplier.cpp
|
||||
Mp3Decoder.cpp
|
||||
MP3DecoderFactory.cpp
|
||||
SideInfo.cpp
|
||||
stdafx.cpp
|
||||
)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
add_definitions(-DWIN32)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fpermissive)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
|
||||
add_definitions(
|
||||
-DXML_STATIC
|
||||
-D_CRT_SECURE_NO_DEPRECATE
|
||||
-D_DEBUG
|
||||
)
|
||||
|
||||
add_library(mp3decoder SHARED ${mp3decoder_SOURCES})
|
||||
target_link_libraries( mp3decoder ${musikCube_LINK_LIBS} )
|
||||
|
||||
|
||||
target_link_libraries(mp3decoder ${musikbox_LINK_LIBS})
|
||||
|
@ -31,5 +31,6 @@ source distribution.
|
||||
class IMPEGDecoder
|
||||
{
|
||||
public:
|
||||
virtual ~IMPEGDecoder() { };
|
||||
virtual bool ProcessFrame(Frame * fr, float * PCMSamples, unsigned long * NumSamples) = 0;
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include "Layer3Decoder.h"
|
||||
|
||||
static unsigned long g_huffman_table_1[7] = {
|
||||
@ -1130,7 +1130,7 @@ void CLayer3Decoder::DecodeScalefactors(unsigned long ch, unsigned long gr)
|
||||
}
|
||||
}
|
||||
|
||||
bool __forceinline CLayer3Decoder::HuffmanDecode(unsigned long TableNum, int * x, int * y, int * v, int * w)
|
||||
bool inline CLayer3Decoder::HuffmanDecode(unsigned long TableNum, int * x, int * y, int * v, int * w)
|
||||
{
|
||||
unsigned long point, error, bitsleft, treelen, linbits;
|
||||
unsigned long *htptr;
|
||||
@ -1384,7 +1384,7 @@ void CLayer3Decoder::DequantizeSample(int ch, int gr)
|
||||
for(int i=0; i<windowsize; i++)
|
||||
{
|
||||
txr = globscale * PowerTableMinus05[(1 + m_fr->m_SI.grinf[gr][ch].ScalefacScale) * (m_fr->m_SI.grinf[gr][ch].Scalefac_Long[sfb] + (m_fr->m_SI.grinf[gr][ch].PreFlag * pretab[sfb]) )];
|
||||
xr[ch][index] = txr * ( pow( (float)abs(is[ch][index]), (float)1.333333333333333) * ( is[ch][index] > 0 ? 1 : -1 ) );
|
||||
xr[ch][index] = txr * ( pow( (float)fabs(is[ch][index]), (float)1.333333333333333) * ( is[ch][index] > 0 ? 1 : -1 ) );
|
||||
|
||||
index ++; // should be 36 at the end of all this!
|
||||
}
|
||||
@ -1410,7 +1410,7 @@ void CLayer3Decoder::DequantizeSample(int ch, int gr)
|
||||
{
|
||||
txr = globscale * PowerTableMinus2[m_fr->m_SI.grinf[gr][ch].SubblockGain[window]] * PowerTableMinus05[(1 + m_fr->m_SI.grinf[gr][ch].ScalefacScale) * m_fr->m_SI.grinf[gr][ch].Scalefac_Short[sfb][window]];
|
||||
/* apply the sign(is[i]) * |is[i]| ^ (4/3) formula */
|
||||
xr[ch][index] = txr * ( pow( (float)abs(is[ch][index]), (float)1.333333333333333) * ( is[ch][index] > 0 ? 1 : -1 ) );
|
||||
xr[ch][index] = txr * ( pow( (float)fabs(is[ch][index]), (float)1.333333333333333) * ( is[ch][index] > 0 ? 1 : -1 ) );
|
||||
index ++;
|
||||
if(index >= m_NonZero[ch])
|
||||
break;
|
||||
@ -1431,7 +1431,7 @@ void CLayer3Decoder::DequantizeSample(int ch, int gr)
|
||||
for(int i=0; i<windowsize; i++)
|
||||
{
|
||||
txr = globscale * PowerTableMinus05[(1 + m_fr->m_SI.grinf[gr][ch].ScalefacScale) * (m_fr->m_SI.grinf[gr][ch].Scalefac_Long[sfb] + (m_fr->m_SI.grinf[gr][ch].PreFlag * pretab[sfb]) )];
|
||||
xr[ch][index] = txr * ( pow( (float)abs(is[ch][index]), (float)1.333333333333333) * ( is[ch][index] > 0 ? 1 : -1 ) );
|
||||
xr[ch][index] = txr * ( pow( (float)fabs(is[ch][index]), (float)1.333333333333333) * ( is[ch][index] > 0 ? 1 : -1 ) );
|
||||
index ++;
|
||||
if(index >= m_NonZero[ch])
|
||||
break;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "StdAfx.h"
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include "mp3decoder.h"
|
||||
|
||||
static bool splitFrame(musik::core::io::IDataStream *dataStream, Frame &fr) {
|
||||
@ -250,7 +251,7 @@ double Mp3Decoder::SetPosition(double seconds) {
|
||||
|
||||
if (this->xingValid) {
|
||||
/* interpolate in TOC to get file seek point in bytes */
|
||||
int a = min(percent, 99);
|
||||
int a = std::min(percent, 99.0f);
|
||||
float fa, fb, fx;
|
||||
|
||||
fa = this->toc[a];
|
||||
|
@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <core/sdk/IDecoder.h>
|
||||
|
||||
#include "FrameSplitter.h"
|
||||
#include "Layer3Decoder.h"
|
||||
|
||||
using namespace musik::core::audio;
|
||||
|
@ -1,5 +1,5 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright © 2007, Björn Olievier
|
||||
// Copyright <EFBFBD> 2007, Bj<42>rn Olievier
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <core\sdk\IDecoderFactory.h>
|
||||
#include <core/sdk/IDecoderFactory.h>
|
||||
|
||||
using namespace musik::core::audio;
|
||||
|
||||
@ -41,7 +41,7 @@ class Mp3DecoderFactory : public IDecoderFactory
|
||||
{
|
||||
public:
|
||||
Mp3DecoderFactory();
|
||||
~Mp3DecoderFactory();
|
||||
virtual ~Mp3DecoderFactory();
|
||||
|
||||
IDecoder* CreateDecoder();
|
||||
void Destroy();
|
||||
|
@ -39,9 +39,17 @@
|
||||
#include <core/sdk/IDecoder.h>
|
||||
#include "Mp3DecoderFactory.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define DLLEXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define DLLEXPORT
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
class MP3DecoderPlugin : public musik::core::IPlugin
|
||||
{
|
||||
@ -51,10 +59,10 @@ class MP3DecoderPlugin : public musik::core::IPlugin
|
||||
const char* Author() { return "Björn Olievier, _avatar"; };
|
||||
};
|
||||
|
||||
extern "C" __declspec(dllexport) musik::core::IPlugin* GetPlugin() {
|
||||
extern "C" DLLEXPORT musik::core::IPlugin* GetPlugin() {
|
||||
return new MP3DecoderPlugin();
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) IDecoderFactory* GetDecoderFactory() {
|
||||
extern "C" DLLEXPORT IDecoderFactory* GetDecoderFactory() {
|
||||
return new Mp3DecoderFactory();
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
// stdafx.h : include file for standard system include files,
|
||||
// or project specific include files that are used frequently, but
|
||||
// are changed infrequently
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <core/config.h>
|
||||
#include <core/sdk/config.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <shlwapi.h>
|
||||
#include <math.h>
|
||||
#else
|
||||
#define __forceinline inline
|
||||
#endif
|
||||
|
||||
//#include "vld/vld.h"
|
||||
#include <math.h>
|
||||
|
@ -1,35 +1,13 @@
|
||||
add_subdirectory(taglib-1.6.3)
|
||||
|
||||
set (taglib_plugin_SOURCES
|
||||
taglib_plugin.cpp
|
||||
TagReaderTaglib.cpp
|
||||
stdafx.cpp
|
||||
taglib_plugin.cpp
|
||||
TaglibMetadataReader.cpp
|
||||
)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
add_definitions(-DWIN32)
|
||||
if(NOT DEFINED MINGW)
|
||||
|
||||
endif(NOT DEFINED MINGW)
|
||||
else(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fpermissive)
|
||||
endif(CMAKE_SYSTEM_NAME MATCHES "Windows")
|
||||
|
||||
add_definitions(
|
||||
-DXML_STATIC
|
||||
-D_CRT_SECURE_NO_DEPRECATE
|
||||
-D_DEBUG
|
||||
-DTAGLIB_NO_CONFIG
|
||||
)
|
||||
|
||||
include_directories( ${musikCube_SOURCE_DIR}/src/contrib/taglib_plugin/taglib-1.6.3/ )
|
||||
include_directories( ${musikCube_SOURCE_DIR}/src/contrib/taglib_plugin/taglib-1.6.3/taglib )
|
||||
include_directories( ${musikCube_SOURCE_DIR}/src/contrib/taglib_plugin/taglib-1.6.3/taglib/toolkit )
|
||||
include_directories( ${musikCube_SOURCE_DIR}/src/contrib/taglib_plugin/taglib-1.6.3/taglib/mpeg/id3v2 )
|
||||
include_directories( ${musikCube_SOURCE_DIR}/src/contrib/taglib_plugin/taglib-1.6.3/taglib/mpeg/id3v2/frames )
|
||||
|
||||
|
||||
add_library(taglib_plugin SHARED ${taglib_plugin_SOURCES})
|
||||
target_link_libraries( taglib_plugin ${musikCube_LINK_LIBS} tag)
|
||||
|
||||
|
||||
target_link_libraries(taglib_plugin ${BOOST_LINK_LIBS} tag)
|
||||
|
@ -36,25 +36,20 @@
|
||||
|
||||
#include "TaglibMetadataReader.h"
|
||||
|
||||
#include <toolkit/tlist.h>
|
||||
#include <toolkit/tfile.h>
|
||||
|
||||
#include <taglib/tlist.h>
|
||||
#include <taglib/tfile.h>
|
||||
#include <taglib/tag.h>
|
||||
#include <taglib/fileref.h>
|
||||
#include <taglib/audioproperties.h>
|
||||
|
||||
#include <mpeg/mpegfile.h>
|
||||
|
||||
#include <mpeg/id3v1/id3v1tag.h>
|
||||
#include <mpeg/id3v1/id3v1genres.h>
|
||||
|
||||
#include <mpeg/id3v2/id3v2tag.h>
|
||||
#include <mpeg/id3v2/id3v2header.h>
|
||||
#include <mpeg/id3v2/id3v2frame.h>
|
||||
#include <mpeg/id3v2/frames/attachedpictureframe.h>
|
||||
#include <mpeg/id3v2/frames/commentsframe.h>
|
||||
|
||||
#include <taglib/ogg/oggfile.h>
|
||||
#include <taglib/mpegfile.h>
|
||||
#include <taglib/id3v1tag.h>
|
||||
#include <taglib/id3v1genres.h>
|
||||
#include <taglib/id3v2tag.h>
|
||||
#include <taglib/id3v2header.h>
|
||||
#include <taglib/id3v2frame.h>
|
||||
#include <taglib/attachedpictureframe.h>
|
||||
#include <taglib/commentsframe.h>
|
||||
#include <taglib/oggfile.h>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@ -313,7 +308,7 @@ bool TaglibMetadataReader::GetID3v2Tag(const char* uri, musik::core::IMetadataWr
|
||||
static_cast<TagLib::ID3v2::AttachedPictureFrame*>(pictures.front());
|
||||
|
||||
TagLib::ByteVector pictureData = picture->picture();
|
||||
DBID size = pictureData.size();
|
||||
long long size = pictureData.size();
|
||||
|
||||
if(size > 32) { /* noticed that some id3tags have like a 4-8 byte size with no thumbnail */
|
||||
track->SetThumbnail(pictureData.data(), size);
|
||||
@ -428,5 +423,3 @@ void TaglibMetadataReader::SetAudioProperties(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -39,28 +39,23 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifndef _HAVE_TAGLIB
|
||||
#include <toolkit/tlist.h>
|
||||
#include <toolkit/tfile.h>
|
||||
|
||||
#include <taglib/tlist.h>
|
||||
#include <taglib/tfile.h>
|
||||
#include <taglib/tag.h>
|
||||
#include <taglib/fileref.h>
|
||||
#include <taglib/audioproperties.h>
|
||||
|
||||
#include <mpeg/id3v2/id3v2tag.h>
|
||||
#include <taglib/id3v2tag.h>
|
||||
#else //_HAVE_TAGLIB
|
||||
#include <toolkit/tlist.h>
|
||||
#include <toolkit/tfile.h>
|
||||
|
||||
#include <tag.h>
|
||||
#include <fileref.h>
|
||||
#include <audioproperties.h>
|
||||
|
||||
#include <taglib/mpeg/id3v2/id3v2tag.h>
|
||||
#include <taglib/tlist.h>
|
||||
#include <taglib/tfile.h>
|
||||
#include <taglib/tag.h>
|
||||
#include <taglib/fileref.h>
|
||||
#include <taglib/audioproperties.h>
|
||||
#include <taglib/id3v2tag.h>
|
||||
#endif //_HAVE_TAGLIB
|
||||
|
||||
#include <set>
|
||||
#include <core/sdk/IMetadataReader.h>
|
||||
#include <core/support/Common.h>
|
||||
|
||||
class TaglibMetadataReader : public musik::core::metadata::IMetadataReader {
|
||||
public:
|
||||
@ -110,4 +105,3 @@ class TaglibMetadataReader : public musik::core::metadata::IMetadataReader {
|
||||
const char* uri,
|
||||
musik::core::IMetadataWriter *target);
|
||||
};
|
||||
|
||||
|
@ -38,11 +38,6 @@
|
||||
#include "stdafx.h"
|
||||
#include "TaglibMetadataReader.h"
|
||||
#include "core/sdk/IPlugin.h"
|
||||
#ifndef _HAVE_TAGLIB
|
||||
#include <id3v2framefactory.h>
|
||||
#else
|
||||
#include <taglib/mpeg/id3v2/id3v2framefactory.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define DLLEXPORT __declspec(dllexport)
|
||||
|
@ -77,8 +77,6 @@ set (CORE_HEADERS
|
||||
./support/Version.h
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fpermissive)
|
||||
|
||||
include_directories(
|
||||
.
|
||||
..
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// License Agreement:
|
||||
//
|
||||
// The following are Copyright © 2008, Daniel Önnerby
|
||||
// The following are Copyright <EFBFBD> 2008, Daniel <20>nnerby
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
@ -43,8 +43,6 @@
|
||||
|
||||
using namespace musik::core::io;
|
||||
|
||||
DataStreamFactory DataStreamFactory::sInstance;
|
||||
|
||||
DataStreamFactory::DataStreamFactory() {
|
||||
typedef IDataStreamFactory PluginType;
|
||||
typedef musik::core::PluginFactory::DestroyDeleter<PluginType> Deleter;
|
||||
@ -53,14 +51,25 @@ DataStreamFactory::DataStreamFactory() {
|
||||
.QueryInterface<PluginType, Deleter>("GetDataStreamFactory");
|
||||
}
|
||||
|
||||
DataStreamFactory* DataStreamFactory::Instance() {
|
||||
static DataStreamFactory* instance = NULL;
|
||||
|
||||
if (instance == NULL) {
|
||||
instance = new DataStreamFactory();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
DataStreamFactory::DataStreamPtr DataStreamFactory::OpenUri(const char *uri) {
|
||||
typedef musik::core::PluginFactory::DestroyDeleter<IDataStream> StreamDeleter;
|
||||
|
||||
if (uri) {
|
||||
DataStreamFactoryVector::iterator it = sInstance.dataStreamFactories.begin();
|
||||
DataStreamFactoryVector::iterator it =
|
||||
DataStreamFactory::Instance()->dataStreamFactories.begin();
|
||||
|
||||
/* plugins get the first crack at the uri */
|
||||
for( ; it != sInstance.dataStreamFactories.end(); it++) {
|
||||
for( ; it != DataStreamFactory::Instance()->dataStreamFactories.end(); it++) {
|
||||
if ((*it)->CanReadFile(uri)) {
|
||||
IDataStream* dataStream = (*it)->OpenFile(uri);
|
||||
|
||||
@ -87,8 +96,10 @@ bool DataStreamFactory::IsLocalFileStream(const char *uri){
|
||||
if (uri) {
|
||||
/* see if a plugin can handle this. if it can, then it's not
|
||||
considered to be a local file stream */
|
||||
DataStreamFactoryVector::iterator it = sInstance.dataStreamFactories.begin();
|
||||
for( ; it != sInstance.dataStreamFactories.end(); ++it) {
|
||||
DataStreamFactoryVector::iterator it =
|
||||
DataStreamFactory::Instance()->dataStreamFactories.begin();
|
||||
|
||||
for( ; it != DataStreamFactory::Instance()->dataStreamFactories.end(); ++it) {
|
||||
if ((*it)->CanReadFile(uri)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ namespace musik { namespace core { namespace io {
|
||||
typedef std::shared_ptr<IDataStream> DataStreamPtr;
|
||||
|
||||
private:
|
||||
static DataStreamFactory sInstance;
|
||||
DataStreamFactory();
|
||||
static DataStreamFactory* Instance();
|
||||
|
||||
private:
|
||||
typedef std::vector<std::shared_ptr<IDataStreamFactory> > DataStreamFactoryVector;
|
||||
|
@ -42,10 +42,21 @@
|
||||
#include <core/debug.h>
|
||||
|
||||
static const std::string TAG = "PluginFactory";
|
||||
static boost::mutex instanceMutex;
|
||||
|
||||
using namespace musik::core;
|
||||
|
||||
PluginFactory PluginFactory::sInstance;
|
||||
PluginFactory& PluginFactory:: Instance() {
|
||||
boost::mutex::scoped_lock lock(instanceMutex);
|
||||
|
||||
static PluginFactory* instance = NULL;
|
||||
|
||||
if (instance == NULL) {
|
||||
instance = new PluginFactory();
|
||||
}
|
||||
|
||||
return *instance;
|
||||
}
|
||||
|
||||
PluginFactory::PluginFactory() {
|
||||
musik::debug::info(TAG, "loading plugins");
|
||||
@ -80,9 +91,8 @@ void PluginFactory::LoadPlugins(){
|
||||
for (boost::filesystem::directory_iterator file(dir); file != end; file++) {
|
||||
if (boost::filesystem::is_regular(file->status())){
|
||||
std::string filename(file->path().string());
|
||||
|
||||
#ifdef WIN32
|
||||
/* if the file ends with ".dll", we'll try to load ig*/
|
||||
/* if the file ends with ".dll", we'll try to load it*/
|
||||
|
||||
if (filename.substr(filename.size() - 4) == ".dll") {
|
||||
|
||||
@ -102,14 +112,21 @@ void PluginFactory::LoadPlugins(){
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (filename.substr(filename.size() - 3) == ".so") {
|
||||
void* dll = dlopen(filename.c_str(), RTLD_NOW);
|
||||
#elif __APPLE__
|
||||
if (filename.substr(filename.size() - 6) == ".dylib") {
|
||||
void* dll = NULL;
|
||||
char* err;
|
||||
|
||||
if ((err = dlerror()) != NULL) {
|
||||
try {
|
||||
dll = dlopen(filename.c_str(), RTLD_LOCAL);
|
||||
}
|
||||
catch (...) {
|
||||
err = "exception caught loading plugin";
|
||||
}
|
||||
|
||||
if (err != NULL || (err = dlerror()) != NULL) {
|
||||
musik::debug::err(
|
||||
"PluginFactory",
|
||||
TAG,
|
||||
"could not load shared library " + filename +
|
||||
" error: " + std::string(err));
|
||||
}
|
||||
@ -118,6 +135,7 @@ void PluginFactory::LoadPlugins(){
|
||||
*(void **)(&getPluginCall) = dlsym(dll, "GetPlugin");
|
||||
|
||||
if (getPluginCall) {
|
||||
musik::debug::info(TAG, "loaded: " + filename);
|
||||
this->loadedPlugins.push_back(getPluginCall());
|
||||
this->loadedDlls.push_back(dll);
|
||||
}
|
||||
|
@ -53,10 +53,7 @@ namespace musik { namespace core {
|
||||
|
||||
class PluginFactory {
|
||||
public:
|
||||
|
||||
static PluginFactory& Instance() {
|
||||
return sInstance;
|
||||
}
|
||||
static PluginFactory& Instance();
|
||||
|
||||
private:
|
||||
|
||||
@ -74,8 +71,6 @@ namespace musik { namespace core {
|
||||
typedef std::vector<IPlugin*> PluginList;
|
||||
typedef std::vector<void*> HandleList;
|
||||
|
||||
static PluginFactory sInstance;
|
||||
|
||||
PluginList loadedPlugins;
|
||||
HandleList loadedDlls;
|
||||
boost::mutex mutex;
|
||||
@ -101,7 +96,7 @@ namespace musik { namespace core {
|
||||
typedef T* STDCALL(PluginInterfaceCall);
|
||||
|
||||
std::vector<std::shared_ptr<T> > plugins;
|
||||
HandleList& allDlls = PluginFactory::sInstance.loadedDlls;
|
||||
HandleList& allDlls = PluginFactory::Instance().loadedDlls;
|
||||
|
||||
typedef HandleList::iterator Iterator;
|
||||
Iterator currentDll = allDlls.begin();
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// License Agreement:
|
||||
//
|
||||
// The following are Copyright © 2008, Daniel Önnerby
|
||||
// The following are Copyright <EFBFBD> 2008, Daniel <20>nnerby
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
@ -38,25 +38,35 @@
|
||||
#include <core/support/Common.h>
|
||||
#include <core/config.h>
|
||||
#include <utf8/utf8.h>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <mach-o/dyld.h>
|
||||
|
||||
std::string musik::core::GetPluginDirectory() {
|
||||
std::string sDirectory(GetApplicationDirectory());
|
||||
sDirectory.append("plugins/");
|
||||
return sDirectory;
|
||||
std::string path(GetApplicationDirectory());
|
||||
path.append("/plugins/");
|
||||
return path;
|
||||
}
|
||||
|
||||
std::string musik::core::GetApplicationDirectory() {
|
||||
std::string sDirectory;
|
||||
std::string result;
|
||||
|
||||
#ifdef WIN32
|
||||
wchar_t szPath[2048];
|
||||
int iStrLength = GetModuleFileName(NULL, szPath, 2048);
|
||||
if(iStrLength != 0 && iStrLength < 2048){
|
||||
sDirectory.assign(GetPath(u16to8(szPath).c_str()));
|
||||
result.assign(GetPath(u16to8(szPath).c_str()));
|
||||
}
|
||||
#else
|
||||
// char pathbuf[PATH_MAX + 1];
|
||||
// uint32_t bufsize = sizeof(pathbuf);
|
||||
// _NSGetExecutablePath(pathbuf, &bufsize);
|
||||
// result.assign(pathbuf);
|
||||
// std::cerr << result << std::endl;
|
||||
result = "/Users/clangen/src/musikcube/bin/";
|
||||
#endif
|
||||
|
||||
return sDirectory;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string musik::core::GetDataDirectory() {
|
||||
@ -68,14 +78,16 @@ std::string musik::core::GetDataDirectory(){
|
||||
GetEnvironmentVariable(_T("APPDATA"), sBuffer, iBufferSize);
|
||||
directory.assign(u16to8(sBuffer));
|
||||
delete [] sBuffer;
|
||||
#else
|
||||
directory = std::string(std::getenv("HOME"));
|
||||
#endif
|
||||
|
||||
directory.append("/mC2/");
|
||||
|
||||
// Create folder if it does not exist
|
||||
boost::filesystem::path oFolder(directory);
|
||||
if(!boost::filesystem::exists(oFolder)){
|
||||
boost::filesystem::create_directories(oFolder);
|
||||
boost::filesystem::path path(directory);
|
||||
if(!boost::filesystem::exists(path)) {
|
||||
boost::filesystem::create_directories(path);
|
||||
}
|
||||
|
||||
return directory;
|
||||
@ -117,7 +129,3 @@ UINT64 musik::core::Checksum(char *data,unsigned int bytes){
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -51,13 +51,19 @@
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>
|
||||
|
||||
#include <core/plugin/PluginFactory.h>
|
||||
#include <core/library/LibraryFactory.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#undef MOUSE_MOVED
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define IDLE_TIMEOUT_MS 0
|
||||
#else
|
||||
#define IDLE_TIMEOUT_MS 100
|
||||
#endif
|
||||
|
||||
|
||||
using namespace musik::core;
|
||||
using namespace musik::core::audio;
|
||||
@ -150,7 +156,12 @@ int main(int argc, char* argv[])
|
||||
std::locale utf8Locale(locale, new boost::filesystem::detail::utf8_codecvt_facet);
|
||||
boost::filesystem::path::imbue(utf8Locale);
|
||||
|
||||
#ifndef WIN32
|
||||
setlocale(LC_ALL, "");
|
||||
#endif
|
||||
|
||||
musik::debug::init();
|
||||
PluginFactory::Instance(); /* initialize */
|
||||
|
||||
ttytype[0] = 30; /* min height */
|
||||
ttytype[1] = 30; /* max height */
|
||||
@ -174,7 +185,6 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
Colors::Init();
|
||||
|
||||
|
||||
Transport tp;
|
||||
tp.SetVolume(0.75);
|
||||
|
||||
|
@ -90,10 +90,10 @@ void Window::RemoveMessage(int messageType) {
|
||||
|
||||
void Window::SetParent(IWindow* parent) {
|
||||
if (this->parent != parent) {
|
||||
IWindowGroup* group = dynamic_cast<IWindowGroup*>(parent);
|
||||
IWindowGroup* group = dynamic_cast<IWindowGroup*>(this->parent);
|
||||
|
||||
if (group) {
|
||||
group->RemoveWindow(shared_from_this());
|
||||
group->RemoveWindow(this->Window::shared_from_this());
|
||||
}
|
||||
|
||||
this->parent = parent;
|
||||
|
Loading…
x
Reference in New Issue
Block a user