]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/wasapi.c
PulseAudio: remove unused datum
[vlc] / modules / audio_output / wasapi.c
index e03ea25a8387354d65a296883be41b9c3a2f6ebf..6d715f59e903b111d4483d0a5509910fcdb2e788 100644 (file)
@@ -29,7 +29,6 @@
 #include <stdlib.h>
 #include <assert.h>
 #include <audioclient.h>
-#include <mmdeviceapi.h>
 
 #include <vlc_common.h>
 #include <vlc_aout.h>
@@ -65,18 +64,6 @@ static UINT64 GetQPC(void)
     return (d.quot * 10000000) + ((d.rem * 10000000) / freq.QuadPart);
 }
 
-static void Enter(void)
-{
-    HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
-    if (unlikely(FAILED(hr)))
-        abort();
-}
-
-static void Leave(void)
-{
-    CoUninitialize();
-}
-
 typedef struct aout_stream_sys
 {
     IAudioClient *client;
@@ -84,7 +71,7 @@ typedef struct aout_stream_sys
     uint8_t chans_table[AOUT_CHAN_MAX];
     uint8_t chans_to_reorder;
 
-    uint8_t bits; /**< Bits per sample */
+    vlc_fourcc_t format; /**< Sample format */
     unsigned rate; /**< Sample rate */
     unsigned bytes_per_frame;
     UINT32 written; /**< Frames written to the buffer */
@@ -138,7 +125,7 @@ static HRESULT Play(aout_stream_t *s, block_t *block)
 
     if (sys->chans_to_reorder)
         aout_ChannelReorder(block->p_buffer, block->i_buffer,
-                          sys->chans_to_reorder, sys->chans_table, sys->bits);
+                          sys->chans_to_reorder, sys->chans_table, sys->format);
 
     hr = IAudioClient_GetService(sys->client, &IID_IAudioRenderClient, &pv);
     if (FAILED(hr))
@@ -256,7 +243,6 @@ static void vlc_ToWave(WAVEFORMATEXTENSIBLE *restrict wf,
             wf->SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
             break;
 
-        case VLC_CODEC_S8:
         case VLC_CODEC_U8:
             audio->i_format = VLC_CODEC_S16N;
         case VLC_CODEC_S16N:
@@ -324,7 +310,7 @@ static unsigned vlc_CheckWaveOrder (const WAVEFORMATEX *restrict wf,
 }
 
 static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict fmt,
-                     IMMDevice *dev, const GUID *sid)
+                     const GUID *sid)
 {
     aout_stream_sys_t *sys = malloc(sizeof (*sys));
     if (unlikely(sys == NULL))
@@ -332,11 +318,7 @@ static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict fmt,
     sys->client = NULL;
 
     void *pv;
-    HRESULT hr;
-
-    Enter();
-    hr = IMMDevice_Activate(dev, &IID_IAudioClient, CLSCTX_ALL, NULL, &pv);
-    Leave();
+    HRESULT hr = aout_stream_Activate(s, &IID_IAudioClient, NULL, &pv);
     if (FAILED(hr))
     {
         msg_Err(s, "cannot activate client (error 0x%lx)", hr);
@@ -374,7 +356,7 @@ static HRESULT Start(aout_stream_t *s, audio_sample_format_t *restrict fmt,
 
     sys->chans_to_reorder = vlc_CheckWaveOrder((hr == S_OK) ? &wf.Format : pwf,
                                                sys->chans_table);
-    sys->bits = fmt->i_bitspersample;
+    sys->format = fmt->i_format;
 
     hr = IAudioClient_Initialize(sys->client, AUDCLNT_SHAREMODE_SHARED, 0,
                                  AOUT_MAX_PREPARE_TIME * 10, 0,
@@ -417,26 +399,13 @@ static void Stop(aout_stream_t *s)
     IAudioClient_Release(sys->client);
 }
 
-#undef aout_stream_Start
-aout_stream_t *aout_stream_Start(vlc_object_t *parent,
-                                 audio_sample_format_t *restrict fmt,
-                                 IMMDevice *dev, const GUID *sid)
+HRESULT aout_stream_Start(aout_stream_t *s,
+                          audio_sample_format_t *restrict fmt, const GUID *sid)
 {
-    aout_stream_t *s = vlc_object_create(parent, sizeof (*s));
-    if (unlikely(s == NULL))
-        return NULL;
-
-    HRESULT hr = Start(s, fmt, dev, sid);
-    if (FAILED(hr))
-    {
-        vlc_object_release(s);
-        s = NULL;
-    }
-    return s;
+    return Start(s, fmt, sid);
 }
 
 void aout_stream_Stop(aout_stream_t *s)
 {
     Stop(s);
-    vlc_object_release(s);
 }