HydrogenAudio

Hosted Forums => foobar2000 => Development - (fb2k) => Topic started by: danZ on 2003-09-01 16:30:39

Title: 0.6 to 0.7 questions
Post by: danZ on 2003-09-01 16:30:39
Finally rebuilding my component for 0.7.  I haven't been able to keep up with the .7 development so I'm just going to ask some questions that may have already been covered.

1.  Are there API calls for every enum that used to be supported by play_control::command() ? 

for example I see the obvious ones ->>> play_control::get()->get_volume() for play_control::VOLUME_GET

are all of the rest covered somewhere?

2.  How do I use the utf8api.dll?  When I compile I get

Linking...
  Creating library Debug/foo_WSGUI_d.lib and object Debug/foo_WSGUI_d.exp
foobar2000_SDK.lib(metadb_handle.obj) : error LNK2001: unresolved external symbol __imp__uSortStringCreate
foobar2000_SDK.lib(metadb_handle.obj) : error LNK2001: unresolved external symbol __imp__uSortStringCompare
foobar2000_SDK.lib(metadb_handle.obj) : error LNK2001: unresolved external symbol __imp__uSortStringFree
../foobar2000/foo_WSGUI_d.dll : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.

foo_WSGUI_d.dll - 4 error(s), 0 warning(s)

I didn't see a uti8api.lib in the SDK and I couldn't get that project to compile so I'm wondering about the proper way to link.

3.  The .7 way to do keyboard shortcuts?

Thanks in advance for answers (unless you tell me to look in the header files or the sample projects  )
Title: 0.6 to 0.7 questions
Post by: Chun-Yu on 2003-09-01 16:35:28
To get utf8api to compile, it depends on PFC.  If you use the "dependencies" thing in VC++, it's pretty simple to get it all working together.
Title: 0.6 to 0.7 questions
Post by: Case on 2003-09-01 16:37:16
Quote
2.  How do I use the utf8api.dll?

Make SDK depend on utf8api and utf8api depend on pfc.
Title: 0.6 to 0.7 questions
Post by: danZ on 2003-09-01 16:39:42
You mean include the .dsp for utf8api.dll in my project (project->insert project into workspace) is the same manner as I've done for PFC and SDK?
Title: 0.6 to 0.7 questions
Post by: paulski on 2003-09-01 16:40:14
The way I made use of shortcuts in 0.7x was to extend "menu_item_main_single". You can then associate it with a menu item heading (such as Playlist/"your feature").
Users will then see this in the shortcuts list in their prefs and can then link a keyboard shortcut to it. This works fine for me, but does mean that it will end up somewhere within the menu structure.
Title: 0.6 to 0.7 questions
Post by: Chun-Yu on 2003-09-01 16:50:01
Quote
You mean include the .dsp for utf8api.dll in my project (project->insert project into workspace) is the same manner as I've done for PFC and SDK?

Yep.  Then set the dependencies as Case said.
Title: 0.6 to 0.7 questions
Post by: Peter on 2003-09-01 17:02:20
Quote
This works fine for me, but does mean that it will end up somewhere within the menu structure.

Not necessarily.
Override this:
virtual enabled_state get_enabled_state(int idx) {return MENU_DEFAULT_ON;}
MENU_DEFAULT_OFF will hide it by default, and MENU_FORCE_OFF will keep it hidden.
Title: 0.6 to 0.7 questions
Post by: paulski on 2003-09-01 18:08:36
Cool, thanks for the info.
Title: 0.6 to 0.7 questions
Post by: danZ on 2003-09-02 15:58:32
Quote
Quote
You mean include the .dsp for utf8api.dll in my project (project->insert project into workspace) is the same manner as I've done for PFC and SDK?

Yep.  Then set the dependencies as Case said.

OK, link errors are resolved - thanks.

Now I have a compiled dll and found a new problem - it doesn't run even though I haven't changed anything from my 0.6 version except for using .7 vs. .6 API calls.

Are there changes to the init/quit etc. that I'm not aware of?

Very strange...
Title: 0.6 to 0.7 questions
Post by: Peter on 2003-09-02 16:17:57
Define "doesn't run".
Title: 0.6 to 0.7 questions
Post by: danZ on 2003-09-02 18:25:21
Quote
Define "doesn't run".

Yeah, sorry.

It gets into some kind of error loop and I just discovered it is spitting our error files.

failure.txt
___________


Illegal operation:
Code: C0000005h, flags: 00000000h, address: 1021916Fh
Access violation, operation: read, address: 6F636573h
Module: "MSVCRTD", loaded at 10200000h - 1026C000h
Symbol: "wcslen" (+0000000Fh)
Additional info: main message loop
This is the first crash logged by this instance.
Code bytes:
1021914Fh:  0C 85 D2 74 02 EB D4 8B 45 08 8B E5 5D C3 CC CC
1021915Fh:  CC 55 8B EC 51 8B 45 08 89 45 FC 8B 4D FC 33 D2
1021916Fh:  66 8B 11 8B 45 FC 83 C0 02 89 45 FC 85 D2 74 02
1021917Fh:  EB E9 8B 45 FC 2B 45 08 D1 F8 83 E8 01 8B E5 5D
Version info:
foobar2000 v0.7 RC8
UNICODE

