Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Use PlaySound api caused memory loading?

Use PlaySound api caused memory loading?

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphicsjsonperformancehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cedricvictor
    wrote on last edited by
    #1

    Dear all: I implement a application, when I get a touch data from WM_INPUT and touch count more than previous, it will play sound, My code show as below:

    void CTouchSoundTrayDlg::OnRawInput(UINT nInputCode, HRAWINPUT hRawInput)
    {
    UINT data_size = 0;
    BOOL bGot = FALSE;
    GetRawInputData(hRawInput, RID_INPUT, NULL, &data_size, sizeof(RAWINPUTHEADER));
    vector data;
    data.resize (data_size);

    if(GetRawInputData (hRawInput, RID\_INPUT, &data \[0\], &data\_size, sizeof(RAWINPUTHEADER))!=data\_size)
    {
    	
    }
    RAWINPUT\* raw = (RAWINPUT\*)(&data \[0\]);
    
    if (raw->header.dwType == RIM\_TYPEHID) 
    {
        RID\_DEVICE\_INFO device\_info;
        UINT info\_size = sizeof(RIDI\_DEVICEINFO);
        GetRawInputDeviceInfo ( raw->header.hDevice, RIDI\_DEVICEINFO, (LPVOID)&device\_info,&info\_size);
        
        if(device\_info.hid.dwVendorId = VENDER\_ID)
        {
            g\_CurFrameTime = GetTickCount64();
       if(g\_CurFrameTime - g\_PreFrameTime > 30)
       {
    	g\_PreUsedSize = 0;
    	g\_CurUsedSize = 0;				  
       }
    		
       g\_PreFrameTime = g\_CurFrameTime;
       DigitizerData\* result = (DigitizerData\*)(raw->data.hid.bRawData);
       g\_CurUsedSize = result->active\_touch\_count;
    
    			  
            if(g\_CurUsedSize <= 5)
            {
           if(g\_PreUsedSize <  g\_CurUsedSize)
           {
               PlaySound(m\_WavPath, NULL, SND\_FILENAME|SND\_ASYNC );
           }
           bGot = TRUE;
       }
    				
       if(bGot)
       {
           g\_PreUsedSize =  g\_CurUsedSize;
       }
         }		
    }	
    Default();
    

    }

    My question is when I touch, it will play sound, and the using memory in task manager will be add, When play music is finish, the using memory is still, will not free ,why? I try to disable the playSound api in my code, and the using memory is stable. Thank your help, Victor

    Richard Andrew x64R 1 Reply Last reply
    0
    • C cedricvictor

      Dear all: I implement a application, when I get a touch data from WM_INPUT and touch count more than previous, it will play sound, My code show as below:

      void CTouchSoundTrayDlg::OnRawInput(UINT nInputCode, HRAWINPUT hRawInput)
      {
      UINT data_size = 0;
      BOOL bGot = FALSE;
      GetRawInputData(hRawInput, RID_INPUT, NULL, &data_size, sizeof(RAWINPUTHEADER));
      vector data;
      data.resize (data_size);

      if(GetRawInputData (hRawInput, RID\_INPUT, &data \[0\], &data\_size, sizeof(RAWINPUTHEADER))!=data\_size)
      {
      	
      }
      RAWINPUT\* raw = (RAWINPUT\*)(&data \[0\]);
      
      if (raw->header.dwType == RIM\_TYPEHID) 
      {
          RID\_DEVICE\_INFO device\_info;
          UINT info\_size = sizeof(RIDI\_DEVICEINFO);
          GetRawInputDeviceInfo ( raw->header.hDevice, RIDI\_DEVICEINFO, (LPVOID)&device\_info,&info\_size);
          
          if(device\_info.hid.dwVendorId = VENDER\_ID)
          {
              g\_CurFrameTime = GetTickCount64();
         if(g\_CurFrameTime - g\_PreFrameTime > 30)
         {
      	g\_PreUsedSize = 0;
      	g\_CurUsedSize = 0;				  
         }
      		
         g\_PreFrameTime = g\_CurFrameTime;
         DigitizerData\* result = (DigitizerData\*)(raw->data.hid.bRawData);
         g\_CurUsedSize = result->active\_touch\_count;
      
      			  
              if(g\_CurUsedSize <= 5)
              {
             if(g\_PreUsedSize <  g\_CurUsedSize)
             {
                 PlaySound(m\_WavPath, NULL, SND\_FILENAME|SND\_ASYNC );
             }
             bGot = TRUE;
         }
      				
         if(bGot)
         {
             g\_PreUsedSize =  g\_CurUsedSize;
         }
           }		
      }	
      Default();
      

      }

      My question is when I touch, it will play sound, and the using memory in task manager will be add, When play music is finish, the using memory is still, will not free ,why? I try to disable the playSound api in my code, and the using memory is stable. Thank your help, Victor

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      I would assume that data structures are initialized to play the sound, and then the data structures are kept for the next sound to play.

      The difficult we do right away... ...the impossible takes slightly longer.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups