title: When to use Release method?
body: <p>I'm creating a &quot;mixer&quot; application that controls volumes of audio sessions and endpoints. My question is, does calling <code>Release</code> method on <code>IMMDevice</code> invalidate previously acquired <code>IAudioEndpointVolume</code> reference? In my program it looks something like this:</p>
  <pre><code>IMMDevice *device;
  IMMDeviceEnumerator *deviceEnumerator;
  IMMDeviceCollection *deviceCollection;
  IAudioEndpointVolume *audioEndpoint;
  
  ... // Initializing device, deviceEnumerator and deviceCollection
  
  // for cycle {
      ...
      deviceCollection-&gt;Item(i, &amp;device);
      device-&gt;Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, NULL, (void**)&amp;audioEndpoint);
      device-&gt;Release();  // Will this cause UB in the next line?
      audioEndpoint-&gt;GetMasterVolume(&amp;volume);
      ...
  //}
  </code></pre>
  <p>Should I use Release method like this or only after Releasing <code>audioEndpoint</code>?</p>