1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
/*
* Copyright (C) 2010-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "cores/AudioEngine/Interfaces/AESink.h"
#include "cores/AudioEngine/Utils/AEDeviceInfo.h"
#include "threads/CriticalSection.h"
#include <stdint.h>
#include <mmsystem.h> /* Microsoft can't write standalone headers */
#include <DSound.h> /* Microsoft can't write standalone headers */
#include <wrl/client.h>
class CAESinkDirectSound : public IAESink
{
public:
virtual const char *GetName() { return "DIRECTSOUND"; }
CAESinkDirectSound();
virtual ~CAESinkDirectSound();
static void Register();
static IAESink* Create(std::string &device, AEAudioFormat &desiredFormat);
virtual bool Initialize(AEAudioFormat &format, std::string &device);
virtual void Deinitialize();
virtual void Stop();
virtual void Drain();
virtual void GetDelay(AEDelayStatus& status);
virtual double GetCacheTotal();
virtual unsigned int AddPackets(uint8_t **data, unsigned int frames, unsigned int offset);
static std::string GetDefaultDevice();
static void EnumerateDevicesEx (AEDeviceInfoList &deviceInfoList, bool force = false);
private:
void AEChannelsFromSpeakerMask(DWORD speakers);
DWORD SpeakerMaskFromAEChannels(const CAEChannelInfo &channels);
void CheckPlayStatus();
bool UpdateCacheStatus();
unsigned int GetSpace();
const char *dserr2str(int err);
Microsoft::WRL::ComPtr<IDirectSoundBuffer> m_pBuffer;
Microsoft::WRL::ComPtr<IDirectSound> m_pDSound;
AEAudioFormat m_format;
enum AEDataFormat m_encodedFormat;
CAEChannelInfo m_channelLayout;
std::string m_device;
unsigned int m_AvgBytesPerSec;
unsigned int m_dwChunkSize;
unsigned int m_dwFrameSize;
unsigned int m_dwBufferLen;
unsigned int m_BufferOffset;
unsigned int m_CacheLen;
unsigned int m_BufferTimeouts;
bool m_running;
bool m_initialized;
bool m_isDirtyDS;
CCriticalSection m_runLock;
};
|