2016-05-31 01:50:06 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Haiku, Inc. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _ADAPTER_IO_H
|
|
|
|
#define _ADAPTER_IO_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <MediaIO.h>
|
|
|
|
#include <OS.h>
|
2019-05-17 21:43:32 +03:00
|
|
|
#include <RWLocker.h>
|
2016-05-31 01:50:06 +03:00
|
|
|
#include <SupportDefs.h>
|
|
|
|
|
|
|
|
|
|
|
|
class BAdapterIO;
|
2016-06-07 16:30:41 +03:00
|
|
|
class RelativePositionIO;
|
2016-05-31 01:50:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
class BInputAdapter {
|
|
|
|
public:
|
2016-06-07 16:30:41 +03:00
|
|
|
virtual ssize_t Write(const void* buffer, size_t size);
|
2016-05-31 01:50:06 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class BAdapterIO;
|
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
BInputAdapter(BAdapterIO* io);
|
|
|
|
virtual ~BInputAdapter();
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
BAdapterIO* fIO;
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
virtual void _ReservedInputAdapter1();
|
|
|
|
virtual void _ReservedInputAdapter2();
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
uint32 _reserved[2];
|
2016-05-31 01:50:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class BAdapterIO : public BMediaIO {
|
|
|
|
public:
|
2016-07-03 16:24:19 +03:00
|
|
|
BAdapterIO(
|
2016-07-09 03:14:37 +03:00
|
|
|
int32 flags,
|
|
|
|
bigtime_t timeout);
|
2016-06-07 16:30:41 +03:00
|
|
|
virtual ~BAdapterIO();
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
virtual void GetFlags(int32* flags) const;
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
virtual ssize_t ReadAt(off_t position, void* buffer,
|
|
|
|
size_t size);
|
|
|
|
virtual ssize_t WriteAt(off_t position,
|
|
|
|
const void* buffer, size_t size);
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
virtual off_t Seek(off_t position, uint32 seekMode);
|
|
|
|
virtual off_t Position() const;
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
virtual status_t SetSize(off_t size);
|
|
|
|
virtual status_t GetSize(off_t* size) const;
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-30 17:27:50 +03:00
|
|
|
virtual status_t Open();
|
|
|
|
|
2016-07-09 17:18:09 +03:00
|
|
|
virtual bool IsRunning() const;
|
|
|
|
|
2016-06-30 17:27:50 +03:00
|
|
|
void SeekCompleted();
|
|
|
|
status_t SetBuffer(BPositionIO* buffer);
|
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
BInputAdapter* BuildInputAdapter();
|
2016-05-31 01:50:06 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
friend class BInputAdapter;
|
|
|
|
|
2016-06-30 17:27:50 +03:00
|
|
|
virtual status_t SeekRequested(off_t position);
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
ssize_t BackWrite(const void* buffer, size_t size);
|
|
|
|
|
2016-05-31 01:50:06 +03:00
|
|
|
private:
|
2016-07-03 16:24:19 +03:00
|
|
|
status_t _EvaluateWait(off_t pos, off_t size);
|
2016-06-07 16:30:41 +03:00
|
|
|
|
|
|
|
int32 fFlags;
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
RelativePositionIO* fBuffer;
|
2016-06-22 22:33:22 +03:00
|
|
|
off_t fTotalSize;
|
2016-06-30 17:27:50 +03:00
|
|
|
bool fOpened;
|
|
|
|
sem_id fSeekSem;
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
BInputAdapter* fInputAdapter;
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
BAdapterIO(const BAdapterIO&);
|
|
|
|
BAdapterIO& operator=(const BAdapterIO&);
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
virtual void _ReservedAdapterIO1();
|
|
|
|
virtual void _ReservedAdapterIO2();
|
|
|
|
virtual void _ReservedAdapterIO3();
|
|
|
|
virtual void _ReservedAdapterIO4();
|
|
|
|
virtual void _ReservedAdapterIO5();
|
2016-05-31 01:50:06 +03:00
|
|
|
|
2016-06-07 16:30:41 +03:00
|
|
|
uint32 _reserved[5];
|
2016-05-31 01:50:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _ADAPTER_IO_H
|