_______________

This is in the code that loads the look file which has not changed at all from the .6 version.

Any suggestions?
Title: 0.6 to 0.7 questions
Post by: Peter on 2003-09-02 19:39:51
Looks like you have written code that crashes. Are you expecting detailed instructions how to use debugger or someone to come and fix your code ?
Title: 0.6 to 0.7 questions
Post by: danZ on 2003-09-02 20:14:18
Quote
Looks like you have written code that crashes. Are you expecting detailed instructions how to use debugger or someone to come and fix your code ?

No, I'm saying all I changed in my .6 code was to use the new play_control API, removed the deprectated APIs (keyboard_shortcuts, etc.) and now code that wasn't modified at all seems to crash - I don't even call wsclen directly in my code so I don't know what's going on since the crash doesn't appear to be in my source code.

I thought that was strange is all.

If you want to fly out and have a look let me know but otherwise I was just seeking any insight into why this might have happened.
Title: 0.6 to 0.7 questions
Post by: Peter on 2003-09-02 20:21:03
Well, I thought it would take less mental effort for some people to run problematic code under debugger and see what happens, rather than write more pointless posts.
From quick search, it looks like you have been passing invalid parameters to string conversion routines, which were possibly tolered before but they no longer are.
Title: 0.6 to 0.7 questions
Post by: danZ on 2003-09-02 20:41:42
Quote
Well, I thought it would take less mental effort for some people to run problematic code under debugger and see what happens, rather than write more pointless posts.
From quick search, it looks like you have been passing invalid parameters to string conversion routines, which were possibly tolered before but they no longer are.

Things go bad as soon as I call

Code: [Select]
  SetWindowPos(
     NULL,0,0,
     m_SkinSize.Width + extraWidth,
     m_SkinSize.Height + extraHeight,SWP_NOMOVE | SWP_NOZORDER);
 }


That function never returns and I can't debug it.

I don't immediately see how this calls wsclen.  Could I have some strange mix of unicode vs non-unicode?
Title: 0.6 to 0.7 questions
Post by: Peter on 2003-09-02 20:48:55
Erm, if you are sure that it's inside SetWindowPos(), then check message handlers for the window you are calling it on.
Title: 0.6 to 0.7 questions
Post by: danZ on 2003-09-03 15:28:23
Quote
Erm, if you are sure that it's inside SetWindowPos(), then check message handlers for the window you are calling it on.

I not sure what you mean - I don't have any message handlers specific to calling SetWindowPos.  I noticed if I skip over the SetWindowPos, the program goes a little farther but then I get the same error later on but I haven't found exactly where.  I'm guessing some other Win32 API call.  I don't get any call stack when this occurs since the program seems to be looping in the main thread (calling the dump_failure_txt method).

Truly, I'm not sure what is going on and not trying to waste any mental power.
Title: 0.6 to 0.7 questions
Post by: Peter on 2003-09-03 15:51:13
Are you running debug version of windows core so win32 api functions call msvcrtd.dll wcslen() ? I don't think you are.
Title: 0.6 to 0.7 questions
Post by: danZ on 2003-09-03 16:31:49
Quote
Are you running debug version of windows core so win32 api functions call msvcrtd.dll wcslen() ? I don't think you are.

No, standard VC++ 6.0 setup on Windows XP.  I noticed that utf8app debug project settings don't define UNICODE preprocessor macro and use _MBCS - is that correct (changing it didn't seem to help my problem - just wondering).
Title: 0.6 to 0.7 questions
Post by: Peter on 2003-09-03 16:50:55
Then it does not crash inside SetWindowPos, some code you compiled calls wcslen. Sorry, I'm getting bored with this thread.
Title: 0.6 to 0.7 questions
Post by: zanson on 2003-09-03 17:35:27
Quote
Quote
Erm, if you are sure that it's inside SetWindowPos(), then check message handlers for the window you are calling it on.

I not sure what you mean - I don't have any message handlers specific to calling SetWindowPos.  I noticed if I skip over the SetWindowPos, the program goes a little farther but then I get the same error later on but I haven't found exactly where.  I'm guessing some other Win32 API call.  I don't get any call stack when this occurs since the program seems to be looping in the main thread (calling the dump_failure_txt method).

Truly, I'm not sure what is going on and not trying to waste any mental power.

danZ: If you can get on IRC, you might try the fb2k irc channel: #foobar2000 on irc.freenode.net
I've never gotten on it, but it would probably be a lot easier for someone to try to help you debug this on IRC then through the forums.
Title: 0.6 to 0.7 questions
Post by: danZ on 2003-09-04 17:21:49
Quote
Then it does not crash inside SetWindowPos, some code you compiled calls wcslen. Sorry, I'm getting bored with this thread.

Sorry to bore you - doesn't seem to be that hard to do

I fixed the problem and thought someone might at least be curious.

First I'm never calling wsclen directly - the call was being made by std::string which is used in one of my libraries.

