# setpaused doesn't work updating from ex to studio

**URL:** <https://qa.fmod.com/t/setpaused-doesnt-work-updating-from-ex-to-studio/11533>\
**Category:** FMOD Studio\
**Created:** [July 1, 2014, 1:09pm UTC](https://qa.fmod.com/t/setpaused-doesnt-work-updating-from-ex-to-studio/11533 "2014-07-01T13:09:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keitel1](https://avatars.discourse-cdn.com/v4/letter/k/3da27b/32.png) [@Keitel1](https://qa.fmod.com/u/Keitel1)\
**Post date:** [July 1, 2014, 1:09pm UTC](https://qa.fmod.com/t/setpaused-doesnt-work-updating-from-ex-to-studio/11533/1 "2014-07-01T13:09:49Z")

</div>

Hi,

After I updated from Fmod ex to Fmod studio I can’t make the setpaused funtion work. I am working in C with Visual Express 2010. I have made the following program to illustrate:

```auto
switch(msg)  
{
	case WM_CREATE:
	
		result = FMOD_System_Create(&systemx);	
		FMOD_System_Init(systemx, 512, FMOD_INIT_NORMAL, NULL);
		result = FMOD_System_CreateSound(systemx, "harmonium0.wav", FMOD_CREATESAMPLE | FMOD_LOOP_NORMAL | FMOD_2D, 0, &sound[0]);
		
		Control[0] = CreateWindow(TEXT("button"), TEXT("Play"),    
         	      WS_VISIBLE | WS_CHILD,
		      200, 200, 50, 50,        
		      hwnd, (HMENU) 1, NULL, NULL);  

 		Control[1] = CreateWindow(TEXT("button"), TEXT("Stop"),    
		     WS_VISIBLE | WS_CHILD,
    		     250, 200, 50, 50,        
		     hwnd, (HMENU) 2, NULL, NULL);  
	
	case WM_COMMAND:
	  				 
		  if (LOWORD(wParam) == 1) {
			 			
				  result = FMOD_System_PlaySound(systemx, sound[0], NULL, 1, &channel[0]);

				  result = FMOD_Channel_SetPaused(channel[0], 0);

				  FMOD_Channel_GetPaused(channel[0], paused);
		  }
				 
 		  if (LOWORD(wParam) == 2) {

          		        result = FMOD_Channel_SetPaused(channel[0], 1);
			
			        result = FMOD_Channel_GetPaused(channel[0], paused);
		   
         			 return 0;
  		}
 
		return 0;		  
			  
	case WM_DESTROY:
	
	       PostQuitMessage(0);
               FMOD_System_Release(systemx);
	}

	return DefWindowProc(hwnd, msg, wParam, lParam);
}	  

```

When clicking the first button, there is no sound. The return values are OK and the paused variable is 0. If I remove the first instance of setpaused and start playing directly from the playsound function, there is sound, but when clicking the second button the sound doesn’t stop. Also then the return values are ok and the paused value is 0.

Hope someone can help me with this.

Thanks in advance.

Sincerely

Keitel

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [July 1, 2014, 9:40pm UTC](https://qa.fmod.com/t/setpaused-doesnt-work-updating-from-ex-to-studio/11533/2 "2014-07-01T21:40:46Z")

</div>

This is probably due to the setPaused(false) being deferred to our async command queue. Are you calling System::update regularly? Calling update is needed to process the command queue among other things.

---

<div class="post-metadata">

**Author:** ![brett](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/brett/32/261_2.png) [@brett](https://qa.fmod.com/u/brett)\
**Post date:** [July 3, 2014, 12:15am UTC](https://qa.fmod.com/t/setpaused-doesnt-work-updating-from-ex-to-studio/11533/3 "2014-07-03T00:15:48Z")

</div>

or you can use FMOD\_INIT\_THREAD\_UNSAFE to remove the queue

---

<div class="post-metadata">

**Author:** ![Keitel1](https://avatars.discourse-cdn.com/v4/letter/k/3da27b/32.png) [@Keitel1](https://qa.fmod.com/u/Keitel1)\
**Post date:** [July 3, 2014, 6:41pm UTC](https://qa.fmod.com/t/setpaused-doesnt-work-updating-from-ex-to-studio/11533/4 "2014-07-03T18:41:36Z")

</div>

Thank you very much. That solved the problems. I placed an update function after each setpaused funtion and then it worked. I am, however, uncertain where it’s most appropriate to place the update function, in case it for instance should slow the program down. I don’t know the diference in functionality between the update command and the other you mentioned neither. But as long as it works, it’s maybe not much to bother about.

-Keitel

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [July 4, 2014, 12:34am UTC](https://qa.fmod.com/t/setpaused-doesnt-work-updating-from-ex-to-studio/11533/5 "2014-07-04T00:34:22Z")

</div>

Usually you would call System::update as part of your game loop, once per frame. Depending on your application structure you might do this in different ways, as long as you call it regularly though you should be fine.

If you use the init flag Brett mentioned it will cause certain operations to happen synchronously without the need for System::update, but in general you should still call update regularly regardless.

---

<div class="post-metadata">

**Author:** ![nick1](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@nick1](https://qa.fmod.com/u/nick1)\
**Post date:** [July 10, 2014, 2:43am UTC](https://qa.fmod.com/t/setpaused-doesnt-work-updating-from-ex-to-studio/11533/6 "2014-07-10T02:43:01Z")

</div>

If you’re only using the windows message loop, try using a timer.

Call

`SetTimer(hwnd, IDT_TIMER1, 50, (TIMERPROC) NULL);`

and then add

`case WM_TIMER: FMOD_System_Update(&systemx)`

to your switch statement.

See more about windows timers: [http://msdn.microsoft.com/en-us/library/windows/desktop/ms644901(v=vs.85).aspx](http://msdn.microsoft.com/en-us/library/windows/desktop/ms644901(v=vs.85).aspx)
