Added changes by kode54

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@872 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
josh-w 2010-10-22 07:35:00 +00:00
parent 7a910e227b
commit 7320d0f97d
6 changed files with 364 additions and 385 deletions

View File

@ -1,89 +1,99 @@
// Microsoft Visual C++ generated resource script. // Microsoft Visual C++ generated resource script.
// //
#include "resource.h" #include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS #define APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Generated from the TEXTINCLUDE 2 resource. // Generated from the TEXTINCLUDE 2 resource.
// //
#include "afxres.h" #include "afxres.h"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS #undef APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// English (Australia) resources // English (Australia) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA) #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA)
#ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS #pragma code_page(1252)
#pragma code_page(1252)
#endif //_WIN32 #ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#ifdef APSTUDIO_INVOKED //
///////////////////////////////////////////////////////////////////////////// // TEXTINCLUDE
// //
// TEXTINCLUDE
// 1 TEXTINCLUDE
BEGIN
1 TEXTINCLUDE "resource.h\0"
BEGIN END
"resource.h\0"
END 2 TEXTINCLUDE
BEGIN
2 TEXTINCLUDE "#include ""afxres.h""\r\n"
BEGIN "\0"
"#include ""afxres.h""\r\n" END
"\0"
END 3 TEXTINCLUDE
BEGIN
3 TEXTINCLUDE "\r\n"
BEGIN "\0"
"\r\n" END
"\0"
END #endif // APSTUDIO_INVOKED
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////// // Dialog
// //
// Dialog
// IDD_CONFIG DIALOGEX 0, 0, 187, 144
STYLE DS_SETFONT | WS_CHILD
IDD_CONFIG DIALOGEX 0, 0, 187, 144 FONT 8, "MS Sans Serif", 0, 0, 0x0
STYLE DS_SETFONT | WS_CHILD BEGIN
FONT 8, "MS Sans Serif", 0, 0, 0x0 LTEXT "Loop Count",IDC_STATIC,7,10,44,12
BEGIN EDITTEXT IDC_LOOP_COUNT,52,7,39,14,ES_AUTOHSCROLL
LTEXT "Loop Count",IDC_STATIC,7,10,44,12 LTEXT "Fade Length",IDC_STATIC,7,25,41,8
EDITTEXT IDC_LOOP_COUNT,52,7,39,14,ES_AUTOHSCROLL EDITTEXT IDC_FADE_SECONDS,52,23,39,14,ES_AUTOHSCROLL
LTEXT "Fade Length",IDC_STATIC,7,25,41,8 LTEXT "seconds",IDC_STATIC,93,25,29,11
EDITTEXT IDC_FADE_SECONDS,52,23,39,14,ES_AUTOHSCROLL LTEXT "Fade Delay",IDC_STATIC,7,40,41,8
LTEXT "seconds",IDC_STATIC,93,25,29,11 EDITTEXT IDC_FADE_DELAY_SECONDS,52,38,39,14,ES_AUTOHSCROLL
LTEXT "Fade Delay",IDC_STATIC,7,40,41,8 LTEXT "seconds",IDC_STATIC,93,40,29,11
EDITTEXT IDC_FADE_DELAY_SECONDS,52,38,39,14,ES_AUTOHSCROLL CONTROL "Loop normally",IDC_LOOP_NORMALLY,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,7,57,77,10
LTEXT "seconds",IDC_STATIC,93,40,29,11 CONTROL "Loop forever",IDC_LOOP_FOREVER,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,7,70,77,10
CONTROL "Loop normally",IDC_LOOP_NORMALLY,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,7,57,77,10 CONTROL "Ignore looping",IDC_IGNORE_LOOP,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,7,83,77,10
CONTROL "Loop forever",IDC_LOOP_FOREVER,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,7,70,77,10 END
CONTROL "Ignore looping",IDC_IGNORE_LOOP,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,7,83,77,10
LTEXT "Thread Priority",IDC_STATIC,21,99,46,8
CONTROL "Slider1",IDC_THREAD_PRIORITY_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | WS_TABSTOP,7,107,77,10 /////////////////////////////////////////////////////////////////////////////
CTEXT "DATARIFIC",IDC_THREAD_PRIORITY_TEXT,7,120,77,18 //
END // DESIGNINFO
//
#endif // English (Australia) resources
///////////////////////////////////////////////////////////////////////////// #ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_CONFIG, DIALOG
#ifndef APSTUDIO_INVOKED BEGIN
///////////////////////////////////////////////////////////////////////////// END
// END
// Generated from the TEXTINCLUDE 3 resource. #endif // APSTUDIO_INVOKED
//
#endif // English (Australia) resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -141,7 +141,7 @@
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="" AdditionalLibraryDirectories=""
IgnoreDefaultLibraryNames="" IgnoreDefaultLibraryNames=""
DelayLoadDLLs="libvorbis.dll;libmpg123-0.dll;libg7221_decode.dll" DelayLoadDLLs=""
SubSystem="2" SubSystem="2"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"

