Sound worked in XP; not in Vista

All questions regarding Windows programming, post here. API,COM, ActiveX, DirectX, OpenGL, MFC and so on...

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

Sound worked in XP; not in Vista

Postby lostpuppy » Mon Aug 11, 2008 9:11 am

First off, I am NOT a programmer. I am seeking advice so that I can manage a project.

I have a C++ application I inherited that manages sound files. The app works fine in XP. When it runs in Vista, everything looks like it is working, but sound files cannot be recorded or played back. I AM able to use other sound apps in Vista and everything works. I just need to have my app modified so it works in Vista. since this app is intended to be used by clients, I can't make tweaks to the OS, I need to make code changes in the app. I looked at the code in Visual Studio, but it all looks greek to me.

Here's my question. I have received estimates from programming shops that suggest a partial rewrite at thousands of dollars. I'd like to think it should be a relatively easy tweak to a module or two. I just don't know where to turn. I would love to get a sense of what's involved so I can make an intelligent decision, since I definitely don't have thousands in the budget. I'm even comfortable following instructions and recompiling the code if that's in the cards.

I'd be happy to share the appropriate section of code if you give me instructions for finding it. If I've done something the wrong way here, please let me know gently. They don't come any greener than me.

Thanks.
lostpuppy
 
Posts: 2
Joined: Mon Aug 11, 2008 9:05 am

Postby MXP » Mon Aug 11, 2008 7:41 pm

It's difficult to tell you were to go since there is very little information about why the app is not working in Vista. There are a few areas which need to be looked into:

1) Does the program write to any locations outside of the current user's directory? This was possible in XP but in Vista requires administrator privileges.

2) Does the program attempt to write to areas of the registry outside HKEY_CURRENT_USER? This requires administrator privileges in Vista.

Microsoft provides a tool, Application Verifier which can help predict some of the incompatibilities you're seeing. Here is some documentation for it.
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm

Postby lostpuppy » Tue Aug 12, 2008 7:33 am

Thanks for responding Colin.

I'm not a programmer, so I don't really know the answers about where the program writes. Perhaps a section of code can help you tell me more. I have a module titled WaveRecorderCtrl that seems to have nearly 2000 lines to it. I don't think I should post all of that here. There's another titled WaveRecorderDlg that is about the same length.

I will try the tool you suggested also.

Thanks again.




Here's the code excerpt. Does this help?

Code: Select all
int CWaveRecorderCtrl::Record()
{
   if (m_bMonitoringInputLevel)
   {
      // Set the start recording flag
      m_bStartRecording = true;

      // Stop monitoring the input level
      StopInputLevelMonitoring();

      return TRUE;
   }

   // Make sure we aren't recording
   if (m_bRecording)
      return FALSE;

   // Make sure we aren't already playing
   if (m_bPlaying)
      return FALSE;

   // Check the handle to the window
   if (!this->m_hWnd)
      return FALSE;

   // Allocate buffer memory
   if (m_pBuffer1)
      delete [] m_pBuffer1;
   if (m_pBuffer2)
      delete [] m_pBuffer2;
   m_pBuffer1 = new BYTE[INPUT_BUFFER_SIZE];
   m_pBuffer2 = new BYTE[INPUT_BUFFER_SIZE];

   if (!m_pBuffer1 || !m_pBuffer2)
   {
      if (m_pBuffer1) delete [] m_pBuffer1;
      if (m_pBuffer2) delete [] m_pBuffer2;

      return FALSE;
   }

   // Open waveform audio device for input
   m_WaveFormat.wFormatTag = WAVE_FORMAT_PCM;
   m_WaveFormat.nChannels = 1;
   m_WaveFormat.nSamplesPerSec = SAMPLE_RATE;
   m_WaveFormat.nAvgBytesPerSec = SAMPLE_RATE;
   m_WaveFormat.nBlockAlign = 1;
   m_WaveFormat.wBitsPerSample = BITS_PER_SAMPLE;
   m_WaveFormat.cbSize = 0;

   if (waveInOpen(&m_hWaveIn, WAVE_MAPPER, &m_WaveFormat, (DWORD)this->m_hWnd, 0, CALLBACK_WINDOW))
   {
      delete [] m_pBuffer1;
      delete [] m_pBuffer2;
      return FALSE;
   }

   // Setup and prepare headers
   m_pWaveHdr1->lpData = (char *)m_pBuffer1;
   m_pWaveHdr1->dwBufferLength = INPUT_BUFFER_SIZE;
   m_pWaveHdr1->dwBytesRecorded = 0;
   m_pWaveHdr1->dwUser = 0;
   m_pWaveHdr1->dwFlags = 0;
   m_pWaveHdr1->dwLoops = 0;
   m_pWaveHdr1->lpNext = NULL;
   m_pWaveHdr1->reserved = 0;

   waveInPrepareHeader(m_hWaveIn, m_pWaveHdr1, sizeof(WAVEHDR));

   m_pWaveHdr2->lpData = (char *)m_pBuffer2;
   m_pWaveHdr2->dwBufferLength = INPUT_BUFFER_SIZE;
   m_pWaveHdr2->dwBytesRecorded = 0;
   m_pWaveHdr2->dwUser = 0;
   m_pWaveHdr2->dwFlags = 0;
   m_pWaveHdr2->dwLoops = 0;
   m_pWaveHdr2->lpNext = NULL;
   m_pWaveHdr2->reserved = 0;

   waveInPrepareHeader(m_hWaveIn, m_pWaveHdr2, sizeof(WAVEHDR));

   // Invalidate the loaded from file flag
   m_loaded_from_file = FALSE;

   return TRUE;
lostpuppy
 
Posts: 2
Joined: Mon Aug 11, 2008 9:05 am

Postby MXP » Tue Aug 12, 2008 10:12 pm

It's unfortunately not informative. If that particular code worked on XP it should work the should continue to work on Vista.
Need information on a function I've posted? Chances are it's at the MSDN.
MXP
 
Posts: 6506
Joined: Mon Sep 22, 2003 5:27 pm

Postby deca5423 » Mon Aug 18, 2008 9:13 am

Like Colin pointed out Vista has a lot of new securities XP didn't have. You can try logging in as administrator on Vista and see if it works to rule this out. Also I didn't know about that Application Verifier, glad I came across this :D
User avatar
deca5423
 
Posts: 45
Joined: Mon May 19, 2008 8:01 am


Return to Windows Programming

Who is online

Users browsing this forum: No registered users and 2 guests