Commit 53ad911a authored by Josh Coalson's avatar Josh Coalson
Browse files

check in new version of the winamp3 plugin

parent 8c13e652
......@@ -15,6 +15,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
EXTRA_DIST = Makefile.vc \
core_api.h \
in_flac.cpp
EXTRA_DIST = \
README.txt \
cnv_flacpcm.cpp \
cnv_flacpcm.dsp \
cnv_flacpcm.dsw \
cnv_flacpcm.h \
flacpcm.cpp \
flacpcm.h
This plugin require the Wasabi SDK, and the project assumes that you have it
installed in the standard place: \Wasabi SDK. If not, you will have to edit
the .dsp file to change the path.
Also, you must build libFLAC first; if you haven't, cd to src\libFLAC and
run 'nmake /f Makefile.vc'
/* FLAC input plugin for Winamp3
* Copyright (C) 2000,2001 Josh Coalson
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* NOTE: this code is derived from the 'rawpcm' example by
* Nullsoft; the original license for the 'rawpcm' example follows.
*/
/*
Nullsoft WASABI Source File License
Copyright 1999-2001 Nullsoft, Inc.
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 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 documentation would be
appreciated but is not required.
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 source distribution.
Brennan Underwood
brennan@nullsoft.com
*/
#include "cnv_flacpcm.h"
#include "flacpcm.h"
static WACNAME wac;
WAComponentClient *the = &wac;
#include "studio/services/servicei.h"
static waServiceT<svc_mediaConverter, FlacPcm> flacpcm;
// {683FA153-4055-467c-ABEE-5E35FA03C51E}
static const GUID guid =
{ 0x683fa153, 0x4055, 0x467c, { 0xab, 0xee, 0x5e, 0x35, 0xfa, 0x3, 0xc5, 0x1e } };
_int nch;
_int samplerate;
_int bps;
WACNAME::WACNAME() : CfgItemI("RAW files support") {
#ifdef FORTIFY
FortifySetName("cnv_flacpcm.wac");
FortifyEnterScope();
#endif
}
WACNAME::~WACNAME() {
#ifdef FORTIFY
FortifyLeaveScope();
#endif
}
GUID WACNAME::getGUID() {
return guid;
}
void WACNAME::onRegisterServices() {
api->service_register(&flacpcm);
api->core_registerExtension("*.flac","FLAC Files");
nch.setName("# of channels");
nch=2;
registerAttribute(&nch);
samplerate.setName("Sample rate");
samplerate=44100;
registerAttribute(&samplerate);
bps.setName("Bits per second");
bps=16;
registerAttribute(&bps);
}
void WACNAME::onDestroy() {
api->service_deregister(&flacpcm);
WAComponentClient::onDestroy();
}
# Microsoft Developer Studio Project File - Name="cnv_flacpcm" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=cnv_flacpcm - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "cnv_flacpcm.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "cnv_flacpcm.mak" CFG="cnv_flacpcm - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "cnv_flacpcm - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "cnv_flacpcm - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName "$/Studio/cnv_flacpcm"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "cnv_flacpcm - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "cnv_flacpcm_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I "\Wasabi SDK\studio" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "cnv_flacpcm_EXPORTS" /D "USE_ASM" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 libFLAC.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib msacm32.lib winmm.lib /nologo /dll /machine:I386 /out:"../../obj/bin/cnv_flacpcm.wac" /libpath:"../../obj/lib"
# SUBTRACT LINK32 /nodefaultlib
!ELSEIF "$(CFG)" == "cnv_flacpcm - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "cnv_flacpcm_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\..\include" /I "\Wasabi SDK\studio" /D "_DEBUG" /D "WACLIENT_NOICONSUPPORT" /D "REAL_STDIO" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "cnv_flacpcm_EXPORTS" /D "USE_ASM" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 libFLAC.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib msacm32.lib winmm.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libc.lib" /out:"../../obj/bin/cnv_flacpcm.wac" /pdbtype:sept /libpath:"../../obj/lib"
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "cnv_flacpcm - Win32 Release"
# Name "cnv_flacpcm - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Group "Wasabi SDK"
# PROP Default_Filter ""
# Begin Source File
SOURCE="\Wasabi SDK\studio\studio\assert.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\attribs\attribute.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\attribs\attrint.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\common\bitmap.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\common\blending.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\common\canvas.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\attribs\cfgitemi.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\studio\corecb.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\common\depend.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\common\nsGUID.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\common\pathparse.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\common\ptrlist.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\common\region.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\studio\services\servicei.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\common\std.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\common\string.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\studio\services\svc_mediaconverter.cpp"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\studio\services\svc_mediaconverter.h"
# End Source File
# Begin Source File
SOURCE="\Wasabi SDK\studio\studio\waclient.cpp"
# End Source File
# End Group
# Begin Source File
SOURCE=.\cnv_flacpcm.cpp
# End Source File
# Begin Source File
SOURCE=.\flacpcm.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\cnv_flacpcm.h
# End Source File
# Begin Source File
SOURCE=.\flacpcm.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# Begin Source File
SOURCE=.\README.txt
# End Source File
# End Target
# End Project
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "cnv_flacpcm"=.\cnv_flacpcm.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
/* FLAC input plugin for Winamp3
* Copyright (C) 2000,2001 Josh Coalson
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* NOTE: this code is derived from the 'rawpcm' example by
* Nullsoft; the original license for the 'rawpcm' example follows.
*/
/*
Nullsoft WASABI Source File License
Copyright 1999-2001 Nullsoft, Inc.
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 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 documentation would be
appreciated but is not required.
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 source distribution.
Brennan Underwood
brennan@nullsoft.com
*/
#ifndef _CNV_FLACPCM_H
#define _CNV_FLACPCM_H
#include "studio/wac.h"
#include "common/rootcomp.h"
#include "attribs/cfgitemi.h"
#include "attribs/attrint.h"
#define WACNAME WACcnv_flacpcm
class WACNAME : public WAComponentClient, public CfgItemI {
public:
WACNAME();
virtual ~WACNAME();
virtual const char *getName() { return "FLAC to PCM converter"; };
virtual GUID getGUID();
virtual void onRegisterServices();
virtual void onDestroy();
virtual int getDisplayComponent() { return FALSE; };
virtual CfgItem *getCfgInterface(int n) { return this; }
};
#endif
/* FLAC input plugin for Winamp3
* Copyright (C) 2000,2001 Josh Coalson
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* NOTE: this code is derived from the 'rawpcm' example by
* Nullsoft; the original license for the 'rawpcm' example follows.
*/
/*
Nullsoft WASABI Source File License
Copyright 1999-2001 Nullsoft, Inc.
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 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 documentation would be
appreciated but is not required.
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 source distribution.
Brennan Underwood
brennan@nullsoft.com
*/
#include "flacpcm.h"
extern "C" {
#include "FLAC/utility.h"
};
struct id3v1_struct {
FLAC__byte raw[128];
char title[31];
char artist[31];
char album[31];
char comment[31];
unsigned year;
unsigned track; /* may be 0 if v1 (not v1.1) tag */
unsigned genre;
char description[1024]; /* the formatted description passed to the gui */
};
static bool get_id3v1_tag_(const char *filename, id3v1_struct *tag);
FlacPcm::FlacPcm():
needs_seek(false),
seek_sample(0),
samples_in_reservoir(0),
abort_flag(false),
reader(0),
decoder(0)
{
}
FlacPcm::~FlacPcm()
{
cleanup();
}
int FlacPcm::getInfos(MediaInfo *infos)
{
reader = infos->getReader();
if(!reader) return 0;
//@@@ to be really "clean" we should go through the reader instead of directly to the file...
if(!FLAC__utility_get_streaminfo(infos->getFilename(), &stream_info))
return 1;
id3v1_struct tag;
//@@@ ditto here...
bool has_tag = get_id3v1_tag_(infos->getFilename(), &tag);
infos->setLength(lengthInMsec());
//@@@ infos->setTitle(Std::filename(infos->getFilename()));
infos->setTitle(tag.description);
infos->setInfo(StringPrintf("FLAC:<%ihz:%ibps:%dch>", stream_info.sample_rate, stream_info.bits_per_sample, stream_info.channels)); //@@@ fix later
if(has_tag) {
infos->setData("Title", tag.title);
infos->setData("Artist", tag.artist);
infos->setData("Album", tag.album);
}
return 0;
}
int FlacPcm::processData(MediaInfo *infos, ChunkList *chunk_list, bool *killswitch)
{
reader = infos->getReader();
if(reader == 0)
return 0;
if(decoder == 0) {
decoder = FLAC__seekable_stream_decoder_new();
if(decoder == 0)
return 0;
FLAC__seekable_stream_decoder_set_md5_checking(decoder, false);
FLAC__seekable_stream_decoder_set_read_callback(decoder, readCallback_);
FLAC__seekable_stream_decoder_set_seek_callback(decoder, seekCallback_);
FLAC__seekable_stream_decoder_set_tell_callback(decoder, tellCallback_);
FLAC__seekable_stream_decoder_set_length_callback(decoder, lengthCallback_);
FLAC__seekable_stream_decoder_set_eof_callback(decoder, eofCallback_);
FLAC__seekable_stream_decoder_set_write_callback(decoder, writeCallback_);
FLAC__seekable_stream_decoder_set_metadata_callback(decoder, metadataCallback_);
FLAC__seekable_stream_decoder_set_error_callback(decoder, errorCallback_);
FLAC__seekable_stream_decoder_set_client_data(decoder, this);
if(FLAC__seekable_stream_decoder_init(decoder) != FLAC__SEEKABLE_STREAM_DECODER_OK) {
cleanup();
return 0;
}
if(!FLAC__seekable_stream_decoder_process_metadata(decoder)) {
cleanup();
return 0;
}
}
if(needs_seek) {
FLAC__seekable_stream_decoder_seek_absolute(decoder, seek_sample);
needs_seek = false;
}
bool eof = false;
while(samples_in_reservoir < 576) {
if(FLAC__seekable_stream_decoder_get_state(decoder) == FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM) {
eof = true;
break;
}
else if(!FLAC__seekable_stream_decoder_process_one_frame(decoder))
break;
}
if(samples_in_reservoir == 0) {
eof = true;
}
else {
const unsigned channels = stream_info.channels;
const unsigned bits_per_sample = stream_info.bits_per_sample;
const unsigned bytes_per_sample = (bits_per_sample+7)/8;
const unsigned sample_rate = stream_info.sample_rate;
unsigned i, n = min(samples_in_reservoir, 576), delta;
signed short *ssbuffer = (signed short*)output;
for(i = 0; i < n*channels; i++)
ssbuffer[i] = reservoir[i];
delta = i;
for( ; i < samples_in_reservoir*channels; i++)
reservoir[i-delta] = reservoir[i];
samples_in_reservoir -= n;
const int bytes = n * channels * bytes_per_sample;
ChunkInfosI *ci=new ChunkInfosI();
ci->addInfo("srate", sample_rate);
ci->addInfo("bps", bits_per_sample);
ci->addInfo("nch", channels);
chunk_list->setChunk("PCM", output, bytes, ci);
}
if(eof)
return 0;
return 1;
}