Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8005493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:14:47+00:00 2026-06-04T17:14:47+00:00

I am using VC++ 2010 Express. I’ve written the following routine: HRESULT DLTimeStampNow::Receive(IMediaSample *pSample)

  • 0

I am using VC++ 2010 Express. I’ve written the following routine:

HRESULT DLTimeStampNow::Receive(IMediaSample *pSample)
{
    long long fnum, fnum2;
    REFERENCE_TIME timeStart=0, timeEnd=10000;

    // make this sample available for the next worker-thread call to Transform()

    pSample->AddRef();

    CRefTime rtStream;

    timeStart = 0;
    timeEnd = 10000;

    pSample->SetTime(&timeStart, &timeEnd);

    EnterCriticalSection(&cs);

    if (pSampleWaiting != NULL)
        ((IMediaSample*)pSampleWaiting)->Release();

    pSampleWaiting = pSample;

    SetEvent(hSampleIsReady);

    LeaveCriticalSection(&cs);

    return S_OK;
}

This is part of a work in progress, which is why variables like fnum and rtStream are present but unused.

At run-time, the VC++ debugger refuses to put breakpoints at timeStart = 0 or timeEnd = 10000, which would be fine except it also fails to initialize them. The debugger shows they contain garbage at the point when execution reaches pSample->SetTime(&timeStart, &timeEnd);. To cope with this, I have added =0 and =10000 to the variable declarations. This works, but why is it necessary? I am guessing the compiler is doing some kind of optimization where it avoids the constant assignments in the code, but it is also forgetting(?) to ever actually assign values to timeStart and timeEnd (unless I initialize them in their declaration statement, as above).

What gives?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:14:49+00:00Added an answer on June 4, 2026 at 5:14 pm

    Compiler optimization could do various things to cause this behavior, such as storing local variables in registers or turning single-use variables into constants. If you want to understand what’s happening, one approach is to use assembly view/mode in the debugger to see what happens before and after the function call to SetTime.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using VS 2010 Express and I've written an app that I want to
I'm using Visual C# 2010 Express (final, not beta or anything) and I'm having
using Visual.Web.Developer.2010.Express; N00b here, I'm in a pickle.. I'm trying to create a web
using Visual.Web.Developer.2010.Express; using SQL.Server.Management.Studio.2008.R2; N00b here, I've got the gridview to look the way
using Visual.Web.Developer.2010.Express; using SQL.Server.Management.Studio.2008.R2; What I'm ultimately trying to do is update a sql
using Visual.Web.Developer.2010.Express; using SQL.Server.Management.Studio.2008.R2; Kinda new at C# here.. I got the first row
I am using Visual Studio C# 2010 Express and is learning. RESTSharp is supposed
I'm using TotoiseSVN client and Assembla backend in a VS 2010 express project. We
I'm using VS Team System 2008 and gonna install VS 2010 Express editions.
I'm using Visual Studio Express 2010, with freeglut_static.lib linked (in Properties>Linker>Input>Additional Dependencies, version 2.8.0)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.