Skip to content

Commit e4da807

Browse files
author
wisepenguin
committed
+ Fixed open file dialog not being modal
+ Fixed add directory dialog not being modal + Enabled XP visual style support + Fixed bitrate display showing parts of previous songs bitrate + WAV file bitrate is now shown
1 parent a13e328 commit e4da807

13 files changed

+79
-23
lines changed

development/official/coolplayer/CPI_Player_Callbacks.c

+21-2
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,32 @@ void CPI_Player_cb_OnStreamInfo(CP_HPLAYER hPlayer, const CPs_FileInfo* pInfo)
4242
{
4343
globals.main_long_track_duration = pInfo->m_iFileLength_Secs;
4444

45+
ZeroMemory(globals.main_text_bitrate, BITRATE_STRLEN);
46+
ZeroMemory(globals.main_text_frequency, FREQ_STRLEN);
47+
48+
{
49+
int i;
50+
for (i = 0; i < 4; i++)
51+
{
52+
globals.main_text_bitrate[i] = ' ';
53+
globals.main_text_frequency[i] = ' ';
54+
}
55+
}
56+
4557
// For those people who do like to know the bitrate (!!)
46-
47-
if (pInfo->m_iBitRate_Kbs)
58+
if (pInfo->m_iBitRate_Kbs >= 1000)
4859
_itoa(pInfo->m_iBitRate_Kbs, globals.main_text_bitrate, 10);
60+
else if (pInfo->m_iBitRate_Kbs < 1000 && pInfo->m_iBitRate_Kbs > 100)
61+
_itoa(pInfo->m_iBitRate_Kbs, globals.main_text_bitrate+1, 10);
62+
else if (pInfo->m_iBitRate_Kbs < 100 && pInfo->m_iBitRate_Kbs > 10)
63+
_itoa(pInfo->m_iBitRate_Kbs, globals.main_text_bitrate+2, 10);
64+
else if (pInfo->m_iBitRate_Kbs < 10)
65+
_itoa(pInfo->m_iBitRate_Kbs, globals.main_text_bitrate+3, 10);
4966
else
5067
globals.main_text_bitrate[0] = '\0';
5168

69+
70+
5271
if (pInfo->m_iFreq_Hz)
5372
_itoa(pInfo->m_iFreq_Hz / 1000, globals.main_text_frequency, 10);
5473
else

development/official/coolplayer/CPI_Player_CoDec_WAV.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ BOOL CPP_OMWAV_OpenFile(CPs_CoDecModule* pModule, const char* pcFilename, DWORD
208208
}
209209

210210
// Setup file info struct - this is re-read every second
211-
pContext->m_FileInfo.m_iBitRate_Kbs = 0; // Suppress bitrate display
211+
// if m_iBitRate_Kbs = 0, bitrate display is suppressed
212+
pContext->m_FileInfo.m_iBitRate_Kbs =
213+
(pFormat->wBitsPerSample * pFormat->wf.nChannels * pFormat->wf.nSamplesPerSec) / 1000;
214+
215+
212216
pContext->m_FileInfo.m_iFreq_Hz = pFormat->wf.nSamplesPerSec;
213217
pContext->m_FileInfo.m_bStereo = pFormat->wf.nChannels == 2 ? TRUE : FALSE;
214218
pContext->m_FileInfo.m_b16bit = pFormat->wBitsPerSample == 16 ? TRUE : FALSE;

development/official/coolplayer/CPI_Playlist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ void CPL_AddPrefixedFile(CP_HPLAYLIST hPlaylist,
10671067
//
10681068
//
10691069
//
1070-
/** TODO - make AddFile load playlists from URLs **/
1070+
/** // TODO: - make AddFile load playlists from URLs **/
10711071
// currently only supports loading m3u from URL
10721072
// and has code duplication for reading m3u file
10731073
void CPL_AddFile(CP_HPLAYLIST hPlaylist, const char* pcFilename)

development/official/coolplayer/CPI_PlaylistItem.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,7 @@ void CPLI_CalculateLength_OGG(CPs_PlaylistItem* pItem)
12421242
//
12431243
//
12441244
//
1245-
/** TODO - reformat and check - move all this to separate function **/
1245+
/** // TODO: - reformat and check - move all this to separate function **/
12461246
// at the moment CPI_Player_CoDec_WAV has this same code
12471247
void CPLI_CalculateLength_WAV(CPs_PlaylistItem* pItem)
12481248
{

development/official/coolplayer/CPI_Verbs.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ wp_Verb glb_pfnAllVerbs[] =
5454
CPVERB_VolumeDown,
5555

5656
CPVERB_OpenFile,
57+
CPVERB_AddFile,
5758
CPVERB_About,
5859
CPVERB_Exit,
5960

@@ -65,8 +66,6 @@ wp_Verb glb_pfnAllVerbs[] =
6566
CPVERB_PlaylistMinimise,
6667
CPVERB_PlaylistMaximise,
6768

68-
/** TODO - move next to OpenFile ? **/
69-
CPVERB_AddFile,
7069
NULL
7170
};
7271
//
@@ -496,7 +495,9 @@ void CPVERB_About(const CPe_VerbAction enAction, void* _pParam)
496495
void CPVERB_Exit(const CPe_VerbAction enAction, void* _pParam)
497496
{
498497
if (enAction == vaDoVerb)
499-
DestroyWindow(windows.wnd_main);
498+
{
499+
DestroyWindow(_pParam);
500+
}
500501
else if (enAction == vaQueryName)
501502
{
502503
CPs_VerbQueryName* pParam = (CPs_VerbQueryName*)_pParam;
@@ -585,7 +586,7 @@ void CPVERB_AddDirectory(const CPe_VerbAction enAction, void* _pParam)
585586
int image = 0;
586587
char directorychoice[MAX_PATH];
587588

588-
browseinfo.hwndOwner = (HWND)_pParam;
589+
browseinfo.hwndOwner = (HWND)windows.wnd_main;
589590
browseinfo.pidlRoot = NULL;
590591
browseinfo.pszDisplayName = directorychoice;
591592
browseinfo.lpszTitle = "Choose a directory to add";

development/official/coolplayer/coolplayer.dsp

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

development/official/coolplayer/coolplayer.rc

+1
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ END
292292
//
293293

294294
IDR_DEFAULTSKIN SKIN DISCARDABLE "res\\Default.CPSkin"
295+
1 24 DISCARDABLE "res\\coolplayer.exe.manifest"
295296
#endif // English (U.K.) resources
296297
/////////////////////////////////////////////////////////////////////////////
297298

development/official/coolplayer/globals.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,15 @@ struct
387387
CPe_QuickFindTerm m_enQuickFindTerm;
388388
} options;
389389

390+
#define BITRATE_STRLEN 40
391+
#define FREQ_STRLEN 40
392+
390393
struct
391394
{
392395
BOOL playlist_bool_addsong;
393396
DWORD playlist_last_add_time;
394-
char main_text_frequency[33];
395-
char main_text_bitrate[33];
397+
char main_text_frequency[FREQ_STRLEN];
398+
char main_text_bitrate[BITRATE_STRLEN];
396399
unsigned long main_long_track_duration;
397400
int main_int_skin_last_number;
398401
CPe_PlayerState m_enPlayerState;

development/official/coolplayer/main.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ int playlist_open_file(BOOL clearlist)
504504
BOOL returnval;
505505
char initialfilename[MAX_PATH * 200] = "";
506506
fn.lStructSize = sizeof(OPENFILENAME);
507-
fn.hwndOwner = (HWND) GetWindowLong(windows.wnd_main, DWL_USER);
507+
fn.hwndOwner = (HWND)windows.wnd_main;
508508
fn.hInstance = NULL;
509509
fn.lpstrFilter = filefilter;
510510
fn.lpstrCustomFilter = NULL;
@@ -1008,8 +1008,7 @@ void options_create(HWND hWnd)
10081008

10091009
void url_create(HWND hWnd)
10101010
{
1011-
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_URL),
1012-
hWnd, (DLGPROC) url_windowproc);
1011+
DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_URL), hWnd, (DLGPROC) url_windowproc);
10131012
}
10141013