View File

@ -1,199 +1,173 @@
#ifdef _MSC_VER #ifdef _MSC_VER
#define _CRT_SECURE_NO_DEPRECATE #define _CRT_SECURE_NO_DEPRECATE
#endif #endif
#include <windows.h> #include <windows.h>
#include <windowsx.h> #include <windowsx.h>
#include <commctrl.h> #include <commctrl.h>
#include <stdio.h> #include <stdio.h>
#include <io.h> #include <io.h>
#include <foobar2000.h> #include <foobar2000.h>
#include <helpers.h> #include <helpers.h>
#include <shared.h> #include <shared.h>
#include "foo_prefs.h" #include "foo_prefs.h"
extern "C" { extern "C" {
#include "../src/vgmstream.h" #include "../src/vgmstream.h"
#include "../src/util.h" #include "../src/util.h"
} }
#include "foo_vgmstream.h" #include "foo_vgmstream.h"
static const char * priority_strings[] = {"Idle","Lowest","Below Normal","Normal","Above Normal","Highest (not recommended)","Time Critical (not recommended)"}; static const GUID guid_cfg_LoopForever = { 0xa19e36eb, 0x72a0, 0x4077, { 0x91, 0x43, 0x38, 0xb4, 0x5, 0xfc, 0x91, 0xc5 } };
static const int priority_values[] = {THREAD_PRIORITY_IDLE,THREAD_PRIORITY_LOWEST,THREAD_PRIORITY_BELOW_NORMAL,THREAD_PRIORITY_NORMAL,THREAD_PRIORITY_ABOVE_NORMAL,THREAD_PRIORITY_HIGHEST,THREAD_PRIORITY_TIME_CRITICAL}; static const GUID guid_cfg_IgnoreLoop = { 0xddda7ab6, 0x7bb6, 0x4abe, { 0xb9, 0x66, 0x2d, 0xb7, 0x8f, 0xe4, 0xcc, 0xab } };
static const GUID guid_cfg_LoopCount = { 0xfc8dfd72, 0xfae8, 0x44cc, { 0xbe, 0x99, 0x1c, 0x7b, 0x27, 0x7a, 0xb6, 0xb9 } };
static const GUID guid_cfg_Priority = { 0x6a94e07f, 0xf565, 0x455f, { 0x87, 0x27, 0x30, 0xce, 0x81, 0x44, 0xd2, 0xf } }; static const GUID guid_cfg_FadeLength = { 0x61da7ef1, 0x56a5, 0x4368, { 0xae, 0x6, 0xec, 0x6f, 0xd7, 0xe6, 0x15, 0x5d } };
static const GUID guid_cfg_LoopForever = { 0xa19e36eb, 0x72a0, 0x4077, { 0x91, 0x43, 0x38, 0xb4, 0x5, 0xfc, 0x91, 0xc5 } }; static const GUID guid_cfg_FadeDelay = { 0x73907787, 0xaf49, 0x4659, { 0x96, 0x8e, 0x9f, 0x70, 0xa1, 0x62, 0x49, 0xc4 } };
static const GUID guid_cfg_IgnoreLoop = { 0xddda7ab6, 0x7bb6, 0x4abe, { 0xb9, 0x66, 0x2d, 0xb7, 0x8f, 0xe4, 0xcc, 0xab } };
static const GUID guid_cfg_LoopCount = { 0xfc8dfd72, 0xfae8, 0x44cc, { 0xbe, 0x99, 0x1c, 0x7b, 0x27, 0x7a, 0xb6, 0xb9 } }; static cfg_bool cfg_LoopForever(guid_cfg_LoopForever, DEFAULT_LOOP_FOREVER);
static const GUID guid_cfg_FadeLength = { 0x61da7ef1, 0x56a5, 0x4368, { 0xae, 0x6, 0xec, 0x6f, 0xd7, 0xe6, 0x15, 0x5d } }; static cfg_bool cfg_IgnoreLoop(guid_cfg_IgnoreLoop, DEFAULT_IGNORE_LOOP);
static const GUID guid_cfg_FadeDelay = { 0x73907787, 0xaf49, 0x4659, { 0x96, 0x8e, 0x9f, 0x70, 0xa1, 0x62, 0x49, 0xc4 } }; static cfg_string cfg_LoopCount(guid_cfg_LoopCount, DEFAULT_LOOP_COUNT);
static cfg_string cfg_FadeLength(guid_cfg_FadeLength, DEFAULT_FADE_SECONDS);
static cfg_uint cfg_Priority(guid_cfg_Priority, DEFAULT_THREAD_PRIORITY); static cfg_string cfg_FadeDelay(guid_cfg_FadeDelay, DEFAULT_FADE_DELAY_SECONDS);
static cfg_bool cfg_LoopForever(guid_cfg_LoopForever, DEFAULT_LOOP_FOREVER);
static cfg_bool cfg_IgnoreLoop(guid_cfg_IgnoreLoop, DEFAULT_IGNORE_LOOP); // Needs to be here in rder to access the static config
static cfg_string cfg_LoopCount(guid_cfg_LoopCount, DEFAULT_LOOP_COUNT); void input_vgmstream::load_settings()
static cfg_string cfg_FadeLength(guid_cfg_FadeLength, DEFAULT_FADE_SECONDS); {
static cfg_string cfg_FadeDelay(guid_cfg_FadeDelay, DEFAULT_FADE_DELAY_SECONDS); // no verification needed here, as it is done below
sscanf(cfg_FadeLength.get_ptr(),"%lf",&fade_seconds);
// Needs to be here in rder to access the static config sscanf(cfg_LoopCount.get_ptr(),"%lf",&loop_count);
void input_vgmstream::load_settings() sscanf(cfg_FadeDelay.get_ptr(),"%lf",&fade_delay_seconds);
{ loop_forever = cfg_LoopForever;
// no verification needed here, as it is done below ignore_loop = cfg_IgnoreLoop;
sscanf(cfg_FadeLength.get_ptr(),"%lf",&fade_seconds); }
sscanf(cfg_LoopCount.get_ptr(),"%lf",&loop_count);
sscanf(cfg_FadeDelay.get_ptr(),"%lf",&fade_delay_seconds); const char * vgmstream_prefs::get_name()
thread_priority = priority_values[cfg_Priority]; {
loop_forever = cfg_LoopForever; return "vgmstream";
ignore_loop = cfg_IgnoreLoop; }
}
const char * vgmstream_prefs::get_name() GUID vgmstream_prefs::get_guid()
{ {
return "vgmstream"; static const GUID guid = { 0x2b5d0302, 0x165b, 0x409c, { 0x94, 0x74, 0x2c, 0x8c, 0x2c, 0xd7, 0x6a, 0x25 } };;
} return guid;
}
GUID vgmstream_prefs::get_guid()
{ GUID vgmstream_prefs::get_parent_guid()
static const GUID guid = { 0x2b5d0302, 0x165b, 0x409c, { 0x94, 0x74, 0x2c, 0x8c, 0x2c, 0xd7, 0x6a, 0x25 } };; {
return guid; return guid_input;
} }
GUID vgmstream_prefs::get_parent_guid() BOOL vgmstreamPreferences::OnInitDialog(CWindow, LPARAM)
{ {
return guid_input; CheckDlgButton(IDC_LOOP_FOREVER, cfg_LoopForever?BST_CHECKED:BST_UNCHECKED);
} CheckDlgButton(IDC_IGNORE_LOOP, cfg_IgnoreLoop?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(IDC_LOOP_NORMALLY, (!cfg_IgnoreLoop && !cfg_LoopForever)?BST_CHECKED:BST_UNCHECKED);
BOOL vgmstreamPreferences::OnInitDialog(CWindow, LPARAM) uSetDlgItemText(m_hWnd, IDC_LOOP_COUNT, cfg_LoopCount);
{ uSetDlgItemText(m_hWnd, IDC_FADE_SECONDS, cfg_FadeLength);
CheckDlgButton(IDC_LOOP_FOREVER, cfg_LoopForever?BST_CHECKED:BST_UNCHECKED); uSetDlgItemText(m_hWnd, IDC_FADE_DELAY_SECONDS, cfg_FadeDelay);
CheckDlgButton(IDC_IGNORE_LOOP, cfg_IgnoreLoop?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(IDC_LOOP_NORMALLY, (!cfg_IgnoreLoop && !cfg_LoopForever)?BST_CHECKED:BST_UNCHECKED); return TRUE;
}
uSetDlgItemText(m_hWnd, IDC_LOOP_COUNT, cfg_LoopCount);
uSetDlgItemText(m_hWnd, IDC_FADE_SECONDS, cfg_FadeLength);
uSetDlgItemText(m_hWnd, IDC_FADE_DELAY_SECONDS, cfg_FadeDelay); t_uint32 vgmstreamPreferences::get_state()
{
SendDlgItemMessage(IDC_THREAD_PRIORITY_SLIDER, TBM_SETRANGE, 1, MAKELONG(0, 6)); t_uint32 state = preferences_state::resettable;
SendDlgItemMessage(IDC_THREAD_PRIORITY_SLIDER, TBM_SETPOS, 1, cfg_Priority); if (HasChanged()) state |= preferences_state::changed;
return state;
uSetDlgItemText(m_hWnd, IDC_THREAD_PRIORITY_TEXT, priority_strings[cfg_Priority]); }
return TRUE;
}
void vgmstreamPreferences::reset()
{
t_uint32 vgmstreamPreferences::get_state() CheckDlgButton(IDC_LOOP_FOREVER, DEFAULT_LOOP_FOREVER?BST_CHECKED:BST_UNCHECKED);
{ CheckDlgButton(IDC_IGNORE_LOOP, DEFAULT_IGNORE_LOOP?BST_CHECKED:BST_UNCHECKED);
t_uint32 state = preferences_state::resettable; CheckDlgButton(IDC_LOOP_NORMALLY, (!DEFAULT_IGNORE_LOOP && !DEFAULT_LOOP_FOREVER)?BST_CHECKED:BST_UNCHECKED);
if (HasChanged()) state |= preferences_state::changed;
return state; uSetDlgItemText(m_hWnd, IDC_LOOP_COUNT, DEFAULT_LOOP_COUNT);
} uSetDlgItemText(m_hWnd, IDC_FADE_SECONDS, DEFAULT_FADE_SECONDS);
uSetDlgItemText(m_hWnd, IDC_FADE_DELAY_SECONDS, DEFAULT_FADE_DELAY_SECONDS);
}
void vgmstreamPreferences::reset()
{
CheckDlgButton(IDC_LOOP_FOREVER, DEFAULT_LOOP_FOREVER?BST_CHECKED:BST_UNCHECKED);
CheckDlgButton(IDC_IGNORE_LOOP, DEFAULT_IGNORE_LOOP?BST_CHECKED:BST_UNCHECKED); void vgmstreamPreferences::apply()
CheckDlgButton(IDC_LOOP_NORMALLY, (!DEFAULT_IGNORE_LOOP && !DEFAULT_LOOP_FOREVER)?BST_CHECKED:BST_UNCHECKED); {
cfg_LoopForever = IsDlgButtonChecked(IDC_LOOP_FOREVER)?true:false;
uSetDlgItemText(m_hWnd, IDC_LOOP_COUNT, DEFAULT_LOOP_COUNT); cfg_IgnoreLoop = IsDlgButtonChecked(IDC_IGNORE_LOOP)?true:false;
uSetDlgItemText(m_hWnd, IDC_FADE_SECONDS, DEFAULT_FADE_SECONDS);
uSetDlgItemText(m_hWnd, IDC_FADE_DELAY_SECONDS, DEFAULT_FADE_DELAY_SECONDS); double temp_fade_seconds;
double temp_fade_delay_seconds;
SendDlgItemMessage(IDC_THREAD_PRIORITY_SLIDER, TBM_SETRANGE, 1, MAKELONG(0, 6)); double temp_loop_count;
SendDlgItemMessage(IDC_THREAD_PRIORITY_SLIDER, TBM_SETPOS, 1, DEFAULT_THREAD_PRIORITY); int consumed;
uSetDlgItemText(m_hWnd, IDC_THREAD_PRIORITY_TEXT, priority_strings[DEFAULT_THREAD_PRIORITY]); pfc::string buf;
} buf = uGetDlgItemText(m_hWnd, IDC_FADE_SECONDS);
if (sscanf(buf.get_ptr(),"%lf%n",&temp_fade_seconds,&consumed)<1
|| consumed!=strlen(buf.get_ptr()) ||
temp_fade_seconds<0) {
void vgmstreamPreferences::apply() uMessageBox(m_hWnd,
{ "Invalid value for Fade Length\n"
cfg_LoopForever = IsDlgButtonChecked(IDC_LOOP_FOREVER)?true:false; "Must be a number greater than or equal to zero",
cfg_IgnoreLoop = IsDlgButtonChecked(IDC_IGNORE_LOOP)?true:false; "Error",MB_OK|MB_ICONERROR);
return;
double temp_fade_seconds; } else cfg_FadeLength = buf.get_ptr();
double temp_fade_delay_seconds;
double temp_loop_count; buf = uGetDlgItemText(m_hWnd, IDC_LOOP_COUNT);
int consumed; if (sscanf(buf.get_ptr(),"%lf%n",&temp_loop_count,&consumed)<1
|| consumed!=strlen(buf.get_ptr()) ||
pfc::string buf; temp_loop_count<0) {
buf = uGetDlgItemText(m_hWnd, IDC_FADE_SECONDS); uMessageBox(m_hWnd,
if (sscanf(buf.get_ptr(),"%lf%n",&temp_fade_seconds,&consumed)<1 "Invalid value for Loop Count\n"
|| consumed!=strlen(buf.get_ptr()) || "Must be a number greater than or equal to zero",
temp_fade_seconds<0) { "Error",MB_OK|MB_ICONERROR);
uMessageBox(m_hWnd, return;
"Invalid value for Fade Length\n" } else cfg_LoopCount = buf.get_ptr();
"Must be a number greater than or equal to zero",
"Error",MB_OK|MB_ICONERROR); buf = uGetDlgItemText(m_hWnd, IDC_FADE_DELAY_SECONDS);
return; if (sscanf(buf.get_ptr(),"%lf%n",&temp_fade_delay_seconds,&consumed)<1
} else cfg_FadeLength = buf.get_ptr(); || consumed!=strlen(buf.get_ptr()) ||
temp_fade_delay_seconds<0) {
buf = uGetDlgItemText(m_hWnd, IDC_LOOP_COUNT); uMessageBox(m_hWnd,
if (sscanf(buf.get_ptr(),"%lf%n",&temp_loop_count,&consumed)<1 "Invalid value for Fade Delay\n"
|| consumed!=strlen(buf.get_ptr()) || "Must be a number",
temp_loop_count<0) { "Error",MB_OK|MB_ICONERROR);
uMessageBox(m_hWnd, return;
"Invalid value for Loop Count\n" } else cfg_FadeDelay = buf.get_ptr();
"Must be a number greater than or equal to zero", }
"Error",MB_OK|MB_ICONERROR);
return;
} else cfg_LoopCount = buf.get_ptr(); bool vgmstreamPreferences::HasChanged()
{
buf = uGetDlgItemText(m_hWnd, IDC_FADE_DELAY_SECONDS); if(IsDlgButtonChecked(IDC_LOOP_FOREVER))
if (sscanf(buf.get_ptr(),"%lf%n",&temp_fade_delay_seconds,&consumed)<1 if(cfg_LoopForever != true) return true;
|| consumed!=strlen(buf.get_ptr()) ||
temp_fade_delay_seconds<0) { if(IsDlgButtonChecked(IDC_IGNORE_LOOP))
uMessageBox(m_hWnd, if(cfg_IgnoreLoop != true) return true;
"Invalid value for Fade Delay\n"
"Must be a number", if(IsDlgButtonChecked(IDC_LOOP_NORMALLY))
"Error",MB_OK|MB_ICONERROR); if(cfg_IgnoreLoop != false || cfg_LoopForever != false) return true;
return;
} else cfg_FadeDelay = buf.get_ptr(); pfc::string FadeLength(cfg_FadeLength);
pfc::string FadeDelay(cfg_FadeDelay);
cfg_Priority = (t_uint32)SendDlgItemMessage(IDC_THREAD_PRIORITY_SLIDER, TBM_GETPOS, 0, 0); pfc::string LoopCount(cfg_LoopCount);
}
if(FadeLength != uGetDlgItemText(m_hWnd, IDC_FADE_SECONDS)) return true;
if(FadeDelay != uGetDlgItemText(m_hWnd, IDC_FADE_DELAY_SECONDS)) return true;
bool vgmstreamPreferences::HasChanged() if(LoopCount != uGetDlgItemText(m_hWnd, IDC_LOOP_COUNT)) return true;
{
if(IsDlgButtonChecked(IDC_LOOP_FOREVER)) return FALSE;
if(cfg_LoopForever != true) return true; }
if(IsDlgButtonChecked(IDC_IGNORE_LOOP))
if(cfg_IgnoreLoop != true) return true; void vgmstreamPreferences::OnEditChange(UINT, int, CWindow)
{
if(IsDlgButtonChecked(IDC_LOOP_NORMALLY)) m_callback->on_state_changed();
if(cfg_IgnoreLoop != false || cfg_LoopForever != false) return true; }
pfc::string FadeLength(cfg_FadeLength);
pfc::string FadeDelay(cfg_FadeDelay); static preferences_page_factory_t<vgmstream_prefs> g_vgmstream_preferences_page_factory;
pfc::string LoopCount(cfg_LoopCount);
if(FadeLength != uGetDlgItemText(m_hWnd, IDC_FADE_SECONDS)) return true;
if(FadeDelay != uGetDlgItemText(m_hWnd, IDC_FADE_DELAY_SECONDS)) return true;
if(LoopCount != uGetDlgItemText(m_hWnd, IDC_LOOP_COUNT)) return true;
int Priority = SendDlgItemMessage(IDC_THREAD_PRIORITY_SLIDER, TBM_GETPOS, 0, 0);
if(Priority != cfg_Priority) return true;
return FALSE;
}
void vgmstreamPreferences::OnEditChange(UINT, int, CWindow)
{
m_callback->on_state_changed();
}
void vgmstreamPreferences::OnVScroll(UINT nSBCode, UINT nPos, CTrackBarCtrl pScrollBar)
{
int index = pScrollBar.GetPos();
uSetDlgItemText(m_hWnd, IDC_THREAD_PRIORITY_TEXT, priority_strings[index]);
m_callback->on_state_changed();
}
static preferences_page_factory_t<vgmstream_prefs> g_vgmstream_preferences_page_factory;

View File

@ -1,70 +1,67 @@
#pragma once #pragma once
#ifndef _FOO_PREFS_H #ifndef _FOO_PREFS_H
#define _FOO_PREFS_H #define _FOO_PREFS_H
#include <foobar2000.h> #include <foobar2000.h>
#include <helpers.h> #include <helpers.h>
#include <shared.h> #include <shared.h>
#include <ATLHelpers.h> #include <ATLHelpers.h>
#include "resource.h" #include "resource.h"
#define DEFAULT_FADE_SECONDS "10.00" #define DEFAULT_FADE_SECONDS "10.00"
#define DEFAULT_FADE_DELAY_SECONDS "0.00" #define DEFAULT_FADE_DELAY_SECONDS "0.00"
#define DEFAULT_LOOP_COUNT "2.00" #define DEFAULT_LOOP_COUNT "2.00"
#define DEFAULT_THREAD_PRIORITY 3 #define DEFAULT_LOOP_FOREVER false
#define DEFAULT_LOOP_FOREVER false #define DEFAULT_IGNORE_LOOP false
#define DEFAULT_IGNORE_LOOP false
class vgmstreamPreferences : public CDialogImpl<vgmstreamPreferences>, public preferences_page_instance {
class vgmstreamPreferences : public CDialogImpl<vgmstreamPreferences>, public preferences_page_instance { public:
public: //Constructor - invoked by preferences_page_impl helpers - don't do Create() in here, preferences_page_impl does this for us
//Constructor - invoked by preferences_page_impl helpers - don't do Create() in here, preferences_page_impl does this for us vgmstreamPreferences(preferences_page_callback::ptr callback) : m_callback(callback) {}
vgmstreamPreferences(preferences_page_callback::ptr callback) : m_callback(callback) {}
//Note that we don't bother doing anything regarding destruction of our class.
//Note that we don't bother doing anything regarding destruction of our class. //The host ensures that our dialog is destroyed first, then the last reference to our preferences_page_instance object is released, causing our object to be deleted.
//The host ensures that our dialog is destroyed first, then the last reference to our preferences_page_instance object is released, causing our object to be deleted.
//dialog resource ID
//dialog resource ID enum {IDD = IDD_CONFIG};
enum {IDD = IDD_CONFIG}; // preferences_page_instance methods (not all of them - get_wnd() is supplied by preferences_page_impl helpers)
// preferences_page_instance methods (not all of them - get_wnd() is supplied by preferences_page_impl helpers) t_uint32 get_state();
t_uint32 get_state(); void apply();
void apply(); void reset();
void reset();
//WTL message map
//WTL message map BEGIN_MSG_MAP(UsfPreferences)
BEGIN_MSG_MAP(UsfPreferences) MSG_WM_INITDIALOG(OnInitDialog)
MSG_WM_INITDIALOG(OnInitDialog) COMMAND_HANDLER_EX(IDC_IGNORE_LOOP, BN_CLICKED, OnEditChange)
COMMAND_HANDLER_EX(IDC_IGNORE_LOOP, BN_CLICKED, OnEditChange) COMMAND_HANDLER_EX(IDC_LOOP_FOREVER, BN_CLICKED, OnEditChange)
COMMAND_HANDLER_EX(IDC_LOOP_FOREVER, BN_CLICKED, OnEditChange) COMMAND_HANDLER_EX(IDC_LOOP_NORMALLY, BN_CLICKED, OnEditChange)
COMMAND_HANDLER_EX(IDC_LOOP_NORMALLY, BN_CLICKED, OnEditChange) COMMAND_HANDLER_EX(IDC_FADE_SECONDS, EN_CHANGE, OnEditChange)
COMMAND_HANDLER_EX(IDC_FADE_SECONDS, EN_CHANGE, OnEditChange) COMMAND_HANDLER_EX(IDC_FADE_DELAY_SECONDS, EN_CHANGE, OnEditChange)
COMMAND_HANDLER_EX(IDC_FADE_DELAY_SECONDS, EN_CHANGE, OnEditChange) COMMAND_HANDLER_EX(IDC_LOOP_COUNT, EN_CHANGE, OnEditChange)
COMMAND_HANDLER_EX(IDC_LOOP_COUNT, EN_CHANGE, OnEditChange) END_MSG_MAP()
MSG_WM_HSCROLL(OnVScroll) private:
END_MSG_MAP() BOOL OnInitDialog(CWindow, LPARAM);
private: void OnEditChange(UINT, int, CWindow);
BOOL OnInitDialog(CWindow, LPARAM); bool HasChanged();
void OnEditChange(UINT, int, CWindow); void OnChanged();
void OnVScroll(UINT nSBCode, UINT nPos, CTrackBarCtrl pScrollBar);
bool HasChanged(); const preferences_page_callback::ptr m_callback;
void OnChanged(); };
const preferences_page_callback::ptr m_callback;
};
class vgmstream_prefs : public preferences_page_impl<vgmstreamPreferences>
{
class vgmstream_prefs : public preferences_page_impl<vgmstreamPreferences> public:
{ const char * get_name();
GUID get_guid();
public: GUID get_parent_guid();
const char * get_name();
GUID get_guid(); };
GUID get_parent_guid();
};
#endif
#endif

View File

@ -42,11 +42,9 @@ class input_vgmstream {
char filename[260]; char filename[260];
t_input_open_reason currentreason; t_input_open_reason currentreason;
VGMSTREAM * vgmstream; VGMSTREAM * vgmstream;
HANDLE decode_thread_handle;
bool decoding; bool decoding;
int paused; int paused;
int decode_abort;
int decode_pos_ms; int decode_pos_ms;
int decode_pos_samples; int decode_pos_samples;
int stream_length_samples; int stream_length_samples;
@ -56,7 +54,6 @@ class input_vgmstream {
double fade_seconds; double fade_seconds;
double fade_delay_seconds; double fade_delay_seconds;
double loop_count; double loop_count;
int thread_priority;
bool loop_forever; bool loop_forever;
int ignore_loop; int ignore_loop;
int seek_pos_samples; int seek_pos_samples;
@ -65,7 +62,7 @@ class input_vgmstream {
short sample_buffer[OUTBUF_SIZE]; short sample_buffer[OUTBUF_SIZE];
void getfileinfo(char *filename, char *title, int *length_in_ms, int *sample_rate, int *channels, abort_callback & p_abort); void getfileinfo(char *filename, char *title, int *length_in_ms, int *total_samples, int *loop_start, int *loop_end, int *sample_rate, int *channels, abort_callback & p_abort);
void load_settings(); void load_settings();
private: private:

View File

@ -31,7 +31,7 @@ extern "C" {
#define APP_NAME "vgmstream plugin" #define APP_NAME "vgmstream plugin"
#define PLUGIN_DESCRIPTION "vgmstream plugin " VERSION " " __DATE__ "\n" \ #define PLUGIN_DESCRIPTION "vgmstream plugin " VERSION " " __DATE__ "\n" \
"by hcs, FastElbja, manakoAT, and bxaimc\n" \ "by hcs, FastElbja, manakoAT, and bxaimc\n" \
"foobar2000 plugin by Josh W\n\n" \ "foobar2000 plugin by Josh W, kode54\n\n" \
"http://sourceforge.net/projects/vgmstream" "http://sourceforge.net/projects/vgmstream"
#define PLUGIN_VERSION VERSION " " __DATE__ #define PLUGIN_VERSION VERSION " " __DATE__
@ -76,7 +76,6 @@ void input_vgmstream::open(service_ptr_t<file> p_filehint,const char * p_path,t_
return; return;
} }
decode_abort = 0;
decode_pos_ms = 0; decode_pos_ms = 0;
decode_pos_samples = 0; decode_pos_samples = 0;
paused = 0; paused = 0;
@ -87,10 +86,13 @@ void input_vgmstream::open(service_ptr_t<file> p_filehint,const char * p_path,t_
break; break;
case input_open_info_read: case input_open_info_read:
if ( p_filehint.is_empty() ) input_open_file_helper( p_filehint, p_path, p_reason, p_abort );
stats = p_filehint->get_stats( p_abort );
break; break;
case input_open_info_write: case input_open_info_write:
//cant write...ever //cant write...ever
throw exception_io_data();
break; break;
default: default:
@ -100,35 +102,34 @@ void input_vgmstream::open(service_ptr_t<file> p_filehint,const char * p_path,t_
void input_vgmstream::get_info(file_info & p_info,abort_callback & p_abort ) { void input_vgmstream::get_info(file_info & p_info,abort_callback & p_abort ) {
int length_in_ms=0, channels = 0, samplerate = 0; int length_in_ms=0, channels = 0, samplerate = 0;
int total_samples = -1;
int loop_start = -1, loop_end = -1;
char title[256]; char title[256];
getfileinfo(filename, title, &length_in_ms, &samplerate, &channels, p_abort); getfileinfo(filename, title, &length_in_ms, &total_samples, &loop_start, &loop_end, &samplerate, &channels, p_abort);
p_info.info_set_int("samplerate", samplerate); p_info.info_set_int("samplerate", samplerate);
p_info.info_set_int("channels", channels); p_info.info_set_int("channels", channels);
p_info.info_set_int("bitspersample",16); p_info.info_set_int("bitspersample",16);
p_info.info_set("encoding","lossless"); p_info.info_set("encoding","lossless");
p_info.info_set_bitrate((samplerate * 16 * channels) / 1000); p_info.info_set_bitrate((samplerate * 16 * channels) / 1000);
if (total_samples > 0)
p_info.info_set_int("stream_total_samples", total_samples);
if (loop_start >= 0 && loop_end >= loop_start)
{
p_info.info_set_int("loop_start", loop_start);
p_info.info_set_int("loop_end", loop_end);
}
p_info.set_length(((double)length_in_ms)/1000); p_info.set_length(((double)length_in_ms)/1000);
} }
void input_vgmstream::decode_initialize(unsigned p_flags,abort_callback & p_abort) { void input_vgmstream::decode_initialize(unsigned p_flags,abort_callback & p_abort) {
if(!loop_forever || !vgmstream->loop_flag) if (p_flags & input_flag_no_looping) loop_forever = false;
p_flags|=input_flag_no_looping; decode_seek( 0, p_abort );
}; };
bool input_vgmstream::decode_run(audio_chunk & p_chunk,abort_callback & p_abort) { bool input_vgmstream::decode_run(audio_chunk & p_chunk,abort_callback & p_abort) {
// why is this being called while this is being called? bad foobar!
while(decoding)
Sleep(10);
decoding = true;
int CurPriority = GetThreadPriority(GetCurrentThread());
SetThreadPriority(GetCurrentThread(), thread_priority);
int max_buffer_samples = sizeof(sample_buffer)/sizeof(sample_buffer[0])/vgmstream->channels; int max_buffer_samples = sizeof(sample_buffer)/sizeof(sample_buffer[0])/vgmstream->channels;
int l = 0, samples_to_do = max_buffer_samples, t= 0; int l = 0, samples_to_do = max_buffer_samples, t= 0;
@ -172,12 +173,9 @@ bool input_vgmstream::decode_run(audio_chunk & p_chunk,abort_callback & p_abort)
decode_pos_ms=decode_pos_samples*1000LL/vgmstream->sample_rate; decode_pos_ms=decode_pos_samples*1000LL/vgmstream->sample_rate;
decoding = false; decoding = false;
SetThreadPriority(GetCurrentThread(), CurPriority);
return samples_to_do==max_buffer_samples; return samples_to_do==max_buffer_samples;
} }
SetThreadPriority(GetCurrentThread(), CurPriority);
decoding = false;
return false; return false;
} }
@ -210,9 +208,7 @@ void input_vgmstream::decode_seek(double p_seconds,abort_callback & p_abort) {
input_vgmstream::input_vgmstream() { input_vgmstream::input_vgmstream() {
vgmstream = NULL; vgmstream = NULL;
decode_thread_handle = INVALID_HANDLE_VALUE;
paused = 0; paused = 0;
decode_abort = 0;
decode_pos_ms = 0; decode_pos_ms = 0;
decode_pos_samples = 0; decode_pos_samples = 0;
stream_length_samples = 0; stream_length_samples = 0;
@ -220,7 +216,6 @@ input_vgmstream::input_vgmstream() {
fade_seconds = 10.0f; fade_seconds = 10.0f;
fade_delay_seconds = 0.0f; fade_delay_seconds = 0.0f;
loop_count = 2.0f; loop_count = 2.0f;
thread_priority = 3;
loop_forever = false; loop_forever = false;
ignore_loop = 0; ignore_loop = 0;
decoding = false; decoding = false;
@ -502,7 +497,7 @@ bool input_vgmstream::g_is_our_path(const char * p_path,const char * p_extension
/* retrieve information on this or possibly another file */ /* retrieve information on this or possibly another file */
void input_vgmstream::getfileinfo(char *filename, char *title, int *length_in_ms, int *sample_rate, int *channels, abort_callback & p_abort) { void input_vgmstream::getfileinfo(char *filename, char *title, int *length_in_ms, int *total_samples, int *loop_start, int *loop_end, int *sample_rate, int *channels, abort_callback & p_abort) {
VGMSTREAM * infostream; VGMSTREAM * infostream;
if (length_in_ms) if (length_in_ms)
@ -514,6 +509,12 @@ void input_vgmstream::getfileinfo(char *filename, char *title, int *length_in_ms
test_length = *length_in_ms; test_length = *length_in_ms;
*sample_rate = infostream->sample_rate; *sample_rate = infostream->sample_rate;
*channels = infostream->channels; *channels = infostream->channels;
*total_samples = infostream->num_samples;
if (infostream->loop_flag)
{
*loop_start = infostream->loop_start_sample;
*loop_end = infostream->loop_end_sample;
}
close_vgmstream(infostream); close_vgmstream(infostream);
infostream=NULL; infostream=NULL;