/*
 * Copyright (c) 2026 Huawei Device Co., Ltd.
 * Licensed under Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with License.
 * You may obtain a copy of License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under 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.
 */

#ifndef MYAPPLICATION_AUDIO_BUFFER_QUEUE_H
#define MYAPPLICATION_AUDIO_BUFFER_QUEUE_H

#include <cstdint>
#include <vector>
#include <mutex>

class AudioBufferQueue {
private:
    std::vector<uint8_t> buffer;
    size_t bufferSize;
    size_t writePos;
    size_t readPos;
    size_t availableData;
    std::mutex mutex;

public:
    AudioBufferQueue(size_t size);
    ~AudioBufferQueue();
    
    size_t Write(int fd, size_t bytesToWrite);
    size_t Read(void* dest, size_t bytesToRead);
    size_t GetAvailableSpace() const;
    void Clear();
    bool IsFull() const;
};

#endif // MYAPPLICATION_AUDIO_BUFFER_QUEUE_H