mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-30 06:32:36 +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)
|
||||
|
@ -1,30 +1,19 @@
|
||||
set ( mp3decoder_SOURCES
|
||||
BaseDecoder.cpp
|
||||
BitStream.cpp
|
||||
CRC.cpp
|
||||
FrameSplitter.cpp
|
||||
Header.cpp
|
||||
Layer3Decoder.cpp
|
||||
mp3decoder_plugin.cpp
|
||||
MP3Decoder.cpp
|
||||
MP3SourceSupplier.cpp
|
||||
SideInfo.cpp
|
||||
stdafx.cpp
|
||||
)
|
||||
set (mp3decoder_SOURCES
|
||||
BaseDecoder.cpp
|
||||
BitStream.cpp
|
||||
CRC.cpp
|
||||
Header.cpp
|
||||
Layer3Decoder.cpp
|
||||
mp3decoder_plugin.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
|
||||
add_definitions(
|
||||
-D_DEBUG
|
||||
)
|
||||
|
||||
add_library( mp3decoder SHARED ${mp3decoder_SOURCES} )
|
||||
target_link_libraries( mp3decoder ${musikCube_LINK_LIBS} )
|
||||
|
||||
|
||||
add_library(mp3decoder SHARED ${mp3decoder_SOURCES})
|
||||
target_link_libraries(mp3decoder ${musikbox_LINK_LIBS})
|
||||
|
@ -1,26 +1,26 @@
|
||||
/*
|
||||
Copyright (c) 2002 Tony Million
|
||||
|
||||
This software is provided 'as-is', without any express or
|
||||
implied warranty. In no event will the authors be held liable
|
||||
This software is provided 'as-is', without any express or
|
||||
implied warranty. In no event will the authors be held liable
|
||||
for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it
|
||||
and redistribute it freely, subject to the following
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it
|
||||
and redistribute it freely, subject to the following
|
||||
restrictions:
|
||||
|
||||
1. The origin of this software must not be
|
||||
misrepresented; you must not claim that you wrote
|
||||
the original software. If you use this software in a
|
||||
product, an acknowledgment in the product
|
||||
1. The origin of this software must not be
|
||||
misrepresented; you must not claim that you wrote
|
||||
the original software. If you use this software in a
|
||||
product, an acknowledgment in the product
|
||||
documentation is required.
|
||||
|
||||
2. Altered source versions must be plainly marked as
|
||||
such, and must not be misrepresented as being the
|
||||
2. Altered source versions must be plainly marked as
|
||||
such, and must not be misrepresented as being the
|
||||
original software.
|
||||
|
||||
3. This notice may not be removed or altered from any
|
||||
3. This notice may not be removed or altered from any
|
||||
source distribution.
|
||||
*/
|
||||
|
||||
@ -31,5 +31,6 @@ source distribution.
|
||||
class IMPEGDecoder
|
||||
{
|
||||
public:
|
||||
virtual ~IMPEGDecoder() { };
|
||||
virtual bool ProcessFrame(Frame * fr, float * PCMSamples, unsigned long * NumSamples) = 0;
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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) {
|
||||
@ -136,7 +137,7 @@ bool Mp3Decoder::GetXingHeader(unsigned char * xingBuffer) {
|
||||
|
||||
xingBuffer += 100;
|
||||
}
|
||||
|
||||
|
||||
this->vbrScale = -1;
|
||||
if (headFlags & VBR_SCALE_FLAG) {
|
||||
this->vbrScale = GET_INT32BE(xingBuffer);
|
||||
@ -249,19 +250,19 @@ double Mp3Decoder::SetPosition(double seconds) {
|
||||
unsigned long offset;
|
||||
|
||||
if (this->xingValid) {
|
||||
/* interpolate in TOC to get file seek point in bytes */
|
||||
int a = min(percent, 99);
|
||||
/* interpolate in TOC to get file seek point in bytes */
|
||||
int a = std::min(percent, 99.0f);
|
||||
float fa, fb, fx;
|
||||
|
||||
fa = this->toc[a];
|
||||
|
||||
|
||||
if (a < 99) {
|
||||
fb = this->toc[a + 1];
|
||||
}
|
||||
else {
|
||||
fb = 256;
|
||||
}
|
||||
|
||||
|
||||
fx = fa + (fb - fa) * (percent - a);
|
||||
offset = (1.0f / 256.0f) * fx * this->streamDataLength;
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <core/sdk/IDecoder.h>
|
||||
|
||||
#include "FrameSplitter.h"
|
||||
#include "Layer3Decoder.h"
|
||||
|
||||
using namespace musik::core::audio;
|
||||
|
@ -1,39 +1,39 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright © 2007, Björn Olievier
|
||||
// Copyright <EFBFBD> 2007, Bj<42>rn Olievier
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#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,22 +39,30 @@
|
||||
#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
|
||||
{
|
||||
void Destroy() { delete this; }
|
||||
const char* Name() { return "MP3 IDecoder"; };
|
||||
const char* Version() { return "0.2"; };
|
||||
const char* Author() { return "Björn Olievier, _avatar"; };
|
||||
const char* Name() { return "MP3 IDecoder"; };
|
||||
const char* Version() { return "0.2"; };
|
||||
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
|
||||
stdafx.cpp
|
||||
taglib_plugin.cpp
|
||||
TaglibMetadataReader.cpp
|
||||
)
|
||||
|
||||
set ( taglib_plugin_SOURCES
|
||||
taglib_plugin.cpp
|
||||
TagReaderTaglib.cpp
|
||||
stdafx.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
|
||||
add_definitions(
|
||||
-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)
|
||||
|
||||
|
||||
add_library(taglib_plugin SHARED ${taglib_plugin_SOURCES})
|
||||
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>
|
||||
@ -186,7 +181,7 @@ bool TaglibMetadataReader::GetID3v2Tag(const char* uri, musik::core::IMetadataWr
|
||||
if (!allTags["TYER"].isEmpty()) { /* ID3v2.3*/
|
||||
this->SetTagValue("year", allTags["TYER"].front()->toString().substr(0, 4), track);
|
||||
}
|
||||
|
||||
|
||||
if (!allTags["TDRC"].isEmpty()) { /* ID3v2.4*/
|
||||
this->SetTagValue("year", allTags["TDRC"].front()->toString().substr(0, 4), track);
|
||||
}
|
||||
@ -309,11 +304,11 @@ bool TaglibMetadataReader::GetID3v2Tag(const char* uri, musik::core::IMetadataWr
|
||||
/* there can be multiple pictures, apparently. let's just use
|
||||
the first one. */
|
||||
|
||||
TagLib::ID3v2::AttachedPictureFrame *picture =
|
||||
TagLib::ID3v2::AttachedPictureFrame *picture =
|
||||
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);
|
||||
@ -373,7 +368,7 @@ void TaglibMetadataReader::SetTagValues(
|
||||
|
||||
void TaglibMetadataReader::SetSlashSeparatedValues(
|
||||
const char* key,
|
||||
TagLib::String tagString,
|
||||
TagLib::String tagString,
|
||||
musik::core::IMetadataWriter *track)
|
||||
{
|
||||
if(!tagString.isEmpty()) {
|
||||
@ -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:
|
||||
@ -81,10 +76,10 @@ class TaglibMetadataReader : public musik::core::metadata::IMetadataReader {
|
||||
musik::core::IMetadataWriter *target);
|
||||
|
||||
void SetTagValue(
|
||||
const char* key,
|
||||
const char* key,
|
||||
const int tagInt,musik::core::IMetadataWriter *target);
|
||||
|
||||
void SetTagValues(const char* key,
|
||||
void SetTagValues(const char* key,
|
||||
const TagLib::ID3v2::FrameList &frame,
|
||||
musik::core::IMetadataWriter *target);
|
||||
|
||||
@ -93,21 +88,20 @@ class TaglibMetadataReader : public musik::core::metadata::IMetadataReader {
|
||||
musik::core::IMetadataWriter *target);
|
||||
|
||||
void SetSlashSeparatedValues(
|
||||
const char* key,
|
||||
const TagLib::ID3v2::FrameList &frame,
|
||||
const char* key,
|
||||
const TagLib::ID3v2::FrameList &frame,
|
||||
musik::core::IMetadataWriter *target);
|
||||
|
||||
void SetSlashSeparatedValues(
|
||||
const char* key,
|
||||
TagLib::String tagString,
|
||||
const char* key,
|
||||
TagLib::String tagString,
|
||||
musik::core::IMetadataWriter *target);
|
||||
|
||||
bool GetID3v2Tag(
|
||||
const char* uri,
|
||||
const char* uri,
|
||||
musik::core::IMetadataWriter *target);
|
||||
|
||||
bool GetGenericTag(
|
||||
const char* uri,
|
||||
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)
|
||||
@ -60,7 +55,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,DWORD ul_reason_for_call,LPVOID lpReserv
|
||||
|
||||
class TaglibPlugin : public musik::core::IPlugin {
|
||||
void Destroy() {
|
||||
delete this;
|
||||
delete this;
|
||||
};
|
||||
|
||||
const char* Name() {
|
||||
|
@ -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,17 +51,28 @@ 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);
|
||||
|
||||
|
||||
if (dataStream) {
|
||||
return DataStreamPtr(dataStream, StreamDeleter());
|
||||
}
|
||||
@ -72,7 +81,7 @@ DataStreamFactory::DataStreamPtr DataStreamFactory::OpenUri(const char *uri) {
|
||||
|
||||
/* no plugins accepted it? try to open as a local file */
|
||||
DataStreamPtr regularFile(new LocalFileStream(), StreamDeleter());
|
||||
|
||||
|
||||
if (regularFile->Open(uri)) {
|
||||
return regularFile;
|
||||
}
|
||||
@ -81,14 +90,16 @@ DataStreamFactory::DataStreamPtr DataStreamFactory::OpenUri(const char *uri) {
|
||||
return DataStreamPtr();
|
||||
}
|
||||
|
||||
bool DataStreamFactory::IsLocalFileStream(const char *uri){
|
||||
bool DataStreamFactory::IsLocalFileStream(const char *uri) {
|
||||
typedef musik::core::PluginFactory::DestroyDeleter<IDataStream> StreamDeleter;
|
||||
|
||||
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");
|
||||
@ -53,7 +64,7 @@ PluginFactory::PluginFactory() {
|
||||
}
|
||||
|
||||
PluginFactory::~PluginFactory(void){
|
||||
for (size_t i = 0; i<this->loadedPlugins.size(); i++) {
|
||||
for (size_t i = 0; i < this->loadedPlugins.size(); i++) {
|
||||
this->loadedPlugins[i]->Destroy();
|
||||
}
|
||||
|
||||
@ -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,28 +38,38 @@
|
||||
#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 musik::core::GetPluginDirectory() {
|
||||
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(){
|
||||
std::string musik::core::GetDataDirectory() {
|
||||
std::string directory;
|
||||
|
||||
#ifdef WIN32
|
||||
@ -68,21 +78,23 @@ 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;
|
||||
}
|
||||
|
||||
std::string musik::core::GetPath(const std::string &sFile){
|
||||
|
||||
|
||||
std::string sPath;
|
||||
int iStrLength;
|
||||
|
||||
@ -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
|
||||
|
||||
#define IDLE_TIMEOUT_MS 0
|
||||
#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