Skip to content

File Device.h

File List > Amplitude > Core > Device.h

Go to the documentation of this file

// Copyright (c) 2021-present Sparky Studios. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#ifndef _AM_CORE_DEVICE_H
#define _AM_CORE_DEVICE_H

#include <SparkyStudios/Audio/Amplitude/Core/Common.h>

namespace SparkyStudios::Audio::Amplitude
{
    class Driver;

    enum class PlaybackOutputFormat : AmUInt16
    {
        Default = 0,

        UInt8 = 1,

        Int16 = 2,

        Int24 = 3,

        Int32 = 4,

        Float32 = 5
    };

    enum class PlaybackOutputChannels : AmUInt16
    {
        Default = 0,

        Mono = 1,

        Stereo = 2,

        Quad = 4,

        Surround_5_1 = 6,

        Surround_7_1 = 8
    };

    enum eDeviceState : AmUInt8
    {
        eDeviceState_Opened,

        eDeviceState_Started,

        eDeviceState_Paused,

        eDeviceState_Stopped,

        eDeviceState_Closed
    };

    enum eDeviceNotification : AmUInt8
    {
        eDeviceNotification_Opened,

        eDeviceNotification_Started,

        eDeviceNotification_Rerouted,

        eDeviceNotification_Stopped,

        eDeviceNotification_Closed
    };

    struct DeviceDescription
    {
        AmString mDeviceName;

        AmObjectID mDeviceID;

        PlaybackOutputFormat mRequestedOutputFormat;

        PlaybackOutputFormat mDeviceOutputFormat;

        PlaybackOutputChannels mRequestedOutputChannels;

        PlaybackOutputChannels mDeviceOutputChannels;

        AmUInt32 mRequestedOutputSampleRate;

        AmUInt32 mDeviceOutputSampleRate;

        AmUInt32 mOutputBufferSize;

        eDeviceState mDeviceState;
    };

    AM_CALLBACK(void, DeviceNotificationCallback)(eDeviceNotification notification, const DeviceDescription& device, Driver* driver);

    AM_API_PUBLIC void RegisterDeviceNotificationCallback(DeviceNotificationCallback callback);

    AM_API_PUBLIC void UnregisterDeviceNotificationCallback();

    AM_API_PUBLIC void CallDeviceNotificationCallback(eDeviceNotification notification, const DeviceDescription& device, Driver* driver);
} // namespace SparkyStudios::Audio::Amplitude

#endif // _AM_CORE_DEVICE_H