Second, since the call was being made in response to various windows messages it was very hard to track down because the error would not be caught in the debugger.  Instead the program would just start looping and spitting out the failure.txt files.  If I would break in the debugger during this I didn't get any useful stack information.

So, the final cause of the problem - a single missing _T() wrapper around one string constant in my code.  Like Z^7 said, apparently tolerated in .6.

Anyway, problem solved, .7 upgrade back on track.

Now back to my other questions.

1.  Will I find API equivalents for all the former play_control::command() calls?
PLAYBACK_NEXT, PLAYBACK_PREV,PLAYBACK_REPEAT,PLAYBACK_SHUFFLE - don't immediately see how to do those in .7.

2.  In another component I'm working on I was creating my own console service

Code: [Select]
static service_factory_single_t<console,mTVUIConsole> mTVUIConsole_instance;


This results in an error now at run time regarding duplicated core service.
Title: 0.6 to 0.7 questions
Post by: paulski on 2003-09-04 17:35:35
To answer (1), have a look at play_control.h. The API is quite different, so you will have to make some changes in your code, but you can achieve the same things. For example, to go to the next track you need something like

play_control::get()->play_start(play_control::TRACK_COMMAND_NEXT);

'hope this helps...
Title: 0.6 to 0.7 questions
Post by: danZ on 2003-09-04 17:38:38
Quote
To answer (1), have a look at play_control.h. The API is quite different, so you will have to make some changes in your code, but you can achieve the same things. For example, to go to the next track you need something like

play_control::get()->play_start(play_control::TRACK_COMMAND_NEXT);

'hope this helps...

Yeah, thanks.
Title: 0.6 to 0.7 questions
Post by: Peter on 2003-09-04 17:43:28
0. Debug / Exceptions, set all to "stop always" 
1. play_control has most of those, playback order control explained here: http://www.hydrogenaudio.org/show.php/showtopic/11110 (http://www.hydrogenaudio.org/show.php/showtopic/11110)
2. If you want to add a new console service, you need to replace/remove existing one; otherwise the one getting console messages will depend on dll loading order.
Title: 0.6 to 0.7 questions
Post by: kode54 on 2003-09-05 01:11:21
Quote
First I'm never calling wsclen directly - the call was being made by std::string which is used in one of my libraries.
Use string8, which is part of PFC. :B

Quote
So, the final cause of the problem - a single missing _T() wrapper around one string constant in my code.  Like Z^7 said, apparently tolerated in .6.
You shouldn't need _T() or UNICODE, as you are now using utf8api and all string constants should be UTF-8.
Title: 0.6 to 0.7 questions
Post by: danZ on 2003-09-05 15:49:48
Quote
Quote
First I'm never calling wsclen directly - the call was being made by std::string which is used in one of my libraries.
Use string8, which is part of PFC. :B

Quote
So, the final cause of the problem - a single missing _T() wrapper around one string constant in my code.  Like Z^7 said, apparently tolerated in .6.
You shouldn't need _T() or UNICODE, as you are now using utf8api and all string constants should be UTF-8.

I wish it were so simple

I have reuseable code in this project that I wrote for other projects and is used in all sorts of different applications and environments.  Therefore, I can't use foobar's string implementation exclusively.

I have a mix of std::string from shared code and foobar's string stuff.
Title: 0.6 to 0.7 questions
Post by: danZ on 2003-09-05 17:01:33
are their analogs for the following v6 play_control enums in v7 - I don't see them.

FOOBAR2000_ALWAYSONTOP
FOOBAR2000_CONFIG,
FOOBAR2000_EXIT,

Edit

Also for hide/show etc. I'm doing this:

user_interface::g_find("Default User Interface")->activate();

How can I make this generic for whichever UI is currently active?

/Edit
Title: 0.6 to 0.7 questions
Post by: foosion on 2003-09-05 17:39:03
Quote
FOOBAR2000_CONFIG,


look into play_control.h:
Code: [Select]
play_control::g_show_config(page_name)
Title: 0.6 to 0.7 questions
Post by: rasbongo on 2003-09-05 20:26:25
HI  all,

does anyone know why, the new version of foobar0.7 has so many dll errors when someone is trying to play mp3's.

is there any solution to this. thanx in advance .
Title: 0.6 to 0.7 questions
Post by: kode54 on 2003-09-05 20:28:47
Quote
FOOBAR2000_ALWAYSONTOP
FOOBAR2000_EXIT,

See all of the menu items/actions on the main and context menu sections in the config?

menu_manager::run_command()


ie. menu_manager::run_command("Foobar2000/Titleformatting help") for a "help" button you can place on any dialog that features a title formatting editor.
Title: 0.6 to 0.7 questions
Post by: danZ on 2003-09-05 20:46:56
Quote
Quote
FOOBAR2000_ALWAYSONTOP
FOOBAR2000_EXIT,

See all of the menu items/actions on the main and context menu sections in the config?

menu_manager::run_command()


ie. menu_manager::run_command("Foobar2000/Titleformatting help") for a "help" button you can place on any dialog that features a title formatting editor.

Ah, that's cool - thanks.