Problem with seek, Crash |
This forum is for developer discussions only. If you have a problem / bug report / idea / feature request that isn't related to foobar2000 SDK, post it in an appropiate forum instead - tech support questions go to support forum, everything else goes to general forum.
All non-developer posts on this forum will be removed. Continued abuse of this forum will result in admin actions (warnings, account suspension).
![]() ![]() |
Problem with seek, Crash |
May 14 2011, 08:33
Post
#1
|
|
![]() Group: Developer Posts: 285 Joined: 12-November 07 From: Frankfurt Member No.: 48701 |
I want to seek ahead by 20 sec.
So i made following code: QUOTE service_ptr_t<file> file_io; abort_callback_dummy abort; file_io->seek_ex(3528000,file::seek_from_current,abort); and put it in mainmenu_command's execute method. Unfortunately this code crashes foobar2000. What's wrong? |
|
|
|
May 14 2011, 09:14
Post
#2
|
|
|
Group: Developer Posts: 648 Joined: 26-September 07 Member No.: 47369 |
I want to seek ahead by 20 sec. I guess, you want to seek ahead during playback. You need to use static_api_ptr_t<playback_control>()->playback_seek(20) for this purpose. Seeking in a file will not do, what you want.Unfortunately this code crashes foobar2000. That is really no suprise. You are using an uninitialised pointer: service_ptr_t<file> file_io |
|
|
|
May 14 2011, 09:34
Post
#3
|
|
![]() Group: Members (Donating) Posts: 770 Joined: 25-September 03 From: Umeå, Sweden Member No.: 9001 |
fbuser's assessment is correct, but I'd like to add some further comments.
When programming, do make an effort to understand the platform you're working with instead of writing syntactically correct but semantically nonsensical code. Do not code by coincidence. Also, there's no such thing as "it just crashed". If you got an access violation, you have at a minimum the address it occured with, which in your case most probably was around null. Your code is the smart pointer version of T* p = 0; p->lol(); No matter what T is, you'll blow up. -------------------- Zao shang yong zao nong zao rang zao ren zao.
To, early in the morning, use a chisel to build a bathtub makes impatient people hot-tempered. |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 25th May 2013 - 09:25 |