Code style cleanup / honored 80 column line length limit. Modified FireWireDVAddOn to use BObjectList.
Feel free to chime in if I missed any style violations. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28000 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "FireWireCard.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -16,7 +18,6 @@
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "FireWireCard.h"
|
||||
#include "glue.h"
|
||||
|
||||
#define TAG (1<<6)
|
||||
@@ -80,10 +81,10 @@ struct mpeg_pldt {
|
||||
|
||||
|
||||
FireWireCard::FireWireCard(const char* path)
|
||||
: fInitStatus(B_OK)
|
||||
, fDev(-1)
|
||||
, fBuf(NULL)
|
||||
, fPad(NULL)
|
||||
: fInitStatus(B_OK),
|
||||
fDev(-1),
|
||||
fBuf(NULL),
|
||||
fPad(NULL)
|
||||
{
|
||||
printf("FireWireCard opening %s\n", path);
|
||||
|
||||
@@ -141,7 +142,8 @@ FireWireCard::GetBufInfo(size_t *rbufsize, int *rcount)
|
||||
status_t
|
||||
FireWireCard::DetectRecvFn()
|
||||
{
|
||||
char *buf, ich = TAG | CHANNEL;
|
||||
char* buf;
|
||||
char ich = TAG | CHANNEL;
|
||||
struct fw_isochreq isoreq;
|
||||
struct fw_isobufreq bufreq;
|
||||
int len;
|
||||
@@ -398,3 +400,4 @@ next:
|
||||
*src = ptr;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#ifndef __FIREWIRE_CARD_H
|
||||
#define __FIREWIRE_CARD_H
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
class FireWireCard
|
||||
{
|
||||
public:
|
||||
@@ -31,8 +33,8 @@ private:
|
||||
ssize_t DvRead(void** buffer);
|
||||
status_t DvExtract(void* dest, void** src, ssize_t* sizeUsed);
|
||||
ssize_t MpegtsRead(void** buffer);
|
||||
status_t MpegtsExtract(void *dest, void **src, ssize_t *sizeUsed);
|
||||
|
||||
status_t MpegtsExtract(void* dest, void** src,
|
||||
ssize_t* sizeUsed);
|
||||
|
||||
status_t fInitStatus;
|
||||
int fDev;
|
||||
@@ -45,3 +47,4 @@ private:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
@@ -38,11 +39,6 @@ make_media_addon(image_id id)
|
||||
return new FireWireDVAddOn(id);
|
||||
}
|
||||
|
||||
FireWireDVAddOn::~FireWireDVAddOn()
|
||||
{
|
||||
CALLED();
|
||||
FreeDeviceList();
|
||||
}
|
||||
|
||||
FireWireDVAddOn::FireWireDVAddOn(image_id id)
|
||||
: BMediaAddOn(id)
|
||||
@@ -51,6 +47,14 @@ FireWireDVAddOn::FireWireDVAddOn(image_id id)
|
||||
ScanFolder("/dev/bus/fw");
|
||||
}
|
||||
|
||||
|
||||
FireWireDVAddOn::~FireWireDVAddOn()
|
||||
{
|
||||
CALLED();
|
||||
FreeDeviceList();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
FireWireDVAddOn::InitCheck(const char** out_failure_text)
|
||||
{
|
||||
@@ -62,6 +66,7 @@ FireWireDVAddOn::InitCheck(const char **out_failure_text)
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
FireWireDVAddOn::CountFlavors()
|
||||
{
|
||||
@@ -69,31 +74,36 @@ FireWireDVAddOn::CountFlavors()
|
||||
return fDeviceList.CountItems();
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
FireWireDVAddOn::GetFlavorAt(int32 n, const flavor_info** out_info)
|
||||
{
|
||||
CALLED();
|
||||
device_info *dev = (device_info *)fDeviceList.ItemAt(n);
|
||||
device_info* dev = fDeviceList.ItemAt(n);
|
||||
if (!dev)
|
||||
return B_ERROR;
|
||||
*out_info = &dev->flavor;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
BMediaNode *
|
||||
FireWireDVAddOn::InstantiateNodeFor(const flavor_info *info, BMessage *config, status_t *out_error)
|
||||
FireWireDVAddOn::InstantiateNodeFor(const flavor_info* info, BMessage* config,
|
||||
status_t* out_error)
|
||||
{
|
||||
CALLED();
|
||||
device_info *dev = (device_info *)fDeviceList.ItemAt(info->internal_id);
|
||||
device_info* dev = fDeviceList.ItemAt(info->internal_id);
|
||||
if (!dev || dev->flavor.internal_id != info->internal_id) {
|
||||
*out_error = B_ERROR;
|
||||
return NULL;
|
||||
}
|
||||
*out_error = B_OK;
|
||||
|
||||
return new FireWireDVNode(this, dev->name, dev->flavor.internal_id, dev->card);
|
||||
return new FireWireDVNode(this, dev->name, dev->flavor.internal_id,
|
||||
dev->card);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
FireWireDVAddOn::WantsAutoStart()
|
||||
{
|
||||
@@ -101,13 +111,16 @@ FireWireDVAddOn::WantsAutoStart()
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
FireWireDVAddOn::AutoStart(int index, BMediaNode **outNode, int32 *outInternalID, bool *outHasMore)
|
||||
FireWireDVAddOn::AutoStart(int index, BMediaNode** outNode,
|
||||
int32* outInternalID, bool* outHasMore)
|
||||
{
|
||||
CALLED();
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FireWireDVAddOn::ScanFolder(const char* path)
|
||||
{
|
||||
@@ -130,6 +143,7 @@ FireWireDVAddOn::ScanFolder(const char *path)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FireWireDVAddOn::AddDevice(FireWireCard* card, const char* path)
|
||||
{
|
||||
@@ -176,8 +190,9 @@ void
|
||||
FireWireDVAddOn::FreeDeviceList()
|
||||
{
|
||||
device_info* dev;
|
||||
while ((dev = (device_info *)fDeviceList.RemoveItem((int32)0))) {
|
||||
while ((dev = fDeviceList.RemoveItemAt(0L))) {
|
||||
delete dev->card;
|
||||
delete dev;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
#define _FIREWIRE_DV_ADDON_H_
|
||||
|
||||
#include <MediaAddOn.h>
|
||||
#include <ObjectList.h>
|
||||
|
||||
class FireWireCard;
|
||||
struct device_info;
|
||||
|
||||
class FireWireDVAddOn : public BMediaAddOn
|
||||
{
|
||||
@@ -27,19 +29,20 @@ public:
|
||||
|
||||
status_t GetFlavorAt(int32 n, const flavor_info** out_info);
|
||||
|
||||
BMediaNode *InstantiateNodeFor(const flavor_info *info, BMessage *config, status_t *out_error);
|
||||
BMediaNode* InstantiateNodeFor(const flavor_info* info,
|
||||
BMessage* config, status_t* out_error);
|
||||
|
||||
bool WantsAutoStart();
|
||||
status_t AutoStart(int index, BMediaNode **outNode, int32 *outInternalID, bool *outHasMore);
|
||||
status_t AutoStart(int index, BMediaNode** outNode,
|
||||
int32* outInternalID, bool* outHasMore);
|
||||
|
||||
protected:
|
||||
void ScanFolder(const char* path);
|
||||
|
||||
void AddDevice(FireWireCard* card, const char* path);
|
||||
void FreeDeviceList();
|
||||
|
||||
protected:
|
||||
BList fDeviceList;
|
||||
BObjectList<device_info> fDeviceList;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
* Copyright (c) 2004-2007 Marcus Overhagen <[email protected]>
|
||||
*/
|
||||
|
||||
#include "FireWireDVNode.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
#include <math.h>
|
||||
@@ -17,18 +19,17 @@
|
||||
#include <sys/uio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <MediaRoster.h>
|
||||
#include <Autolock.h>
|
||||
#include <Buffer.h>
|
||||
#include <BufferGroup.h>
|
||||
#include <ParameterWeb.h>
|
||||
#include <TimeSource.h>
|
||||
#include <String.h>
|
||||
#include <Autolock.h>
|
||||
#include <Debug.h>
|
||||
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <MediaRoster.h>
|
||||
#include <ParameterWeb.h>
|
||||
#include <Path.h>
|
||||
#include <TimeSource.h>
|
||||
#include <String.h>
|
||||
|
||||
#include "FireWireDVNode.h"
|
||||
#include "FireWireCard.h"
|
||||
@@ -42,7 +43,7 @@
|
||||
#ifdef TRACE
|
||||
# undef TRACE
|
||||
#endif
|
||||
#define TRACE_FIREWIRE_NODE
|
||||
//#define TRACE_FIREWIRE_NODE
|
||||
#ifdef TRACE_FIREWIRE_NODE
|
||||
# define TRACE(x...) printf(x)
|
||||
#else
|
||||
@@ -53,20 +54,19 @@
|
||||
|
||||
#define M_REFRESH_PARAMETER_WEB (BTimedEventQueue::B_USER_EVENT + 1)
|
||||
|
||||
FireWireDVNode::FireWireDVNode(
|
||||
BMediaAddOn *addon, const char *name,
|
||||
FireWireDVNode::FireWireDVNode(BMediaAddOn* addon, const char* name,
|
||||
int32 internal_id, FireWireCard* card)
|
||||
: BMediaNode(name)
|
||||
, BBufferProducer(B_MEDIA_ENCODED_VIDEO)
|
||||
, BControllable()
|
||||
, BMediaEventLooper()
|
||||
, fOutputEnabledEncVideo(false)
|
||||
, fCard(card)
|
||||
, fCaptureThreadsActive(false)
|
||||
, fThreadIdCardReader(-1)
|
||||
, fTerminateThreads(false)
|
||||
, fBufferGroupEncVideo(0)
|
||||
, fCaptureActive(false)
|
||||
: BMediaNode(name),
|
||||
BBufferProducer(B_MEDIA_ENCODED_VIDEO),
|
||||
BControllable(),
|
||||
BMediaEventLooper(),
|
||||
fOutputEnabledEncVideo(false),
|
||||
fCard(card),
|
||||
fCaptureThreadsActive(false),
|
||||
fThreadIdCardReader(-1),
|
||||
fTerminateThreads(false),
|
||||
fBufferGroupEncVideo(0),
|
||||
fCaptureActive(false)
|
||||
{
|
||||
CALLED();
|
||||
|
||||
@@ -92,8 +92,6 @@ FireWireDVNode::~FireWireDVNode()
|
||||
|
||||
|
||||
/* BMediaNode */
|
||||
|
||||
|
||||
BMediaAddOn*
|
||||
FireWireDVNode::AddOn(int32* internal_id) const
|
||||
{
|
||||
@@ -134,8 +132,6 @@ FireWireDVNode::SetRunMode(run_mode mode)
|
||||
|
||||
|
||||
/* BMediaEventLooper */
|
||||
|
||||
|
||||
void
|
||||
FireWireDVNode::NodeRegistered()
|
||||
{
|
||||
@@ -188,8 +184,6 @@ FireWireDVNode::HandleEvent(const media_timed_event *event,
|
||||
|
||||
|
||||
/* BBufferProducer */
|
||||
|
||||
|
||||
status_t
|
||||
FireWireDVNode::FormatChangeRequested(const media_source& source,
|
||||
const media_destination& destination, media_format* io_format,
|
||||
@@ -280,7 +274,8 @@ FireWireDVNode::FormatSuggestionRequested(
|
||||
|
||||
|
||||
status_t
|
||||
FireWireDVNode::FormatProposal(const media_source &source, media_format *format)
|
||||
FireWireDVNode::FormatProposal(const media_source& source,
|
||||
media_format* format)
|
||||
{
|
||||
CALLED();
|
||||
/* The connection process:
|
||||
@@ -456,8 +451,6 @@ FireWireDVNode::AdditionalBufferRequested(const media_source &source,
|
||||
|
||||
|
||||
/* FireWireDVNode */
|
||||
|
||||
|
||||
void
|
||||
FireWireDVNode::HandleTimeWarp(bigtime_t performance_time)
|
||||
{
|
||||
@@ -608,12 +601,12 @@ FireWireDVNode::card_reader_thread()
|
||||
//what should the start_time be?
|
||||
hdr->start_time = TimeSource()->PerformanceTimeFor(system_time());
|
||||
|
||||
lock.Lock();
|
||||
fLock.Lock();
|
||||
if (B_OK != SendBuffer(buf, fOutputEncVideo.destination)) {
|
||||
TRACE("OutVideo: sending buffer failed\n");
|
||||
buf->Recycle();
|
||||
}
|
||||
lock.Unlock();
|
||||
fLock.Unlock();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -675,7 +668,8 @@ FireWireDVNode::CreateParameterWeb()
|
||||
|
||||
|
||||
status_t
|
||||
FireWireDVNode::GetParameterValue(int32 id, bigtime_t *last_change, void *value, size_t *size)
|
||||
FireWireDVNode::GetParameterValue(int32 id, bigtime_t* last_change,
|
||||
void* value, size_t* size)
|
||||
{
|
||||
TRACE("FireWireDVNode::GetParameterValue, id 0x%lx\n", id);
|
||||
//do we need Parameter for firewire dv?
|
||||
@@ -684,9 +678,12 @@ FireWireDVNode::GetParameterValue(int32 id, bigtime_t *last_change, void *value,
|
||||
|
||||
|
||||
void
|
||||
FireWireDVNode::SetParameterValue(int32 id, bigtime_t when, const void *value, size_t size)
|
||||
FireWireDVNode::SetParameterValue(int32 id, bigtime_t when, const void* value,
|
||||
size_t size)
|
||||
{
|
||||
TRACE("FireWireDVNode::SetParameterValue, id 0x%lx, size %ld, value 0x%lx\n", id, size, *(const int32 *)value);
|
||||
TRACE("FireWireDVNode::SetParameterValue, id 0x%lx, size %ld, "
|
||||
"value 0x%lx\n", id, size, *(const int32*)value);
|
||||
//do we need parameter for firewire dv?
|
||||
TRACE("FireWireDVNode::SetParameterValue finished\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ class FireWireDVNode : public virtual BBufferProducer,
|
||||
public virtual BControllable, public virtual BMediaEventLooper {
|
||||
public:
|
||||
FireWireDVNode(BMediaAddOn *addon,
|
||||
const char *name, int32 internal_id, FireWireCard *card);
|
||||
const char *name, int32 internal_id,
|
||||
FireWireCard *card);
|
||||
virtual ~FireWireDVNode();
|
||||
|
||||
virtual status_t InitCheck() const { return fInitStatus; }
|
||||
@@ -46,24 +47,28 @@ virtual void SetRunMode(run_mode mode);
|
||||
/* BMediaEventLooper */
|
||||
protected:
|
||||
virtual void NodeRegistered();
|
||||
|
||||
virtual void HandleEvent(const media_timed_event *event,
|
||||
bigtime_t lateness, bool realTimeEvent = false);
|
||||
bigtime_t lateness,
|
||||
bool realTimeEvent = false);
|
||||
|
||||
/* BBufferProducer */
|
||||
protected:
|
||||
virtual status_t FormatSuggestionRequested(media_type type, int32 quality,
|
||||
media_format * format);
|
||||
virtual status_t FormatSuggestionRequested(media_type type,
|
||||
int32 quality, media_format* format);
|
||||
virtual status_t FormatProposal(const media_source &source,
|
||||
media_format* format);
|
||||
virtual status_t FormatChangeRequested(const media_source &source,
|
||||
virtual status_t FormatChangeRequested(
|
||||
const media_source &source,
|
||||
const media_destination &destination,
|
||||
media_format *io_format, int32 *_deprecated_);
|
||||
virtual status_t GetNextOutput(int32 * cookie, media_output * out_output);
|
||||
media_format* io_format,
|
||||
int32* _deprecated_);
|
||||
virtual status_t GetNextOutput(int32* cookie,
|
||||
media_output* out_output);
|
||||
virtual status_t DisposeOutputCookie(int32 cookie);
|
||||
virtual status_t SetBufferGroup(const media_source& for_source,
|
||||
BBufferGroup* group);
|
||||
virtual status_t VideoClippingChanged(const media_source &for_source,
|
||||
virtual status_t VideoClippingChanged(
|
||||
const media_source& for_source,
|
||||
int16 num_shorts, int16* clip_data,
|
||||
const media_video_display_info &display,
|
||||
int32* _deprecated_);
|
||||
@@ -71,24 +76,31 @@ virtual status_t GetLatency(bigtime_t * out_latency);
|
||||
virtual status_t PrepareToConnect(const media_source& what,
|
||||
const media_destination& where,
|
||||
media_format* format,
|
||||
media_source *out_source, char *out_name);
|
||||
virtual void Connect(status_t error, const media_source &source,
|
||||
media_source* out_source,
|
||||
char* out_name);
|
||||
virtual void Connect(status_t error,
|
||||
const media_source& source,
|
||||
const media_destination& destination,
|
||||
const media_format & format, char *io_name);
|
||||
const media_format& format,
|
||||
char* io_name);
|
||||
virtual void Disconnect(const media_source& what,
|
||||
const media_destination& where);
|
||||
virtual void LateNoticeReceived(const media_source& what,
|
||||
bigtime_t how_much, bigtime_t performance_time);
|
||||
virtual void EnableOutput(const media_source & what, bool enabled,
|
||||
int32 * _deprecated_);
|
||||
virtual void AdditionalBufferRequested(const media_source & source,
|
||||
media_buffer_id prev_buffer, bigtime_t prev_time,
|
||||
bigtime_t how_much,
|
||||
bigtime_t performance_time);
|
||||
virtual void EnableOutput(const media_source& what,
|
||||
bool enabled, int32* _deprecated_);
|
||||
virtual void AdditionalBufferRequested(
|
||||
const media_source& source,
|
||||
media_buffer_id prev_buffer,
|
||||
bigtime_t prev_time,
|
||||
const media_seek_tag* prev_tag);
|
||||
|
||||
/* BControllable */
|
||||
protected:
|
||||
virtual status_t GetParameterValue(int32 id, bigtime_t *last_change,
|
||||
void *value, size_t *size);
|
||||
virtual status_t GetParameterValue(int32 id,
|
||||
bigtime_t* last_change, void* value,
|
||||
size_t* size);
|
||||
virtual void SetParameterValue(int32 id, bigtime_t when,
|
||||
const void* value, size_t size);
|
||||
|
||||
@@ -115,31 +127,21 @@ private:
|
||||
void card_reader_thread();
|
||||
|
||||
status_t fInitStatus;
|
||||
|
||||
int32 fInternalID;
|
||||
BMediaAddOn* fAddOn;
|
||||
|
||||
bool fOutputEnabledEncVideo;
|
||||
|
||||
media_output fOutputEncVideo;
|
||||
|
||||
media_format fDefaultFormatEncVideo;
|
||||
|
||||
FireWireCard* fCard;
|
||||
|
||||
bool fCaptureThreadsActive;
|
||||
|
||||
thread_id fThreadIdCardReader;
|
||||
|
||||
volatile bool fTerminateThreads;
|
||||
|
||||
BBufferGroup* fBufferGroupEncVideo;
|
||||
|
||||
BParameterWeb* fWeb;
|
||||
|
||||
bool fCaptureActive;
|
||||
BLocker lock;
|
||||
BLocker fLock;
|
||||
|
||||
};
|
||||
|
||||
#endif // __FIREWIRE_DV_NODE_H
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
SubDir HAIKU_TOP src add-ons media media-add-ons firewire_dv ;
|
||||
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
|
||||
UsePrivateHeaders media ;
|
||||
|
||||
UsePrivateHeaders firewire ;
|
||||
UsePrivateHeaders media ;
|
||||
UsePrivateHeaders shared ;
|
||||
|
||||
Addon firewire_dv.media_addon :
|
||||
FireWireCard.cpp
|
||||
|
||||
Reference in New Issue
Block a user