//
//  HA_RaspMXObject.h
//  HA_server
//
//  Created by hark on 2014/07/28.
//  Copyright (c) 2014年 hark. All rights reserved.
//

#ifndef __HA_server__HA_RaspMXObject__
#define __HA_server__HA_RaspMXObject__

#ifdef __cplusplus
#include <iostream>
#include "HA_Object.h"
#include "HA_buffer.h"
#include "HA_device.h"

#define MX_DEVICE_CH_NUM 16

namespace HARKAndroid {
    
class RaspMXObject : public DeviceObject {
private:

    pthread_t thread_id;
    ::pthread_mutex_t Being_Stopped_mutex;
    bool BeingStopped;

public:

    RaspMXObject(const RaspMXObject&);
    RaspMXObject();
    RaspMXObject(const char * const filename, const int length, const int advance);
    virtual ~RaspMXObject();
    RaspMXObject& operator = (const RaspMXObject&);
    
    int GetBits()
    {
    	return 24;
    }
    
    int GetChannels()
    {
        return MX_DEVICE_CH_NUM;
    }
    
    int channel_offset;
    void SetChannelOffset(int offset)
    {
        if(offset == 8)
        {
            channel_offset = 8;
        }
        else
        {
            channel_offset = 0;
        }
    }

    int open();
    int start(BufferObject&);
    int stop();
    int close();
    
    int SetBeingStopped();
    int ResetBeingStopped();
    bool isBeingStopped();

    BufferObject *buffer;
    int fd;

};

} // end of namespace

#endif // __cpusplus

#endif /* defined(__HA_server__HA_RaspMXObject__) */