10151014
void main_menuproc(HWND hWnd, LPPOINT points)
@@ -1035,7 +1034,8 @@ void main_menuproc(HWND hWnd, LPPOINT points)
10351034
{
10361035

10371036
case MENU_EXIT:
1038-
DestroyWindow(hWnd);
1037+
CPVERB_Exit(vaDoVerb, hWnd);
1038+
// DestroyWindow(hWnd);
10391039
break;
10401040

10411041
case MENU_PLAYLIST:
@@ -1435,8 +1435,8 @@ main_windowproc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
14351435
break;
14361436

14371437
case ExitButton:
1438-
DestroyWindow(hWnd);
1439-
1438+
CPVERB_Exit(vaDoVerb, hWnd);
1439+
// DestroyWindow(hWnd);
14401440
break;
14411441

14421442
case EjectButton:

development/official/coolplayer/options.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,7 @@ options_windowproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
181181
return TRUE;
182182
}
183183

184-
case WM_CLOSE:
185-
EndDialog(hwndDlg, 1);
186-
return TRUE;
187-
184+
188185
case WM_COMMAND:
189186

190187
switch (LOWORD(wParam))
@@ -257,7 +254,7 @@ options_windowproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
257254
case IDCANCEL:
258255
EndDialog(hwndDlg, 1);
259256
break;
260-
257+
261258
case IDOK:
262259
{
263260
BOOL duplicatesalreadyremoved =

development/official/coolplayer/res/changes.txt

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ CoolPlayer Revision History
22
===========================
33
Version 219
44
+ Fixed potential buffer overflow when reading OGG tags
5+
+ Fixed open file dialog not being modal
6+
+ Fixed add directory dialog not being modal
7+
+ Enabled XP visual style support
8+
+ Fixed bitrate display showing parts of previous songs bitrate
9+
+ WAV file bitrate is now shown
510

611
Version 218
712
+ Fixed channels being swapped when toggling EQ
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
3+
<assemblyIdentity
4+
version="1.0.0.0"
5+
processorArchitecture="X86"
6+
name="CoolPlayer" type="win32"
7+
/>
8+
<description>Small, fast music player for MP3, OGG, and WAV files</description>
9+
<dependency>
10+
<dependentAssembly>
11+
<assemblyIdentity
12+
type="win32"
13+
name="Microsoft.Windows.Common-Controls"
14+
version="6.0.0.0"
15+
processorArchitecture="X86"
16+
publicKeyToken="6595b64144ccf1df"
17+
language="*"
18+
/>
19+
</dependentAssembly>
20+
</dependency>
21+
</assembly>

development/official/coolplayer/skin.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ int main_set_default_skin(void)
9191
"");
9292
main_skin_set_struct_value(TimeText, 59, 35, 13, 14, 0, 0, 0, 0, 0,
9393
"");
94-
main_skin_set_struct_value(BitrateText, 89, 48, 0, 0, 0, 0, 0, 0, 0,
94+
95+
main_skin_set_struct_value(BitrateText, 83, 48, 0, 0, 0, 0, 0, 0, 0,
9596
"");
9697
main_skin_set_struct_value(FreqText, 125, 48, 0, 0, 0, 0, 0, 0, 0, "");
9798

0 commit comments

Comments
 (0)