summaryrefslogtreecommitdiff
path: root/plugins/mRadio
diff options
context:
space:
mode:
authorAlexey Kulakov <panda75@bk.ru>2014-02-02 09:39:36 +0000
committerAlexey Kulakov <panda75@bk.ru>2014-02-02 09:39:36 +0000
commit7c53c3c262dd67bbe9bcac3971621face2455f82 (patch)
treedc3ac8c5fb55a284a82a2b55968bf6d6d3de19b5 /plugins/mRadio
parent5abedf89d15719fb5e2ba394363ad85264ac2f58 (diff)
Miranda API update
mRadio:refactoring git-svn-id: http://svn.miranda-ng.org/main/trunk@8000 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/mRadio')
-rw-r--r--plugins/mRadio/i_hotkey.inc1
-rw-r--r--plugins/mRadio/i_myservice.inc141
-rw-r--r--plugins/mRadio/i_optdlg.inc477
-rw-r--r--plugins/mRadio/i_service.inc16
-rw-r--r--plugins/mRadio/i_tray.inc91
-rw-r--r--plugins/mRadio/i_variables.inc2
-rw-r--r--plugins/mRadio/i_visual.inc4
-rw-r--r--plugins/mRadio/mradio.dpr266
-rw-r--r--plugins/mRadio/rbass.pas (renamed from plugins/mRadio/i_bass.inc)407
-rw-r--r--plugins/mRadio/rccenter.pas (renamed from plugins/mRadio/i_cc.inc)70
-rw-r--r--plugins/mRadio/rframeapi.pas (renamed from plugins/mRadio/i_frameapi.inc)72
-rw-r--r--plugins/mRadio/rglobal.pas (renamed from plugins/mRadio/i_vars.inc)193
-rw-r--r--plugins/mRadio/roptions.pas251
13 files changed, 1188 insertions, 803 deletions
diff --git a/plugins/mRadio/i_hotkey.inc b/plugins/mRadio/i_hotkey.inc
index 380c714623..9fb613fe5f 100644
--- a/plugins/mRadio/i_hotkey.inc
+++ b/plugins/mRadio/i_hotkey.inc
@@ -52,7 +52,6 @@ begin
hkrec.lParam := MRC_MUTE;
CallService(MS_HOTKEY_REGISTER,0,lparam(@hkrec));
- //??
hkrec.DefHotKey := DefRadioKeyRecord;
hkrec.pszName := HKN_RECORD;
hkrec.pszDescription.a:= 'Start/Stop Record';
diff --git a/plugins/mRadio/i_myservice.inc b/plugins/mRadio/i_myservice.inc
index d938a08d92..4f50cf573c 100644
--- a/plugins/mRadio/i_myservice.inc
+++ b/plugins/mRadio/i_myservice.inc
@@ -137,8 +137,147 @@ begin
else
EQ_OFF;
end;
- if eq[0].wnd<>0 then // if options opened
+ if eq[0].wnd<>0 then // if options opened (can use hVolCtrl)
begin
CheckDlgButton(GetParent(eq[0].wnd),IDC_EQOFF,isEQ_OFF);
end;
end;
+
+//----- Import-export -----
+
+function ImportOneStation(group:PAnsiChar;section:pointer):int;
+var
+ p:pWideChar;
+ pc:pAnsiChar;
+begin
+ result:=0;
+ pc:=GetParamSectionStr(section,'URL');
+ if pc<>nil then
+ begin
+ result:=CallService(MS_DB_CONTACT_ADD,0,0);
+ if result<>0 then
+ begin
+ CallService(MS_PROTO_ADDTOCONTACT,result,lparam(PluginName));
+ DBWriteString(result,PluginName,optStationURL,pc);
+ DBWriteString(result,PluginName,optFirstName ,pc);
+
+ pc:=GetParamSectionStr(section,optBitrate,'0');
+ DBWriteString(result,PluginName,optBitrate,pc);
+ DBWriteWord (result,PluginName,optAge ,StrToInt(pc));
+
+ pc:=GetParamSectionStr(section,'Name',GetSectionName(section));
+ DBWriteString(result,strCList ,optMyHandle,pc);
+ DBWriteString(result,PluginName,optNick ,pc);
+
+ pc:=GetParamSectionStr(section,optGenre,'unknown');
+ DBWriteString(result,PluginName,optGenre ,pc);
+ DBWriteString(result,PluginName,optLastName,pc);
+
+ SetStatus(result,ID_STATUS_OFFLINE);
+
+ if group=nil then
+ group:=GetParamSectionStr(section,optGroup);
+
+ AnsiToWide(group,p,MirandaCP);
+ CreateGroupW(p,result);
+ mFreeMem(p);
+ CallService(MS_IGNORE_IGNORE,result,IGNOREEVENT_ALL);
+ end;
+ end;
+end;
+
+function ImportAll(wParam:WPARAM;lParam:LPARAM):int; cdecl;
+var
+ dst:array [0..MAX_PATH-1] of AnsiChar;
+ pc:pAnsiChar;
+ lstorage,section,list:pointer;
+begin
+ result:=0;
+ if lParam<>0 then
+ StrCopy(dst,PAnsiChar(lParam));
+ if (lParam<>0) or ShowDlg(dst,'radio.ini',nil,true) then
+ begin
+ lstorage:=OpenStorage(dst);
+ if lstorage<>nil then
+ begin
+ list:=GetSectionList(lstorage);
+
+ pc:=list;
+ while pc^<>#0 do
+ begin
+ section:=SearchSection(lstorage,pc);
+ if ImportOneStation(pAnsiChar(wParam),section)<>0 then inc(result);
+ while pc^<>#0 do inc(pc);
+ inc(pc);
+ end;
+
+ FreeSectionList(list);
+
+ CloseStorage(lstorage);
+ end;
+ end;
+end;
+
+procedure ExportRadioContact(num:integer;fname:PAnsiChar;hContact:THANDLE);
+var
+ pc:pAnsiChar;
+ section:array [0..15] of AnsiChar;
+begin
+ IntToStr(section,num);
+ pc:=DBReadString(hContact,strCList,optMyHandle);
+ WritePrivateProfileStringA(section,'Name',pc,fname);
+ mFreeMem(pc);
+
+ pc:=DBReadString(hContact,PluginName,optStationURL);
+ WritePrivateProfileStringA(section,'URL',pc,fname);
+ mFreeMem(pc);
+
+ pc:=DBReadString(hContact,PluginName,optGenre);
+ if pc<>nil then
+ begin
+ WritePrivateProfileStringA(section,optGenre,pc,fname);
+ mFreeMem(pc);
+ end;
+
+ pc:=DBReadString(hContact,PluginName,optBitrate);
+ if pc<>nil then
+ begin
+ WritePrivateProfileStringA(section,optBitrate,pc,fname);
+ mFreeMem(pc);
+ end;
+
+ pc:=DBReadString(hContact,strCList,optGroup);
+ if pc<>nil then
+ begin
+ WritePrivateProfileStringA(section,optGroup,pc,fname);
+ mFreeMem(pc);
+ end;
+end;
+
+function ExportAll(wParam:WPARAM;lParam:LPARAM):int; cdecl;
+var
+ dst:array [0..MAX_PATH-1] of AnsiChar;
+ hContact:THANDLE;
+begin
+ result:=0;
+ if lParam<>0 then
+ StrCopy(dst,PAnsiChar(lParam));
+ if (lParam<>0) or ShowDlg(dst,'radio.ini',nil,false) then
+ begin
+ if (wParam<>0) and (CallService(MS_DB_CONTACT_IS,wParam,0)<>0) then
+ begin
+ result:=1;
+ ExportRadioContact(result,dst,wParam)
+ end
+ else
+ begin
+ hContact:=db_find_first(PluginName);
+ while hContact<>0 do
+ begin
+ inc(result);
+ ExportRadioContact(result,dst,hContact);
+ hContact:=db_find_next(hContact,PluginName);
+ end;
+ end;
+ end;
+end;
diff --git a/plugins/mRadio/i_optdlg.inc b/plugins/mRadio/i_optdlg.inc
index 7f1ec138cd..f807d65a22 100644
--- a/plugins/mRadio/i_optdlg.inc
+++ b/plugins/mRadio/i_optdlg.inc
@@ -1,142 +1,5 @@
{Options dialog}
-function ImportOneStation(group:PAnsiChar;section:pointer):int;
-var
- p:pWideChar;
- pc:pAnsiChar;
-begin
- result:=0;
- pc:=GetParamSectionStr(section,'URL');
- if pc<>nil then
- begin
- result:=CallService(MS_DB_CONTACT_ADD,0,0);
- if result<>0 then
- begin
- CallService(MS_PROTO_ADDTOCONTACT,result,lparam(PluginName));
- DBWriteString(result,PluginName,optStationURL,pc);
- DBWriteString(result,PluginName,optFirstName ,pc);
-
- pc:=GetParamSectionStr(section,optBitrate,'0');
- DBWriteString(result,PluginName,optBitrate,pc);
- DBWriteWord (result,PluginName,optAge ,StrToInt(pc));
-
- pc:=GetParamSectionStr(section,'Name',GetSectionName(section));
- DBWriteString(result,strCList ,optMyHandle,pc);
- DBWriteString(result,PluginName,optNick ,pc);
-
- pc:=GetParamSectionStr(section,optGenre,'unknown');
- DBWriteString(result,PluginName,optGenre ,pc);
- DBWriteString(result,PluginName,optLastName,pc);
-
- SetStatus(result,ID_STATUS_OFFLINE);
-
- if group=nil then
- group:=GetParamSectionStr(section,optGroup);
-
- AnsiToWide(group,p,MirandaCP);
- CreateGroupW(p,result);
- mFreeMem(p);
- CallService(MS_IGNORE_IGNORE,result,IGNOREEVENT_ALL);
- end;
- end;
-end;
-
-function ImportAll(wParam:WPARAM;lParam:LPARAM):int; cdecl;
-var
- dst:array [0..MAX_PATH-1] of AnsiChar;
- pc:pAnsiChar;
- lstorage,section,list:pointer;
-begin
- result:=0;
- if lParam<>0 then
- StrCopy(dst,PAnsiChar(lParam));
- if (lParam<>0) or ShowDlg(dst,'radio.ini',nil,true) then
- begin
- lstorage:=OpenStorage(dst);
- if lstorage<>nil then
- begin
- list:=GetSectionList(lstorage);
-
- pc:=list;
- while pc^<>#0 do
- begin
- section:=SearchSection(lstorage,pc);
- if ImportOneStation(pAnsiChar(wParam),section)<>0 then inc(result);
- while pc^<>#0 do inc(pc);
- inc(pc);
- end;
-
- FreeSectionList(list);
-
- CloseStorage(lstorage);
- end;
- end;
-end;
-
-procedure ExportRadioContact(num:integer;fname:PAnsiChar;hContact:THANDLE);
-var
- pc:pAnsiChar;
- section:array [0..15] of AnsiChar;
-begin
- IntToStr(section,num);
- pc:=DBReadString(hContact,strCList,optMyHandle);
- WritePrivateProfileStringA(section,'Name',pc,fname);
- mFreeMem(pc);
-
- pc:=DBReadString(hContact,PluginName,optStationURL);
- WritePrivateProfileStringA(section,'URL',pc,fname);
- mFreeMem(pc);
-
- pc:=DBReadString(hContact,PluginName,optGenre);
- if pc<>nil then
- begin
- WritePrivateProfileStringA(section,optGenre,pc,fname);
- mFreeMem(pc);
- end;
-
- pc:=DBReadString(hContact,PluginName,optBitrate);
- if pc<>nil then
- begin
- WritePrivateProfileStringA(section,optBitrate,pc,fname);
- mFreeMem(pc);
- end;
-
- pc:=DBReadString(hContact,strCList,optGroup);
- if pc<>nil then
- begin
- WritePrivateProfileStringA(section,optGroup,pc,fname);
- mFreeMem(pc);
- end;
-end;
-
-function ExportAll(wParam:WPARAM;lParam:LPARAM):int; cdecl;
-var
- dst:array [0..MAX_PATH-1] of AnsiChar;
- hContact:THANDLE;
-begin
- result:=0;
- if lParam<>0 then
- StrCopy(dst,PAnsiChar(lParam));
- if (lParam<>0) or ShowDlg(dst,'radio.ini',nil,false) then
- begin
- if (wParam<>0) and (CallService(MS_DB_CONTACT_IS,wParam,0)<>0) then
- begin
- result:=1;
- ExportRadioContact(result,dst,wParam)
- end
- else
- begin
- hContact:=db_find_first(PluginName);
- while hContact<>0 do
- begin
- inc(result);
- ExportRadioContact(result,dst,hContact);
- hContact:=db_find_next(hContact,PluginName);
- end;
- end;
- end;
-end;
-
function MakeFilter(dst,descr,full,filter:PWideChar;show:bool=true):pWideChar;
var
p:PWideChar;
@@ -179,19 +42,25 @@ begin
pc:=MakeFilter(pc,'Playlist files',full,'*.pls;*.m3u;*.m3u8;*.asx');
pc:=MakeFilter(pc,'BASS built-in' ,full,'*.mp3;*.mp2;*.mp1;*.ogg;*.wav;*.aif');
- ph:=pointer(BASS_PluginGetInfo(0));
- if ph<>nil then
+ if BassStatus=rbs_null then
+ MyLoadBass;
+
+ if BassStatus<>rbs_null then
begin
- while ph^<>0 do
+ ph:=pointer(BASS_PluginGetInfo(0));
+ if ph<>nil then
begin
- Info:=BASS_PluginGetInfo(ph^);
- for i:=0 to Info^.formatc-1 do
-//!! need to translate Ansi -> wide
- with Info^.Formats[i] do
- begin
- pc:=MakeFilter(pc,FastAnsiToWideBuf(name,tmpbuf1),full,FastAnsiToWideBuf(exts,tmpbuf2));
- end;
- inc(ph);
+ while ph^<>0 do
+ begin
+ Info:=BASS_PluginGetInfo(ph^);
+ for i:=0 to Info^.formatc-1 do
+ //!! need to translate Ansi -> wide
+ with Info^.Formats[i] do
+ begin
+ pc:=MakeFilter(pc,FastAnsiToWideBuf(name,tmpbuf1),full,FastAnsiToWideBuf(exts,tmpbuf2));
+ end;
+ inc(ph);
+ end;
end;
end;
pc:=MakeFilter(pc,'All supported formats',nil,full,false);
@@ -241,17 +110,6 @@ var
begin
result:=0;
case hMessage of
- WM_DESTROY: begin
- DBWriteByte(0,PluginName,optLoop ,doLoop);
- DBWriteByte(0,PluginName,optShuffle ,doShuffle);
- DBWriteByte(0,PluginName,optContRec ,doContRec);
- DBWriteByte(0,PluginName,optPlayFirst,PlayFirst);
- DBWriteByte(0,PluginName,optConnect ,AuConnect);
- DBWriteByte(0,PluginName,optAutoMute ,AuMute);
- DBWriteByte(0,PluginName,optOffline ,AsOffline);
-
- DBWriteUnicode(0,PluginName,optStatusTmpl,StatusTmpl);
- end;
WM_INITDIALOG: begin
DlgInit:=1;
@@ -383,7 +241,7 @@ begin
DBWriteUnicode(i,strCList,optGroup,dst)
else
DBDeleteSetting(i,strCList,optGroup);
-
+
end
else if loword(wParam)=IDC_ADD_INI then
begin
@@ -451,13 +309,6 @@ begin
doLoop:=IsDlgButtonChecked(Dialog,IDC_LOOP);
if chan<>0 then
begin
-{
- BASS_ChannelGetInfo(chan,info);
- if doLoop<>BST_UNCHECKED then
- info.flags:=info.flags or BASS_SAMPLE_LOOP
- else
- info.flags:=info.flags and not BASS_SAMPLE_LOOP;
-}
BASS_ChannelFlags(chan,ord(doLoop<>BST_UNCHECKED),BASS_SAMPLE_LOOP);
end;
@@ -472,7 +323,8 @@ begin
end
else
recpath:=GetDefaultRecPath;
- DBWriteUnicode(0,PluginName,optRecPath,recpath);
+
+ SaveCommonSettings;
end;
end;
@@ -483,171 +335,71 @@ end;
//----- Tech tab -----
-const
- OldEQPreset:integer=-1;
-const
- optOldPreset:pAnsiChar='oldpreset';
- optPresets :pAnsiChar='numpreset';
- optPreset :pAnsiChar='preset_';
- optPreDescr :pAnsiChar='predescr_';
-
-const
- PresetMax = 17;
-
-procedure InitPresets;
-type
- tP = array [0..9] of AnsiChar;
-begin
- StrDupW(Presets[00].name,'Acoustic' ); tP(Presets[00].preset):=#$01#$02#$00#$00#$00#$00#$00#$01#$01#$03;
- StrDupW(Presets[01].name,'Blues' ); tP(Presets[01].preset):=#$01#$02#$01#$00#$00#$00#$00#$00#$00#$FE;
- StrDupW(Presets[02].name,'Classical'); tP(Presets[02].preset):=#$01#$04#$01#$00#$00#$00#$00#$00#$01#$01;
- StrDupW(Presets[03].name,'Country' ); tP(Presets[03].preset):=#$00#$00#$01#$01#$00#$00#$01#$01#$01#$01;
- StrDupW(Presets[04].name,'Dance' ); tP(Presets[04].preset):=#$04#$03#$02#$01#$FF#$FF#$02#$04#$05#$05;
- StrDupW(Presets[05].name,'Folk' ); tP(Presets[05].preset):=#$FF#$00#$00#$01#$01#$00#$01#$01#$01#$00;
- StrDupW(Presets[06].name,'Grunge' ); tP(Presets[06].preset):=#$01#$00#$FF#$00#$00#$02#$01#$FF#$FE#$FD;
- StrDupW(Presets[07].name,'Jazz' ); tP(Presets[07].preset):=#$00#$01#$02#$03#$03#$01#$01#$03#$04#$05;
- StrDupW(Presets[08].name,'Metall' ); tP(Presets[08].preset):=#$FE#$00#$00#$00#$00#$03#$02#$04#$06#$05;
- StrDupW(Presets[09].name,'New Age' ); tP(Presets[09].preset):=#$03#$03#$00#$00#$00#$00#$00#$00#$02#$02;
- StrDupW(Presets[10].name,'Opera' ); tP(Presets[10].preset):=#$00#$01#$02#$04#$01#$02#$00#$00#$00#$00;
- StrDupW(Presets[11].name,'Rap' ); tP(Presets[11].preset):=#$00#$04#$04#$00#$00#$00#$01#$04#$05#$07;
- StrDupW(Presets[12].name,'Reggae' ); tP(Presets[12].preset):=#$03#$00#$FD#$00#$05#$00#$02#$03#$04#$05;
- StrDupW(Presets[13].name,'Rock' ); tP(Presets[13].preset):=#$00#$02#$04#$00#$00#$00#$02#$04#$05#$06;
- StrDupW(Presets[14].name,'Speech' ); tP(Presets[14].preset):=#$FE#$02#$00#$00#$00#$00#$FF#$FE#$FD#$FC;
- StrDupW(Presets[15].name,'Swing' ); tP(Presets[15].preset):=#$FF#$00#$00#$02#$02#$00#$02#$02#$03#$03;
- StrDupW(Presets[16].name,'Techno' ); tP(Presets[16].preset):=#$05#$08#$FF#$FE#$FD#$FF#$04#$06#$06#$06;
-end;
-
-procedure LoadPresets;
-var
- num,preset,descr:array [0..63] of AnsiChar;
- i:integer;
- p,pd:pAnsiChar;
-begin
- p :=StrCopyE(preset,optPreset);
- pd:=StrCopyE(descr ,optPreDescr);
-
- i:=DBReadByte(0,PluginName,optPresets);
- if i=0 then
- begin
- SetLength(Presets,PresetMax);
- InitPresets;
- end
- else
- begin
- OldEQPreset:=integer(DBReadByte(0,PluginName,optOldPreset,byte(-1)));
- SetLength(Presets,i);
- for i:=0 to HIGH(Presets) do
- begin
- StrCopy(p ,IntToStr(num,i)); DBReadStruct (0,PluginName,preset,@Presets[i].preset,10);
- StrCopy(pd,num); Presets[i].name:=DBReadUnicode(0,PluginName,descr);
- end;
- end;
-end;
-
-procedure SavePresets;
-var
- num,preset,descr:array [0..63] of AnsiChar;
- i,j:integer;
- p,pd:pAnsiChar;
-begin
- p :=StrCopyE(preset,optPreset);
- pd:=StrCopyE(descr ,optPreDescr);
- j:=DBReadByte(0,PluginName,optPresets);
- for i:=0 to HIGH(Presets) do
- begin
- StrCopy(p ,IntToStr(num,i)); DBWriteStruct (0,PluginName,preset,@Presets[i].preset,10);
- StrCopy(pd,num); DBWriteUnicode(0,PluginName,descr ,Presets[i].name);
- end;
- while j>Length(Presets) do
- begin
- dec(j);
- StrCopy(p ,IntToStr(num,j)); DBDeleteSetting(0,PluginName,preset);
- StrCopy(pd,num); DBDeleteSetting(0,PluginName,descr);
- end;
- DBWriteByte(0,PluginName,optOldPreset,OldEQPreset);
- DBWriteByte(0,PluginName,optPresets ,Length(Presets));
-end;
-
-procedure FreePresets;
-var
- i:integer;
-begin
- for i:=0 to HIGH(Presets) do
- mFreeMem(Presets[i].name);
-end;
-
procedure FillDeviceCombo(wnd:HWND;choose:pAnsiChar);
var
i,select,def:integer;
info:BASS_DEVICEINFO;
buf: array [0..255] of AnsiChar;
begin
- SendMessage(wnd,CB_RESETCONTENT,0,0);
- i:=0;
- select:=-1;
def:=0;
- repeat
- if not BASS_GetDeviceInfo(i+1,info) then
- break;
- if (info.flags and BASS_DEVICE_ENABLED)<>0 then
- begin
- if (info.flags and BASS_DEVICE_INIT)<>0 then
- begin
- select:=i;
- buf[0]:='>';
- end
- else if (info.flags and BASS_DEVICE_DEFAULT)<>0 then
- begin
- def:=i;
- buf[0]:='*';
- end
- else buf[0]:=' ';
- if select<0 then
+ SendMessage(wnd,CB_RESETCONTENT,0,0);
+ if BassStatus<>rbs_null then
+ begin
+ i:=0;
+ select:=-1;
+ repeat
+ if not BASS_GetDeviceInfo(i+1,info) then
+ break;
+ if (info.flags and BASS_DEVICE_ENABLED)<>0 then
begin
- if StrCmp(info.name,choose)=0 then
+ if (info.flags and BASS_DEVICE_INIT)<>0 then
+ begin
select:=i;
+ buf[0]:='>';
+ end
+ else if (info.flags and BASS_DEVICE_DEFAULT)<>0 then
+ begin
+ def:=i;
+ buf[0]:='*';
+ end
+ else buf[0]:=' ';
+ if select<0 then
+ begin
+ if StrCmp(info.name,choose)=0 then
+ select:=i;
+ end;
+ StrCopy(@buf[1],info.name);
+ SendMessageA(wnd,CB_ADDSTRING,0,lparam(@buf));
end;
- StrCopy(@buf[1],info.name);
- SendMessageA(wnd,CB_ADDSTRING,0,lparam(@buf));
- end;
- inc(i);
- until false;
- if select>=0 then
- def:=select;
+ inc(i);
+ until false;
+ if select>=0 then
+ def:=select;
+ end;
SendMessage(wnd,CB_SETCURSEL,def,0);
-// not acceptable coz we added 1st char
-// SendMessageW(wnd,CB_SELECTSTRING,twparam(-1),tlparam(choose))
end;
function DlgProcOptTech(Dialog:HWnd;hMessage:uint;wParam:WPARAM;lParam:LPARAM):lresult; stdcall;
const
DlgInit:integer=1;
var
- i:integer;
hEAXCombo:THANDLE;
ltmp:longbool;
-// info:BASS_CHANNELINFO;
- buf1:array [0..4] of AnsiChar;
wnd:HWND;
buf:array [0..MAX_PATH-1] of WideChar;
- dst:pWideChar;
+ dst,old:pWideChar;
+ device:pAnsiChar;
+ i,level:integer;
begin
result:=0;
case hMessage of
WM_DESTROY: begin
hVolCtrl:=0;
- buf1[0]:='E';
- buf1[1]:='Q';
- buf1[2]:='_';
- buf1[4]:=#0;
for i:=0 to 9 do
begin
- buf1[3]:=AnsiChar(ORD('0')+i);
- DBWriteByte(0,PluginName,buf1,trunc(eq[i].param.fGain)+15);
eq[i].wnd:=0;
end;
- DBWriteByte(0,PluginName,optEQ_OFF ,isEQ_OFF);
end;
WM_INITDIALOG: begin
@@ -672,11 +424,14 @@ begin
SendMessageW(hEAXCombo,CB_ADDSTRING,0,tlparam(TranslateW(EAXItems[i].name)));
SendMessage(hEAXCombo,CB_SETCURSEL,DBReadByte(0,PluginName,optEAXType,0),0);
+ if BassStatus=rbs_null then
+ MyLoadBass;
// Fill combo with devices
FillDeviceCombo(GetDlgItem(Dialog,IDC_DEVICE),usedevice);
// Add preset to combo
wnd:=GetDlgItem(Dialog,IDC_PRESET);
+
for i:=0 to HIGH(Presets) do
SendMessageW(wnd,CB_ADDSTRING,0,tlparam(Presets[i].name));
SendMessage(wnd,CB_SETCURSEL,OldEQPreset,0);
@@ -710,6 +465,11 @@ begin
BN_CLICKED: begin
case loword(wParam) of
+ IDC_EQOFF, IDC_ZERO:
+ SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
+ end;
+
+ case loword(wParam) of
IDC_BASSPTHBTN: begin
dst:=nil;
@@ -814,6 +574,7 @@ begin
break;
end;
end;
+ SendMessage(GetParent(Dialog),PSM_CHANGED,0,0);
end;
WM_HSCROLL: begin
@@ -824,58 +585,96 @@ begin
if integer(PNMHdr(lParam)^.code)=PSN_APPLY then
begin
SavePresets;
+ level:=0;
- mFreeMem(usedevice);
- usedevice:=GetDlgText(Dialog,IDC_DEVICE,true);
- StrCopy(usedevice,usedevice+1);
- DBWriteString(0,PluginName,optDevice,usedevice);
+ device:=GetDlgText(Dialog,IDC_DEVICE,true);
+ StrCopy(device,device+1);
+ if StrCmp(usedevice,device)<>0 then
+ begin
+ level:=1;
+ mFreeMem(usedevice);
+ usedevice:=device;
+ end
+ else
+ mFreeMem(device);
//!! bass path saving here
+ old:=DBReadUnicode(0,PluginName,optBASSPath,nil);
dst:=GetDlgText(Dialog,IDC_BASSPATH);
- DBWriteUnicode(0,PluginName,optBASSPath,dst);
+ if lstrcmpiw(dst,old)<>0 then
+ begin
+ level:=2;
+ DBWriteUnicode(0,PluginName,optBASSPath,dst);
+ end;
mFreeMem(dst);
-
- ForcedMono:=IsDlgButtonChecked(Dialog,IDC_MONO);
- DBWriteByte(0,PluginName,optForcedMono,ForcedMono);
+ mFreeMem(old);
i:=SendDlgItemMessage(Dialog,IDC_EAXTYPE,CB_GETCURSEL,0,0);
DBWriteByte(0,PluginName,optEAXType,i);
- if i=0 then
- BASS_SetEAXParameters(-1,0,-1,-1)
- else
- BASS_SetEAXPreset(EAXItems[i].code);
-
- NumTries:=GetDlgItemInt(Dialog,IDC_TRIES,ltmp,false);
- if NumTries<1 then NumTries:=1;
- DBWriteByte(0,PluginName,optNumTries,NumTries);
- i:=GetDlgItemInt(Dialog,IDC_PREBUF,ltmp,false);
- if i>100 then i:=100;
- if cardinal(i)<>sPreBuf then
+{
+ level>0 - need to change
+ ActiveContact<>0 - need to restart
+ BassStatus<>rbs_null - need to stop (free, unload)
+ really, if ActiveContact<>0 then BassStatus<>rbs_null
+}
+ //!!really, need to do it if only active atm
+ // need to reload dll or change outpout device
+ // don't change proxy
+ if level>0 then
begin
- sPreBuf:=i;
- BASS_SetConfig(BASS_CONFIG_NET_PREBUF,i);
- DBWriteWord(0,PluginName,optPreBuf,sPreBuf);
- end;
+ ltmp:=ActiveContact<>0;
+ if ltmp then
+ CallService(MS_RADIO_COMMAND,MRC_STOP,1);
+ // save current, stop, bass free
- i:=GetDlgItemInt(Dialog,IDC_BUFFER,ltmp,false);
- if i>20000 then i:=20000;
- if cardinal(i)<>sBuffer then
+ MyFreeBass;
+ if level=2 then
+ begin
+ MyUnloadBass;
+ // load dll
+ if ltmp then
+ MyLoadBass;
+ end;
+ // init device, restore current
+ if ltmp and (BassStatus=rbs_load) then
+ begin
+ MyInitBass;
+ end;
+ if ltmp and (BassStatus=rbs_init) then
+ begin
+ CallService(MS_RADIO_COMMAND,MRC_PAUSE,0);
+ end;
+ end
+ // if device re-init, EAX settings applied there
+ else if BassStatus=rbs_init then
begin
- sBuffer:=i;
- BASS_SetConfig(BASS_CONFIG_NET_BUFFER,i);
- DBWriteWord(0,PluginName,optBuffer,sBuffer);
+ if i=0 then
+ BASS_SetEAXParameters(-1,0,-1,-1)
+ else
+ BASS_SetEAXPreset(EAXItems[i].code);
end;
- i:=GetDlgItemInt(Dialog,IDC_TIMEOUT,ltmp,false);
- if i>30000 then i:=30000;
- if cardinal(i)<>sTimeout then
- begin
- sTimeout:=i;
- BASS_SetConfig(BASS_CONFIG_NET_TIMEOUT,i);
- DBWriteWord(0,PluginName,optTimeout,sTimeout);
- end;
+ ForcedMono:=IsDlgButtonChecked(Dialog,IDC_MONO);
+
+ NumTries:=GetDlgItemInt(Dialog,IDC_TRIES,ltmp,false);
+ if NumTries<1 then NumTries:=1;
+
+ // Bass config settings
+
+ sPreBuf:=GetDlgItemInt(Dialog,IDC_PREBUF,ltmp,false);
+ if sPreBuf>100 then sPreBuf:=100;
+
+ sBuffer:=GetDlgItemInt(Dialog,IDC_BUFFER,ltmp,false);
+ if sBuffer>20000 then sBuffer:=20000;
+
+ sTimeout:=GetDlgItemInt(Dialog,IDC_TIMEOUT,ltmp,false);
+ if sTimeout>30000 then sTimeout:=30000;
+
+ SetBassConfig;
+
+ SaveTechSettings;
end;
end;
diff --git a/plugins/mRadio/i_service.inc b/plugins/mRadio/i_service.inc
index 05072dfd94..fbc644711e 100644
--- a/plugins/mRadio/i_service.inc
+++ b/plugins/mRadio/i_service.inc
@@ -13,8 +13,8 @@ begin
result:=PF4_NOCUSTOMAUTH or PF4_AVATARS;
PFLAG_UNIQUEIDTEXT:
result:=int_ptr(Translate('Radio station URL'));
-// PFLAG_UNIQUEIDSETTING:
-// result:=int_ptr(optStationURL)
+ PFLAG_UNIQUEIDSETTING:
+ result:=int_ptr(optStationURL)
else
result:=0;
end
@@ -53,7 +53,7 @@ begin
end;
if StrPosW(buf,'%radio_active%')<>nil then
begin
- StrReplaceW(buf,'%radio_active%',ActiveURLw);
+ StrReplaceW(buf,'%radio_active%',ActiveURL);
end;
if StrPosW(buf,'%radio_genre%')<>nil then // saved as String
begin
@@ -99,7 +99,7 @@ begin
if (ccs^.hContact<>0) and (PluginStatus=ID_STATUS_ONLINE) and
(DBReadWord(ccs^.hContact,PluginName,optStatus,ID_STATUS_OFFLINE)=ID_STATUS_ONLINE) then
begin
- mir_forkthread(@GetAwayMsgProc,pointer(ccs^.hContact));
+ {CloseHandle}(mir_forkthread(@GetAwayMsgProc,pointer(ccs^.hContact)));
result:=AckHandle;
end
else
@@ -134,18 +134,14 @@ begin
if wParam=PluginStatus then
exit;
- mFreeMem(proxy);
PluginStatus:=ID_STATUS_OFFLINE;
if wParam<>ID_STATUS_OFFLINE then
begin
- if MyInitBASS<>0 then
+// if MyInitBASS then
begin
PluginStatus:=ID_STATUS_ONLINE;
- proxy:=GetProxy(hNetLib);
- BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,proxy);
-
if (ActiveContact<>0) and (AuConnect<>0) then
CallService(MS_RADIO_COMMAND,MRC_PLAY,ActiveContact);
end;
@@ -153,13 +149,13 @@ begin
else //offline
begin
CallService(MS_RADIO_COMMAND,MRC_STOP,0);
-// StopStation;
end;
SetStatus(0,ID_STATUS_OFFLINE);
ProtoBroadcastAck(PluginName,0,ACKTYPE_STATUS,ACKRESULT_SUCCESS,OldStatus,PluginStatus);
end;
+// really, can be replaced by helper function. this one more effective
function CreateProtoService(serviceName:PAnsiChar;pFunc:pointer):THANDLE;
var
temp:array [0..MAXMODULELABELLENGTH-1] of AnsiChar;
diff --git a/plugins/mRadio/i_tray.inc b/plugins/mRadio/i_tray.inc
index f0a463c5de..ab0a04e41d 100644
--- a/plugins/mRadio/i_tray.inc
+++ b/plugins/mRadio/i_tray.inc
@@ -1,6 +1,9 @@
{}
var
+ doTray:bool;
+var
trayradioparent:THANDLE;
+ trayprotoh:THANDLE;
trayparent:THANDLE;
traymute :THANDLE;
trayplay :THANDLE;
@@ -79,7 +82,10 @@ begin
begin
mFreeMem(tmp.name);
DestroyServiceFunction(tmp.service);
- CallService(MS_CLIST_REMOVETRAYMENUITEM,tmp.menuitem,0);
+ if doTray then
+ CallService(MS_CLIST_REMOVETRAYMENUITEM,tmp.menuitem,0)
+ else
+ CallService(MS_CLIST_REMOVEMAINMENUITEM,tmp.menuitem,0);
mFreeMem(tmp);
List_Remove(@trayStations,i);
end;
@@ -101,7 +107,10 @@ begin
mi.position :=i;
mi.pszService:=@buf;
mi.szName.w :=tmp.name;
- tmp.menuitem:=Menu_AddTrayMenuItem(@mi);
+ if doTray then
+ tmp.menuitem:=Menu_AddTrayMenuItem(@mi)
+ else
+ tmp.menuitem:=Menu_AddMainMenuItem(@mi);
end;
end;
end;
@@ -116,6 +125,15 @@ begin
result:=CallService(MS_RADIO_COMMAND,MRC_STOP,0);
end;
+function TrayProto(wParam:WPARAM;lParam:LPARAM):int_ptr; cdecl;
+begin
+ if PluginStatus=ID_STATUS_ONLINE then
+ wParam:=ID_STATUS_OFFLINE
+ else
+ wParam:=ID_STATUS_ONLINE;
+ result:=Service_SetStatus(wParam,lParam);
+end;
+
procedure CreateTrayMenu();
var
mi:TCListMenuItem;
@@ -126,12 +144,28 @@ begin
mi.flags :=CMIF_UNICODE;
mi.szName.w:=cPluginName;
mi.hIcon :=CallService(MS_SKIN2_GETICON,0,lparam(IcoBtnSettings));
- trayradioparent:=Menu_AddTrayMenuItem(@mi);
+ if doTray then
+ trayradioparent:=Menu_AddTrayMenuItem(@mi)
+ else
+ trayradioparent:=Menu_AddMainMenuItem(@mi);
FillChar(mi, sizeof(mi), 0);
mi.cbSize :=sizeof(mi);
mi.szPopupName:=TChar(trayradioparent);
+ if PluginStatus=ID_STATUS_ONLINE then
+ mi.szName.w :='mRadio off'
+ else
+ mi.szName.w :='mRadio on';
+ mi.flags:=CMIF_UNICODE or CMIF_ROOTHANDLE;
+ mi.position :=0;
+ srvtraystop:=CreateServiceFunction('mRadio/TrayProto',@TrayProto);
+ mi.pszService:='mRadio/TrayProto';
+ if doTray then
+ trayprotoh:=Menu_AddTrayMenuItem(@mi)
+ else
+ trayprotoh:=Menu_AddMainMenuItem(@mi);
+
if gVolume<0 then
mi.flags:=CMIF_UNICODE or CMIF_ROOTHANDLE or CMIF_CHECKED
else
@@ -139,7 +173,10 @@ begin
mi.szName.w :='Mute';
mi.pszService:=MS_RADIO_MUTE;
mi.position :=1;
- traymute:=Menu_AddTrayMenuItem(@mi);
+ if doTray then
+ traymute:=Menu_AddTrayMenuItem(@mi)
+ else
+ traymute:=Menu_AddMainMenuItem(@mi);
mi.flags:=CMIF_UNICODE or CMIF_ROOTHANDLE;
if CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_GET)<>RD_STATUS_PLAYING then
@@ -150,18 +187,27 @@ begin
mi.position :=2;
srvtrayplaypause:=CreateServiceFunction('mRadio/TrayPlayPause',@TrayPlayPause);
mi.pszService:='mRadio/TrayPlayPause';
- trayplay:=Menu_AddTrayMenuItem(@mi);
+ if doTray then
+ trayplay:=Menu_AddTrayMenuItem(@mi)
+ else
+ trayplay:=Menu_AddTrayMenuItem(@mi);
mi.szName.w :='Stop';
mi.position :=3;
srvtraystop:=CreateServiceFunction('mRadio/TrayStop',@TrayStop);
mi.pszService:='mRadio/TrayStop';
- Menu_AddTrayMenuItem(@mi);
+ if doTray then
+ Menu_AddTrayMenuItem(@mi)
+ else
+ Menu_AddMainMenuItem(@mi);
mi.szName.w :='Play Station';
mi.position :=1000;
mi.pszService:=nil;
- trayparent:=Menu_AddTrayMenuItem(@mi);
+ if doTray then
+ trayparent:=Menu_AddTrayMenuItem(@mi)
+ else
+ trayparent:=Menu_AddMainMenuItem(@mi);
end;
function TrayPrebuild(wParam:WPARAM;lParam:LPARAM):int; cdecl;
@@ -171,6 +217,15 @@ var
begin
FillChar(mi,sizeof(mi),0);
mi.cbSize:=sizeof(mi);
+
+ mi.flags:=CMIM_NAME or CMIF_UNICODE;
+ if PluginStatus=ID_STATUS_ONLINE then
+ playstr:='mRadio off'
+ else
+ playstr:='mRadio on';
+ mi.szName.w:=playstr;
+ CallService(MS_CLIST_MODIFYMENUITEM,trayprotoh,tlparam(@mi));
+
if gVolume<0 then
mi.flags:=CMIM_FLAGS or CMIF_CHECKED
else
@@ -191,13 +246,14 @@ end;
procedure CreateMIMTrayMenu;
begin
- if ServiceExists(MS_CLIST_ADDTRAYMENUITEM)<>0 then
-// if hiddenwindow<>0 then
- begin
- CreateTrayMenu();
- MakeStationsMenu();
- HookEvent(ME_CLIST_PREBUILDTRAYMENU,@TrayPrebuild);
- end;
+ doTray:=ServiceExists(MS_CLIST_ADDTRAYMENUITEM)<>0;
+
+ CreateTrayMenu();
+ MakeStationsMenu();
+ if doTray then
+ HookEvent(ME_CLIST_PREBUILDTRAYMENU,@TrayPrebuild)
+ else
+ HookEvent(ME_CLIST_PREBUILDMAINMENU,@TrayPrebuild)
end;
procedure RemoveTrayItems;
@@ -218,7 +274,8 @@ begin
DestroyServiceFunction(srvtrayplaypause);
DestroyServiceFunction(srvtraystop);
- if ServiceExists(MS_CLIST_REMOVETRAYMENUITEM)<>0 then
- CallService(MS_CLIST_REMOVETRAYMENUITEM,trayradioparent,0);
-
+ if doTray then
+ CallService(MS_CLIST_REMOVETRAYMENUITEM,trayradioparent,0)
+ else
+ CallService(MS_CLIST_REMOVEMAINMENUITEM,trayradioparent,0);
end;
diff --git a/plugins/mRadio/i_variables.inc b/plugins/mRadio/i_variables.inc
index fead4afad8..8420510193 100644
--- a/plugins/mRadio/i_variables.inc
+++ b/plugins/mRadio/i_variables.inc
@@ -35,7 +35,7 @@ begin
case i of
0: res:=DBReadUnicode(ActiveContact,strCList ,optMyHandle);
1: res:=DBReadUnicode(ActiveContact,PluginName,optStationURL);
- 2: StrDupW(res,ActiveURLw);
+ 2: StrDupW(res,ActiveURL);
3: res:=DBReadUnicode(ActiveContact,PluginName,optGenre);
4: res:=DBReadUnicode(ActiveContact,PluginName,optBitrate);
5: res:=MakeMessage;
diff --git a/plugins/mRadio/i_visual.inc b/plugins/mRadio/i_visual.inc
index 77012b55f2..3c0b56ebb2 100644
--- a/plugins/mRadio/i_visual.inc
+++ b/plugins/mRadio/i_visual.inc
@@ -1,4 +1,8 @@
{Visual part}
+var
+ hCMenuItemRec,
+ hCMenuItemPlay:THANDLE;
+
function OnContactMenu(hContact:WPARAM;lParam:LPARAM):int;cdecl;
var
mi:TCListMenuItem;
diff --git a/plugins/mRadio/mradio.dpr b/plugins/mRadio/mradio.dpr
index 4cf4aa75b5..9600988e0d 100644
--- a/plugins/mRadio/mradio.dpr
+++ b/plugins/mRadio/mradio.dpr
@@ -11,100 +11,18 @@ uses
// FastMM4,
Windows,messages,commctrl
,common,io,wrapper,wrapdlgs,syswin
- ,Dynamic_Bass,dynbasswma
- ,m_api,dbsettings,mirutils,playlist,memini;
+ ,Dynamic_Bass
+ ,m_api,dbsettings,mirutils,memini,
+ rbass,rglobal,rccenter,rframeapi,roptions;
{$include mr_rc.inc}
{$r mradio.res}
-{$include i_vars.inc}
-
-const
- cPluginName = 'mRadio';
-const
- PluginName:PAnsiChar = cPluginName;
-
-function MakeMessage:pWideChar;
-var
- p,artist,title:pWideChar;
- len:cardinal;
-begin
- artist:=DBReadUnicode(0,PluginName,optArtist);
- title :=DBReadUnicode(0,PluginName,optTitle);
- len:=StrLenW(artist);
- if (artist<>nil) and (title<>nil) then
- inc(len,3);
- inc(len,StrLenW(title));
-
- if len>0 then
- begin
- mGetMem(result,(len+1)*SizeOf(WideChar));
- p:=result;
- if artist<>nil then
- begin
- p:=StrCopyEW(p,artist);
- if title<>nil then
- p:=StrCopyEW(p,' - ');
- mFreeMem(artist);
- end;
- if title<>nil then
- begin
- StrCopyW(p,title);
- mFreeMem(title);
- end;
- end
- else
- result:=nil;
-end;
-
-procedure SetStatus(hContact:THANDLE;status:integer);
-begin
-// if Status=ID_STATUS_OFFLINE then
-// MyStopBass;
-
- if status=ID_STATUS_OFFLINE then
- begin
- if (AsOffline=BST_UNCHECKED) or (PluginStatus<>ID_STATUS_OFFLINE) then
- status:=ID_STATUS_INVISIBLE;
- end;
-
- if hContact=0 then
- begin
- hContact:=db_find_first(PluginName);
- while hContact<>0 do
- begin
- DBWriteWord(hContact,PluginName,optStatus,status);
- hContact:=db_find_next(hContact,PluginName);
- end;
- end
- else
- DBWriteWord(hContact,PluginName,optStatus,status);
-end;
-
-function GetDefaultRecPath:pWideChar;
-var
- dat:TREPLACEVARSDATA;
- mstr,szData:pWideChar;
- buf:array [0..MAX_PATH-1] of WideChar;
-begin
- FillChar(dat,SizeOf(dat),0);
- dat.cbSize :=SizeOf(TREPLACEVARSDATA);
- dat.dwFlags:=RVF_UNICODE;
- szData:='%miranda_userdata%'+'\'+cPluginName;
- mstr:=pWideChar(CallService(MS_UTILS_REPLACEVARS, WPARAM(szData), LPARAM(@dat)));
- PathToRelativeW(mstr,buf);
- StrDupW(result,buf);
- mir_free(mstr);
-end;
-
{$include i_search.inc}
-{$include i_bass.inc}
-{$include i_cc.inc}
{$include i_variables.inc}
{$include i_service.inc}
{$include i_myservice.inc}
{$include i_hotkey.inc}
-{$include i_frameapi.inc}
{$include i_tray.inc}
{$include i_visual.inc}
{$include i_optdlg.inc}
@@ -114,12 +32,12 @@ begin
result:=@PluginInfo;
PluginInfo.cbSize :=SizeOf(TPLUGININFOEX);
PluginInfo.shortName :='mRadio Mod';
- PluginInfo.version :=$00000203;
+ PluginInfo.version :=$00000204;
PluginInfo.description:='This plugin plays and records Internet radio streams.'+
' Also local media files can be played.';
PluginInfo.author :='Awkward';
PluginInfo.authorEmail:='panda75@bk.ru; awk1975@ya.ru';
- PluginInfo.copyright :='(c) 2007-2013 Awkward';
+ PluginInfo.copyright :='(c) 2007-2014 Awkward';
PluginInfo.homepage :='http://code.google.com/p/delphi-miranda-plugins/';
PluginInfo.flags :=UNICODE_AWARE;
PluginInfo.uuid :=MIID_MRADIO;
@@ -128,26 +46,35 @@ end;
function OnModulesLoaded(wParam:WPARAM;lParam:LPARAM):int;cdecl;
var
nlu:TNETLIBUSER;
- szTemp:array [0..255] of AnsiChar;
- i:integer;
+ buf:array [0..MAX_PATH-1] of WideChar;
+ szTemp:array [0..255] of AnsiChar absolute buf;
+ pc:pWideChar;
begin
- DBWriteDWord(0,PluginName,optVersion,PluginInfo.version);
+ // buf = miranda directory
+ // must be same as %miranda_path% of MS_UTILS_REPLACEVARS
- szTemp[0]:='E';
- szTemp[1]:='Q';
- szTemp[2]:='_';
- szTemp[4]:=#0;
- for i:=0 to 9 do
- begin
- szTemp[3]:=AnsiChar(ORD('0')+i);
- eq[i].param.fGain:=DBReadByte(0,PluginName,szTemp,15)-15;
- end;
- LoadPresets;
+ GetModuleFileNameW(0,buf,MAX_PATH-1);
+ pc:=StrEndW(buf);
+ repeat
+ dec(pc);
+ until pc^='\';
+ inc(pc);
+ pc^:=#0;
+
+ // INI file path
+ StrCopyW(pc,'plugins\mradio.ini');
+ FastWideToAnsi(buf,storage);
+ mGetMem(storagep,MAX_PATH+32);
+ CallService(MS_DB_GETPROFILEPATH,MAX_PATH-1,tlparam(storagep));
+ StrCat(storagep,'\mradio.ini');
+
+ DBWriteDWord(0,PluginName,optVersion,PluginInfo.version); //??
RegisterIcons;
CreateMenu;
CreateMIMTrayMenu;
+ //-- network (for proxy)
FillChar(nlu,SizeOf(nlu),0);
StrCopy(szTemp,Translate('%s server connection'));
StrReplace(szTemp,'%s',PluginName);
@@ -159,51 +86,17 @@ begin
// CallService(MS_RADIO_COMMAND,MRC_RECORD,2); record off - not so necessary
- recpath:=DBReadUnicode(0,PluginName,optRecPath);
- if (recpath=nil) or (recpath^=#0) then
- begin
- recpath:=GetDefaultRecPath;
- end;
-
- usedevice:=DBReadString(0,PluginName,optDevice);
-
- sPreBuf:=DBReadWord(0,PluginName,optPreBuf,75);
- BASS_SetConfig(BASS_CONFIG_NET_PREBUF,sPreBuf);
-
- sBuffer:=DBReadWord(0,PluginName,optBuffer,5000);
- BASS_SetConfig(BASS_CONFIG_NET_BUFFER,sBuffer);
-
- sTimeout:=DBReadWord(0,PluginName,optTimeout,5000);
- BASS_SetConfig(BASS_CONFIG_NET_TIMEOUT,sTimeout);
-
- doLoop :=DBReadByte(0,PluginName,optLoop);
- doShuffle :=DBReadByte(0,PluginName,optShuffle);
- doContRec :=DBReadByte(0,PluginName,optContRec);
- PlayFirst :=DBReadByte(0,PluginName,optPlayFirst);
- isEQ_OFF :=DBReadByte(0,PluginName,optEQ_OFF);
- AuConnect :=DBReadByte(0,PluginName,optConnect);
- AuMute :=DBReadByte(0,PluginName,optAutoMute);
- AsOffline :=DBReadByte(0,PluginName,optOffline);
- gVolume :=DBReadByte(0,PluginName,optVolume,50);
- NumTries :=DBReadByte(0,PluginName,optNumTries,1);
- ForcedMono:=DBReadByte(0,PluginName,optForcedMono);
- if NumTries<1 then NumTries:=1;
+ LoadPresets;
+ LoadSettings;
SetStatus(0,ID_STATUS_OFFLINE);
- StatusTmpl:=DBReadUnicode(0,PluginName,optStatusTmpl,'%radio_title%');
-
CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_NOSTATION);
IsMultiThread:=true;
RegisterVariables;
- if AuConnect<>BST_UNCHECKED then
- ActiveContact:=LoadContact(PluginName,optLastStn)
- else
- ActiveContact:=0;
-
HookEvent(ME_DB_CONTACT_SETTINGCHANGED,@OnSettingsChanged);
HookEvent(ME_DB_CONTACT_DELETED ,@OnContactDeleted);
randomize;
@@ -229,22 +122,21 @@ begin
UnregisterHotKey;
DestroyProtoServices;
- DestroyWindow(hiddenwindow);
DestroyFrame();
- MyFreeBASS;
+
+ MyUnloadBass;
+
DBWriteByte(0,PluginName,optVolume,gVolume);
DestroyHookableEvent(hhRadioStatus);
-
CallService(MS_NETLIB_CLOSEHANDLE,hNetLib,0);
+
mFreeMem(storage);
mFreeMem(storagep);
- mFreeMem(recpath);
- mFreeMem(usedevice);
- mFreeMem(StatusTmpl);
- mFreeMem(basspath);
+
FreePresets;
+ FreeSettings;
{
//delete cover files
buf[0]:=#0;
@@ -268,71 +160,49 @@ end;
function Load(): int; cdecl;
var
desc:TPROTOCOLDESCRIPTOR;
- szTemp:array [0..MAX_PATH-1] of WideChar;
- pc:pWideChar;
- custom:pWideChar;
begin
Langpack_register;
- GetModuleFileNameW(0,szTemp,MAX_PATH-1);
- pc:=StrEndW(szTemp);
- repeat
- dec(pc);
- until pc^='\';
- inc(pc);
- pc^:=#0;
+ // register protocol
+ FillChar(desc,SizeOf(desc),0);
+ desc.cbSize:=PROTOCOLDESCRIPTOR_V3_SIZE;//SizeOf(desc);
+ desc.szName:=PluginName;
+ desc._type :=PROTOTYPE_VIRTUAL;
+ CallService(MS_PROTO_REGISTERMODULE,0,lparam(@desc));
- custom:=DBReadUnicode(0,PluginName,optBASSPath,nil);
+ // hooks and services
+ hhRadioStatus:=CreateHookableEvent(ME_RADIO_STATUS);
+
+ CreateServiceFunction(MS_RADIO_PLAYSTOP,@Service_RadioPlayStop);
+ CreateServiceFunction(MS_RADIO_RECORD ,@Service_RadioRecord);
+ CreateServiceFunction(MS_RADIO_SETTINGS,@Service_RadioSettings);
+ CreateServiceFunction(MS_RADIO_SETVOL ,@Service_RadioSetVolume);
+ CreateServiceFunction(MS_RADIO_GETVOL ,@Service_RadioGetVolume);
+ CreateServiceFunction(MS_RADIO_MUTE ,@Service_RadioMute);
+ CreateServiceFunction(MS_RADIO_COMMAND ,@ControlCenter);
+ CreateServiceFunction(MS_RADIO_EQONOFF ,@Service_EqOnOff);
+
+ CreateServiceFunction(MS_RADIO_TRAYMENU,@CreateTrayMenu);
+
+ CreateServiceFunction(MS_RADIO_EXPORT ,@ExportAll);
+ CreateServiceFunction(MS_RADIO_IMPORT ,@ImportAll);
+
+
+ CreateProtoServices;
+
+ HookEvent(ME_SYSTEM_MODULESLOADED ,@OnModulesLoaded);
+ HookEvent(ME_SYSTEM_OKTOEXIT ,@PreShutdown);
+ HookEvent(ME_CLIST_DOUBLECLICKED ,@Service_RadioPlayStop{@DblClickProc});
+ HookEvent(ME_OPT_INITIALISE ,@OnOptInitialise);
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU,@OnContactMenu);
+
+ PluginStatus:=ID_STATUS_OFFLINE;
- if MyLoadBASS(szTemp,custom) then
- begin
- StrCopyW(pc,'plugins\mradio.ini');
-// StrDup(storage,szTemp);
- FastWideToAnsi(szTemp,storage);
- mGetMem(storagep,MAX_PATH+32);
- CallService(MS_DB_GETPROFILEPATH,MAX_PATH-1,lparam(storagep));
- StrCat(storagep,'\mradio.ini');
-
- FillChar(desc,SizeOf(desc),0);
- desc.cbSize:=PROTOCOLDESCRIPTOR_V3_SIZE;//SizeOf(desc);
- desc.szName:=PluginName;
- desc._type :=PROTOTYPE_VIRTUAL;
- CallService(MS_PROTO_REGISTERMODULE,0,lparam(@desc));
-
- hhRadioStatus:=CreateHookableEvent(ME_RADIO_STATUS);
-
- CreateServiceFunction(MS_RADIO_PLAYSTOP,@Service_RadioPlayStop);
- CreateServiceFunction(MS_RADIO_RECORD ,@Service_RadioRecord);
- CreateServiceFunction(MS_RADIO_SETTINGS,@Service_RadioSettings);
- CreateServiceFunction(MS_RADIO_SETVOL ,@Service_RadioSetVolume);
- CreateServiceFunction(MS_RADIO_GETVOL ,@Service_RadioGetVolume);
- CreateServiceFunction(MS_RADIO_MUTE ,@Service_RadioMute);
- CreateServiceFunction(MS_RADIO_COMMAND ,@ControlCenter);
- CreateServiceFunction(MS_RADIO_EQONOFF ,@Service_EqOnOff);
-
- hiddenwindow:=CreateHiddenWindow;
- CreateServiceFunction(MS_RADIO_TRAYMENU,@CreateTrayMenu);
-
- CreateServiceFunction(MS_RADIO_EXPORT ,@ExportAll);
- CreateServiceFunction(MS_RADIO_IMPORT ,@ImportAll);
-
-
- CreateProtoServices;
- HookEvent(ME_SYSTEM_MODULESLOADED ,@OnModulesLoaded);
- HookEvent(ME_SYSTEM_OKTOEXIT ,@PreShutdown);
- HookEvent(ME_CLIST_DOUBLECLICKED ,@Service_RadioPlayStop{@DblClickProc});
- HookEvent(ME_OPT_INITIALISE ,@OnOptInitialise);
- HookEvent(ME_CLIST_PREBUILDCONTACTMENU,@OnContactMenu);
-
- PluginStatus:=ID_STATUS_OFFLINE;
- end;
- mFreeMem(custom);
Result:=0;
end;
function Unload: int; cdecl;
begin
- Unload_BASSDLL;
Result:=0;
end;
diff --git a/plugins/mRadio/i_bass.inc b/plugins/mRadio/rbass.pas
index 5e430de282..91728b4d32 100644
--- a/plugins/mRadio/i_bass.inc
+++ b/plugins/mRadio/rbass.pas
@@ -1,4 +1,36 @@
{BASS dll code}
+unit rbass;
+
+interface
+
+uses
+ windows;
+
+procedure BassError(text:PWideChar);
+procedure OpenURL(url:PWideChar); cdecl;
+procedure StopStation;
+function GetMusicFormat:PAnsiChar;
+
+procedure EQ_ON;
+procedure EQ_OFF;
+procedure SetSndVol(arg:integer);
+procedure SetBassConfig;
+
+procedure MyFreeBASS;
+function MyInitBASS:bool;
+procedure MyUnloadBass;
+function MyLoadBASS:bool;
+function CheckBassStatus:bool;
+
+implementation
+
+uses
+ common, m_api, io
+ ,dbsettings, mirutils, wrapdlgs
+ ,Dynamic_Bass,dynbasswma
+ ,rglobal
+ ;
+
const
signMP3 = $FBFF;
signID3 = $00334449;
@@ -7,8 +39,6 @@ const
const
BASSName = 'bass.dll';
StationHeader:PByte=nil;
-const
- basspath:PWideChar=nil;
var
hdrlen:integer;
syncMETA,
@@ -18,30 +48,20 @@ var
syncEND:HSYNC;
SaveHeader:bool;
-procedure SetSndVol(arg:integer);
-begin
- if arg<0 then
- arg:=gVolume
- else
- gVolume:=arg;
-
- if chan<>0 then
- begin
- if arg<0 then arg:=0;
- BASS_ChannelSetAttribute(chan,BASS_ATTRIB_VOL,arg/100);
- end;
-end;
+const
+ hRecord:THANDLE = 0;
procedure BassError(text:PWideChar);
begin
MessageboxW(0,TranslateW(text),TranslateW('Sorry!'),MB_ICONERROR)
end;
+// now called from BASS_Init only, so no dll load check
procedure ErrorCustom(text:pWideChar=nil);
var
buf:array [0..255] of WideChar;
- idx:integer;
pcw:pWideChar;
+ idx:integer;
begin
idx:=BASS_ErrorGetCode();
if (idx<0) or (idx>BASS_ERROR_MAXNUMBER) then
@@ -58,10 +78,37 @@ begin
TranslateW('Oops! BASS error'),MB_ICONERROR)
end;
+
+
+procedure SetBassConfig;
+begin
+ if BassStatus=rbs_null then exit;
+
+ BASS_SetConfig(BASS_CONFIG_NET_PREBUF ,sPreBuf);
+ BASS_SetConfig(BASS_CONFIG_NET_BUFFER ,sBuffer);
+ BASS_SetConfig(BASS_CONFIG_NET_TIMEOUT,sTimeout);
+end;
+
+procedure SetSndVol(arg:integer);
+begin
+ if arg<0 then
+ arg:=gVolume
+ else
+ gVolume:=arg;
+
+ // no BASS dll - no channel
+ if chan<>0 then
+ begin
+ if arg<0 then arg:=0;
+ BASS_ChannelSetAttribute(chan,BASS_ATTRIB_VOL,arg/100);
+ end;
+end;
+
procedure EQ_OFF;
var
- i:dword;
+ i:cardinal;
begin
+ // no BASS dll - no channel
if chan<>0 then
for i:=0 to 9 do
BASS_ChannelRemoveFX(chan,eq[i].fx);
@@ -70,8 +117,9 @@ end;
procedure EQ_ON;
var
- i:dword;
+ i:cardinal;
begin
+ // no BASS dll - no channel
if chan<>0 then
begin
for i:=0 to 9 do
@@ -82,86 +130,12 @@ begin
end;
end;
-function MyLoadBASS(root:PwideChar;custom:pWideChar):bool;
-var
- pc:PWideChar;
- buf:array [0..MAX_PATH-1] of WideChar;
-begin
- result:=true;
- mGetMem(basspath,1024);
- pc:=StrCopyEW(basspath,custom);
- if (pc-1)^<>'\' then
- begin
- pc^:='\';
- inc(pc);
- end;
- StrCopyW(pc,BASSName);
- if not Load_BASSDLL(basspath) then
- begin
- pc:=StrCopyW(StrCopyEW(basspath,root),BASSName);
- if not Load_BASSDLL(basspath) then
- begin
- pc:=StrCopyW(StrCopyEW(pc,'plugins\'),BASSName);
- if not Load_BASSDLL(basspath) then
- begin
- pc:=StrCopyW(StrCopyEW(pc,'bass\'),BASSName);
- if not Load_BASSDLL(basspath) then
- begin
- if (custom<>nil) and (custom^<>#0) then
- BassError('BASS.DLL not found!');
- result:=false;
- end;
- end;
- end;
- end;
- if (not result) and ((custom=nil) or (custom^=#0)) then
- begin
- if MessageboxA(0,Translate('BASS.DLL not found! Choose BASS.dll path manually'),
- cPluginName,MB_YESNO)=IDYES then
- begin
- pc := nil;
- if SelectDirectory(TranslateW('Choose BASS.dll path'),pc,0) then
- begin
- PathToRelativeW(pc,buf);
- pc:=StrCopyEW(basspath,buf);
- if (pc-1)^<>'\' then
- begin
- pc^:='\';
- inc(pc);
- end;
- pc^:=#0;
- DBWriteUnicode(0,PluginName,optBASSPath,basspath);
- StrCopyW(pc,BASSName);
-
- if not Load_BASSDLL(basspath) then
- BassError('BASS.DLL not found!')
- else
- result:=true;
- end;
-
- end;
- end;
-
- if result then
- begin
- if (BASS_GetVersion shr 16)<BASSVERSION then
- begin
- Unload_BASSDLL;
- result:=false;
- BassError('Wrong version of BASS.DLL');
- end
- else
- begin
- pc^:=#0; // cut BASSName
- exit;
- end;
- end;
- mFreeMem(basspath);
-end;
procedure MyStopBASS;
begin
+ if BassStatus=rbs_null then exit;
+
if ActiveContact<>0 then
begin
if syncMETA<>0 then
@@ -194,9 +168,13 @@ end;
procedure MyFreeBASS;
begin
- MyStopBASS;
- BASS_Free;
- BASS_PluginFree(0);
+ if BassStatus=rbs_init then
+ begin
+ MyStopBASS;
+ BASS_Free;
+
+ BassStatus:=rbs_load;
+ end;
end;
procedure StopStation;
@@ -205,7 +183,7 @@ begin
BASS_StreamFree(chan); // close old stream
chan:=0;
mFreeMem(StationHeader);
- mFreeMem(ActiveURLw);
+ mFreeMem(ActiveURL);
DBDeleteSetting(ActiveContact,strCList,optStatusMsg);
MyStopBASS;
end;
@@ -217,7 +195,7 @@ var
begin
// default device
result:=-1;
- i:=1;
+ i:=1; // 0 is always the "no sound" device
repeat
if not BASS_GetDeviceInfo(i,info) then
break;
@@ -233,64 +211,213 @@ begin
until false;
end;
-function MyInitBASS:int;
+function MyInitBASS:bool;
var
- fd:TWin32FindDataW;
- fh:THANDLE;
- buf:array [0..MAX_PATH-1] of WideChar;
-// buf1:array [0..31] of WideChar;
- pc:PWideChar;
- p:Bool;
num:integer;
begin
- if Inited then
+ if BassSTatus=rbs_null then
begin
- result:=1;
+ result:=false;
exit;
+ // or can do this:
+ MyLoadBass;
+ if BassSTatus=rbs_null then
+ begin
+ result:=false;
+ exit;
+ end;
end;
- Inited:=true;
- BASS_Free;
+ if BassStatus=rbs_init then
+ begin
+ result:=true;
+ exit;
+ end;
num:=GetDeviceNumber;
- p:=BASS_Init(num,44100,BASS_DEVICE_3D,0,nil);
- if not p then
- p:=BASS_Init(num,44100,0,0,nil);
+ result:=BASS_Init(num,44100,BASS_DEVICE_3D,0,nil);
+ if not result then
+ result:=BASS_Init(num,44100,0,0,nil);
// not default device choosed - check default now
- if (not p) and (num>=0) then
+ if (not result) and (num>=0) then
begin
- p:=BASS_Init(-1,44100,BASS_DEVICE_3D,0,nil);
- if not p then
- p:=BASS_Init(-1,44100,0,0,nil);
+ result:=BASS_Init(-1,44100,BASS_DEVICE_3D,0,nil);
+ if not result then
+ result:=BASS_Init(-1,44100,0,0,nil);
end;
- if not p then
+ if not result then
begin
ErrorCustom('Can''t initialize device');
- result:=0;
end
else
begin
- pc:=StrCopyW(StrCopyEW(buf,basspath),'bass*.dll');
- fh:=FindFirstFileW(buf,fd);
- if fh<>INVALID_HANDLE_VALUE then
+ num:=DBReadByte(0,PluginName,optEAXType,0);
+ if num=0 then
+ BASS_SetEAXParameters(-1,0,-1,-1)
+ else
+ BASS_SetEAXPreset(EAXItems[num].code);
+ end;
+
+ if result then
+ BassStatus:=rbs_init;
+end;
+
+procedure MyUnloadBass;
+begin
+ MyFreeBASS;
+ if BassStatus=rbs_load then
+ begin
+ BASS_PluginFree(0);
+ Unload_BASSDLL;
+
+ BassStatus:=rbs_null;
+ end;
+end;
+
+function MyLoadBASS:bool;
+var
+ pc,custom:PWideChar;
+ basspath:PWideChar;
+ buf:array [0..MAX_PATH-1] of WideChar;
+ fh:THANDLE;
+ fd:TWin32FindDataW;
+begin
+ if BassStatus<>rbs_null then
+ begin
+ result:=true;
+ exit;
+ end;
+
+ mGetMem(basspath,1024);
+
+ // trying to load Bass.dll from custom
+ custom:=DBReadUnicode(0,PluginName,optBASSPath,nil);
+ if custom<>nil then
+ begin
+ pc:=StrCopyEW(basspath,custom);
+ if (pc-1)^<>'\' then
+ begin
+ pc^:='\';
+ inc(pc);
+ end;
+ StrCopyW(pc,BASSName);
+
+ result:=Load_BASSDLL(basspath);
+ end
+ else
+ result:=false;
+
+ if not result then
+ begin
+ GetModuleFileNameW(0,buf,MAX_PATH-1);
+ pc:=StrEndW(buf);
+ repeat
+ dec(pc);
+ until pc^='\';
+ inc(pc);
+ pc^:=#0;
+
+ pc:=StrCopyW(StrCopyEW(basspath,buf),BASSName); // %miranda_path%\
+ result:=Load_BASSDLL(basspath);
+ if not result then
begin
- repeat
- StrCopyW(pc,fd.cFileName);
- if BASS_PluginLoad(pAnsiChar(@buf),BASS_UNICODE)=0 then
- until not FindNextFileW(fh,fd);
- FindClose(fh);
+ pc:=StrCopyW(StrCopyEW(pc,'plugins\'),BASSName); // %miranda_path%\plugins\
+ result:=Load_BASSDLL(basspath);
+ if not result then
+ begin
+ pc:=StrCopyW(StrCopyEW(pc,'bass\'),BASSName); // %miranda_path%\plugins\bass\
+ result:=Load_BASSDLL(basspath);
+ end;
end;
- // enable ASX processing (if WMA loaded)
- BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 2); // 2 - enable internet and local playlists
+ end;
- fh:=DBReadByte(0,PluginName,optEAXType,0);
- if fh=0 then
- BASS_SetEAXParameters(-1,0,-1,-1)
+ // not found but custom path is empty
+ if (not result) and (custom=nil) then
+ begin
+ if MessageboxW(0,TranslateW('BASS.DLL not found! Choose BASS.dll path manually'),
+ cPluginName,MB_YESNO)=IDYES then
+ begin
+ pc:=nil;
+ if SelectDirectory(TranslateW('Choose BASS.dll path'),pc,0) then
+ begin
+ //!! if options page opened, need to change edit field
+
+ PathToRelativeW(pc,buf);
+ pc:=StrCopyEW(basspath,buf);
+ if (pc-1)^<>'\' then
+ begin
+ pc^:='\';
+ inc(pc);
+ end;
+ pc^:=#0;
+ DBWriteUnicode(0,PluginName,optBASSPath,basspath);
+ StrCopyW(pc,BASSName);
+
+ result:=Load_BASSDLL(basspath);
+ end;
+ end;
+ end;
+
+ // check Bass.dll version
+ if result then
+ begin
+ if (BASS_GetVersion shr 16)<BASSVERSION then
+ begin
+ Unload_BASSDLL;
+ result:=false;
+ BassError('Wrong version of BASS.DLL');
+ end
else
- BASS_SetEAXPreset(EAXItems[fh].code);
- result:=1;
+ begin
+ // load Bass plugins
+ pc:=StrCopyW(pc,'bass*.dll');
+ fh:=FindFirstFileW(basspath,fd);
+ if fh<>THANDLE(INVALID_HANDLE_VALUE) then
+ begin
+ repeat
+ StrCopyW(pc,fd.cFileName);
+ if BASS_PluginLoad(pAnsiChar(basspath),BASS_UNICODE)=0 then
+ until not FindNextFileW(fh,fd);
+ FindClose(fh);
+ end;
+
+ // enable ASX processing (if WMA loaded)
+ BASS_SetConfig(BASS_CONFIG_NET_PLAYLIST, 2); // 2 - enable internet and local playlists
+ end;
+ end
+ else
+ begin
+ BassError('BASS.DLL not found!');
+ end;
+
+ mFreeMem(custom);
+ mFreeMem(basspath);
+
+ if result then
+ BassStatus:=rbs_load;
+end;
+
+function CheckBassStatus:bool;
+var
+ proxy:pAnsiChar;
+begin
+ if BassStatus=rbs_null then
+ MyLoadBass;
+
+ if BassStatus<>rbs_null then
+ begin
+ SetBassConfig;
+
+ proxy:=GetProxy(hNetLib);
+ BASS_SetConfigPtr(BASS_CONFIG_NET_PROXY,proxy);
+ mFreeMem(proxy);
end;
+
+ if BassStatus=rbs_load then
+ MyInitBass;
+
+ result:=BassStatus<>rbs_null;
end;
function GetMusicFormat:PAnsiChar;
@@ -348,6 +475,9 @@ begin
if recpath<>nil then
begin
ConvertFileName(recpath,buf,ActiveContact);
+// pcw:=ParseVarString(recpath,ActiveContact);
+// CallService(MS_UTILS_PATHTOABSOLUTEW,WPARAM(pcw),LPARAM(buf));
+// mFreeMem(pcw);
if not ForceDirectories(buf) then
begin
result:=nil;
@@ -376,6 +506,8 @@ begin
result:=buf;
end;
+
+
procedure StatusProc(buffer:Pointer;len,user:DWORD); stdcall;
var
pc:pWideChar;
@@ -729,7 +861,7 @@ begin
end;
end;
{$IFDEF Debug}
-logmeta(tag,artist,title);
+//logmeta(tag,artist,title);
{$ENDIF}
mFreeMem(oldartist);
mFreeMem(oldtitle);
@@ -826,6 +958,9 @@ var
EAXUsed:bool;
ansiurl:array [0..511] of AnsiChar;
begin
+ if not CheckBassStatus then exit;
+ if BassStatus<>rbs_init then exit; //!! check for record
+
if plist=nil then
CallService(MS_RADIO_COMMAND,MRC_STATUS,RD_STATUS_CONNECT);
@@ -967,3 +1102,5 @@ begin
BASS_ChannelPlay(chan,FALSE);
end;
end;
+
+end.
diff --git a/plugins/mRadio/i_cc.inc b/plugins/mRadio/rccenter.pas
index c9364d1e8a..6f75ef48ae 100644
--- a/plugins/mRadio/i_cc.inc
+++ b/plugins/mRadio/rccenter.pas
@@ -1,17 +1,25 @@
{}
+unit rccenter;
-function GetStatusText(status:integer;toCList:boolean=false):PWideChar;
-begin
- case status of
- RD_STATUS_PAUSED : result:='paused';
- RD_STATUS_STOPPED: if toCList then result:=nil else result:='stopped';
- RD_STATUS_CONNECT: result:='connecting';
- RD_STATUS_ABORT : result:='aborting';
- RD_STATUS_PLAYING: if toCList then result:=nil else result:='playing';
- else
- result:=nil;
- end;
-end;
+interface
+
+uses
+ windows;
+
+function ControlCenter(code:WPARAM;arg:LPARAM):int_ptr; cdecl;
+
+implementation
+
+uses
+ common, m_api,
+ dbsettings, playlist, mirutils,
+ rglobal, rbass,
+ Dynamic_Bass,
+ syswin;
+
+const
+ optCurElement :PAnsiChar = 'LastPlayed';
+ optActiveURL :PAnsiChar = 'ActiveURL'; // center
procedure ConstructMsg(artist,title:PWideChar;status:integer=-1);
var
@@ -112,21 +120,21 @@ begin
// play new station?
if arg<>0 then
begin
- ActiveURLw:=DBReadUnicode(arg,PluginName,optStationURL);
+ ActiveURL:=DBReadUnicode(arg,PluginName,optStationURL);
// no URL for this contact
- if (ActiveURLw=nil) or (ActiveURLw^=#0) then exit;
+ if (ActiveURL=nil) or (ActiveURL^=#0) then exit;
ActiveContact:=arg;
- RemoteSong:=StrPosW(ActiveURLw,'://')<>nil;
+ RemoteSong:=StrPosW(ActiveURL,'://')<>nil;
- if isPlaylist(ActiveURLw)<>0 then
+ if isPlaylist(ActiveURL)<>0 then
begin
if RemoteSong then
begin
GetTempPathW(MAX_PATH,tmpbuf);
GetTempFileNameW(tmpbuf,'mr',GetCurrentTime,buf1);
- if not GetFile(ActiveURLw,buf1,hNetLib) then
+ if not GetFile(ActiveURL,buf1,hNetLib) then
begin
exit;
end;
@@ -135,7 +143,7 @@ begin
end
else
begin
- plFile:=ActiveURLw;
+ plFile:=ActiveURL;
plLocal:=true;
end;
@@ -160,15 +168,15 @@ begin
plist.Track:=DBReadWord(ActiveContact,PluginName,optCurElement);
end;
- mFreeMem(ActiveURLw);
- ActiveURLw:=plist.GetSong;
+ mFreeMem(ActiveURL);
+ ActiveURL:=plist.GetSong;
end;
- RemoteSong:=StrPosW(ActiveURLw,'://')<>nil; // coz activeuRLw can be changed
+ RemoteSong:=StrPosW(ActiveURL,'://')<>nil; // coz ActiveURL can be changed
end
else
plist:=nil;
- if (ActiveURLw<>nil) and (ActiveURLw^<>#0) then
+ if (ActiveURL<>nil) and (ActiveURL^<>#0) then
begin
if RemoteSong then
begin
@@ -182,7 +190,7 @@ begin
ControlCenter(MRC_STATUS,RD_STATUS_NEWSTATION);
if Assigned(plist) then
ControlCenter(MRC_STATUS,RD_STATUS_CONNECT);
- mir_forkthread(@OpenURL,ActiveURLw);
+ {CloseHandle}(mir_forkthread(@OpenURL,ActiveURL));
end;
end
// play current from start
@@ -193,9 +201,9 @@ begin
arg :=RD_STATUS_PLAYING;
end
// play playlist entry?
- else if Assigned(plist) and (ActiveURLw<>nil) and (ActiveURLw^<>#0) then
+ else if Assigned(plist) and (ActiveURL<>nil) and (ActiveURL^<>#0) then
begin
- mir_forkthread(@OpenURL,ActiveURLw);
+ {CloseHandle}(mir_forkthread(@OpenURL,ActiveURL));
end;
end;
@@ -280,7 +288,7 @@ begin
if Assigned(plist) then
begin
StopStation;
- ActiveURLw:=plist.Next;
+ ActiveURL:=plist.Next;
ControlCenter(MRC_PLAY,0);
end;
end;
@@ -289,7 +297,7 @@ begin
if Assigned(plist) then
begin
StopStation;
- ActiveURLw:=plist.Previous;
+ ActiveURL:=plist.Previous;
ControlCenter(MRC_PLAY,0)
end;
end;
@@ -378,10 +386,10 @@ begin
RD_STATUS_NEWTRACK: begin
SetStatus(ActiveContact,ID_STATUS_ONLINE);
- DBWriteUnicode(0,PluginName,optActiveURL,ActiveURLw);
+ DBWriteUnicode(0,PluginName,optActiveURL,ActiveURL);
DBWriteString(0,PluginName,optActiveCodec,GetMusicFormat);
- arg :=lparam(ActiveURLw);
+ arg :=lparam(ActiveURL);
// for case when tags was in meta
artist:=DBReadUnicode(0,PluginName,optArtist);
@@ -408,7 +416,7 @@ begin
if arg=0 then
begin
PlayStatus:=RD_STATUS_PLAYING;
- if StrPosW(ActiveURLw,'://')=nil then //local only
+ if StrPosW(ActiveURL,'://')=nil then //local only
begin
artist:=DBReadUnicode(0,PluginName,optArtist);
title :=DBReadUnicode(0,PluginName,optTitle);
@@ -431,3 +439,5 @@ begin
end;
end;
+
+end.
diff --git a/plugins/mRadio/i_frameapi.inc b/plugins/mRadio/rframeapi.pas
index 8f70edbf7a..0aba02c517 100644
--- a/plugins/mRadio/i_frameapi.inc
+++ b/plugins/mRadio/rframeapi.pas
@@ -1,4 +1,26 @@
{mRadio frame}
+unit rframeapi;
+
+interface
+
+uses
+ windows;
+
+const
+ hVolFrmCtrl:HWND=0;
+
+procedure CreateFrame(parent:HWND);
+procedure DestroyFrame;
+
+implementation
+
+uses
+ messages,commctrl,
+ m_api,common,
+ rglobal;
+
+{$include mr_rc.inc}
+
const
frm_back:pAnsiChar = 'Frame background';
const
@@ -28,40 +50,44 @@ begin
result:=CallWindowProc(OldSliderWndProc, Dialog, hMessage, wParam, lParam);
end;
+procedure MakeTooltip(Dialog:HWND);
+var
+ hwndTooltip:HWND;
+ ti:TTOOLINFOW;
+begin
+ hwndTooltip:=CreateWindowW(TOOLTIPS_CLASS,nil,TTS_ALWAYSTIP,
+ integer(CW_USEDEFAULT),integer(CW_USEDEFAULT),
+ integer(CW_USEDEFAULT),integer(CW_USEDEFAULT),
+ Dialog,0,hInstance,nil);
+
+ FillChar(ti,SizeOf(ti),0);
+ ti.cbSize :=sizeof(TOOLINFO);
+ ti.uFlags :=TTF_IDISHWND or TTF_SUBCLASS;
+ ti.hwnd :=Dialog;
+ ti.hinst :=hInstance;
+ ti.uId :=GetDlgItem(Dialog,IDC_RADIO_MUTE);
+ ti.lpszText:=pWideChar(TranslateW('Mute'));
+ SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,tlparam(@ti));
+end;
+
function RadioFrameProc(Dialog:HWnd;hMessage:UINT;wParam:WPARAM;lParam:LPARAM):lresult; stdcall;
var
urd:TUTILRESIZEDIALOG;
rc:TRECT;
- ti:TTOOLINFOW;
- hwndTooltip:HWND;
tmp:pAnsiChar;
begin
result:=0;
case hMessage of
WM_DESTROY: begin
hVolFrmCtrl :=0;
- hMuteFrmCtrl:=0;
DeleteObject(hbr);
end;
WM_INITDIALOG: begin
- hMuteFrmCtrl:=GetDlgItem(Dialog,IDC_RADIO_MUTE);
- SendMessage(hMuteFrmCtrl, BUTTONSETASFLATBTN,0,0);
+ SendDlgItemMessage(Dialog,IDC_RADIO_MUTE, BUTTONSETASFLATBTN,0,0);
// SetButtonIcon(hMuteFrmCtrl,IcoBtnOn);
- hwndTooltip:=CreateWindowW(TOOLTIPS_CLASS,nil,TTS_ALWAYSTIP,
- integer(CW_USEDEFAULT),integer(CW_USEDEFAULT),
- integer(CW_USEDEFAULT),integer(CW_USEDEFAULT),
- Dialog,0,hInstance,nil);
-
- FillChar(ti,SizeOf(ti),0);
- ti.cbSize :=sizeof(TOOLINFO);
- ti.uFlags :=TTF_IDISHWND or TTF_SUBCLASS;
- ti.hwnd :=Dialog;
- ti.hinst :=hInstance;
- ti.uId :=hMuteFrmCtrl;
- ti.lpszText:=pWideChar(TranslateW('Mute'));
- SendMessageW(hwndTooltip,TTM_ADDTOOLW,0,tlparam(@ti));
+ MakeTooltip(Dialog);
hVolFrmCtrl:=GetDlgItem(Dialog,IDC_RADIO_VOL);
SendMessage(hVolFrmCtrl,TBM_SETRANGE,0,MAKELONG(0,100));
@@ -103,7 +129,7 @@ begin
end;
WM_CTLCOLORBTN: begin
- if THANDLE(lParam)=hMuteFrmCtrl then
+ if THANDLE(lParam)=GetDlgItem(Dialog,IDC_RADIO_MUTE) then
begin
SetBkColor(wParam, frm_bkg);
result:=hbr;
@@ -128,7 +154,7 @@ begin
BN_CLICKED: begin
case loword(wParam) of
IDC_RADIO_MUTE: begin
- Service_RadioMute(0,1);
+ CallService(MS_RADIO_MUTE,0,1);
end;
end;
end;
@@ -137,7 +163,7 @@ begin
WM_HSCROLL: begin
// gVolume:=SendMessage(lParam,TBM_GETPOS,0,0);
- Service_RadioSetVolume(SendMessage(lParam,TBM_GETPOS,0,0){gVolume},2)
+ CallService(MS_RADIO_SETVOL,SendMessage(lParam,TBM_GETPOS,0,0){gVolume},2)
end;
else
@@ -220,7 +246,7 @@ begin
hbr:=0;
colorhook:=HookEvent(ME_COLOUR_RELOAD,@ColorReload);
ColorReload(0,0);
- Service_RadioSetVolume(gVolume,0);
+ CallService(MS_RADIO_SETVOL,gVolume,0);
end;
end;
end;
@@ -236,3 +262,5 @@ begin
DestroyWindow(FrameWnd);
FrameWnd:=0;
end;
+
+end.
diff --git a/plugins/mRadio/i_vars.inc b/plugins/mRadio/rglobal.pas
index 086279d522..283daae17c 100644
--- a/plugins/mRadio/i_vars.inc
+++ b/plugins/mRadio/rglobal.pas
@@ -1,33 +1,35 @@
{used variables}
+unit rglobal;
+
+interface
+
+uses
+ windows,
+ Dynamic_Bass,
+ playlist;
{$include m_radio.inc}
const
- optActiveCodec:PAnsiChar = 'ActiveCodec';
- optLastStn :PAnsiChar = 'LastStation';
- optConnect :PAnsiChar = 'AutoConnect';
- optAutoMute :PAnsiChar = 'AutoMute';
- optDevice :PAnsichar = 'Device';
- optEQ_OFF :PAnsiChar = 'eqoff';
- optStatusMsg :PAnsiChar = 'StatusMsg';
- optCurElement :PAnsiChar = 'LastPlayed';
- optPlayFirst :PAnsiChar = 'PlayFromFirst';
- optActiveURL :PAnsiChar = 'ActiveURL';
- optContRec :PAnsiChar = 'ContRec';
- optLoop :PAnsiChar = 'Loop';
- optShuffle :PAnsiChar = 'Shuffle';
- optRecPath :PAnsiChar = 'RecordPath';
- optStatus :PAnsiChar = 'Status';
+ cPluginName = 'mRadio';
+const
+ PluginName:PAnsiChar = cPluginName;
+
+const
+ BassStatus:(rbs_null,rbs_load,rbs_init) = rbs_null;
+
+const
+ chan :HSTREAM = 0;
+ ActiveContact:THANDLE = 0;
+ ActiveURL :PWideChar = nil;
+
+const
optVolume :PAnsiChar = 'Volume';
- optBuffer :PAnsiChar = 'Buffer';
- optPreBuf :PAnsiChar = 'PreBuf';
- optTimeout :PAnsiChar = 'Timeout';
- optVersion :PAnsiChar = 'version';
- optStatusTmpl :PAnsiChar = 'StatusTmpl';
- optNumTries :PAnsiChar = 'NumTries';
- optOffline :PAnsiChar = 'asOffline';
+
+ optVersion :PAnsiChar = 'version'; //??
+
// mRadio compatibility
- optStationURL :PAnsiChar = 'StationURL';
+//optStationurl <<
optMyHandle :PAnsiChar = 'MyHandle';
optGenre :PAnsiChar = 'Genre';
optBitrate :PAnsiChar = 'Bitrate';
@@ -36,21 +38,25 @@ const
optNick :PAnsiChar = 'Nick';
optLastName :PAnsiChar = 'LastName';
optAge :PAnsiChar = 'Age';
- // 3D sound support
- optEAXType :PAnsiChar = 'EAXtype';
- optForcedMono :PAnsiChar = 'ForcedMono';
optGroup :PAnsiChar = 'Group';
+
+const
+ optEAXType :PAnsiChar = 'EAXtype';
+ optStatusMsg :PAnsiChar = 'StatusMsg';
optBASSPath :PAnsiChar = 'BASSpath';
+
+ optLastStn :PAnsiChar = 'LastStation';
+ optActiveCodec:PAnsiChar = 'ActiveCodec';
+ optStationURL :PAnsiChar = 'StationURL'; // mRadio compatibility
+const
optTitle :PAnsiChar = 'Title';
optArtist :PAnsiChar = 'Artist';
+ optStatus :PAnsiChar = 'Status';
var
hhRadioStatus,
- hCMenuItemRec,
- hCMenuItemPlay,
hNetLib:THANDLE;
- hiddenwindow:HWND;
var
plist:tPlaylist;
// plFile:pWideChar; // playlist file name (for delete after using?)
@@ -71,20 +77,17 @@ var
PluginStatus:integer;
storagep,storage:PAnsiChar;
recpath:pWideChar;
+ StatusTmpl:pWideChar;
sBuffer,
sTimeout,
sPreBuf:cardinal;
usedevice:PAnsiChar;
-const
- hVolCtrl :HWND=0;
- hVolFrmCtrl :HWND=0;
-const
- hMuteFrmCtrl:HWND=0;
-const
- Inited:boolean=false;
-const
- StatusTmpl:pWideChar = nil;
- proxy:pAnsiChar = nil;
+
+const // inside INC files only
+ hVolCtrl:HWND=0;
+
+//----- Equalizer -----
+
type
tEQRec = record
fx :HFX;
@@ -104,6 +107,9 @@ var
(fx:0;wnd:0;param:(fCenter:12000;fBandwidth:18;fGain:0);text:'12k'),
(fx:0;wnd:0;param:(fCenter:14000;fBandwidth:18;fGain:0);text:'14k'),
(fx:0;wnd:0;param:(fCenter:16000;fBandwidth:18;fGain:0);text:'16k'));
+
+//----- Button icons -----
+
const
IcoBtnSettings:PAnsiChar = 'Radio_Setting';
IcoBtnOn :PAnsiChar = 'Radio_On';
@@ -112,11 +118,8 @@ const
IcoBtnRecDn :PAnsiChar = 'Radio_RecDn';
IcoBtnAdd :PAnsiChar = 'Radio_Add';
IcoBtnDel :PAnsiChar = 'Radio_Del';
-const
- hRecord :THANDLE = 0;
- chan :HSTREAM = 0;
- ActiveContact:THANDLE = 0;
- ActiveURLw :PWideChar = nil;
+
+//----- EAX -----
type
TEAXItem = record
@@ -153,10 +156,102 @@ const
(name:'Dizzy' ; code:EAX_ENVIRONMENT_DIZZY),
(name:'Psychotic' ; code:EAX_ENVIRONMENT_PSYCHOTIC));
-type
- tPreset = record
- name :PWideChar;
- preset:array [0..9] of shortint;
+
+function MakeMessage:pWideChar;
+procedure SetStatus(hContact:THANDLE;status:integer);
+function GetDefaultRecPath:pWideChar;
+function GetStatusText(status:integer;toCList:boolean=false):PWideChar;
+
+
+implementation
+
+uses
+ m_api, common, dbsettings;
+
+procedure SetStatus(hContact:THANDLE;status:integer);
+begin
+// if Status=ID_STATUS_OFFLINE then
+// MyStopBass;
+
+ if status=ID_STATUS_OFFLINE then
+ begin
+ if (AsOffline=BST_UNCHECKED) or (PluginStatus<>ID_STATUS_OFFLINE) then
+ status:=ID_STATUS_INVISIBLE;
end;
+
+ if hContact=0 then
+ begin
+ hContact:=db_find_first(PluginName);
+ while hContact<>0 do
+ begin
+ DBWriteWord(hContact,PluginName,optStatus,status);
+ hContact:=db_find_next(hContact,PluginName);
+ end;
+ end
+ else
+ DBWriteWord(hContact,PluginName,optStatus,status);
+end;
+
+function MakeMessage:pWideChar;
var
- Presets: array of tPreset;
+ p,artist,title:pWideChar;
+ len:cardinal;
+begin
+ artist:=DBReadUnicode(0,PluginName,optArtist);
+ title :=DBReadUnicode(0,PluginName,optTitle);
+ len:=StrLenW(artist);
+ if (artist<>nil) and (title<>nil) then
+ inc(len,3);
+ inc(len,StrLenW(title));
+
+ if len>0 then
+ begin
+ mGetMem(result,(len+1)*SizeOf(WideChar));
+ p:=result;
+ if artist<>nil then
+ begin
+ p:=StrCopyEW(p,artist);
+ if title<>nil then
+ p:=StrCopyEW(p,' - ');
+ mFreeMem(artist);
+ end;
+ if title<>nil then
+ begin
+ StrCopyW(p,title);
+ mFreeMem(title);
+ end;
+ end
+ else
+ result:=nil;
+end;
+
+function GetDefaultRecPath:pWideChar;
+var
+ dat:TREPLACEVARSDATA;
+ mstr,szData:pWideChar;
+ buf:array [0..MAX_PATH-1] of WideChar;
+begin
+ FillChar(dat,SizeOf(dat),0);
+ dat.cbSize :=SizeOf(TREPLACEVARSDATA);
+ dat.dwFlags:=RVF_UNICODE;
+ szData:='%miranda_userdata%'+'\'+cPluginName;
+ mstr:=pWideChar(CallService(MS_UTILS_REPLACEVARS, WPARAM(szData), LPARAM(@dat)));
+ PathToRelativeW(mstr,buf);
+ StrDupW(result,buf);
+ mir_free(mstr);
+end;
+
+function GetStatusText(status:integer;toCList:boolean=false):PWideChar;
+begin
+ case status of
+ RD_STATUS_PAUSED : result:='paused';
+ RD_STATUS_STOPPED: if toCList then result:=nil else result:='stopped';
+ RD_STATUS_CONNECT: result:='connecting';
+ RD_STATUS_ABORT : result:='aborting';
+ RD_STATUS_PLAYING: if toCList then result:=nil else result:='playing';
+ else
+ result:=nil;
+ end;
+end;
+
+end.
diff --git a/plugins/mRadio/roptions.pas b/plugins/mRadio/roptions.pas
new file mode 100644
index 0000000000..347747521c
--- /dev/null
+++ b/plugins/mRadio/roptions.pas
@@ -0,0 +1,251 @@
+{Different settings}
+unit roptions;
+
+interface
+
+//----- Presets -----
+
+type
+ tPreset = record
+ name :PWideChar;
+ preset:array [0..9] of shortint;
+ end;
+var
+ Presets: array of tPreset;
+ OldEQPreset:integer;
+
+procedure LoadPresets;
+procedure SavePresets;
+procedure FreePresets;
+
+procedure FreeSettings;
+procedure LoadSettings;
+procedure SaveCommonSettings;
+procedure SaveTechSettings;
+
+
+implementation
+
+uses
+ windows,
+ common,dbsettings,mirutils,
+ rglobal;
+
+const
+ optRecPath :PAnsiChar = 'RecordPath';
+ optStatusTmpl :PAnsiChar = 'StatusTmpl';
+
+ optLoop :PAnsiChar = 'Loop';
+ optShuffle :PAnsiChar = 'Shuffle';
+ optPlayFirst :PAnsiChar = 'PlayFromFirst';
+ optContRec :PAnsiChar = 'ContRec';
+ optConnect :PAnsiChar = 'AutoConnect';
+ optAutoMute :PAnsiChar = 'AutoMute';
+ optOffline :PAnsiChar = 'asOffline';
+
+ optEQ_OFF :PAnsiChar = 'eqoff';
+ optForcedMono :PAnsiChar = 'ForcedMono';
+ optPreBuf :PAnsiChar = 'PreBuf';
+ optBuffer :PAnsiChar = 'Buffer';
+ optTimeout :PAnsiChar = 'Timeout';
+ optNumTries :PAnsiChar = 'NumTries';
+ optDevice :PAnsichar = 'Device';
+
+{
+const
+ optVolume :PAnsiChar = 'Volume';
+}
+//----- Presets -----
+
+const
+ optOldPreset:pAnsiChar='oldpreset';
+ optPresets :pAnsiChar='numpreset';
+ optPreset :pAnsiChar='preset_';
+ optPreDescr :pAnsiChar='predescr_';
+
+const
+ PresetMax = 17;
+
+procedure InitPresets;
+type
+ tP = array [0..9] of AnsiChar;
+begin
+ StrDupW(Presets[00].name,'Acoustic' ); tP(Presets[00].preset):=#$01#$02#$00#$00#$00#$00#$00#$01#$01#$03;
+ StrDupW(Presets[01].name,'Blues' ); tP(Presets[01].preset):=#$01#$02#$01#$00#$00#$00#$00#$00#$00#$FE;
+ StrDupW(Presets[02].name,'Classical'); tP(Presets[02].preset):=#$01#$04#$01#$00#$00#$00#$00#$00#$01#$01;
+ StrDupW(Presets[03].name,'Country' ); tP(Presets[03].preset):=#$00#$00#$01#$01#$00#$00#$01#$01#$01#$01;
+ StrDupW(Presets[04].name,'Dance' ); tP(Presets[04].preset):=#$04#$03#$02#$01#$FF#$FF#$02#$04#$05#$05;
+ StrDupW(Presets[05].name,'Folk' ); tP(Presets[05].preset):=#$FF#$00#$00#$01#$01#$00#$01#$01#$01#$00;
+ StrDupW(Presets[06].name,'Grunge' ); tP(Presets[06].preset):=#$01#$00#$FF#$00#$00#$02#$01#$FF#$FE#$FD;
+ StrDupW(Presets[07].name,'Jazz' ); tP(Presets[07].preset):=#$00#$01#$02#$03#$03#$01#$01#$03#$04#$05;
+ StrDupW(Presets[08].name,'Metall' ); tP(Presets[08].preset):=#$FE#$00#$00#$00#$00#$03#$02#$04#$06#$05;
+ StrDupW(Presets[09].name,'New Age' ); tP(Presets[09].preset):=#$03#$03#$00#$00#$00#$00#$00#$00#$02#$02;
+ StrDupW(Presets[10].name,'Opera' ); tP(Presets[10].preset):=#$00#$01#$02#$04#$01#$02#$00#$00#$00#$00;
+ StrDupW(Presets[11].name,'Rap' ); tP(Presets[11].preset):=#$00#$04#$04#$00#$00#$00#$01#$04#$05#$07;
+ StrDupW(Presets[12].name,'Reggae' ); tP(Presets[12].preset):=#$03#$00#$FD#$00#$05#$00#$02#$03#$04#$05;
+ StrDupW(Presets[13].name,'Rock' ); tP(Presets[13].preset):=#$00#$02#$04#$00#$00#$00#$02#$04#$05#$06;
+ StrDupW(Presets[14].name,'Speech' ); tP(Presets[14].preset):=#$FE#$02#$00#$00#$00#$00#$FF#$FE#$FD#$FC;
+ StrDupW(Presets[15].name,'Swing' ); tP(Presets[15].preset):=#$FF#$00#$00#$02#$02#$00#$02#$02#$03#$03;
+ StrDupW(Presets[16].name,'Techno' ); tP(Presets[16].preset):=#$05#$08#$FF#$FE#$FD#$FF#$04#$06#$06#$06;
+end;
+
+procedure LoadPresets;
+var
+ num,preset,descr:array [0..63] of AnsiChar;
+ i:integer;
+ p,pd:pAnsiChar;
+begin
+ p :=StrCopyE(preset,optPreset);
+ pd:=StrCopyE(descr ,optPreDescr);
+
+ i:=DBReadByte(0,PluginName,optPresets);
+ if i=0 then
+ begin
+ SetLength(Presets,PresetMax);
+ InitPresets;
+ OldEQPreset:=-1;
+ end
+ else
+ begin
+ OldEQPreset:=integer(DBReadByte(0,PluginName,optOldPreset,byte(-1)));
+ SetLength(Presets,i);
+ for i:=0 to HIGH(Presets) do
+ begin
+ StrCopy(p ,IntToStr(num,i)); DBReadStruct (0,PluginName,preset,@Presets[i].preset,10);
+ StrCopy(pd,num); Presets[i].name:=DBReadUnicode(0,PluginName,descr);
+ end;
+ end;
+end;
+
+procedure SavePresets;
+var
+ num,preset,descr:array [0..63] of AnsiChar;
+ i,j:integer;
+ p,pd:pAnsiChar;
+begin
+ p :=StrCopyE(preset,optPreset);
+ pd:=StrCopyE(descr ,optPreDescr);
+ j:=DBReadByte(0,PluginName,optPresets);
+ for i:=0 to HIGH(Presets) do
+ begin
+ StrCopy(p ,IntToStr(num,i)); DBWriteStruct (0,PluginName,preset,@Presets[i].preset,10);
+ StrCopy(pd,num); DBWriteUnicode(0,PluginName,descr ,Presets[i].name);
+ end;
+ while j>Length(Presets) do
+ begin
+ dec(j);
+ StrCopy(p ,IntToStr(num,j)); DBDeleteSetting(0,PluginName,preset);
+ StrCopy(pd,num); DBDeleteSetting(0,PluginName,descr);
+ end;
+ DBWriteByte(0,PluginName,optOldPreset,OldEQPreset);
+ DBWriteByte(0,PluginName,optPresets ,Length(Presets));
+end;
+
+procedure FreePresets;
+var
+ i:integer;
+begin
+ for i:=0 to HIGH(Presets) do
+ mFreeMem(Presets[i].name);
+end;
+
+//----- Common settings -----
+
+procedure FreeSettings;
+begin
+ mFreeMem(recpath);
+ mFreeMem(StatusTmpl);
+ mFreeMem(usedevice);
+end;
+
+procedure LoadSettings;
+var
+ szTemp:array [0..7] of AnsiChar;
+ i:integer;
+begin
+ //-- record
+ recpath:=DBReadUnicode(0,PluginName,optRecPath);
+ if recpath=nil then
+ recpath:=GetDefaultRecPath;
+
+ //-- mRadio settings
+ doLoop :=DBReadByte(0,PluginName,optLoop);
+ doShuffle :=DBReadByte(0,PluginName,optShuffle);
+ doContRec :=DBReadByte(0,PluginName,optContRec);
+ PlayFirst :=DBReadByte(0,PluginName,optPlayFirst);
+ AuConnect :=DBReadByte(0,PluginName,optConnect);
+ AuMute :=DBReadByte(0,PluginName,optAutoMute);
+ AsOffline :=DBReadByte(0,PluginName,optOffline);
+ StatusTmpl:=DBReadUnicode(0,PluginName,optStatusTmpl,'%radio_title%');
+
+ //-- Tech settings
+ usedevice :=DBReadString(0,PluginName,optDevice);
+
+ sPreBuf :=DBReadWord(0,PluginName,optPreBuf ,75);
+ sBuffer :=DBReadWord(0,PluginName,optBuffer ,5000);
+ sTimeout :=DBReadWord(0,PluginName,optTimeout,5000);
+
+ isEQ_OFF :=DBReadByte(0,PluginName,optEQ_OFF);
+ gVolume :=DBReadByte(0,PluginName,optVolume,50);
+ ForcedMono:=DBReadByte(0,PluginName,optForcedMono);
+ NumTries :=DBReadByte(0,PluginName,optNumTries,1);
+ if NumTries<1 then NumTries:=1;
+
+ //-- Equalizer
+ szTemp[0]:='E';
+ szTemp[1]:='Q';
+ szTemp[2]:='_';
+ szTemp[4]:=#0;
+ for i:=0 to 9 do
+ begin
+ szTemp[3]:=AnsiChar(ORD('0')+i);
+ eq[i].param.fGain:=DBReadByte(0,PluginName,szTemp,15)-15;
+ end;
+
+ if AuConnect<>BST_UNCHECKED then
+ ActiveContact:=LoadContact(PluginName,optLastStn)
+ else
+ ActiveContact:=0;
+end;
+
+procedure SaveCommonSettings;
+begin
+ DBWriteByte(0,PluginName,optLoop ,doLoop);
+ DBWriteByte(0,PluginName,optShuffle ,doShuffle);
+ DBWriteByte(0,PluginName,optContRec ,doContRec);
+ DBWriteByte(0,PluginName,optPlayFirst,PlayFirst);
+ DBWriteByte(0,PluginName,optConnect ,AuConnect);
+ DBWriteByte(0,PluginName,optAutoMute ,AuMute);
+ DBWriteByte(0,PluginName,optOffline ,AsOffline);
+
+ DBWriteUnicode(0,PluginName,optStatusTmpl,StatusTmpl);
+ DBWriteUnicode(0,PluginName,optRecPath ,recpath);
+end;
+
+procedure SaveTechSettings;
+var
+ szTemp:array [0..7] of AnsiChar;
+ i:integer;
+begin
+ DBWriteWord(0,PluginName,optTimeout,sTimeout);
+ DBWriteWord(0,PluginName,optBuffer,sBuffer);
+ DBWriteWord(0,PluginName,optPreBuf,sPreBuf);
+
+ DBWriteByte(0,PluginName,optForcedMono,ForcedMono);
+ DBWriteByte(0,PluginName,optNumTries,NumTries);
+ DBWriteByte(0,PluginName,optEQ_OFF ,isEQ_OFF);
+
+ DBWriteString(0,PluginName,optDevice,usedevice);
+
+ szTemp[0]:='E';
+ szTemp[1]:='Q';
+ szTemp[2]:='_';
+ szTemp[4]:=#0;
+ for i:=0 to 9 do
+ begin
+ szTemp[3]:=AnsiChar(ORD('0')+i);
+ DBWriteByte(0,PluginName,szTemp,trunc(eq[i].param.fGain)+15);
+ end;
+end;
+
+end.