carb/audio/IAudioDevice.h

File members: carb/audio/IAudioDevice.h

// Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#pragma once

#include "../Interface.h"
#include "AudioTypes.h"

namespace carb
{
namespace audio
{

enum class DeviceType
{
    ePlayback,
    eCapture,
};

enum class DeviceBackend
{
    eNull,

    eWindowsAudioServices,

    ePulseAudio,

    eAlsa,

    eCoreAudio,
};

typedef void (*DeviceNotifyCallback)(void* ctx);

class DeviceChangeNotifier;

struct IAudioDevice
{
#ifndef DOXYGEN_SHOULD_SKIP_THIS
    CARB_PLUGIN_INTERFACE("carb::audio::IAudioDevice", 1, 1);
#endif

    size_t(CARB_ABI* getDeviceCount)(DeviceType dir);

    AudioResult(CARB_ABI* getDeviceCaps)(DeviceType dir, size_t index, carb::audio::DeviceCaps* caps);

    DeviceChangeNotifier*(CARB_ABI* createNotifier)(DeviceType type, DeviceNotifyCallback callback, void* context);

    void(CARB_ABI* destroyNotifier)(DeviceChangeNotifier* notifier);

    DeviceBackend(CARB_ABI* getBackend)();

    AudioResult(CARB_ABI* getDeviceName)(DeviceType type, size_t index, DeviceCaps* caps);

    AudioResult(CARB_ABI* getDeviceCapsByGuid)(DeviceType dir,
                                               const carb::extras::Guid* guid,
                                               carb::audio::DeviceCaps* caps);

    AudioResult(CARB_ABI* getDeviceNameByGuid)(DeviceType dir,
                                               const carb::extras::Guid* guid,
                                               carb::audio::DeviceCaps* caps);
};

} // namespace audio
} // namespace carb