![]() |
EAccessViolation mit Codeoptimierung
Delphi-Quellcode:
Wieso kommt hier eine EAccessViolation ? Wenn ich in den Optionen vom Compiler die Codeoptimierung abschalte {$O-} gibt es keine Probleme.
type
FSOUND_SAMPLE = record buff: Punsignedchar; // pointer to sound data ... end; PFSOUND_SAMPLE = ^FSOUND_SAMPLE; FSOUND_CHANNEL = record index: int; // position in channel pool. volume: int; // current volume (00-FFh). frequency: int; // speed or rate of playback in hz. pan: int; // panning value (00-FFh). actualvolume: int; // driver level current volume. actualpan: int; // driver level panning value. sampleoffset: unsignedint; // sample offset (sample starts playing from here). sptr: PFSOUND_SAMPLE; // currently playing sample ... end; PFSOUND_CHANNEL = ^FSOUND_CHANNEL; procedure... ... asm push ebp mov ebx, mix_mixptr mov mix_mixbuffptr, ebx mov ecx, cptr mov mix_cptr, ecx cmp ecx, 0 // if (!cptr) ... je @MixExit // ... then skip this channel! >>>--> mov ebx, [ecx+FSOUND_CHANNEL.sptr] // load the correct SAMPLE pointer // for this channel mov mix_sptr, ebx // store sample pointer away cmp ebx, 0 // if (!sptr) ... je @MixExit // ... then skip this channel! // get pointer to sample buffer mov eax, [ebx+FSOUND_SAMPLE.buff] mov mix_samplebuff, eax ... |
Re: EAccessViolation mit Codeoptimierung
Grundsätzlich: Register sichern! Die in der Hilfe angegebenen frei zu verwendeten CPU Register sind bei eingeschalteter Optimierung hinfällig. Daher sind alle als "nicht veränderbar" zu betrachten. Daher debugge auch mal, ob alle deine Variablen richtig referenziert werden und du somit auf das richtige zugreifst. Auch musst du unbedingt das Directionflag wieder herstellen, wenn du es veränderst!
|
Re: EAccessViolation mit Codeoptimierung
Moin,
:gruebel: aha, die CPU Register sind bei eingeschalteter Optimierung hinfällig. Das heisst wohl dass der Compiler bei dem Optimieren möglicherweise die Register ändert oder ersetzt ?. Leider habe ich nicht genug Kenntnisse von der Materie Assembler. Die Hilfe hilft mir nicht wirklich, da ich nur die PE-Version besitze. Könntest du (und oder auch die anderen ;) ) mir zeigen wie das gemacht werden muss ? Zitat:
|
Re: EAccessViolation mit Codeoptimierung
Zitat:
|
Re: EAccessViolation mit Codeoptimierung
Wie kann man das jetzt ändern ?
Delphi-Quellcode:
var
cptr: PFSOUND_CHANNEL; procedure FSOUND_Mixer_FPU_Ramp(mixptr: Pointer; len: int; returnaddress: char); var count: int; begin // static FSOUND_CHANNEL *cptr; // static int count; // IMPORTANT no local variables on stack.. we are trashing EBP. static puts values on heap. if (len <= 0) then exit; mix_numsamples := len; mix_mixptr := unsignedint(mixptr); mix_mixbuffend := mix_mixptr + (mix_numsamples shl 3); //============================================================================================== // LOOP THROUGH CHANNELS //============================================================================================== for count := 0 to 64 - 1 do begin cptr := @_FSOUND_Channel[count]; asm push ebp mov ebx, mix_mixptr mov mix_mixbuffptr, ebx mov ecx, cptr mov mix_cptr, ecx cmp ecx, 0 // if (!cptr) ... je @MixExit // ... then skip this channel! mov ebx, [ecx+FSOUND_CHANNEL.sptr] // load the correct SAMPLE pointer for this channel mov mix_sptr, ebx // store sample pointer away cmp ebx, 0 // if (!sptr) ... je @MixExit // ... then skip this channel! // get pointer to sample buffer mov eax, [ebx+FSOUND_SAMPLE.buff] mov mix_samplebuff, eax
Delphi-Quellcode:
Ist möglicherweise unsicher. Das heisst mann müsste das so machen: (nicht lachen bitte)
mov ebx, [ecx+FSOUND_CHANNEL.sptr]
Delphi-Quellcode:
PS.: das Programm ist nicht von mir.
add ecx, FSOUND_CHANNEL.sptr
mov ebx, [ecx] |
Re: EAccessViolation mit Codeoptimierung
Delphi-Quellcode:
Habe ich mal versucht, aber dann haut der Sound nicht hin, aber es klappt mit der Optimierung. :gruebel:
add ecx, FSOUND_CHANNEL.sptr
mov ebx, [ecx] |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:29 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz