Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
Signed-off-by: Éloïse Brosseau <[email protected]>
  • Loading branch information
eloisebrosseau committed Dec 10, 2024
1 parent 88761cf commit f94e50f
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 107 deletions.
18 changes: 9 additions & 9 deletions src/plugins/output/AJADevices/AJADevices/AJAModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ namespace AJADevices
SimpleMode
};

AJAModule( NativeDisplayPtr, unsigned int app4CC, OperationMode );
virtual ~AJAModule();

virtual std::string name() const;
virtual std::string SDKIdentifier() const;
virtual std::string SDKInfo() const;
virtual void open();
virtual void close();
virtual bool isOpen() const;
AJAModule( NativeDisplayPtr, unsigned int appID, OperationMode );
~AJAModule() override;

[[nodiscard]] std::string name() const override;
[[nodiscard]] std::string SDKIdentifier() const override;
[[nodiscard]] std::string SDKInfo() const override;
void open() override;
void close() override;
[[nodiscard]] bool isOpen() const override;

private:
OperationMode m_mode{ OperationMode::ProMode };
Expand Down
169 changes: 80 additions & 89 deletions src/plugins/output/AJADevices/AJADevices/KonaVideoDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,21 @@
#include <GL/glu.h>
#endif

#if defined( PLATFORM_DARWIN )
#include <TwkGLF/GL.h>
#endif

#include <TwkGLF/GLFBO.h>
#include <TwkGLF/GLFence.h>
#include <iostream>
#include <stl_ext/thread_group.h>
#include "ajatypes.h"
#include "ntv2enums.h"
#include "ntv2devicefeatures.h"
#include "ntv2devicescanner.h"
#include "ntv2utils.h"
#include "ntv2card.h"
#include "ntv2vpid.h"

namespace AJADevices
{
class AJAModule;

typedef boost::mutex::scoped_lock ScopedLock;
typedef boost::mutex Mutex;
typedef boost::condition_variable Condition;
using ScopedLock = boost::mutex::scoped_lock;
using Mutex = boost::mutex;
using Condition = boost::condition_variable;

struct KonaAudioFormat
{
Expand Down Expand Up @@ -90,8 +82,8 @@ namespace AJADevices
unsigned int flags{ 0 };
};

typedef std::vector<KonaVideoFormat> KonaVideoFormatVector;
typedef std::vector<KonaDataFormat> KonaDataFormatVector;
using KonaVideoFormatVector = std::vector<KonaVideoFormat>;
using KonaDataFormatVector = std::vector<KonaDataFormat>;

struct KonaSyncMode
{
Expand Down Expand Up @@ -188,17 +180,17 @@ namespace AJADevices
// Types
//

typedef TwkUtil::Timer Timer;
typedef TwkGLF::GLFence GLFence;
typedef std::vector<unsigned char*> BufferVector;
typedef stl_ext::thread_group ThreadGroup;
typedef std::vector<int> AudioBuffer;
typedef std::vector<AudioBuffer> AudioBufferVector;
typedef std::vector<Time> TimeVector;
typedef TwkGLF::GLFBO GLFBO;
typedef AUTOCIRCULATE_TRANSFER_STATUS_STRUCT StatusStruct;
typedef std::vector<NTV2Channel> ChannelVector;
typedef std::vector<std::pair<ULWord, ULWord> > VPIDVector;
using Timer = TwkUtil::Timer;
using GLFence = TwkGLF::GLFence;
using BufferVector = std::vector<unsigned char*>;
using ThreadGroup = stl_ext::thread_group;
using AudioBuffer = std::vector<int>;
using AudioBufferVector = std::vector<AudioBuffer>;
using TimeVector = std::vector<Time>;
using GLFBO = TwkGLF::GLFBO;
using StatusStruct = AUTOCIRCULATE_TRANSFER_STATUS_STRUCT;
using ChannelVector = std::vector<NTV2Channel>;
using VPIDVector = std::vector<std::pair<ULWord, ULWord>>;

//
// This is basically the ring buffer element. Each method uses
Expand Down Expand Up @@ -244,7 +236,7 @@ namespace AJADevices
Mutex stateMutex;
};

typedef std::vector<FrameData> FrameDataVector;
using FrameDataVector = std::vector<FrameData>;

//
// VideoChannel is a logical indepenent output. For example the
Expand Down Expand Up @@ -273,7 +265,7 @@ namespace AJADevices
FrameDataVector data;
};

typedef std::vector<VideoChannel*> VideoChannelVector;
using VideoChannelVector = std::vector<VideoChannel*>;

//
// See next comment for explanation
Expand Down Expand Up @@ -308,92 +300,92 @@ namespace AJADevices
// stereo, or quad 4K, can be used.
//

KonaVideoDevice( AJAModule*, const std::string& name, unsigned int devicenum,
KonaVideoDevice( AJAModule*, const std::string& name, unsigned int deviceIndex,
unsigned int appID, OperationMode mode = OperationMode::ProMode );

virtual ~KonaVideoDevice();
~KonaVideoDevice() override;

//
// KonaVideoDevice API
//

virtual Time outputTime() const;
virtual Time inputTime() const;
virtual void resetClock() const;
Time outputTime() const override;
Time inputTime() const override;
void resetClock() const override;

virtual void beginTransfer() const;
virtual void endTransfer() const;
void beginTransfer() const override;
void endTransfer() const override;

//
// GLBindableVideoDevice API
//

virtual bool isStereo() const;
virtual bool isDualStereo() const;
bool isStereo() const override;
bool isDualStereo() const override;

virtual bool willBlockOnTransfer() const;
virtual void bind( const TwkGLF::GLVideoDevice* ) const;
virtual void bind2( const TwkGLF::GLVideoDevice*,
const TwkGLF::GLVideoDevice* ) const;
virtual void transfer( const TwkGLF::GLFBO* ) const;
virtual void transfer2( const TwkGLF::GLFBO*, const TwkGLF::GLFBO* ) const;
bool willBlockOnTransfer() const override;
void bind( const TwkGLF::GLVideoDevice* ) const override;
void bind2( const TwkGLF::GLVideoDevice*,
const TwkGLF::GLVideoDevice* ) const override;
void transfer( const TwkGLF::GLFBO* ) const override;
void transfer2( const TwkGLF::GLFBO*, const TwkGLF::GLFBO* ) const override;

virtual void unbind() const;
void unbind() const override;

//
// VideoDevice Audio API
//
virtual size_t numAudioFormats() const;
virtual AudioFormat audioFormatAtIndex( size_t ) const;
virtual void setAudioFormat( size_t );
virtual size_t currentAudioFormat() const;
virtual void audioFrameSizeSequence( AudioFrameSizeVector& ) const;
virtual void transferAudio( void* interleavedData, size_t n ) const;
size_t numAudioFormats() const override;
AudioFormat audioFormatAtIndex( size_t ) const override;
void setAudioFormat( size_t ) override;
size_t currentAudioFormat() const override;
void audioFrameSizeSequence( AudioFrameSizeVector& ) const override;
void transferAudio( void* interleavedData, size_t n ) const override;

//
// VideoDevice Video API
//

virtual size_t asyncMaxMappedBuffers() const;
virtual Time deviceLatency() const;

virtual size_t numVideoFormats() const;
virtual VideoFormat videoFormatAtIndex( size_t ) const;
virtual void setVideoFormat( size_t );
virtual size_t currentVideoFormat() const;

virtual size_t numVideo4KTransports() const;
virtual Video4KTransport video4KTransportAtIndex( size_t ) const;
virtual void setVideo4KTransport( size_t );
virtual size_t currentVideo4KTransport() const;

virtual size_t numDataFormats() const;
virtual DataFormat dataFormatAtIndex( size_t ) const;
virtual void setDataFormat( size_t );
virtual size_t currentDataFormat() const;

virtual size_t numSyncModes() const;
virtual SyncMode syncModeAtIndex( size_t ) const;
virtual void setSyncMode( size_t );
virtual size_t currentSyncMode() const;

virtual size_t numSyncSources() const;
virtual SyncSource syncSourceAtIndex( size_t ) const;
virtual void setSyncSource( size_t );
virtual size_t currentSyncSource() const;

virtual Resolution resolution() const;
virtual Offset offset() const; // defaults to 0,0
virtual Timing timing() const;
virtual VideoFormat format() const;
virtual size_t width() const;
virtual size_t height() const;
virtual void open( const StringVector& );
virtual void close();
virtual bool isOpen() const;
size_t asyncMaxMappedBuffers() const override;
Time deviceLatency() const override;

size_t numVideoFormats() const override;
VideoFormat videoFormatAtIndex( size_t ) const override;
void setVideoFormat( size_t ) override;
size_t currentVideoFormat() const override;

size_t numVideo4KTransports() const override;
Video4KTransport video4KTransportAtIndex( size_t ) const override;
void setVideo4KTransport( size_t ) override;
size_t currentVideo4KTransport() const override;

size_t numDataFormats() const override;
DataFormat dataFormatAtIndex( size_t ) const override;
void setDataFormat( size_t ) override;
size_t currentDataFormat() const override;

size_t numSyncModes() const override;
SyncMode syncModeAtIndex( size_t ) const override;
void setSyncMode( size_t ) override;
size_t currentSyncMode() const override;

size_t numSyncSources() const override;
SyncSource syncSourceAtIndex( size_t ) const override;
void setSyncSource( size_t ) override;
size_t currentSyncSource() const override;

Resolution resolution() const override;
Offset offset() const override; // defaults to 0,0
Timing timing() const override;
VideoFormat format() const override;
size_t width() const override;
size_t height() const override;
void open( const StringVector& ) override;
void close() override;
bool isOpen() const override;
virtual void makeCurrent() const;
virtual void clearCaches() const;
virtual void syncBuffers() const;
void clearCaches() const override;
void syncBuffers() const override;

void threadMain();
void lockDevice( bool lock, const char* threadName = "" ) const;
Expand Down Expand Up @@ -446,9 +438,8 @@ namespace AJADevices
void routeHDMI( NTV2Standard standard, const KonaDataFormat& d,
bool tsiEnabled, bool outputIsRGB );

private:
unsigned int m_appID{ 0 };
unsigned int m_devicenum{ 0 };
unsigned int m_deviceIndex{ 0 };
NTV2DeviceID m_deviceID{ DEVICE_ID_INVALID };
CNTV2Card* m_card{ nullptr };
NTV2EveryFrameTaskMode m_taskMode{ NTV2_TASK_MODE_INVALID };
Expand Down
3 changes: 0 additions & 3 deletions src/plugins/output/AJADevices/AJAModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
#endif
#include <sstream>
#include "ajatypes.h"
#include "ntv2enums.h"
#include "ntv2devicefeatures.h"
#include "ntv2devicescanner.h"
#include <ntv2card.h>
#include "ntv2utils.h"

namespace AJADevices
{
Expand Down
13 changes: 7 additions & 6 deletions src/plugins/output/AJADevices/KonaVideoDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "ntv2devicefeatures.h"
#include "ntv2formatdescriptor.h"
#include "ntv2vpid.h"
#include <stl_ext/replace_alloc.h>
#include <boost/program_options.hpp>
#include <boost/algorithm/string.hpp>
Expand Down Expand Up @@ -600,15 +601,15 @@ namespace AJADevices
bool KonaVideoDevice::m_infoFeedback = false;

KonaVideoDevice::KonaVideoDevice( AJAModule* m, const string& name,
unsigned int devicenum, unsigned int appID,
unsigned int deviceIndex, unsigned int appID,
OperationMode mode )
: GLBindableVideoDevice( m, name,
BlockingTransfer | ASyncReadBack | ImageOutput |
ProvidesSync | FixedResolution |
NormalizedCoordinates | FlippedImage |
Clock | AudioOutput ),
m_appID( appID ),
m_devicenum( devicenum ),
m_deviceIndex( deviceIndex ),
m_card( 0 ),
m_operationMode( mode ),
m_bound( false ),
Expand Down Expand Up @@ -710,7 +711,7 @@ namespace AJADevices
//
// Again, this affects *only* 4K timings.

m_card = new CNTV2Card( m_devicenum );
m_card = new CNTV2Card( m_deviceIndex );
bool ok = m_card->IsOpen();

if( ok )
Expand All @@ -721,7 +722,7 @@ namespace AJADevices
m_deviceNumVideoChannels = NTV2DeviceGetNumVideoChannels( m_deviceID );
m_deviceHasDualLink = NTV2DeviceCanDoDualLink( m_deviceID );
m_deviceHas3G = NTV2DeviceCanDo3GOut(
m_deviceID, 0 ); // XXX this 0 might need to be m_info->deviceIndex
m_deviceID, 0 );
m_deviceHDMIVersion = NTV2DeviceGetHDMIVersion( m_deviceID );
m_deviceHasHDMIStereo = NTV2DeviceCanDoHDMIOutStereo( m_deviceID );
m_deviceHasCSC = NTV2DeviceCanDoWidget( m_deviceID, NTV2_WgtCSC1 );
Expand Down Expand Up @@ -891,7 +892,7 @@ namespace AJADevices
m_actualVideoFormat = videoFormatsCP[0];
m_actualDataFormat = dataFormatsCP[0];

if( !m_open ) m_card = new CNTV2Card( m_devicenum );
if( !m_open ) m_card = new CNTV2Card( m_deviceIndex );

m_channelVector.clear();

Expand Down Expand Up @@ -1120,7 +1121,7 @@ namespace AJADevices
cout << "INFO: simple-routing = " << (int)m_simpleRouting << endl;
}

m_card = new CNTV2Card( m_devicenum );
m_card = new CNTV2Card( m_deviceIndex );

m_open = m_card->IsOpen();

Expand Down

0 comments on commit f94e50f

Please sign in to comment.