Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.

Document all functions, class, struct, union, enum, macro, variable, typedefs.  This isn't the actual document in itself but empty documentation using any old documentation if it was there.

This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.

Some notes:
 * Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
 * Some multiline comments may have been munged into single line comments
 * Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
 * Enum comments can go after the enumeration itself '[value] /// comment'
 * include/aegisub/*.h haven't been converted yet, this will be done in a later commit
 * Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.

See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.

Originally committed to SVN as r3312.
This commit is contained in:
Amar Takhar 2009-07-29 22:59:22 +00:00
parent d6fbe6fc8e
commit 6ee2f98349
324 changed files with 16843 additions and 3876 deletions

View file

@ -36,6 +36,8 @@
#pragma once #pragma once
#ifndef _AEGISUB_ENDIAN_H #ifndef _AEGISUB_ENDIAN_H
/// DOCME
#define _AEGISUB_ENDIAN_H #define _AEGISUB_ENDIAN_H
@ -48,15 +50,23 @@
// But this is an OS X system building a universal binary // But this is an OS X system building a universal binary
// Apple's GCC defines _BIG_ENDIAN when building for PPC // Apple's GCC defines _BIG_ENDIAN when building for PPC
# ifdef _BIG_ENDIAN # ifdef _BIG_ENDIAN
/// DOCME
# define HAVE_BIG_ENDIAN # define HAVE_BIG_ENDIAN
# else # else
/// DOCME
# define HAVE_LITTLE_ENDIAN # define HAVE_LITTLE_ENDIAN
# endif # endif
/// DOCME
# undef HAVE_DYNAMIC_ENDIAN # undef HAVE_DYNAMIC_ENDIAN
# else // !HAVE_UNIVERSAL_ENDIAN # else // !HAVE_UNIVERSAL_ENDIAN
// We aren't building an OS X universal binary // We aren't building an OS X universal binary
// Use the dynamic endian code // Use the dynamic endian code
# ifndef HAVE_DYNAMIC_ENDIAN # ifndef HAVE_DYNAMIC_ENDIAN
/// DOCME
# define HAVE_DYNAMIC_ENDIAN # define HAVE_DYNAMIC_ENDIAN
# endif # endif
# endif //HAVE_UNIVERSAL_ENDIAN # endif //HAVE_UNIVERSAL_ENDIAN
@ -73,6 +83,8 @@
#include <stdint.h> #include <stdint.h>
/// DOCME
namespace Endian { namespace Endian {
// Unconditionally reverse endianness // Unconditionally reverse endianness
@ -80,6 +92,11 @@ namespace Endian {
// These are only defined for unsigned ints, // These are only defined for unsigned ints,
// Use reinterpret_cast on the values if you need signed values. // Use reinterpret_cast on the values if you need signed values.
/// @brief DOCME
/// @param val
/// @return
///
inline uint16_t Reverse(uint16_t val) inline uint16_t Reverse(uint16_t val)
{ {
return return
@ -87,6 +104,11 @@ namespace Endian {
((val & 0xFF00) >> 8); ((val & 0xFF00) >> 8);
} }
/// @brief DOCME
/// @param val
/// @return
///
inline uint32_t Reverse(uint32_t val) inline uint32_t Reverse(uint32_t val)
{ {
return return
@ -96,6 +118,11 @@ namespace Endian {
((val & 0xFF000000) >> 24); ((val & 0xFF000000) >> 24);
} }
/// @brief DOCME
/// @param val
/// @return
///
inline uint64_t Reverse(uint64_t val) inline uint64_t Reverse(uint64_t val)
{ {
return return
@ -116,6 +143,11 @@ namespace Endian {
// Regular, fast, templatized conditional reversing // Regular, fast, templatized conditional reversing
template <class T> template <class T>
/// @brief DOCME
/// @param val
/// @return
///
inline T LittleToMachine(T val) inline T LittleToMachine(T val)
{ {
#ifdef HAVE_BIG_ENDIAN #ifdef HAVE_BIG_ENDIAN
@ -128,6 +160,11 @@ namespace Endian {
} }
template <class T> template <class T>
/// @brief DOCME
/// @param val
/// @return
///
inline T BigToMachine(T val) inline T BigToMachine(T val)
{ {
#ifdef HAVE_LITTLE_ENDIAN #ifdef HAVE_LITTLE_ENDIAN
@ -140,6 +177,11 @@ namespace Endian {
} }
template <class T> template <class T>
/// @brief DOCME
/// @param val
/// @return
///
inline T MachineToLittle(T val) inline T MachineToLittle(T val)
{ {
#ifdef HAVE_BIG_ENDIAN #ifdef HAVE_BIG_ENDIAN
@ -152,6 +194,11 @@ namespace Endian {
} }
template <class T> template <class T>
/// @brief DOCME
/// @param val
/// @return
///
inline T MachineToBig(T val) inline T MachineToBig(T val)
{ {
#ifdef HAVE_LITTLE_ENDIAN #ifdef HAVE_LITTLE_ENDIAN
@ -179,22 +226,45 @@ namespace Endian {
// Unions to pack together ints and get their physical bytes // Unions to pack together ints and get their physical bytes
/// DOCME
union bytes16 { union bytes16 {
/// DOCME
uint8_t byte[2]; uint8_t byte[2];
/// DOCME
uint16_t word; uint16_t word;
}; };
/// DOCME
union bytes32 { union bytes32 {
/// DOCME
uint8_t byte[4]; uint8_t byte[4];
/// DOCME
uint32_t word; uint32_t word;
}; };
/// DOCME
union bytes64 { union bytes64 {
/// DOCME
uint8_t byte[8]; uint8_t byte[8];
/// DOCME
uint64_t word; uint64_t word;
}; };
// 16 bit words // 16 bit words
/// @brief DOCME
/// @param val
/// @return
///
inline uint16_t MachineToBig(uint16_t val) inline uint16_t MachineToBig(uint16_t val)
{ {
bytes16 pack; bytes16 pack;
@ -205,6 +275,11 @@ namespace Endian {
return pack.word; return pack.word;
} }
/// @brief DOCME
/// @param val
/// @return
///
inline uint16_t MachineToLittle(uint16_t val) inline uint16_t MachineToLittle(uint16_t val)
{ {
bytes16 pack; bytes16 pack;
@ -215,6 +290,11 @@ namespace Endian {
return pack.word; return pack.word;
} }
/// @brief DOCME
/// @param val
/// @return
///
inline uint16_t BigToMachine(uint16_t val) inline uint16_t BigToMachine(uint16_t val)
{ {
bytes16 pack; bytes16 pack;
@ -224,6 +304,11 @@ namespace Endian {
return uint16_t(pack.byte[1]) | (uint16_t(pack.byte[0]) << 8); return uint16_t(pack.byte[1]) | (uint16_t(pack.byte[0]) << 8);
} }
/// @brief DOCME
/// @param val
/// @return
///
inline uint16_t LittleToMachine(uint16_t val) inline uint16_t LittleToMachine(uint16_t val)
{ {
bytes16 pack; bytes16 pack;
@ -236,6 +321,11 @@ namespace Endian {
// 32 bit words // 32 bit words
/// @brief DOCME
/// @param val
/// @return
///
inline uint32_t MachineToBig(uint32_t val) inline uint32_t MachineToBig(uint32_t val)
{ {
bytes32 pack; bytes32 pack;
@ -246,6 +336,11 @@ namespace Endian {
return pack.word; return pack.word;
} }
/// @brief DOCME
/// @param val
/// @return
///
inline uint32_t MachineToLittle(uint32_t val) inline uint32_t MachineToLittle(uint32_t val)
{ {
bytes32 pack; bytes32 pack;
@ -256,6 +351,11 @@ namespace Endian {
return pack.word; return pack.word;
} }
/// @brief DOCME
/// @param val
/// @return
///
inline uint32_t BigToMachine(uint32_t val) inline uint32_t BigToMachine(uint32_t val)
{ {
bytes32 pack; bytes32 pack;
@ -267,6 +367,11 @@ namespace Endian {
uint32_t(pack.byte[3]); uint32_t(pack.byte[3]);
} }
/// @brief DOCME
/// @param val
/// @return
///
inline uint32_t LittleToMachine(uint32_t val) inline uint32_t LittleToMachine(uint32_t val)
{ {
bytes32 pack; bytes32 pack;
@ -281,6 +386,11 @@ namespace Endian {
// 64 bit words // 64 bit words
/// @brief DOCME
/// @param val
/// @return
///
inline uint64_t MachineToBig(uint64_t val) inline uint64_t MachineToBig(uint64_t val)
{ {
bytes64 pack; bytes64 pack;
@ -295,6 +405,11 @@ namespace Endian {
return pack.word; return pack.word;
} }
/// @brief DOCME
/// @param val
/// @return
///
inline uint64_t MachineToLittle(uint64_t val) inline uint64_t MachineToLittle(uint64_t val)
{ {
bytes64 pack; bytes64 pack;
@ -309,6 +424,11 @@ namespace Endian {
return pack.word; return pack.word;
} }
/// @brief DOCME
/// @param val
/// @return
///
inline uint64_t BigToMachine(uint64_t val) inline uint64_t BigToMachine(uint64_t val)
{ {
bytes64 pack; bytes64 pack;
@ -324,6 +444,10 @@ namespace Endian {
uint64_t(pack.byte[7]); uint64_t(pack.byte[7]);
} }
/// @brief DOCME
/// @param val
///
inline uint64_t LittleToMachine(uint64_t val) inline uint64_t LittleToMachine(uint64_t val)
{ {
bytes64 pack; bytes64 pack;
@ -346,3 +470,4 @@ namespace Endian {
#endif #endif

View file

@ -49,19 +49,25 @@
#include "standard_paths.h" #include "standard_paths.h"
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
///////////////
// Constructor /// @brief Constructor
///
AegisubLocale::AegisubLocale () { AegisubLocale::AegisubLocale () {
locale = NULL; locale = NULL;
curCode = -1; curCode = -1;
} }
/// @brief DOCME
///
AegisubLocale::~AegisubLocale() { AegisubLocale::~AegisubLocale() {
delete locale; delete locale;
} }
//////////////
// Initialize /// @brief Initialize
/// @param language
///
void AegisubLocale::Init(int language) { void AegisubLocale::Init(int language) {
if (language == -1) language = wxLANGUAGE_ENGLISH; if (language == -1) language = wxLANGUAGE_ENGLISH;
if (locale) delete locale; if (locale) delete locale;
@ -86,8 +92,10 @@ void AegisubLocale::Init(int language) {
} }
///////////////////
// Pick a language /// @brief Pick a language
/// @return
///
int AegisubLocale::PickLanguage() { int AegisubLocale::PickLanguage() {
// Get list // Get list
wxArrayInt langs = GetAvailableLanguages(); wxArrayInt langs = GetAvailableLanguages();
@ -120,8 +128,9 @@ int AegisubLocale::PickLanguage() {
} }
///////////////////////////////////
// Get list of available languages /// @brief Get list of available languages
///
wxArrayInt AegisubLocale::GetAvailableLanguages() { wxArrayInt AegisubLocale::GetAvailableLanguages() {
wxArrayInt final; wxArrayInt final;
@ -177,3 +186,4 @@ wxArrayInt AegisubLocale::GetAvailableLanguages() {
return final; return final;
} }

View file

@ -35,6 +35,8 @@
/// ///
#ifndef LOCALE_H #ifndef LOCALE_H
/// DOCME
#define LOCALE_H #define LOCALE_H
@ -43,14 +45,22 @@
class wxLocale; class wxLocale;
////////////////////////
// Aegisub locale class /// DOCME
/// @class AegisubLocale
/// @brief DOCME
///
/// DOCME
class AegisubLocale { class AegisubLocale {
private: private:
/// DOCME
wxLocale *locale; wxLocale *locale;
wxArrayInt GetAvailableLanguages(); wxArrayInt GetAvailableLanguages();
public: public:
/// DOCME
int curCode; int curCode;
AegisubLocale(); AegisubLocale();
@ -62,3 +72,4 @@ public:
#endif #endif

View file

@ -44,8 +44,10 @@
#include "ass_attachment.h" #include "ass_attachment.h"
///////////////
// Constructor /// @brief Constructor
/// @param _name
///
AssAttachment::AssAttachment(wxString _name) { AssAttachment::AssAttachment(wxString _name) {
// Parse name // Parse name
filename = _name; filename = _name;
@ -63,14 +65,17 @@ AssAttachment::AssAttachment(wxString _name) {
} }
//////////////
// Destructor /// @brief Destructor
///
AssAttachment::~AssAttachment() { AssAttachment::~AssAttachment() {
} }
/////////
// Clone /// @brief Clone
/// @return
///
AssEntry *AssAttachment::Clone() { AssEntry *AssAttachment::Clone() {
// New object // New object
AssAttachment *clone = new AssAttachment(filename); AssAttachment *clone = new AssAttachment(filename);
@ -83,29 +88,36 @@ AssEntry *AssAttachment::Clone() {
} }
////////////
// Get data /// @brief Get data
/// @return
///
const DataVec &AssAttachment::GetData() { const DataVec &AssAttachment::GetData() {
return data->GetData(); return data->GetData();
} }
/////////////////
// Add more data /// @brief Add more data
/// @param _data
///
void AssAttachment::AddData(wxString _data) { void AssAttachment::AddData(wxString _data) {
data->AddData(_data); data->AddData(_data);
} }
//////////////////////
// Finish adding data /// @brief Finish adding data
///
void AssAttachment::Finish() { void AssAttachment::Finish() {
data->Finish(); data->Finish();
} }
/////////////////////////////////////
// Get encoded data to write on file /// @brief Get encoded data to write on file
/// @return
///
const wxString AssAttachment::GetEntryData() { const wxString AssAttachment::GetEntryData() {
// Get data // Get data
const DataVec &dat = data->GetData(); const DataVec &dat = data->GetData();
@ -162,8 +174,11 @@ const wxString AssAttachment::GetEntryData() {
} }
/////////////////////
// Extract as a file /// @brief Extract as a file
/// @param filename
/// @return
///
void AssAttachment::Extract(wxString filename) { void AssAttachment::Extract(wxString filename) {
// Open file // Open file
wxFileOutputStream fp(filename); wxFileOutputStream fp(filename);
@ -172,8 +187,10 @@ void AssAttachment::Extract(wxString filename) {
} }
/////////////////////////////
// Read a file as attachment /// @brief Read a file as attachment
/// @param filename
///
void AssAttachment::Import(wxString filename) { void AssAttachment::Import(wxString filename) {
// Data // Data
DataVec &datavec = data->GetData(); DataVec &datavec = data->GetData();
@ -190,8 +207,11 @@ void AssAttachment::Import(wxString filename) {
} }
////////////////
// Get filename /// @brief Get filename
/// @param raw
/// @return
///
wxString AssAttachment::GetFileName(bool raw) { wxString AssAttachment::GetFileName(bool raw) {
// Raw // Raw
if (raw || filename.Right(4).Lower() != _T(".ttf")) return filename; if (raw || filename.Right(4).Lower() != _T(".ttf")) return filename;
@ -212,35 +232,41 @@ wxString AssAttachment::GetFileName(bool raw) {
/////////////////// Attachment //////////////////
/////////////// /// @brief Constructor Attachment //////////////////
// Constructor ///
AttachData::AttachData() { AttachData::AttachData() {
} }
//////////////
// Destructor /// @brief Destructor
///
AttachData::~AttachData() { AttachData::~AttachData() {
} }
////////////
// Get data /// @brief Get data
/// @return
///
DataVec &AttachData::GetData() { DataVec &AttachData::GetData() {
return data; return data;
} }
////////////
// Add data /// @brief Add data
/// @param data
///
void AttachData::AddData(wxString data) { void AttachData::AddData(wxString data) {
buffer += data; buffer += data;
} }
//////////
// Finish /// @brief Finish
///
void AttachData::Finish() { void AttachData::Finish() {
// Source and dest buffers // Source and dest buffers
unsigned char src[4]; unsigned char src[4];
@ -289,3 +315,4 @@ void AttachData::Finish() {
buffer.Shrink(); buffer.Shrink();
} }

View file

@ -45,16 +45,24 @@
#include <vector> #include <vector>
///////////
// Typedef /// DOCME
typedef std::vector<unsigned char> DataVec; typedef std::vector<unsigned char> DataVec;
///////////////////
// Attachment data /// DOCME
/// @class AttachData
/// @brief DOCME
///
/// DOCME
class AttachData { class AttachData {
private: private:
/// DOCME
DataVec data; DataVec data;
/// DOCME
wxString buffer; wxString buffer;
public: public:
@ -67,11 +75,19 @@ public:
}; };
//////////////////////////////
// Class to store attachments /// DOCME
/// @class AssAttachment
/// @brief DOCME
///
/// DOCME
class AssAttachment : public AssEntry { class AssAttachment : public AssEntry {
private: private:
/// DOCME
boost::shared_ptr<AttachData> data; boost::shared_ptr<AttachData> data;
/// DOCME
wxString filename; wxString filename;
public: public:
@ -85,6 +101,9 @@ public:
wxString GetFileName(bool raw=false); wxString GetFileName(bool raw=false);
const wxString GetEntryData(); const wxString GetEntryData();
/// @brief DOCME
///
ASS_EntryType GetType() { return ENTRY_ATTACHMENT; } ASS_EntryType GetType() { return ENTRY_ATTACHMENT; }
AssEntry *Clone(); AssEntry *Clone();
@ -92,3 +111,4 @@ public:
~AssAttachment(); ~AssAttachment();
}; };

View file

@ -48,8 +48,9 @@
#include "utils.h" #include "utils.h"
////////////////////// AssDialogue //////////////////////
// Constructs AssDialogue /// @brief Constructs AssDialogue AssDialogue //////////////////////
///
AssDialogue::AssDialogue() { AssDialogue::AssDialogue() {
group = _T("[Events]"); group = _T("[Events]");
@ -68,6 +69,11 @@ AssDialogue::AssDialogue() {
} }
/// @brief DOCME
/// @param _data
/// @param version
///
AssDialogue::AssDialogue(wxString _data,int version) { AssDialogue::AssDialogue(wxString _data,int version) {
// Set group // Set group
group = _T("[Events]"); group = _T("[Events]");
@ -92,22 +98,25 @@ AssDialogue::AssDialogue(wxString _data,int version) {
} }
//////////////
// Destructor /// @brief Destructor
///
AssDialogue::~AssDialogue () { AssDialogue::~AssDialogue () {
Clear(); Clear();
} }
/////////
// Clear /// @brief Clear
///
void AssDialogue::Clear () { void AssDialogue::Clear () {
ClearBlocks(); ClearBlocks();
} }
////////////////
// Clear blocks /// @brief Clear blocks
///
void AssDialogue::ClearBlocks() { void AssDialogue::ClearBlocks() {
using std::vector; using std::vector;
for (vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) { for (vector<AssDialogueBlock*>::iterator cur=Blocks.begin();cur!=Blocks.end();cur++) {
@ -117,8 +126,12 @@ void AssDialogue::ClearBlocks() {
} }
//////////////////
// Parse ASS Data /// @brief Parse ASS Data
/// @param rawData
/// @param version
/// @return
///
bool AssDialogue::Parse(wxString rawData, int version) { bool AssDialogue::Parse(wxString rawData, int version) {
size_t pos = 0; size_t pos = 0;
wxString temp; wxString temp;
@ -213,8 +226,10 @@ bool AssDialogue::Parse(wxString rawData, int version) {
} }
/////////////
// Make data /// @brief Make data
/// @return
///
wxString AssDialogue::MakeData() { wxString AssDialogue::MakeData() {
// Prepare // Prepare
static wxString final = _T(""); static wxString final = _T("");
@ -254,27 +269,34 @@ wxString AssDialogue::MakeData() {
} }
//////////////////////////////////
// Update AssDialogue's data line /// @brief Update AssDialogue's data line
///
void AssDialogue::UpdateData () { void AssDialogue::UpdateData () {
} }
//////////////////
// Get entry data /// @brief Get entry data
/// @return
///
const wxString AssDialogue::GetEntryData() { const wxString AssDialogue::GetEntryData() {
return MakeData(); return MakeData();
} }
//////////////////
// Set entry data /// @brief Set entry data
/// @param newData
///
void AssDialogue::SetEntryData(wxString newData) { void AssDialogue::SetEntryData(wxString newData) {
} }
///////////////////////////////
// Get SSA version of Dialogue /// @brief Get SSA version of Dialogue
/// @return
///
wxString AssDialogue::GetSSAText () { wxString AssDialogue::GetSSAText () {
// Prepare // Prepare
wxString work = _T(""); wxString work = _T("");
@ -308,10 +330,9 @@ wxString AssDialogue::GetSSAText () {
} }
//////////////////
// Parse SRT tags /// @brief Yea, I convert to ASS tags, then parse that. So sue me. -------------- Parse SRT tags
// -------------- ///
// Yea, I convert to ASS tags, then parse that. So sue me.
void AssDialogue::ParseSRTTags () { void AssDialogue::ParseSRTTags () {
// Search and replace // Search and replace
size_t total = 0; size_t total = 0;
@ -448,8 +469,9 @@ void AssDialogue::ParseSRTTags () {
} }
//////////////////
// Parse ASS tags /// @brief Parse ASS tags
///
void AssDialogue::ParseASSTags () { void AssDialogue::ParseASSTags () {
// Clear blocks // Clear blocks
ClearBlocks(); ClearBlocks();
@ -544,16 +566,19 @@ void AssDialogue::ParseASSTags () {
} }
//////////////
// Strip tags /// @brief Strip tags
///
void AssDialogue::StripTags () { void AssDialogue::StripTags () {
static wxRegEx reg(_T("\\{[^\\{]*\\}"),wxRE_ADVANCED); static wxRegEx reg(_T("\\{[^\\{]*\\}"),wxRE_ADVANCED);
reg.Replace(&Text,_T("")); reg.Replace(&Text,_T(""));
} }
////////////////////////
// Strip a specific tag /// @brief Strip a specific tag
/// @param tagName
///
void AssDialogue::StripTag (wxString tagName) { void AssDialogue::StripTag (wxString tagName) {
// Parse // Parse
using std::list; using std::list;
@ -583,11 +608,9 @@ void AssDialogue::StripTag (wxString tagName) {
} }
///////////////////////
// Convert tags to SRT /// @brief TODO: Improve this code ------------------- Convert tags to SRT
// ------------------- ///
// TODO: Improve this code
//
void AssDialogue::ConvertTagsToSRT () { void AssDialogue::ConvertTagsToSRT () {
// Setup // Setup
using std::list; using std::list;
@ -688,8 +711,9 @@ void AssDialogue::ConvertTagsToSRT () {
} }
//////////////////////////
// Updates text from tags /// @brief Updates text from tags
///
void AssDialogue::UpdateText () { void AssDialogue::UpdateText () {
using std::vector; using std::vector;
Text = _T(""); Text = _T("");
@ -704,8 +728,11 @@ void AssDialogue::UpdateText () {
} }
/////////////////////////////
// Sets margin from a string /// @brief Sets margin from a string
/// @param origvalue
/// @param which
///
void AssDialogue::SetMarginString(const wxString origvalue,int which) { void AssDialogue::SetMarginString(const wxString origvalue,int which) {
// Make it numeric // Make it numeric
wxString strvalue = origvalue; wxString strvalue = origvalue;
@ -732,8 +759,12 @@ void AssDialogue::SetMarginString(const wxString origvalue,int which) {
} }
//////////////////////////
// Gets string for margin /// @brief Gets string for margin
/// @param which
/// @param pad
/// @return
///
wxString AssDialogue::GetMarginString(int which,bool pad) { wxString AssDialogue::GetMarginString(int which,bool pad) {
if (which < 0 || which >= 4) throw new Aegisub::InvalidMarginIdError; if (which < 0 || which >= 4) throw new Aegisub::InvalidMarginIdError;
int value = Margin[which]; int value = Margin[which];
@ -742,8 +773,14 @@ wxString AssDialogue::GetMarginString(int which,bool pad) {
} }
///////////////////////////////////
// Process parameters via callback /// @brief Process parameters via callback
/// @param tagName
/// @param par_n
/// @param param
/// @param userData)
/// @param userData
///
void AssDialogue::ProcessParameters(void (*callback)(wxString tagName,int par_n,AssOverrideParameter *param,void *userData),void *userData) { void AssDialogue::ProcessParameters(void (*callback)(wxString tagName,int par_n,AssOverrideParameter *param,void *userData),void *userData) {
// Apply for all override blocks // Apply for all override blocks
AssDialogueBlockOverride *curBlock; AssDialogueBlockOverride *curBlock;
@ -758,8 +795,11 @@ void AssDialogue::ProcessParameters(void (*callback)(wxString tagName,int par_n,
} }
///////////////////////////////
// Checks if two lines collide /// @brief Checks if two lines collide
/// @param target
/// @return
///
bool AssDialogue::CollidesWith(AssDialogue *target) { bool AssDialogue::CollidesWith(AssDialogue *target) {
if (!target) return false; if (!target) return false;
int a = Start.GetMS(); int a = Start.GetMS();
@ -770,8 +810,10 @@ bool AssDialogue::CollidesWith(AssDialogue *target) {
} }
////////////////////////
// Return just the text without any overrides /// @brief Return just the text without any overrides
/// @return
///
wxString AssDialogue::GetStrippedText() const { wxString AssDialogue::GetStrippedText() const {
wxString justtext = wxString(_T("")); wxString justtext = wxString(_T(""));
bool inCode = false; bool inCode = false;
@ -783,8 +825,10 @@ wxString AssDialogue::GetStrippedText() const {
} }
return justtext; return justtext;
} }
/////////
// Clone /// @brief Clone
/// @return
///
AssEntry *AssDialogue::Clone() const { AssEntry *AssDialogue::Clone() const {
// Create clone // Create clone
AssDialogue *final = new AssDialogue(); AssDialogue *final = new AssDialogue();
@ -808,23 +852,26 @@ AssEntry *AssDialogue::Clone() const {
} }
////////////////////// AssDialogueBlock //////////////////////
/////////////// /// @brief Constructor AssDialogueBlock //////////////////////
// Constructor ///
AssDialogueBlock::AssDialogueBlock () { AssDialogueBlock::AssDialogueBlock () {
} }
//////////////
// Destructor /// @brief Destructor
/// @return
///
AssDialogueBlock::~AssDialogueBlock () { AssDialogueBlock::~AssDialogueBlock () {
} }
////////////////////////////
// Returns as a plain block /// @brief If it isn't a plain block, returns NULL ---------------------- Returns as a plain block
// ---------------------- /// @param base
// If it isn't a plain block, returns NULL /// @return
///
AssDialogueBlockPlain *AssDialogueBlock::GetAsPlain(AssDialogueBlock *base) { AssDialogueBlockPlain *AssDialogueBlock::GetAsPlain(AssDialogueBlock *base) {
if (!base) return NULL; if (!base) return NULL;
if (base->GetType() == BLOCK_PLAIN) { if (base->GetType() == BLOCK_PLAIN) {
@ -834,10 +881,11 @@ AssDialogueBlockPlain *AssDialogueBlock::GetAsPlain(AssDialogueBlock *base) {
} }
////////////////////////////////
// Returns as an override block /// @brief If it isn't an override block, returns NULL ---------------------------- Returns as an override block
// ---------------------------- /// @param base
// If it isn't an override block, returns NULL /// @return
///
AssDialogueBlockOverride *AssDialogueBlock::GetAsOverride(AssDialogueBlock *base) { AssDialogueBlockOverride *AssDialogueBlock::GetAsOverride(AssDialogueBlock *base) {
if (!base) return NULL; if (!base) return NULL;
if (base->GetType() == BLOCK_OVERRIDE) { if (base->GetType() == BLOCK_OVERRIDE) {
@ -847,10 +895,11 @@ AssDialogueBlockOverride *AssDialogueBlock::GetAsOverride(AssDialogueBlock *base
} }
//////////////////////////////
// Returns as a drawing block /// @brief If it isn't an drawing block, returns NULL ---------------------------- Returns as a drawing block
// ---------------------------- /// @param base
// If it isn't an drawing block, returns NULL /// @return
///
AssDialogueBlockDrawing *AssDialogueBlock::GetAsDrawing(AssDialogueBlock *base) { AssDialogueBlockDrawing *AssDialogueBlock::GetAsDrawing(AssDialogueBlock *base) {
if (!base) return NULL; if (!base) return NULL;
if (base->GetType() == BLOCK_DRAWING) { if (base->GetType() == BLOCK_DRAWING) {
@ -860,22 +909,27 @@ AssDialogueBlockDrawing *AssDialogueBlock::GetAsDrawing(AssDialogueBlock *base)
} }
////////////////////// AssDialogueBlockPlain //////////////////////
/////////////// /// @brief Constructor AssDialogueBlockPlain //////////////////////
// Constructor ///
AssDialogueBlockPlain::AssDialogueBlockPlain () { AssDialogueBlockPlain::AssDialogueBlockPlain () {
} }
////////////////////// AssDialogueBlockDrawing //////////////////////
/////////////// /// @brief Constructor AssDialogueBlockDrawing //////////////////////
// Constructor ///
AssDialogueBlockDrawing::AssDialogueBlockDrawing () { AssDialogueBlockDrawing::AssDialogueBlockDrawing () {
} }
////////////////////////
// Multiply coordinates /// @brief Multiply coordinates
/// @param mx
/// @param my
/// @param x
/// @param y
///
void AssDialogueBlockDrawing::TransformCoords(int mx,int my,double x,double y) { void AssDialogueBlockDrawing::TransformCoords(int mx,int my,double x,double y) {
// HACK: Implement a proper parser ffs!! // HACK: Implement a proper parser ffs!!
wxStringTokenizer tkn(GetText(),_T(" "),wxTOKEN_DEFAULT); wxStringTokenizer tkn(GetText(),_T(" "),wxTOKEN_DEFAULT);
@ -917,3 +971,4 @@ void AssDialogueBlockDrawing::TransformCoords(int mx,int my,double x,double y) {

View file

@ -54,45 +54,63 @@ class AssDialogueBlockOverride;
class AssDialogueBlockDrawing; class AssDialogueBlockDrawing;
///////////////////
// Block type enum /// DOCME
enum ASS_BlockType { enum ASS_BlockType {
/// DOCME
BLOCK_BASE, BLOCK_BASE,
/// DOCME
BLOCK_PLAIN, BLOCK_PLAIN,
/// DOCME
BLOCK_OVERRIDE, BLOCK_OVERRIDE,
/// DOCME
BLOCK_DRAWING BLOCK_DRAWING
}; };
////////////////////// /// DOCME
// AssDialogue Blocks /// @class AssDialogueBlock
// ------------------
// A block is each group in the text field of an AssDialogue /// @brief AssDialogue Blocks
// For example: ///
// Yes, I {\i1}am{\i0} here. /// A block is each group in the text field of an AssDialogue
// /// @verbatium
// Gets split in five blocks: /// Yes, I {\i1}am{\i0} here.
// "Yes, I " (Plain) ///
// "\i1" (Override) /// Gets split in five blocks:
// "am" (Plain) /// "Yes, I " (Plain)
// "\i0" (Override) /// "\i1" (Override)
// " here." (Plain) /// "am" (Plain)
// /// "\i0" (Override)
// Also note how {}s are discarded. /// " here." (Plain)
// Override blocks are further divided in AssOverrideTag's. ///
// /// Also note how {}s are discarded.
// The GetText() method generates a new value for the "text" field from /// Override blocks are further divided in AssOverrideTag's.
// the other fields in the specific class, and returns the new value. ///
// /// The GetText() method generates a new value for the "text" field from
/// the other fields in the specific class, and returns the new value.
/// @endverbatium
class AssDialogueBlock { class AssDialogueBlock {
public: public:
/// DOCME
wxString text; wxString text;
/// DOCME
AssDialogue *parent; AssDialogue *parent;
AssDialogueBlock(); AssDialogueBlock();
virtual ~AssDialogueBlock(); virtual ~AssDialogueBlock();
virtual ASS_BlockType GetType() = 0; virtual ASS_BlockType GetType() = 0;
/// @brief DOCME
/// @return
///
virtual wxString GetText() { return text; } virtual wxString GetText() { return text; }
static AssDialogueBlockPlain *GetAsPlain(AssDialogueBlock *base); // Returns a block base as a plain block if it is valid, null otherwise static AssDialogueBlockPlain *GetAsPlain(AssDialogueBlock *base); // Returns a block base as a plain block if it is valid, null otherwise
static AssDialogueBlockOverride *GetAsOverride(AssDialogueBlock *base); // Returns a block base as an override block if it is valid, null otherwise static AssDialogueBlockOverride *GetAsOverride(AssDialogueBlock *base); // Returns a block base as an override block if it is valid, null otherwise
@ -100,47 +118,64 @@ public:
}; };
/////////////////////////////
// Plain dialogue block text /// DOCME
// ------------------------- /// @class AssDialogueBlockPlain
// This is used for standard text
// type = BLOCK_PLAIN /// @brief DOCME
// ///
/// DOCME
class AssDialogueBlockPlain : public AssDialogueBlock { class AssDialogueBlockPlain : public AssDialogueBlock {
public: public:
/// @brief DOCME
/// @return
///
ASS_BlockType GetType() { return BLOCK_PLAIN; } ASS_BlockType GetType() { return BLOCK_PLAIN; }
AssDialogueBlockPlain(); AssDialogueBlockPlain();
}; };
/////////////////////////////
// Plain dialogue block text /// DOCME
// ------------------------- /// @class AssDialogueBlockDrawing
// This is used for drawing commands /// @brief DOCME
// type = BLOCK_DRAWING ///
// /// DOCME
class AssDialogueBlockDrawing : public AssDialogueBlock { class AssDialogueBlockDrawing : public AssDialogueBlock {
public: public:
/// DOCME
int Scale; int Scale;
/// @brief DOCME
/// @return
///
ASS_BlockType GetType() { return BLOCK_DRAWING; } ASS_BlockType GetType() { return BLOCK_DRAWING; }
AssDialogueBlockDrawing(); AssDialogueBlockDrawing();
void TransformCoords(int trans_x,int trans_y,double mult_x,double mult_y); void TransformCoords(int trans_x,int trans_y,double mult_x,double mult_y);
}; };
//////////////////////
// Override tag block /// DOCME
// ------------------ /// @class AssDialogueBlockOverride
// Used to store ASS overrides /// @brief DOCME
// Type = BLOCK_OVERRIDE ///
// /// DOCME
class AssDialogueBlockOverride : public AssDialogueBlock { class AssDialogueBlockOverride : public AssDialogueBlock {
public: public:
AssDialogueBlockOverride(); AssDialogueBlockOverride();
~AssDialogueBlockOverride(); ~AssDialogueBlockOverride();
/// DOCME
std::vector<AssOverrideTag*> Tags; std::vector<AssOverrideTag*> Tags;
/// @brief DOCME
/// @return
///
ASS_BlockType GetType() { return BLOCK_OVERRIDE; } ASS_BlockType GetType() { return BLOCK_OVERRIDE; }
wxString GetText(); wxString GetText();
void ParseTags(); // Parses tags void ParseTags(); // Parses tags
@ -148,25 +183,53 @@ public:
}; };
////////////////////////////////////////
// Class for Dialogue and Comment lines /// DOCME
/// @class AssDialogue
/// @brief DOCME
///
/// DOCME
class AssDialogue : public AssEntry { class AssDialogue : public AssEntry {
private: private:
wxString MakeData(); wxString MakeData();
public: public:
/// DOCME
std::vector<AssDialogueBlock*> Blocks; // Contains information about each block of text std::vector<AssDialogueBlock*> Blocks; // Contains information about each block of text
/// DOCME
bool Comment; // Is this a comment line? bool Comment; // Is this a comment line?
/// DOCME
int Layer; // Layer number int Layer; // Layer number
/// DOCME
int Margin[4]; // Margins: 0 = Left, 1 = Right, 2 = Top (Vertical), 3 = Bottom int Margin[4]; // Margins: 0 = Left, 1 = Right, 2 = Top (Vertical), 3 = Bottom
/// DOCME
AssTime Start; // Starting time AssTime Start; // Starting time
/// DOCME
AssTime End; // Ending time AssTime End; // Ending time
/// DOCME
wxString Style; // Style name wxString Style; // Style name
/// DOCME
wxString Actor; // Actor name wxString Actor; // Actor name
/// DOCME
wxString Effect; // Effect name wxString Effect; // Effect name
/// DOCME
wxString Text; // Raw text data wxString Text; // Raw text data
/// @brief DOCME
/// @return
///
ASS_EntryType GetType() { return ENTRY_DIALOGUE; } ASS_EntryType GetType() { return ENTRY_DIALOGUE; }
bool Parse(wxString data,int version=1); // Parses raw ASS data into everything else bool Parse(wxString data,int version=1); // Parses raw ASS data into everything else
@ -186,10 +249,29 @@ public:
void SetEntryData(wxString newData); void SetEntryData(wxString newData);
void Clear(); // Wipes all data void Clear(); // Wipes all data
/// @brief DOCME
/// @return
///
virtual int GetStartMS() const { return Start.GetMS(); } virtual int GetStartMS() const { return Start.GetMS(); }
/// @brief DOCME
/// @return
///
virtual int GetEndMS() const { return End.GetMS(); } virtual int GetEndMS() const { return End.GetMS(); }
/// @brief DOCME
/// @param newStart
///
virtual void SetStartMS(const int newStart) { AssEntry::SetStartMS(newStart); Start.SetMS(newStart); } virtual void SetStartMS(const int newStart) { AssEntry::SetStartMS(newStart); Start.SetMS(newStart); }
/// @brief DOCME
/// @param newEnd
///
virtual void SetEndMS(const int newEnd) { End.SetMS(newEnd); } virtual void SetEndMS(const int newEnd) { End.SetMS(newEnd); }
/// @brief DOCME
///
void FixStartMS() { AssEntry::SetStartMS(Start.GetMS()); } // Update StartMS in AssEntry from the Start value here void FixStartMS() { AssEntry::SetStartMS(Start.GetMS()); } // Update StartMS in AssEntry from the Start value here
void SetMarginString(const wxString value,int which); // Set string to a margin value (0 = left, 1 = right, 2 = vertical/top, 3 = bottom) void SetMarginString(const wxString value,int which); // Set string to a margin value (0 = left, 1 = right, 2 = vertical/top, 3 = bottom)
@ -204,3 +286,4 @@ public:
~AssDialogue(); ~AssDialogue();
}; };

View file

@ -45,34 +45,46 @@
#include "ass_entry.h" #include "ass_entry.h"
////////////////////// AssEntry //////////////////////
/////////////////////// /// @brief Constructs AssEntry AssEntry //////////////////////
// Constructs AssEntry ///
AssEntry::AssEntry() { AssEntry::AssEntry() {
Valid = true; Valid = true;
} }
/// @brief DOCME
/// @param _data
///
AssEntry::AssEntry(wxString _data) { AssEntry::AssEntry(wxString _data) {
data = _data; data = _data;
Valid = true; Valid = true;
} }
///////////////////////////
// Destructor for AssEntry /// @brief Destructor for AssEntry
///
AssEntry::~AssEntry() { AssEntry::~AssEntry() {
} }
///////////////////////////
// Comparison for STL Sort /// @brief Comparison for STL Sort
/// @param t1
/// @param t2
/// @return
///
bool operator < (const AssEntry &t1, const AssEntry &t2) { bool operator < (const AssEntry &t1, const AssEntry &t2) {
return (t1.GetStartMS() < t2.GetStartMS()); return (t1.GetStartMS() < t2.GetStartMS());
} }
////////////////////////////////////////////////////////////////
// Returns an entry as dialogue if possible, else, returns NULL /// @brief Returns an entry as dialogue if possible, else, returns NULL
/// @param base
/// @return
///
AssDialogue *AssEntry::GetAsDialogue(AssEntry *base) { AssDialogue *AssEntry::GetAsDialogue(AssEntry *base) {
if (!base) return NULL; if (!base) return NULL;
if (base->GetType() == ENTRY_DIALOGUE) { if (base->GetType() == ENTRY_DIALOGUE) {
@ -82,8 +94,11 @@ AssDialogue *AssEntry::GetAsDialogue(AssEntry *base) {
} }
/////////////////////////////////////////////////////////////
// Returns an entry as style if possible, else, returns NULL /// @brief Returns an entry as style if possible, else, returns NULL
/// @param base
/// @return
///
AssStyle *AssEntry::GetAsStyle(AssEntry *base) { AssStyle *AssEntry::GetAsStyle(AssEntry *base) {
if (!base) return NULL; if (!base) return NULL;
if (base->GetType() == ENTRY_STYLE) { if (base->GetType() == ENTRY_STYLE) {
@ -93,8 +108,11 @@ AssStyle *AssEntry::GetAsStyle(AssEntry *base) {
} }
///////////////////////////////////////////////////////////////////
// Returns an entry as attachment if possible, else, returns NULL /// @brief Returns an entry as attachment if possible, else, returns NULL
/// @param base
/// @return
///
AssAttachment *AssEntry::GetAsAttachment(AssEntry *base) { AssAttachment *AssEntry::GetAsAttachment(AssEntry *base) {
if (!base) return NULL; if (!base) return NULL;
if (base->GetType() == ENTRY_ATTACHMENT) { if (base->GetType() == ENTRY_ATTACHMENT) {
@ -104,8 +122,10 @@ AssAttachment *AssEntry::GetAsAttachment(AssEntry *base) {
} }
//////////////////////
// Get SSA conversion /// @brief Get SSA conversion
/// @return
///
wxString AssEntry::GetSSAText() { wxString AssEntry::GetSSAText() {
// Special cases // Special cases
if (data.Lower() == _T("[v4+ styles]")) return wxString(_T("[V4 Styles]")); if (data.Lower() == _T("[v4+ styles]")) return wxString(_T("[V4 Styles]"));
@ -118,8 +138,9 @@ wxString AssEntry::GetSSAText() {
} }
/////////
// Clone /// @brief Clone
///
AssEntry *AssEntry::Clone() const { AssEntry *AssEntry::Clone() const {
// Create clone // Create clone
AssEntry *final = new AssEntry(); AssEntry *final = new AssEntry();
@ -134,3 +155,4 @@ AssEntry *AssEntry::Clone() const {
return final; return final;
} }

View file

@ -52,36 +52,70 @@ class AssStyle;
class AssAttachment; class AssAttachment;
///////////////////
// Entry type enum /// DOCME
enum ASS_EntryType { enum ASS_EntryType {
/// DOCME
ENTRY_BASE, ENTRY_BASE,
/// DOCME
ENTRY_DIALOGUE, ENTRY_DIALOGUE,
/// DOCME
ENTRY_STYLE, ENTRY_STYLE,
/// DOCME
ENTRY_ATTACHMENT ENTRY_ATTACHMENT
}; };
/// DOCME
namespace Aegisub { namespace Aegisub {
// Thrown when someone supplies an invalid margin ID to a function expecting one
// (Usually limited to range 0..3.) /// DOCME
/// @class InvalidMarginIdError
/// @brief DOCME
///
/// DOCME
class InvalidMarginIdError : public InternalError { class InvalidMarginIdError : public InternalError {
public: public:
/// @brief DOCME
/// @return
///
InvalidMarginIdError() : InternalError(_T("Invalid margin id"), 0) { } InvalidMarginIdError() : InternalError(_T("Invalid margin id"), 0) { }
/// @brief DOCME
/// @return
///
const wxChar *GetName() { return _T("internal_error/invalid_margin_id"); } const wxChar *GetName() { return _T("internal_error/invalid_margin_id"); }
}; };
}; };
////////////////////////////////////
// Base class for each line in file /// DOCME
/// @class AssEntry
/// @brief DOCME
///
/// DOCME
class AssEntry { class AssEntry {
private: private:
/// DOCME
wxString data; // Raw data, exactly the same line that appears on the .ass (note that this will be in ass even if source wasn't) wxString data; // Raw data, exactly the same line that appears on the .ass (note that this will be in ass even if source wasn't)
/// DOCME
int StartMS; // This is only stored for sorting issues, in order to keep non-dialogue lines aligned int StartMS; // This is only stored for sorting issues, in order to keep non-dialogue lines aligned
public: public:
/// DOCME
bool Valid; // Flags as valid or not bool Valid; // Flags as valid or not
/// DOCME
wxString group; // Group it belongs to, e.g. "[Events]" wxString group; // Group it belongs to, e.g. "[Events]"
AssEntry(); AssEntry();
@ -90,13 +124,42 @@ public:
virtual AssEntry *Clone() const; virtual AssEntry *Clone() const;
/// @brief DOCME
/// @return
///
virtual int GetStartMS() const { return StartMS; } virtual int GetStartMS() const { return StartMS; }
/// @brief DOCME
/// @return
///
virtual int GetEndMS() const { return StartMS; } virtual int GetEndMS() const { return StartMS; }
/// @brief DOCME
/// @param newStart
///
virtual void SetStartMS(const int newStart) { StartMS = newStart; } virtual void SetStartMS(const int newStart) { StartMS = newStart; }
/// @brief DOCME
/// @param newEnd
/// @return
///
virtual void SetEndMS(const int newEnd) { /* do nothing */ (void)newEnd; } virtual void SetEndMS(const int newEnd) { /* do nothing */ (void)newEnd; }
/// @brief DOCME
/// @return
///
virtual ASS_EntryType GetType() { return ENTRY_BASE; } virtual ASS_EntryType GetType() { return ENTRY_BASE; }
/// @brief DOCME
/// @return
///
virtual const wxString GetEntryData() { return data; } virtual const wxString GetEntryData() { return data; }
/// @brief DOCME
/// @param newData
///
virtual void SetEntryData(wxString newData) { if (newData.IsEmpty()) data.Clear(); else data = newData; } virtual void SetEntryData(wxString newData) { if (newData.IsEmpty()) data.Clear(); else data = newData; }
virtual wxString GetSSAText(); virtual wxString GetSSAText();
@ -108,3 +171,4 @@ public:
// This operator is for sorting // This operator is for sorting
bool operator < (const AssEntry &t1, const AssEntry &t2); bool operator < (const AssEntry &t1, const AssEntry &t2);

View file

@ -43,8 +43,9 @@
#include "ass_file.h" #include "ass_file.h"
///////////////
// Constructor /// @brief Constructor
///
AssExportFilter::AssExportFilter() { AssExportFilter::AssExportFilter() {
hidden = false; hidden = false;
autoExporter = false; autoExporter = false;
@ -54,8 +55,9 @@ AssExportFilter::AssExportFilter() {
} }
//////////////
// Destructor /// @brief Destructor
///
AssExportFilter::~AssExportFilter() { AssExportFilter::~AssExportFilter() {
try { try {
Unregister(); Unregister();
@ -66,8 +68,11 @@ AssExportFilter::~AssExportFilter() {
} }
////////////
// Register /// @brief Register
/// @param name
/// @param priority
///
void AssExportFilter::Register (wxString name,int priority) { void AssExportFilter::Register (wxString name,int priority) {
// Check if it's registered // Check if it's registered
// Changed this to an assert, since this kind of error should really only happen during dev. -jfs // Changed this to an assert, since this kind of error should really only happen during dev. -jfs
@ -114,8 +119,9 @@ try_new_name:
} }
//////////////
// Unregister /// @brief Unregister
///
void AssExportFilter::Unregister () { void AssExportFilter::Unregister () {
// Check if it's registered // Check if it's registered
if (!IsRegistered()) throw wxString::Format(_T("Unregister export filter: name \"%s\" is not registered."), RegisterName.c_str()); if (!IsRegistered()) throw wxString::Format(_T("Unregister export filter: name \"%s\" is not registered."), RegisterName.c_str());
@ -126,8 +132,10 @@ void AssExportFilter::Unregister () {
} }
/////////////////////////////
// Checks if it's registered /// @brief Checks if it's registered
/// @return
///
bool AssExportFilter::IsRegistered() { bool AssExportFilter::IsRegistered() {
// Check name // Check name
if (RegisterName.IsEmpty()) { if (RegisterName.IsEmpty()) {
@ -148,49 +156,61 @@ bool AssExportFilter::IsRegistered() {
} }
/////////////
// Get sizer /// @brief Get sizer
/// @param parent
/// @return
///
wxWindow *AssExportFilter::GetConfigDialogWindow(wxWindow *parent) { wxWindow *AssExportFilter::GetConfigDialogWindow(wxWindow *parent) {
return NULL; return NULL;
} }
////////////////////
// Config dialog OK /// @brief Config dialog OK
/// @param IsDefault
///
void AssExportFilter::LoadSettings(bool IsDefault) { void AssExportFilter::LoadSettings(bool IsDefault) {
} }
//////////////////////
// Description reader /// @brief Description reader
/// @return
///
const wxString& AssExportFilter::GetDescription() const { const wxString& AssExportFilter::GetDescription() const {
return description; return description;
} }
///////////////
// Static list /// DOCME
AssExportFilterChain *AssExportFilterChain::instance=NULL; AssExportFilterChain *AssExportFilterChain::instance=NULL;
////////////
// Get list /// @brief Get list
/// @return
///
FilterList *AssExportFilterChain::GetFilterList() { FilterList *AssExportFilterChain::GetFilterList() {
if (instance == NULL) instance = new AssExportFilterChain(); if (instance == NULL) instance = new AssExportFilterChain();
return &(instance->Filters); return &(instance->Filters);
} }
///////////////////////
// Get unprepared list /// @brief Get unprepared list
/// @return
///
FilterList *AssExportFilterChain::GetUnpreparedFilterList() { FilterList *AssExportFilterChain::GetUnpreparedFilterList() {
if (instance == NULL) instance = new AssExportFilterChain(); if (instance == NULL) instance = new AssExportFilterChain();
return &(instance->Unprepared); return &(instance->Unprepared);
} }
///////////////////
// Prepare filters /// @brief Prepare filters
///
void AssExportFilterChain::PrepareFilters() { void AssExportFilterChain::PrepareFilters() {
for (FilterList::iterator cur=instance->Unprepared.begin();cur!=instance->Unprepared.end();cur++) { for (FilterList::iterator cur=instance->Unprepared.begin();cur!=instance->Unprepared.end();cur++) {
(*cur)->Init(); (*cur)->Init();
@ -198,3 +218,4 @@ void AssExportFilterChain::PrepareFilters() {
instance->Unprepared.clear(); instance->Unprepared.clear();
} }

View file

@ -54,21 +54,31 @@ class DialogExport;
class AssExporter; class AssExporter;
////////////
// Typedefs /// DOCME
typedef std::list<AssExportFilter*> FilterList; typedef std::list<AssExportFilter*> FilterList;
//////////////////////////////////////
// Singleton for storing filter chain /// DOCME
/// @class AssExportFilterChain
/// @brief DOCME
///
/// DOCME
class AssExportFilterChain { class AssExportFilterChain {
friend class AssExportFilter; friend class AssExportFilter;
friend class AssExporter; friend class AssExporter;
private: private:
/// DOCME
FilterList Filters; FilterList Filters;
/// DOCME
FilterList Unprepared; FilterList Unprepared;
/// DOCME
static AssExportFilterChain *instance; static AssExportFilterChain *instance;
static FilterList *GetFilterList(); static FilterList *GetFilterList();
static FilterList *GetUnpreparedFilterList(); static FilterList *GetUnpreparedFilterList();
@ -78,20 +88,36 @@ public:
}; };
////////////////////////////
// Base export filter class /// DOCME
/// @class AssExportFilter
/// @brief DOCME
///
/// DOCME
class AssExportFilter { class AssExportFilter {
friend class AssExporter; friend class AssExporter;
friend class AssExportFilterChain; friend class AssExportFilterChain;
private: private:
/// DOCME
wxString RegisterName; wxString RegisterName;
/// DOCME
int Priority; int Priority;
protected: protected:
/// DOCME
bool autoExporter; bool autoExporter;
/// DOCME
bool hidden; bool hidden;
/// DOCME
bool initialized; bool initialized;
/// DOCME
wxString description; wxString description;
void Register(wxString name,int priority=0); // Register the filter with specific name. Higher priority filters get the file to process first. void Register(wxString name,int priority=0); // Register the filter with specific name. Higher priority filters get the file to process first.
@ -110,3 +136,4 @@ public:
virtual void LoadSettings(bool IsDefault); // Config dialog is done - extract data now. virtual void LoadSettings(bool IsDefault); // Config dialog is done - extract data now.
}; };

View file

@ -45,22 +45,28 @@
#include "frame_main.h" #include "frame_main.h"
///////////////
// Constructor /// @brief Constructor
/// @param subs
///
AssExporter::AssExporter (AssFile *subs) { AssExporter::AssExporter (AssFile *subs) {
OriginalSubs = subs; OriginalSubs = subs;
IsDefault = true; IsDefault = true;
} }
//////////////
// Destructor /// @brief Destructor
///
AssExporter::~AssExporter () { AssExporter::~AssExporter () {
} }
/////////////////////////
// Draw control settings /// @brief Draw control settings
/// @param parent
/// @param AddTo
///
void AssExporter::DrawSettings(wxWindow *parent,wxSizer *AddTo) { void AssExporter::DrawSettings(wxWindow *parent,wxSizer *AddTo) {
IsDefault = false; IsDefault = false;
wxWindow *window; wxWindow *window;
@ -85,8 +91,10 @@ void AssExporter::DrawSettings(wxWindow *parent,wxSizer *AddTo) {
} }
///////////////////////
// Add filter to chain /// @brief Add filter to chain
/// @param name
///
void AssExporter::AddFilter(wxString name) { void AssExporter::AddFilter(wxString name) {
// Get filter // Get filter
AssExportFilter *filter = NULL; AssExportFilter *filter = NULL;
@ -106,8 +114,9 @@ void AssExporter::AddFilter(wxString name) {
} }
///////////////////////////////////////////
// Adds all autoexporting filters to chain /// @brief Adds all autoexporting filters to chain
///
void AssExporter::AddAutoFilters() { void AssExporter::AddAutoFilters() {
FilterList::iterator begin = AssExportFilterChain::GetFilterList()->begin(); FilterList::iterator begin = AssExportFilterChain::GetFilterList()->begin();
FilterList::iterator end = AssExportFilterChain::GetFilterList()->end(); FilterList::iterator end = AssExportFilterChain::GetFilterList()->end();
@ -119,8 +128,10 @@ void AssExporter::AddAutoFilters() {
} }
///////////////////////////
// Get name of all filters /// @brief Get name of all filters
/// @return
///
wxArrayString AssExporter::GetAllFilterNames() { wxArrayString AssExporter::GetAllFilterNames() {
wxArrayString names; wxArrayString names;
FilterList::iterator begin = AssExportFilterChain::GetFilterList()->begin(); FilterList::iterator begin = AssExportFilterChain::GetFilterList()->begin();
@ -132,8 +143,11 @@ wxArrayString AssExporter::GetAllFilterNames() {
} }
////////////////////////
// Transform for export /// @brief Transform for export
/// @param export_dialog
/// @return
///
AssFile *AssExporter::ExportTransform(wxWindow *export_dialog) { AssFile *AssExporter::ExportTransform(wxWindow *export_dialog) {
// Copy // Copy
AssFile *Subs = new AssFile(*OriginalSubs); AssFile *Subs = new AssFile(*OriginalSubs);
@ -149,8 +163,12 @@ AssFile *AssExporter::ExportTransform(wxWindow *export_dialog) {
} }
//////////
// Export /// @brief Export
/// @param filename
/// @param charset
/// @param export_dialog
///
void AssExporter::Export(wxString filename, wxString charset, wxWindow *export_dialog) { void AssExporter::Export(wxString filename, wxString charset, wxWindow *export_dialog) {
// Get transformation // Get transformation
AssFile *Subs = ExportTransform(export_dialog); AssFile *Subs = ExportTransform(export_dialog);
@ -161,8 +179,11 @@ void AssExporter::Export(wxString filename, wxString charset, wxWindow *export_d
} }
///////////////////////////////////
// Get window associated with name /// @brief Get window associated with name
/// @param name
/// @return
///
wxSizer *AssExporter::GetSettingsSizer(wxString name) { wxSizer *AssExporter::GetSettingsSizer(wxString name) {
SizerMap::iterator pos = Sizers.find(name); SizerMap::iterator pos = Sizers.find(name);
if (pos == Sizers.end()) return NULL; if (pos == Sizers.end()) return NULL;
@ -170,8 +191,10 @@ wxSizer *AssExporter::GetSettingsSizer(wxString name) {
} }
/////////////////////////////
// Get description of filter /// @brief Get description of filter
/// @param name
///
wxString AssExporter::GetDescription(wxString name) { wxString AssExporter::GetDescription(wxString name) {
FilterList::iterator begin = AssExportFilterChain::GetFilterList()->begin(); FilterList::iterator begin = AssExportFilterChain::GetFilterList()->begin();
FilterList::iterator end = AssExportFilterChain::GetFilterList()->end(); FilterList::iterator end = AssExportFilterChain::GetFilterList()->end();
@ -183,3 +206,4 @@ wxString AssExporter::GetDescription(wxString name) {
throw wxString::Format(_T("Filter not found: %s"), name.c_str()); throw wxString::Format(_T("Filter not found: %s"), name.c_str());
} }

View file

@ -54,19 +54,33 @@ class AssExportFilter;
class AssFile; class AssFile;
////////////
// Typedefs /// DOCME
typedef std::list<AssExportFilter*> FilterList; typedef std::list<AssExportFilter*> FilterList;
/// DOCME
typedef std::map<wxString,wxSizer*> SizerMap; typedef std::map<wxString,wxSizer*> SizerMap;
//////////////////
// Exporter class /// DOCME
/// @class AssExporter
/// @brief DOCME
///
/// DOCME
class AssExporter { class AssExporter {
private: private:
/// DOCME
SizerMap Sizers; SizerMap Sizers;
/// DOCME
FilterList Filters; FilterList Filters;
/// DOCME
AssFile *OriginalSubs; AssFile *OriginalSubs;
/// DOCME
bool IsDefault; bool IsDefault;
public: public:
@ -80,7 +94,11 @@ public:
void Export(wxString file, wxString charset, wxWindow *export_dialog=NULL); void Export(wxString file, wxString charset, wxWindow *export_dialog=NULL);
AssFile *ExportTransform(wxWindow *export_dialog=NULL); AssFile *ExportTransform(wxWindow *export_dialog=NULL);
wxSizer *GetSettingsSizer(wxString name); wxSizer *GetSettingsSizer(wxString name);
/// @brief DOCME
///
AssFile *GetOriginalSubs() { return OriginalSubs; } AssFile *GetOriginalSubs() { return OriginalSubs; }
wxString GetDescription(wxString name); wxString GetDescription(wxString name);
}; };

View file

@ -58,24 +58,29 @@
#include "subtitle_format.h" #include "subtitle_format.h"
////////////////////// AssFile //////////////////////
/////////////////////// /// @brief AssFile constructor AssFile //////////////////////
// AssFile constructor ///
AssFile::AssFile () { AssFile::AssFile () {
AssOverrideTagProto::LoadProtos(); AssOverrideTagProto::LoadProtos();
Clear(); Clear();
} }
//////////////////////
// AssFile destructor /// @brief AssFile destructor
///
AssFile::~AssFile() { AssFile::~AssFile() {
Clear(); Clear();
} }
/////////////////////
// Load generic subs /// @brief Load generic subs
/// @param _filename
/// @param charset
/// @param addToRecent
///
void AssFile::Load (const wxString _filename,const wxString charset,bool addToRecent) { void AssFile::Load (const wxString _filename,const wxString charset,bool addToRecent) {
bool ok = true; bool ok = true;
@ -148,8 +153,13 @@ void AssFile::Load (const wxString _filename,const wxString charset,bool addToRe
} }
////////////////////////////
// Save a file to Hard Disk /// @brief Save a file to Hard Disk
/// @param _filename
/// @param setfilename
/// @param addToRecent
/// @param encoding
///
void AssFile::Save(wxString _filename,bool setfilename,bool addToRecent,const wxString encoding) { void AssFile::Save(wxString _filename,bool setfilename,bool addToRecent,const wxString encoding) {
// Finds last dot // Finds last dot
int i = 0; int i = 0;
@ -182,8 +192,11 @@ void AssFile::Save(wxString _filename,bool setfilename,bool addToRecent,const wx
} }
////////////////////////////////
// Saves a file to a ram vector /// @brief Saves a file to a ram vector
/// @param dst
/// @param encoding
///
void AssFile::SaveMemory(std::vector<char> &dst,const wxString encoding) { void AssFile::SaveMemory(std::vector<char> &dst,const wxString encoding) {
// Set encoding // Set encoding
wxString enc = encoding; wxString enc = encoding;
@ -227,8 +240,10 @@ void AssFile::SaveMemory(std::vector<char> &dst,const wxString encoding) {
} }
////////////////////////////////////////////
// Exports file with proper transformations /// @brief Exports file with proper transformations
/// @param _filename
///
void AssFile::Export(wxString _filename) { void AssFile::Export(wxString _filename) {
AssExporter exporter(this); AssExporter exporter(this);
exporter.AddAutoFilters(); exporter.AddAutoFilters();
@ -236,8 +251,10 @@ void AssFile::Export(wxString _filename) {
} }
//////////////////
// Can save file? /// @brief Can save file?
/// @return
///
bool AssFile::CanSave() { bool AssFile::CanSave() {
// ASS format? // ASS format?
wxString ext = filename.Lower().Right(4); wxString ext = filename.Lower().Right(4);
@ -307,12 +324,15 @@ bool AssFile::CanSave() {
//} //}
///////////////////////
// Appends line to Ass /// @brief even moving things out of order might break ASS parsing - AMZ. I strongly advice you against touching this function unless you know what you're doing; ------------------- Appends line to Ass
// ------------------- /// @param data
// I strongly advice you against touching this function unless you know what you're doing; /// @param group
// even moving things out of order might break ASS parsing - AMZ. /// @param lasttime
// /// @param version
/// @param outGroup
/// @return
///
int AssFile::AddLine (wxString data,wxString group,int lasttime,int &version,wxString *outGroup) { int AssFile::AddLine (wxString data,wxString group,int lasttime,int &version,wxString *outGroup) {
// Group // Group
AssEntry *entry = NULL; AssEntry *entry = NULL;
@ -456,8 +476,9 @@ int AssFile::AddLine (wxString data,wxString group,int lasttime,int &version,wxS
} }
//////////////////////////////
// Clears contents of assfile /// @brief Clears contents of assfile
///
void AssFile::Clear () { void AssFile::Clear () {
for (std::list<AssEntry*>::iterator cur=Line.begin();cur != Line.end();cur++) { for (std::list<AssEntry*>::iterator cur=Line.begin();cur != Line.end();cur++) {
if (*cur) delete *cur; if (*cur) delete *cur;
@ -470,8 +491,10 @@ void AssFile::Clear () {
} }
//////////////////////
// Loads default subs /// @brief Loads default subs
/// @param defline
///
void AssFile::LoadDefault (bool defline) { void AssFile::LoadDefault (bool defline) {
// Clear first // Clear first
Clear(); Clear();
@ -503,8 +526,10 @@ void AssFile::LoadDefault (bool defline) {
} }
////////////////////
// Copy constructor /// @brief Copy constructor
/// @param from
///
AssFile::AssFile (AssFile &from) { AssFile::AssFile (AssFile &from) {
using std::list; using std::list;
@ -520,8 +545,10 @@ AssFile::AssFile (AssFile &from) {
} }
//////////////////////
// Insert a new style /// @brief Insert a new style
/// @param style
///
void AssFile::InsertStyle (AssStyle *style) { void AssFile::InsertStyle (AssStyle *style) {
// Variables // Variables
using std::list; using std::list;
@ -577,8 +604,10 @@ void AssFile::InsertStyle (AssStyle *style) {
} }
////////////////////
// Insert attachment /// @brief Insert attachment
/// @param attach
///
void AssFile::InsertAttachment (AssAttachment *attach) { void AssFile::InsertAttachment (AssAttachment *attach) {
// Search for insertion point // Search for insertion point
std::list<AssEntry*>::iterator insPoint=Line.end(),cur; std::list<AssEntry*>::iterator insPoint=Line.end(),cur;
@ -616,8 +645,10 @@ void AssFile::InsertAttachment (AssAttachment *attach) {
} }
///////////////////////////////
// Insert attachment from file /// @brief Insert attachment from file
/// @param filename
///
void AssFile::InsertAttachment (wxString filename) { void AssFile::InsertAttachment (wxString filename) {
// Get name // Get name
wxFileName fname(filename); wxFileName fname(filename);
@ -642,8 +673,11 @@ void AssFile::InsertAttachment (wxString filename) {
} }
////////////////////
// Gets script info /// @brief Gets script info
/// @param _key
/// @return
///
wxString AssFile::GetScriptInfo(const wxString _key) { wxString AssFile::GetScriptInfo(const wxString _key) {
// Prepare // Prepare
wxString key = _key;; wxString key = _key;;
@ -675,8 +709,11 @@ wxString AssFile::GetScriptInfo(const wxString _key) {
} }
//////////////////////////
// Get script info as int /// @brief Get script info as int
/// @param key
/// @return
///
int AssFile::GetScriptInfoAsInt(const wxString key) { int AssFile::GetScriptInfoAsInt(const wxString key) {
long temp = 0; long temp = 0;
try { try {
@ -689,8 +726,12 @@ int AssFile::GetScriptInfoAsInt(const wxString key) {
} }
//////////////////////////
// Set a script info line /// @brief Set a script info line
/// @param _key
/// @param value
/// @return
///
void AssFile::SetScriptInfo(const wxString _key,const wxString value) { void AssFile::SetScriptInfo(const wxString _key,const wxString value) {
// Prepare // Prepare
wxString key = _key;; wxString key = _key;;
@ -745,8 +786,11 @@ void AssFile::SetScriptInfo(const wxString _key,const wxString value) {
} }
//////////////////
// Get resolution /// @brief Get resolution
/// @param sw
/// @param sh
///
void AssFile::GetResolution(int &sw,int &sh) { void AssFile::GetResolution(int &sw,int &sh) {
// Height // Height
wxString temp = GetScriptInfo(_T("PlayResY")); wxString temp = GetScriptInfo(_T("PlayResY"));
@ -788,8 +832,10 @@ void AssFile::GetResolution(int &sw,int &sh) {
} }
///////////////////////////////////
// Adds a comment to [Script Info] /// @brief Adds a comment to [Script Info]
/// @param _comment
///
void AssFile::AddComment(const wxString _comment) { void AssFile::AddComment(const wxString _comment) {
wxString comment = _T("; "); wxString comment = _T("; ");
comment += _comment; comment += _comment;
@ -814,8 +860,10 @@ void AssFile::AddComment(const wxString _comment) {
} }
//////////////////////
// Get list of styles /// @brief Get list of styles
/// @return
///
wxArrayString AssFile::GetStyles() { wxArrayString AssFile::GetStyles() {
wxArrayString styles; wxArrayString styles;
AssStyle *curstyle; AssStyle *curstyle;
@ -829,8 +877,11 @@ wxArrayString AssFile::GetStyles() {
} }
///////////////////////////////
// Gets style of specific name /// @brief Gets style of specific name
/// @param name
/// @return
///
AssStyle *AssFile::GetStyle(wxString name) { AssStyle *AssFile::GetStyle(wxString name) {
AssStyle *curstyle; AssStyle *curstyle;
for (entryIter cur=Line.begin();cur!=Line.end();cur++) { for (entryIter cur=Line.begin();cur!=Line.end();cur++) {
@ -843,15 +894,20 @@ AssStyle *AssFile::GetStyle(wxString name) {
} }
////////////////////////////////////
// Adds file name to list of recent /// @brief Adds file name to list of recent
/// @param file
///
void AssFile::AddToRecent(wxString file) { void AssFile::AddToRecent(wxString file) {
Options.AddToRecentList(file,_T("Recent sub")); Options.AddToRecentList(file,_T("Recent sub"));
} }
///////////////////////////////
// List of supported wildcards /// @brief List of supported wildcards
/// @param mode
/// @return
///
wxString AssFile::GetWildcardList(int mode) { wxString AssFile::GetWildcardList(int mode) {
//if (mode == 0) return _T("All Supported Types (*.ass,*.ssa,*.srt,*.txt,*.mkv,*.mks,*.mka)|*.ass;*.ssa;*.srt;*.txt;*.mkv;*.mks;*.mka|Advanced Substation Alpha (*.ass)|*.ass|Substation Alpha (*.ssa)|*.ssa|SubRip (*.srt)|*.srt|Plain-text (*.txt)|*.txt|Matroska (*.mkv,*.mks,*.mka)|*.mkv;*.mks;*.mka"); //if (mode == 0) return _T("All Supported Types (*.ass,*.ssa,*.srt,*.txt,*.mkv,*.mks,*.mka)|*.ass;*.ssa;*.srt;*.txt;*.mkv;*.mks;*.mka|Advanced Substation Alpha (*.ass)|*.ass|Substation Alpha (*.ssa)|*.ssa|SubRip (*.srt)|*.srt|Plain-text (*.txt)|*.txt|Matroska (*.mkv,*.mks,*.mka)|*.mkv;*.mks;*.mka");
//else if (mode == 1) return _T("Advanced Substation Alpha (*.ass)|*.ass"); //else if (mode == 1) return _T("Advanced Substation Alpha (*.ass)|*.ass");
@ -865,8 +921,10 @@ wxString AssFile::GetWildcardList(int mode) {
} }
////////////////////////////////////////////
// Compress/decompress for storage on stack /// @brief Compress/decompress for storage on stack
/// @param compress
///
void AssFile::CompressForStack(bool compress) { void AssFile::CompressForStack(bool compress) {
AssDialogue *diag; AssDialogue *diag;
for (entryIter cur=Line.begin();cur!=Line.end();cur++) { for (entryIter cur=Line.begin();cur!=Line.end();cur++) {
@ -882,15 +940,19 @@ void AssFile::CompressForStack(bool compress) {
} }
//////////////////////////////
// Checks if file is modified /// @brief Checks if file is modified
/// @return
///
bool AssFile::IsModified() { bool AssFile::IsModified() {
return Modified; return Modified;
} }
/////////////////////////
// Flag file as modified /// @brief Flag file as modified
/// @param desc
///
void AssFile::FlagAsModified(wxString desc) { void AssFile::FlagAsModified(wxString desc) {
// Clear redo // Clear redo
if (!RedoStack.empty()) { if (!RedoStack.empty()) {
@ -907,8 +969,10 @@ void AssFile::FlagAsModified(wxString desc) {
} }
//////////////
// Stack push /// @brief Stack push
/// @param desc
///
void AssFile::StackPush(wxString desc) { void AssFile::StackPush(wxString desc) {
// Places copy on stack // Places copy on stack
AssFile *curcopy = new AssFile(*top); AssFile *curcopy = new AssFile(*top);
@ -931,8 +995,9 @@ void AssFile::StackPush(wxString desc) {
} }
/////////////
// Stack pop /// @brief Stack pop
///
void AssFile::StackPop() { void AssFile::StackPop() {
bool addcopy = false; bool addcopy = false;
wxString undodesc=_T(""); wxString undodesc=_T("");
@ -964,8 +1029,9 @@ void AssFile::StackPop() {
} }
//////////////
// Stack redo /// @brief Stack redo
///
void AssFile::StackRedo() { void AssFile::StackRedo() {
bool addcopy = false; bool addcopy = false;
@ -992,8 +1058,9 @@ void AssFile::StackRedo() {
} }
///////////////
// Stack clear /// @brief Stack clear
///
void AssFile::StackClear() { void AssFile::StackClear() {
// Clear undo // Clear undo
for (std::list<AssFile*>::iterator cur=UndoStack.begin();cur!=UndoStack.end();cur++) { for (std::list<AssFile*>::iterator cur=UndoStack.begin();cur!=UndoStack.end();cur++) {
@ -1011,8 +1078,10 @@ void AssFile::StackClear() {
} }
///////////////
// Stack reset /// @brief Stack reset
/// @return
///
void AssFile::StackReset() { void AssFile::StackReset() {
StackClear(); StackClear();
delete top; delete top;
@ -1021,38 +1090,59 @@ void AssFile::StackReset() {
} }
//////////////////////////////////
// Returns if undo stack is empty /// @brief Returns if undo stack is empty
/// @return
///
bool AssFile::IsUndoStackEmpty() { bool AssFile::IsUndoStackEmpty() {
if (StackModified) return (UndoStack.size() <= 1); if (StackModified) return (UndoStack.size() <= 1);
else return UndoStack.empty(); else return UndoStack.empty();
} }
//////////////////////////////////
// Returns if redo stack is empty /// @brief Returns if redo stack is empty
/// @return
///
bool AssFile::IsRedoStackEmpty() { bool AssFile::IsRedoStackEmpty() {
return RedoStack.empty(); return RedoStack.empty();
} }
/// @brief DOCME
/// @return
///
wxString AssFile::GetUndoDescription() { wxString AssFile::GetUndoDescription() {
return (IsUndoStackEmpty())?_T(""):(UndoStack.back())->undodescription; return (IsUndoStackEmpty())?_T(""):(UndoStack.back())->undodescription;
} }
/// @brief DOCME
/// @return
///
wxString AssFile::GetRedoDescription() { wxString AssFile::GetRedoDescription() {
return (IsRedoStackEmpty())?_T(""):(RedoStack.back())->undodescription; return (IsRedoStackEmpty())?_T(""):(RedoStack.back())->undodescription;
} }
//////////
// Global /// DOCME
AssFile *AssFile::top; AssFile *AssFile::top;
/// DOCME
std::list<AssFile*> AssFile::UndoStack; std::list<AssFile*> AssFile::UndoStack;
/// DOCME
std::list<AssFile*> AssFile::RedoStack; std::list<AssFile*> AssFile::RedoStack;
/// DOCME
bool AssFile::Popping; bool AssFile::Popping;
/// DOCME
bool AssFile::StackModified; bool AssFile::StackModified;

View file

@ -58,23 +58,42 @@ class AssDialogueBlockPlain;
class AssEntry; class AssEntry;
//////////////////////////////////////
// Class to store the actual ass file /// DOCME
/// @class AssFile
/// @brief DOCME
///
/// DOCME
class AssFile { class AssFile {
private: private:
/// DOCME
bool Modified; bool Modified;
// Stack operations
/// DOCME
static std::list<AssFile*> UndoStack; static std::list<AssFile*> UndoStack;
/// DOCME
static std::list<AssFile*> RedoStack; static std::list<AssFile*> RedoStack;
/// DOCME
static bool StackModified; static bool StackModified;
static void StackClear(); static void StackClear();
public: public:
/// DOCME
std::list<AssEntry*> Line; std::list<AssEntry*> Line;
/// DOCME
wxString filename; wxString filename;
/// DOCME
wxString undodescription; wxString undodescription;
/// DOCME
bool loaded; bool loaded;
AssFile(); AssFile();
@ -116,23 +135,39 @@ public:
static bool IsRedoStackEmpty(); // Checks if undo stack is empty static bool IsRedoStackEmpty(); // Checks if undo stack is empty
static wxString GetUndoDescription(); // Gets field undodescription from back of UndoStack static wxString GetUndoDescription(); // Gets field undodescription from back of UndoStack
static wxString GetRedoDescription(); // Gets field undodescription from back of RedoStack static wxString GetRedoDescription(); // Gets field undodescription from back of RedoStack
/// DOCME
static bool Popping; // Flags the stack as popping. You must unset this after popping static bool Popping; // Flags the stack as popping. You must unset this after popping
/// DOCME
static AssFile *top; // Current script file. It is "above" the stack. static AssFile *top; // Current script file. It is "above" the stack.
}; };
////////////
// Typedefs /// DOCME
typedef std::list<AssEntry*>::iterator entryIter; typedef std::list<AssEntry*>::iterator entryIter;
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
// Hack to get STL sort to work on a list of pointers // Hack to get STL sort to work on a list of pointers
template <typename T> template <typename T>
/// DOCME
/// @class LessByPointedToValue
/// @brief DOCME
///
/// DOCME
class LessByPointedToValue : std::binary_function<T const *, T const *, bool> { class LessByPointedToValue : std::binary_function<T const *, T const *, bool> {
public: public:
/// @brief DOCME
/// @param x
/// @param y
///
bool operator()(T const * x, T const * y) const { bool operator()(T const * x, T const * y) const {
return std::less<T>()(*x, *y); return std::less<T>()(*x, *y);
} }
}; };

View file

@ -40,6 +40,9 @@
#include "ass_karaoke.h" #include "ass_karaoke.h"
#include "ass_override.h" #include "ass_override.h"
/// @brief DOCME
///
AssKaraokeSyllable::AssKaraokeSyllable() AssKaraokeSyllable::AssKaraokeSyllable()
{ {
duration = 0; duration = 0;
@ -49,6 +52,11 @@ AssKaraokeSyllable::AssKaraokeSyllable()
tag = 0; tag = 0;
} }
/// @brief DOCME
/// @param line
/// @param syls
///
void ParseAssKaraokeTags(const AssDialogue *line, AssKaraokeVector &syls) void ParseAssKaraokeTags(const AssDialogue *line, AssKaraokeVector &syls)
{ {
// Assume line already has tags parsed // Assume line already has tags parsed
@ -120,3 +128,4 @@ void ParseAssKaraokeTags(const AssDialogue *line, AssKaraokeVector &syls)
} }

View file

@ -39,17 +39,32 @@
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include <vector> #include <vector>
/// DOCME
struct AssKaraokeSyllable { struct AssKaraokeSyllable {
/// DOCME
int duration; // centiseconds int duration; // centiseconds
/// DOCME
wxString text; // stripped text of syllable wxString text; // stripped text of syllable
/// DOCME
wxString unstripped_text; // including misc. tags wxString unstripped_text; // including misc. tags
/// DOCME
wxString type; // highlight type, \k \K \kf \ko (backslash included) wxString type; // highlight type, \k \K \kf \ko (backslash included)
/// DOCME
AssOverrideTag *tag; // parsed override tag for direct modification AssOverrideTag *tag; // parsed override tag for direct modification
AssKaraokeSyllable(); AssKaraokeSyllable();
}; };
/// DOCME
typedef std::vector<AssKaraokeSyllable> AssKaraokeVector; typedef std::vector<AssKaraokeSyllable> AssKaraokeVector;
void ParseAssKaraokeTags(const AssDialogue *line, AssKaraokeVector &syls); void ParseAssKaraokeTags(const AssDialogue *line, AssKaraokeVector &syls);

View file

@ -45,24 +45,27 @@
#include <wx/log.h> #include <wx/log.h>
////////////////////// AssOverrideParameter //////////////////////
/////////////// /// @brief Constructor AssOverrideParameter //////////////////////
// Constructor ///
AssOverrideParameter::AssOverrideParameter () { AssOverrideParameter::AssOverrideParameter () {
classification = PARCLASS_NORMAL; classification = PARCLASS_NORMAL;
ommited = false; ommited = false;
} }
//////////////
// Destructor /// @brief Destructor
///
AssOverrideParameter::~AssOverrideParameter () { AssOverrideParameter::~AssOverrideParameter () {
DeleteValue(); DeleteValue();
} }
////////
// Copy /// @brief Copy
/// @param param
///
void AssOverrideParameter::CopyFrom (const AssOverrideParameter &param) { void AssOverrideParameter::CopyFrom (const AssOverrideParameter &param) {
switch(param.GetType()) { switch(param.GetType()) {
case VARDATA_INT: SetInt(param.AsInt()); break; case VARDATA_INT: SetInt(param.AsInt()); break;
@ -77,20 +80,25 @@ void AssOverrideParameter::CopyFrom (const AssOverrideParameter &param) {
ommited = param.ommited; ommited = param.ommited;
} }
/// @brief DOCME
/// @param param
///
void AssOverrideParameter::operator= (const AssOverrideParameter &param) { void AssOverrideParameter::operator= (const AssOverrideParameter &param) {
CopyFrom(param); CopyFrom(param);
} }
////////////////////// AssDialogueBlockOverride //////////////////////
/////////////// /// @brief Constructor AssDialogueBlockOverride //////////////////////
// Constructor ///
AssDialogueBlockOverride::AssDialogueBlockOverride () { AssDialogueBlockOverride::AssDialogueBlockOverride () {
} }
//////////////
// Destructor /// @brief Destructor
///
AssDialogueBlockOverride::~AssDialogueBlockOverride () { AssDialogueBlockOverride::~AssDialogueBlockOverride () {
for (size_t i=0;i<Tags.size();i++) { for (size_t i=0;i<Tags.size();i++) {
delete Tags[i]; delete Tags[i];
@ -99,8 +107,9 @@ AssDialogueBlockOverride::~AssDialogueBlockOverride () {
} }
/////////////
// Read tags /// @brief Read tags
///
void AssDialogueBlockOverride::ParseTags () { void AssDialogueBlockOverride::ParseTags () {
// Clear current vector // Clear current vector
for (size_t i=0;i<Tags.size();i++) { for (size_t i=0;i<Tags.size();i++) {
@ -141,8 +150,10 @@ void AssDialogueBlockOverride::ParseTags () {
} }
///////////////////////////
// Get Text representation /// @brief Get Text representation
/// @return
///
wxString AssDialogueBlockOverride::GetText () { wxString AssDialogueBlockOverride::GetText () {
text = _T(""); text = _T("");
for (std::vector<AssOverrideTag*>::iterator cur=Tags.begin();cur!=Tags.end();cur++) { for (std::vector<AssOverrideTag*>::iterator cur=Tags.begin();cur!=Tags.end();cur++) {
@ -152,8 +163,13 @@ wxString AssDialogueBlockOverride::GetText () {
} }
///////////////////////////////////
// Process parameters via callback /// @brief Process parameters via callback
/// @param (callback)(wxString
/// @param int
/// @param )
/// @param userData
///
void AssDialogueBlockOverride::ProcessParameters(void (*callback)(wxString,int,AssOverrideParameter *,void *),void *userData) { void AssDialogueBlockOverride::ProcessParameters(void (*callback)(wxString,int,AssOverrideParameter *,void *),void *userData) {
AssOverrideTag *curTag; AssOverrideTag *curTag;
AssOverrideParameter *curPar; AssOverrideParameter *curPar;
@ -184,9 +200,12 @@ void AssDialogueBlockOverride::ProcessParameters(void (*callback)(wxString,int,A
} }
///////////////////////// AssOverrideParamProto //////////////////////////
/////////////// /// @brief Constructor AssOverrideParamProto //////////////////////////
// Constructor /// @param _type
/// @param opt
/// @param classi
///
AssOverrideParamProto::AssOverrideParamProto (VariableDataType _type,int opt,ASS_ParameterClass classi) { AssOverrideParamProto::AssOverrideParamProto (VariableDataType _type,int opt,ASS_ParameterClass classi) {
type = _type; type = _type;
optional = opt; optional = opt;
@ -194,33 +213,39 @@ AssOverrideParamProto::AssOverrideParamProto (VariableDataType _type,int opt,ASS
} }
//////////////
// Destructor /// @brief Destructor
///
AssOverrideParamProto::~AssOverrideParamProto() { AssOverrideParamProto::~AssOverrideParamProto() {
} }
///////////////////////// AssOverrideTagProto //////////////////////////
/////////////// /// DOCME
// Static vars
std::list<AssOverrideTagProto> AssOverrideTagProto::proto; std::list<AssOverrideTagProto> AssOverrideTagProto::proto;
/// DOCME
bool AssOverrideTagProto::loaded = false; bool AssOverrideTagProto::loaded = false;
///////////////
// Constructor /// @brief Constructor
///
AssOverrideTagProto::AssOverrideTagProto() { AssOverrideTagProto::AssOverrideTagProto() {
} }
//////////////
// Destructor /// @brief Destructor
///
AssOverrideTagProto::~AssOverrideTagProto() { AssOverrideTagProto::~AssOverrideTagProto() {
} }
///////////////////
// Load prototypes /// @brief Load prototypes
/// @return
///
void AssOverrideTagProto::LoadProtos () { void AssOverrideTagProto::LoadProtos () {
if (loaded) return; if (loaded) return;
loaded = true; loaded = true;
@ -526,23 +551,25 @@ void AssOverrideTagProto::LoadProtos () {
} }
//////////////////////// AssOverrideTag //////////////////////////
/////////////// /// @brief Constructor AssOverrideTag //////////////////////////
// Constructor ///
AssOverrideTag::AssOverrideTag () { AssOverrideTag::AssOverrideTag () {
valid = false; valid = false;
} }
//////////////
// Destructor /// @brief Destructor
///
AssOverrideTag::~AssOverrideTag () { AssOverrideTag::~AssOverrideTag () {
Clear(); Clear();
} }
/////////
// Clear /// @brief Clear
///
void AssOverrideTag::Clear() { void AssOverrideTag::Clear() {
for (std::vector<AssOverrideParameter*>::iterator cur=Params.begin();cur!=Params.end();cur++) { for (std::vector<AssOverrideParameter*>::iterator cur=Params.begin();cur!=Params.end();cur++) {
delete *cur; delete *cur;
@ -552,8 +579,10 @@ void AssOverrideTag::Clear() {
} }
////////////////////////////
// Parses text and sets tag /// @brief Parses text and sets tag
/// @param text
///
void AssOverrideTag::SetText (const wxString &text) { void AssOverrideTag::SetText (const wxString &text) {
// Determine name // Determine name
Name = _T(""); Name = _T("");
@ -580,15 +609,19 @@ void AssOverrideTag::SetText (const wxString &text) {
} }
/////////////////////////
// Checks if it is valid /// @brief Checks if it is valid
/// @return
///
bool AssOverrideTag::IsValid() { bool AssOverrideTag::IsValid() {
return valid; return valid;
} }
/////////////////////
// Parses parameters /// @brief Parses parameters
/// @param text
///
void AssOverrideTag::ParseParameters(const wxString &text) { void AssOverrideTag::ParseParameters(const wxString &text) {
// Clear first // Clear first
Clear(); Clear();
@ -780,8 +813,9 @@ end_tokenizing:
} }
//////////////
// Get string /// @brief Get string
///
wxString AssOverrideTag::ToString() { wxString AssOverrideTag::ToString() {
// Start with name // Start with name
wxString result = Name; wxString result = Name;
@ -814,3 +848,4 @@ wxString AssOverrideTag::ToString() {
return result; return result;
} }

View file

@ -50,27 +50,54 @@
class AssDialogueBlockOverride; class AssDialogueBlockOverride;
// Enum of parameter classification
// This is used for things like checking which tags VFR needs to update /// DOCME
enum ASS_ParameterClass { enum ASS_ParameterClass {
/// DOCME
PARCLASS_NORMAL, PARCLASS_NORMAL,
/// DOCME
PARCLASS_ABSOLUTE_SIZE, PARCLASS_ABSOLUTE_SIZE,
/// DOCME
PARCLASS_ABSOLUTE_POS_X, PARCLASS_ABSOLUTE_POS_X,
/// DOCME
PARCLASS_ABSOLUTE_POS_Y, PARCLASS_ABSOLUTE_POS_Y,
/// DOCME
PARCLASS_RELATIVE_SIZE_X, PARCLASS_RELATIVE_SIZE_X,
/// DOCME
PARCLASS_RELATIVE_SIZE_Y, PARCLASS_RELATIVE_SIZE_Y,
/// DOCME
PARCLASS_RELATIVE_TIME_START, PARCLASS_RELATIVE_TIME_START,
/// DOCME
PARCLASS_RELATIVE_TIME_END, PARCLASS_RELATIVE_TIME_END,
//PARCLASS_RELATIVE_TIME_START_CENTI,
//PARCLASS_RELATIVE_TIME_END_CENTI, /// DOCME
PARCLASS_KARAOKE, PARCLASS_KARAOKE,
/// DOCME
PARCLASS_DRAWING PARCLASS_DRAWING
}; };
// Actual class
/// DOCME
/// @class AssOverrideParameter
/// @brief DOCME
///
/// DOCME
class AssOverrideParameter : public VariableData { class AssOverrideParameter : public VariableData {
public: public:
/// DOCME
ASS_ParameterClass classification; ASS_ParameterClass classification;
/// DOCME
bool ommited; bool ommited;
AssOverrideParameter(); AssOverrideParameter();
@ -81,18 +108,24 @@ public:
}; };
///////////////////////////
// Class for override tags /// DOCME
// ----------------------- /// @class AssOverrideTag
// /// @brief DOCME
// GetText() returns the text representation of the tag ///
// /// DOCME
class AssOverrideTag { class AssOverrideTag {
private: private:
/// DOCME
bool valid; bool valid;
public: public:
/// DOCME
wxString Name; wxString Name;
/// DOCME
std::vector <AssOverrideParameter*> Params; std::vector <AssOverrideParameter*> Params;
AssOverrideTag(); AssOverrideTag();
@ -106,36 +139,82 @@ public:
}; };
///////////////////////////
// Override tags prototype /// DOCME
enum ASS_ParameterOptional { enum ASS_ParameterOptional {
/// DOCME
NOT_OPTIONAL = 0xFF, NOT_OPTIONAL = 0xFF,
/// DOCME
OPTIONAL_0 = 0x00, OPTIONAL_0 = 0x00,
/// DOCME
OPTIONAL_1 = 0x01, OPTIONAL_1 = 0x01,
/// DOCME
OPTIONAL_2 = 0x02, OPTIONAL_2 = 0x02,
/// DOCME
OPTIONAL_3 = 0x04, OPTIONAL_3 = 0x04,
/// DOCME
OPTIONAL_4 = 0x08, OPTIONAL_4 = 0x08,
/// DOCME
OPTIONAL_5 = 0x10, OPTIONAL_5 = 0x10,
/// DOCME
OPTIONAL_6 = 0x20, OPTIONAL_6 = 0x20,
/// DOCME
OPTIONAL_7 = 0x40 OPTIONAL_7 = 0x40
}; };
/// DOCME
/// @class AssOverrideParamProto
/// @brief DOCME
///
/// DOCME
class AssOverrideParamProto { class AssOverrideParamProto {
public: public:
/// DOCME
int optional; int optional;
/// DOCME
VariableDataType type; VariableDataType type;
/// DOCME
AssOverrideParameter defaultValue; AssOverrideParameter defaultValue;
/// DOCME
ASS_ParameterClass classification; ASS_ParameterClass classification;
AssOverrideParamProto (VariableDataType _type,int opt=NOT_OPTIONAL,ASS_ParameterClass classi=PARCLASS_NORMAL); AssOverrideParamProto (VariableDataType _type,int opt=NOT_OPTIONAL,ASS_ParameterClass classi=PARCLASS_NORMAL);
~AssOverrideParamProto(); ~AssOverrideParamProto();
}; };
/// DOCME
/// @class AssOverrideTagProto
/// @brief DOCME
///
/// DOCME
class AssOverrideTagProto { class AssOverrideTagProto {
public: public:
/// DOCME
wxString name; wxString name;
/// DOCME
std::vector<AssOverrideParamProto> params; std::vector<AssOverrideParamProto> params;
/// DOCME
static std::list<AssOverrideTagProto> proto; static std::list<AssOverrideTagProto> proto;
/// DOCME
static bool loaded; static bool loaded;
static void LoadProtos(); static void LoadProtos();
@ -143,3 +222,4 @@ public:
~AssOverrideTagProto(); ~AssOverrideTagProto();
}; };

View file

@ -44,20 +44,27 @@
#include "utils.h" #include "utils.h"
#include <ctype.h> #include <ctype.h>
///////////////////////// AssColor //////////////////////////
//////////////// /// @brief Constructors AssColor //////////////////////////
// Constructors ///
AssColor::AssColor () { AssColor::AssColor () {
r=g=b=a=0; r=g=b=a=0;
} }
/// @brief DOCME
/// @param color
///
AssColor::AssColor (wxColour &color) { AssColor::AssColor (wxColour &color) {
SetWXColor(color); SetWXColor(color);
} }
//////////////////
// Parse from SSA/ASS /// @brief Parse from SSA/ASS
/// @param value
/// @return
///
void AssColor::Parse(const wxString value) { void AssColor::Parse(const wxString value) {
if (value.Len() > 0 && value[0] == _T('#')) { if (value.Len() > 0 && value[0] == _T('#')) {
// HTML colour // HTML colour
@ -91,15 +98,19 @@ void AssColor::Parse(const wxString value) {
} }
///////////////////
// Gets a wxColour /// @brief Gets a wxColour
/// @return
///
wxColour AssColor::GetWXColor() { wxColour AssColor::GetWXColor() {
return wxColour(r,g,b,255-a); return wxColour(r,g,b,255-a);
} }
//////////////////////
// Sets color from wx /// @brief Sets color from wx
/// @param color
///
void AssColor::SetWXColor(const wxColor &color) { void AssColor::SetWXColor(const wxColor &color) {
r = color.Red(); r = color.Red();
g = color.Green(); g = color.Green();
@ -108,8 +119,13 @@ void AssColor::SetWXColor(const wxColor &color) {
} }
///////////////////////////////
// Get formatted in ASS format /// @brief Get formatted in ASS format
/// @param alpha
/// @param stripped
/// @param isStyle
/// @return
///
wxString AssColor::GetASSFormatted (bool alpha,bool stripped,bool isStyle) { wxString AssColor::GetASSFormatted (bool alpha,bool stripped,bool isStyle) {
wxString work; wxString work;
if (!stripped) work += _T("&H"); if (!stripped) work += _T("&H");
@ -120,8 +136,10 @@ wxString AssColor::GetASSFormatted (bool alpha,bool stripped,bool isStyle) {
} }
/////////////////////////
// Get decimal formatted /// @brief Get decimal formatted
/// @return
///
wxString AssColor::GetSSAFormatted () { wxString AssColor::GetSSAFormatted () {
long color = (a<<24)+(b<<16)+(g<<8)+r; long color = (a<<24)+(b<<16)+(g<<8)+r;
wxString output=wxString::Format(_T("%i"),(long)color); wxString output=wxString::Format(_T("%i"),(long)color);
@ -129,20 +147,28 @@ wxString AssColor::GetSSAFormatted () {
} }
/////////////
// Operators /// @brief Operators
/// @param col
/// @return
///
bool AssColor::operator==(AssColor &col) const { bool AssColor::operator==(AssColor &col) const {
return r==col.r && g==col.g && b==col.b && a==col.a; return r==col.r && g==col.g && b==col.b && a==col.a;
} }
/// @brief DOCME
/// @param col
/// @return
///
bool AssColor::operator!=(AssColor &col) const { bool AssColor::operator!=(AssColor &col) const {
return r!=col.r || g!=col.g || b!=col.b || a!=col.a; return r!=col.r || g!=col.g || b!=col.b || a!=col.a;
} }
///////////////////////// AssStyle /////////////////////////
/////////////////////// /// @brief Default Constructor AssStyle /////////////////////////
// Default Constructor ///
AssStyle::AssStyle() { AssStyle::AssStyle() {
group = _T("[V4+ Styles]"); group = _T("[V4+ Styles]");
@ -191,8 +217,11 @@ AssStyle::AssStyle() {
} }
///////////////
// Constructor /// @brief Constructor
/// @param _data
/// @param version
///
AssStyle::AssStyle(wxString _data,int version) { AssStyle::AssStyle(wxString _data,int version) {
Valid = Parse(_data,version); Valid = Parse(_data,version);
if (!Valid) { if (!Valid) {
@ -202,14 +231,19 @@ AssStyle::AssStyle(wxString _data,int version) {
} }
//////////////
// Destructor /// @brief Destructor
///
AssStyle::~AssStyle() { AssStyle::~AssStyle() {
} }
//////////////////////////////
// Parses value from ASS data /// @brief Parses value from ASS data
/// @param rawData
/// @param version
/// @return
///
bool AssStyle::Parse(wxString rawData,int version) { bool AssStyle::Parse(wxString rawData,int version) {
// Tokenize // Tokenize
wxString temp; wxString temp;
@ -412,8 +446,9 @@ bool AssStyle::Parse(wxString rawData,int version) {
} }
///////////////////////////////////////
// Writes data back to ASS (v4+) format /// @brief Writes data back to ASS (v4+) format
///
void AssStyle::UpdateData() { void AssStyle::UpdateData() {
wxString final; wxString final;
@ -437,8 +472,11 @@ void AssStyle::UpdateData() {
} }
/////////////////////////////
// Sets margin from a string /// @brief Sets margin from a string
/// @param str
/// @param which
///
void AssStyle::SetMarginString(const wxString str,int which) { void AssStyle::SetMarginString(const wxString str,int which) {
if (which < 0 || which >= 4) throw new Aegisub::InvalidMarginIdError; if (which < 0 || which >= 4) throw new Aegisub::InvalidMarginIdError;
if (!str.IsNumber()) throw _T("Invalid margin value"); if (!str.IsNumber()) throw _T("Invalid margin value");
@ -451,8 +489,11 @@ void AssStyle::SetMarginString(const wxString str,int which) {
} }
//////////////////////////
// Gets string for margin /// @brief Gets string for margin
/// @param which
/// @return
///
wxString AssStyle::GetMarginString(int which) { wxString AssStyle::GetMarginString(int which) {
if (which < 0 || which >= 4) throw new Aegisub::InvalidMarginIdError; if (which < 0 || which >= 4) throw new Aegisub::InvalidMarginIdError;
wxString result = wxString::Format(_T("%04i"),Margin[which]); wxString result = wxString::Format(_T("%04i"),Margin[which]);
@ -460,8 +501,10 @@ wxString AssStyle::GetMarginString(int which) {
} }
///////////////////////////////
// Convert style to SSA string /// @brief Convert style to SSA string
/// @return
///
wxString AssStyle::GetSSAText() { wxString AssStyle::GetSSAText() {
wxString output; wxString output;
int align = 0; int align = 0;
@ -492,8 +535,10 @@ wxString AssStyle::GetSSAText() {
} }
/////////
// Clone /// @brief Clone
/// @return
///
AssEntry *AssStyle::Clone() const { AssEntry *AssStyle::Clone() const {
// Create clone // Create clone
AssStyle *final = new AssStyle(); AssStyle *final = new AssStyle();
@ -534,8 +579,11 @@ AssEntry *AssStyle::Clone() const {
} }
///////////////////////////
// Equal to another style? /// @brief Equal to another style?
/// @param style
/// @return
///
bool AssStyle::IsEqualTo(AssStyle *style) { bool AssStyle::IsEqualTo(AssStyle *style) {
// memcmp won't work because strings won't match // memcmp won't work because strings won't match
if (style->alignment != alignment || if (style->alignment != alignment ||
@ -569,8 +617,10 @@ bool AssStyle::IsEqualTo(AssStyle *style) {
} }
/////////////////////////////////////
// Get a list of valid ASS encodings /// @brief Get a list of valid ASS encodings
/// @param encodingStrings
///
void AssStyle::GetEncodings(wxArrayString &encodingStrings) { void AssStyle::GetEncodings(wxArrayString &encodingStrings) {
encodingStrings.Clear(); encodingStrings.Clear();
encodingStrings.Add(wxString(_T("0 - ")) + _("ANSI")); encodingStrings.Add(wxString(_T("0 - ")) + _("ANSI"));
@ -594,3 +644,4 @@ void AssStyle::GetEncodings(wxArrayString &encodingStrings) {
encodingStrings.Add(wxString(_T("255 - ")) + _("OEM")); encodingStrings.Add(wxString(_T("255 - ")) + _("OEM"));
} }

View file

@ -43,13 +43,25 @@
#include "ass_entry.h" #include "ass_entry.h"
/////////////////////////
// Class to store colors /// DOCME
/// @class AssColor
/// @brief DOCME
///
/// DOCME
class AssColor { class AssColor {
public: public:
/// DOCME
int r; // Red component int r; // Red component
/// DOCME
int g; // Green component int g; // Green component
/// DOCME
int b; // Blue component int b; // Blue component
/// DOCME
int a; // Alpha component int a; // Alpha component
AssColor(); AssColor();
@ -66,36 +78,87 @@ public:
}; };
/////////////////////////
// Class to store styles /// DOCME
/// @class AssStyle
/// @brief DOCME
///
/// DOCME
class AssStyle : public AssEntry { class AssStyle : public AssEntry {
public: public:
/// DOCME
wxString name; wxString name;
/// DOCME
wxString font; wxString font;
/// DOCME
double fontsize; double fontsize;
/// DOCME
AssColor primary; AssColor primary;
/// DOCME
AssColor secondary; AssColor secondary;
/// DOCME
AssColor outline; AssColor outline;
/// DOCME
AssColor shadow; AssColor shadow;
/// DOCME
bool bold; bool bold;
/// DOCME
bool italic; bool italic;
/// DOCME
bool underline; bool underline;
/// DOCME
bool strikeout; bool strikeout;
/// DOCME
double scalex; double scalex;
/// DOCME
double scaley; double scaley;
/// DOCME
double spacing; double spacing;
/// DOCME
double angle; double angle;
/// DOCME
int borderstyle; int borderstyle;
/// DOCME
double outline_w; double outline_w;
/// DOCME
double shadow_w; double shadow_w;
/// DOCME
int alignment; int alignment;
/// DOCME
int Margin[4]; int Margin[4];
/// DOCME
int encoding; int encoding;
/// DOCME
int relativeTo; int relativeTo;
/// @brief DOCME
///
ASS_EntryType GetType() { return ENTRY_STYLE; } ASS_EntryType GetType() { return ENTRY_STYLE; }
bool Parse(wxString data,int version=1); // Parses raw ASS/SSA data into everything else bool Parse(wxString data,int version=1); // Parses raw ASS/SSA data into everything else
@ -114,3 +177,4 @@ public:
~AssStyle(); ~AssStyle();
}; };

View file

@ -48,8 +48,11 @@
#include "standard_paths.h" #include "standard_paths.h"
///////////////////////
// Save styles to disk /// @brief Save styles to disk
/// @param name
/// @return
///
void AssStyleStorage::Save(wxString name) { void AssStyleStorage::Save(wxString name) {
if (name.IsEmpty()) return; if (name.IsEmpty()) return;
@ -61,8 +64,11 @@ void AssStyleStorage::Save(wxString name) {
} }
/////////////////////////
// Load styles from disk /// @brief Load styles from disk
/// @param name
/// @return
///
void AssStyleStorage::Load(wxString name) { void AssStyleStorage::Load(wxString name) {
if (name.IsEmpty()) return; if (name.IsEmpty()) return;
Clear(); Clear();
@ -84,8 +90,9 @@ void AssStyleStorage::Load(wxString name) {
} }
/////////
// Clear /// @brief Clear
///
void AssStyleStorage::Clear () { void AssStyleStorage::Clear () {
using std::list; using std::list;
for (list<AssStyle*>::iterator cur=style.begin();cur!=style.end();cur++) { for (list<AssStyle*>::iterator cur=style.begin();cur!=style.end();cur++) {
@ -95,8 +102,10 @@ void AssStyleStorage::Clear () {
} }
/////////////
// Get names /// @brief Get names
/// @return
///
wxArrayString AssStyleStorage::GetNames() { wxArrayString AssStyleStorage::GetNames() {
wxArrayString names; wxArrayString names;
for (std::list<AssStyle*>::iterator cur=style.begin();cur!=style.end();cur++) { for (std::list<AssStyle*>::iterator cur=style.begin();cur!=style.end();cur++) {
@ -106,8 +115,10 @@ wxArrayString AssStyleStorage::GetNames() {
} }
///////////////////////
// Get a style by name /// @brief Get a style by name
/// @param name
///
AssStyle *AssStyleStorage::GetStyle(wxString name) { AssStyle *AssStyleStorage::GetStyle(wxString name) {
for (std::list<AssStyle*>::iterator cur=style.begin();cur!=style.end();cur++) { for (std::list<AssStyle*>::iterator cur=style.begin();cur!=style.end();cur++) {
if ((*cur)->name == name) return *cur; if ((*cur)->name == name) return *cur;
@ -115,3 +126,4 @@ AssStyle *AssStyleStorage::GetStyle(wxString name) {
return NULL; return NULL;
} }

View file

@ -36,6 +36,8 @@
#ifndef ASS_STYLE_STORAGE_H #ifndef ASS_STYLE_STORAGE_H
/// DOCME
#define ASS_STYLE_STORAGE_H #define ASS_STYLE_STORAGE_H
@ -51,10 +53,16 @@
class AssStyle; class AssStyle;
/////////////////
// Storage class /// DOCME
/// @class AssStyleStorage
/// @brief DOCME
///
/// DOCME
class AssStyleStorage { class AssStyleStorage {
public: public:
/// DOCME
std::list<AssStyle*> style; std::list<AssStyle*> style;
wxArrayString GetNames(); wxArrayString GetNames();
@ -67,3 +75,4 @@ public:
#endif #endif

View file

@ -49,17 +49,19 @@
////////////////////// AssTime //////////////////////
// AssTime constructors /// @brief AssTime constructors AssTime //////////////////////
///
AssTime::AssTime () { AssTime::AssTime () {
time = 0; time = 0;
} }
////////////////////
// Parses from ASS /// @brief Note that this function is atomic, it won't touch the values if it's invalid. --------------- Parses from ASS
// --------------- /// @param text
// Note that this function is atomic, it won't touch the values if it's invalid. /// @return
///
void AssTime::ParseASS (const wxString text) { void AssTime::ParseASS (const wxString text) {
// Prepare // Prepare
size_t pos = 0; size_t pos = 0;
@ -114,8 +116,10 @@ void AssTime::ParseASS (const wxString text) {
} }
///////////////////
// Parses from SRT /// @brief Parses from SRT
/// @param _text
///
void AssTime::ParseSRT (const wxString _text) { void AssTime::ParseSRT (const wxString _text) {
// Prepare // Prepare
wxString text = _text; wxString text = _text;
@ -144,20 +148,29 @@ void AssTime::ParseSRT (const wxString _text) {
} }
//////////////////////////////////////////
// AssTime conversion to/from miliseconds /// @brief AssTime conversion to/from miliseconds
/// @return
///
int AssTime::GetMS () const { int AssTime::GetMS () const {
if (!UseMSPrecision) return time/10*10; if (!UseMSPrecision) return time/10*10;
else return time; else return time;
} }
/// @brief DOCME
/// @param _ms
///
void AssTime::SetMS (int _ms) { void AssTime::SetMS (int _ms) {
time = _ms; time = _ms;
} }
////////////////
// ASS Formated /// @brief ASS Formated
/// @param msPrecision
/// @return
///
wxString AssTime::GetASSFormated (bool msPrecision) { wxString AssTime::GetASSFormated (bool msPrecision) {
int h,m,s,ms; int h,m,s,ms;
int _ms = time; int _ms = time;
@ -202,8 +215,10 @@ wxString AssTime::GetASSFormated (bool msPrecision) {
} }
////////////////
// SRT Formated /// @brief SRT Formated
/// @return
///
wxString AssTime::GetSRTFormated () { wxString AssTime::GetSRTFormated () {
int h,m,s,ms; int h,m,s,ms;
int _ms = time; int _ms = time;
@ -247,51 +262,108 @@ wxString AssTime::GetSRTFormated () {
} }
//////////////////////
// AssTime comparison /// @brief AssTime comparison
/// @param t1
/// @param t2
/// @return
///
bool operator < (AssTime &t1, AssTime &t2) { bool operator < (AssTime &t1, AssTime &t2) {
return (t1.GetMS() < t2.GetMS()); return (t1.GetMS() < t2.GetMS());
} }
/// @brief DOCME
/// @param t1
/// @param t2
/// @return
///
bool operator > (AssTime &t1, AssTime &t2) { bool operator > (AssTime &t1, AssTime &t2) {
return (t1.GetMS() > t2.GetMS()); return (t1.GetMS() > t2.GetMS());
} }
/// @brief DOCME
/// @param t1
/// @param t2
/// @return
///
bool operator <= (AssTime &t1, AssTime &t2) { bool operator <= (AssTime &t1, AssTime &t2) {
return (t1.GetMS() <= t2.GetMS()); return (t1.GetMS() <= t2.GetMS());
} }
/// @brief DOCME
/// @param t1
/// @param t2
/// @return
///
bool operator >= (AssTime &t1, AssTime &t2) { bool operator >= (AssTime &t1, AssTime &t2) {
return (t1.GetMS() >= t2.GetMS()); return (t1.GetMS() >= t2.GetMS());
} }
/// @brief DOCME
/// @param t1
/// @param t2
/// @return
///
bool operator == (AssTime &t1, AssTime &t2) { bool operator == (AssTime &t1, AssTime &t2) {
return (t1.GetMS() == t2.GetMS()); return (t1.GetMS() == t2.GetMS());
} }
/// @brief DOCME
/// @param t1
/// @param t2
/// @return
///
bool operator != (AssTime &t1, AssTime &t2) { bool operator != (AssTime &t1, AssTime &t2) {
return (t1.GetMS() != t2.GetMS()); return (t1.GetMS() != t2.GetMS());
} }
/////////////////
// Static option /// DOCME
bool AssTime::UseMSPrecision = false; bool AssTime::UseMSPrecision = false;
///////
// Get /// @brief Get
/// @return
///
int AssTime::GetTimeHours() { return time / 3600000; } int AssTime::GetTimeHours() { return time / 3600000; }
/// @brief DOCME
/// @return
///
int AssTime::GetTimeMinutes() { return (time % 3600000)/60000; } int AssTime::GetTimeMinutes() { return (time % 3600000)/60000; }
/// @brief DOCME
/// @return
///
int AssTime::GetTimeSeconds() { return (time % 60000)/1000; } int AssTime::GetTimeSeconds() { return (time % 60000)/1000; }
/// @brief DOCME
/// @return
///
int AssTime::GetTimeMiliseconds() { return (time % 1000); } int AssTime::GetTimeMiliseconds() { return (time % 1000); }
/// @brief DOCME
/// @return
///
int AssTime::GetTimeCentiseconds() { return (time % 1000)/10; } int AssTime::GetTimeCentiseconds() { return (time % 1000)/10; }
///////
// Constructor /// @brief Constructor
/// @param separator
/// @param numerator
/// @param denominator
/// @param dropframe
///
FractionalTime::FractionalTime (wxString separator, int numerator, int denominator, bool dropframe) { FractionalTime::FractionalTime (wxString separator, int numerator, int denominator, bool dropframe) {
drop = dropframe; drop = dropframe;
if (drop) { if (drop) {
@ -311,14 +383,18 @@ FractionalTime::FractionalTime (wxString separator, int numerator, int denominat
throw _T("FractionalTime: no separator specified"); throw _T("FractionalTime: no separator specified");
} }
///////
// Destructor /// @brief Destructor
///
FractionalTime::~FractionalTime () { FractionalTime::~FractionalTime () {
sep.Clear(); sep.Clear();
} }
///////
// SMPTE text string to milliseconds conversion /// @brief SMPTE text string to milliseconds conversion
/// @param _text
/// @return
///
int FractionalTime::ToMillisecs (wxString _text) { int FractionalTime::ToMillisecs (wxString _text) {
wxString text = _text; wxString text = _text;
wxString re_str = _T(""); wxString re_str = _T("");
@ -376,22 +452,30 @@ int FractionalTime::ToMillisecs (wxString _text) {
return msecs_f; return msecs_f;
} }
///////
// SMPTE text string to AssTime conversion /// @brief SMPTE text string to AssTime conversion
/// @param _text
/// @return
///
AssTime FractionalTime::ToAssTime (wxString _text) { AssTime FractionalTime::ToAssTime (wxString _text) {
AssTime time; AssTime time;
time.SetMS((int)ToMillisecs(_text)); time.SetMS((int)ToMillisecs(_text));
return time; return time;
} }
///////
// AssTime to SMPTE text string conversion /// @brief AssTime to SMPTE text string conversion
/// @param time
/// @return
///
wxString FractionalTime::FromAssTime(AssTime time) { wxString FractionalTime::FromAssTime(AssTime time) {
return FromMillisecs(time.GetMS()); return FromMillisecs(time.GetMS());
} }
///////
// Milliseconds to SMPTE text string conversion /// @brief Milliseconds to SMPTE text string conversion
/// @param msec
///
wxString FractionalTime::FromMillisecs(int64_t msec) { wxString FractionalTime::FromMillisecs(int64_t msec) {
int h=0, m=0, s=0, f=0; // hours, minutes, seconds, fractions int h=0, m=0, s=0, f=0; // hours, minutes, seconds, fractions
int fn = (msec*(int64_t)num) / (1000*den); // frame number int fn = (msec*(int64_t)num) / (1000*den); // frame number
@ -444,3 +528,4 @@ RETURN:
return wxString::Format(_T("%02i") + sep + _T("%02i") + sep + _T("%02i") + sep + _T("%02i"),h,m,s,f); return wxString::Format(_T("%02i") + sep + _T("%02i") + sep + _T("%02i") + sep + _T("%02i"),h,m,s,f);
} }

View file

@ -45,13 +45,21 @@
#include <stdint.h> #include <stdint.h>
/////////////////////////////
// Class for Ass format time /// DOCME
/// @class AssTime
/// @brief DOCME
///
/// DOCME
class AssTime { class AssTime {
private: private:
/// DOCME
int time; // Miliseconds int time; // Miliseconds
public: public:
/// DOCME
static bool UseMSPrecision; static bool UseMSPrecision;
AssTime(); AssTime();
@ -80,17 +88,31 @@ bool operator >= (AssTime &t1, AssTime &t2);
/////////////////////////////
// Class for that annoying SMPTE format timecodes stuff /// DOCME
/// @class FractionalTime
/// @brief DOCME
///
/// DOCME
class FractionalTime { class FractionalTime {
private: private:
/// DOCME
int time; // milliseconds, like in AssTime int time; // milliseconds, like in AssTime
/// DOCME
/// DOCME
int num, den; // numerator/denominator int num, den; // numerator/denominator
/// DOCME
bool drop; // EVIL bool drop; // EVIL
/// DOCME
wxString sep; // separator; someone might have separators of more than one character :V wxString sep; // separator; someone might have separators of more than one character :V
// A period is roughly 10 minutes and is used for the dropframe stuff;
// SMPTE dropframe timecodes drops 18 timestamps per 18000, hence the number 17982. /// DOCME
static const int frames_per_period = 17982; static const int frames_per_period = 17982;
public: public:
@ -106,3 +128,4 @@ public:
wxString FromMillisecs(int64_t msec); wxString FromMillisecs(int64_t msec);
}; };

View file

@ -60,8 +60,10 @@
//#include "bevelButton.h" //#include "bevelButton.h"
//#endif //#endif
///////////////
// Constructor /// @brief Constructor
/// @param parent
///
AudioBox::AudioBox(wxWindow *parent) : AudioBox::AudioBox(wxWindow *parent) :
wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL|wxBORDER_RAISED) wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL|wxBORDER_RAISED)
{ {
@ -229,8 +231,9 @@ wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL|wxBORDER_RAISE
} }
//////////////
// Destructor /// @brief Destructor
///
AudioBox::~AudioBox() { AudioBox::~AudioBox() {
audioScroll->PopEventHandler(true); audioScroll->PopEventHandler(true);
HorizontalZoom->PopEventHandler(true); HorizontalZoom->PopEventHandler(true);
@ -239,8 +242,12 @@ AudioBox::~AudioBox() {
} }
////////////
// Set file /// @brief Set file
/// @param file
/// @param FromVideo
/// @return
///
void AudioBox::SetFile(wxString file,bool FromVideo) { void AudioBox::SetFile(wxString file,bool FromVideo) {
wxLogDebug(_T("AudioBox::SetFile(file=%s, FromVideo=%d)"), file.c_str(), FromVideo?1:0); wxLogDebug(_T("AudioBox::SetFile(file=%s, FromVideo=%d)"), file.c_str(), FromVideo?1:0);
loaded = false; loaded = false;
@ -299,22 +306,28 @@ BEGIN_EVENT_TABLE(AudioBox,wxPanel)
END_EVENT_TABLE() END_EVENT_TABLE()
/////////////////////
// Scrollbar changed /// @brief Scrollbar changed
/// @param event
///
void AudioBox::OnScrollbar(wxScrollEvent &event) { void AudioBox::OnScrollbar(wxScrollEvent &event) {
audioDisplay->SetPosition(event.GetPosition()*12); audioDisplay->SetPosition(event.GetPosition()*12);
} }
///////////////////////////////
// Horizontal zoom bar changed /// @brief Horizontal zoom bar changed
/// @param event
///
void AudioBox::OnHorizontalZoom(wxScrollEvent &event) { void AudioBox::OnHorizontalZoom(wxScrollEvent &event) {
audioDisplay->SetSamplesPercent(event.GetPosition()); audioDisplay->SetSamplesPercent(event.GetPosition());
} }
/////////////////////////////
// Vertical zoom bar changed /// @brief Vertical zoom bar changed
/// @param event
///
void AudioBox::OnVerticalZoom(wxScrollEvent &event) { void AudioBox::OnVerticalZoom(wxScrollEvent &event) {
int pos = event.GetPosition(); int pos = event.GetPosition();
if (pos < 1) pos = 1; if (pos < 1) pos = 1;
@ -328,8 +341,10 @@ void AudioBox::OnVerticalZoom(wxScrollEvent &event) {
} }
//////////////////////
// Volume bar changed /// @brief Volume bar changed
/// @param event
///
void AudioBox::OnVolume(wxScrollEvent &event) { void AudioBox::OnVolume(wxScrollEvent &event) {
if (!VerticalLink->GetValue()) { if (!VerticalLink->GetValue()) {
int pos = event.GetPosition(); int pos = event.GetPosition();
@ -340,8 +355,10 @@ void AudioBox::OnVolume(wxScrollEvent &event) {
} }
////////////////////////
// Bars linked/unlinked /// @brief Bars linked/unlinked
/// @param event
///
void AudioBox::OnVerticalLink(wxCommandEvent &event) { void AudioBox::OnVerticalLink(wxCommandEvent &event) {
int pos = VerticalZoom->GetValue(); int pos = VerticalZoom->GetValue();
if (pos < 1) pos = 1; if (pos < 1) pos = 1;
@ -358,8 +375,11 @@ void AudioBox::OnVerticalLink(wxCommandEvent &event) {
} }
////////
// Sash /// @brief Sash
/// @param event
/// @return
///
void AudioBox::OnSash(wxSashEvent& event) { void AudioBox::OnSash(wxSashEvent& event) {
// OK? // OK?
if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE) return; if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE) return;
@ -405,8 +425,10 @@ void AudioBox::OnSash(wxSashEvent& event) {
} }
//////////////////
// Play selection /// @brief Play selection
/// @param event
///
void AudioBox::OnPlaySelection(wxCommandEvent &event) { void AudioBox::OnPlaySelection(wxCommandEvent &event) {
int start=0,end=0; int start=0,end=0;
audioDisplay->SetFocus(); audioDisplay->SetFocus();
@ -415,8 +437,10 @@ void AudioBox::OnPlaySelection(wxCommandEvent &event) {
} }
/////////////////
// Play dialogue /// @brief Play dialogue
/// @param event
///
void AudioBox::OnPlayDialogue(wxCommandEvent &event) { void AudioBox::OnPlayDialogue(wxCommandEvent &event) {
int start=0,end=0; int start=0,end=0;
audioDisplay->SetFocus(); audioDisplay->SetFocus();
@ -426,16 +450,20 @@ void AudioBox::OnPlayDialogue(wxCommandEvent &event) {
} }
////////////////
// Stop Playing /// @brief Stop Playing
/// @param event
///
void AudioBox::OnStop(wxCommandEvent &event) { void AudioBox::OnStop(wxCommandEvent &event) {
audioDisplay->SetFocus(); audioDisplay->SetFocus();
audioDisplay->Stop(); audioDisplay->Stop();
} }
////////
// Next /// @brief Next
/// @param event
///
void AudioBox::OnNext(wxCommandEvent &event) { void AudioBox::OnNext(wxCommandEvent &event) {
audioDisplay->SetFocus(); audioDisplay->SetFocus();
audioDisplay->Stop(); audioDisplay->Stop();
@ -443,8 +471,10 @@ void AudioBox::OnNext(wxCommandEvent &event) {
} }
////////////
// Previous /// @brief Previous
/// @param event
///
void AudioBox::OnPrev(wxCommandEvent &event) { void AudioBox::OnPrev(wxCommandEvent &event) {
audioDisplay->SetFocus(); audioDisplay->SetFocus();
audioDisplay->Stop(); audioDisplay->Stop();
@ -452,8 +482,10 @@ void AudioBox::OnPrev(wxCommandEvent &event) {
} }
/////////////////
// 500 ms before /// @brief 500 ms before
/// @param event
///
void AudioBox::OnPlay500Before(wxCommandEvent &event) { void AudioBox::OnPlay500Before(wxCommandEvent &event) {
int start=0,end=0; int start=0,end=0;
audioDisplay->SetFocus(); audioDisplay->SetFocus();
@ -462,8 +494,10 @@ void AudioBox::OnPlay500Before(wxCommandEvent &event) {
} }
////////////////
// 500 ms after /// @brief 500 ms after
/// @param event
///
void AudioBox::OnPlay500After(wxCommandEvent &event) { void AudioBox::OnPlay500After(wxCommandEvent &event) {
int start=0,end=0; int start=0,end=0;
audioDisplay->SetFocus(); audioDisplay->SetFocus();
@ -472,8 +506,10 @@ void AudioBox::OnPlay500After(wxCommandEvent &event) {
} }
////////////////
// First 500 ms /// @brief First 500 ms
/// @param event
///
void AudioBox::OnPlay500First(wxCommandEvent &event) { void AudioBox::OnPlay500First(wxCommandEvent &event) {
int start=0,end=0; int start=0,end=0;
audioDisplay->SetFocus(); audioDisplay->SetFocus();
@ -484,8 +520,10 @@ void AudioBox::OnPlay500First(wxCommandEvent &event) {
} }
///////////////
// Last 500 ms /// @brief Last 500 ms
/// @param event
///
void AudioBox::OnPlay500Last(wxCommandEvent &event) { void AudioBox::OnPlay500Last(wxCommandEvent &event) {
int start=0,end=0; int start=0,end=0;
audioDisplay->SetFocus(); audioDisplay->SetFocus();
@ -496,8 +534,10 @@ void AudioBox::OnPlay500Last(wxCommandEvent &event) {
} }
////////////////////////
// Start to end of file /// @brief Start to end of file
/// @param event
///
void AudioBox::OnPlayToEnd(wxCommandEvent &event) { void AudioBox::OnPlayToEnd(wxCommandEvent &event) {
int start=0,end=0; int start=0,end=0;
audioDisplay->SetFocus(); audioDisplay->SetFocus();
@ -506,8 +546,11 @@ void AudioBox::OnPlayToEnd(wxCommandEvent &event) {
} }
//////////////////
// Commit changes /// @brief Commit changes
/// @param event
/// @return
///
void AudioBox::OnCommit(wxCommandEvent &event) { void AudioBox::OnCommit(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnCommit")); wxLogDebug(_T("AudioBox::OnCommit"));
audioDisplay->SetFocus(); audioDisplay->SetFocus();
@ -517,8 +560,11 @@ void AudioBox::OnCommit(wxCommandEvent &event) {
} }
//////////////////
// Toggle karaoke /// @brief Toggle karaoke
/// @param event
/// @return
///
void AudioBox::OnKaraoke(wxCommandEvent &event) { void AudioBox::OnKaraoke(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnKaraoke")); wxLogDebug(_T("AudioBox::OnKaraoke"));
audioDisplay->SetFocus(); audioDisplay->SetFocus();
@ -545,8 +591,9 @@ void AudioBox::OnKaraoke(wxCommandEvent &event) {
} }
////////////////////////
// Sets karaoke buttons /// @brief Sets karaoke buttons
///
void AudioBox::SetKaraokeButtons() { void AudioBox::SetKaraokeButtons() {
// What to enable // What to enable
bool join,split; bool join,split;
@ -573,8 +620,10 @@ void AudioBox::SetKaraokeButtons() {
} }
///////////////
// Join button /// @brief Join button
/// @param event
///
void AudioBox::OnJoin(wxCommandEvent &event) { void AudioBox::OnJoin(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnJoin")); wxLogDebug(_T("AudioBox::OnJoin"));
audioDisplay->SetFocus(); audioDisplay->SetFocus();
@ -586,8 +635,10 @@ void AudioBox::OnJoin(wxCommandEvent &event) {
} }
////////////////
// Split button /// @brief Split button
/// @param event
///
void AudioBox::OnSplit(wxCommandEvent &event) { void AudioBox::OnSplit(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnSplit")); wxLogDebug(_T("AudioBox::OnSplit"));
audioDisplay->SetFocus(); audioDisplay->SetFocus();
@ -599,16 +650,20 @@ void AudioBox::OnSplit(wxCommandEvent &event) {
} }
///////////////
// Goto button /// @brief Goto button
/// @param event
///
void AudioBox::OnGoto(wxCommandEvent &event) { void AudioBox::OnGoto(wxCommandEvent &event) {
audioDisplay->SetFocus(); audioDisplay->SetFocus();
audioDisplay->MakeDialogueVisible(true); audioDisplay->MakeDialogueVisible(true);
} }
/////////////
// Auto Goto /// @brief Auto Goto
/// @param event
///
void AudioBox::OnAutoGoto(wxCommandEvent &event) { void AudioBox::OnAutoGoto(wxCommandEvent &event) {
audioDisplay->SetFocus(); audioDisplay->SetFocus();
Options.SetBool(_T("Audio Autoscroll"),AutoScroll->GetValue()); Options.SetBool(_T("Audio Autoscroll"),AutoScroll->GetValue());
@ -616,8 +671,10 @@ void AudioBox::OnAutoGoto(wxCommandEvent &event) {
} }
///////////////
// Auto Commit /// @brief Auto Commit
/// @param event
///
void AudioBox::OnAutoCommit(wxCommandEvent &event) { void AudioBox::OnAutoCommit(wxCommandEvent &event) {
audioDisplay->SetFocus(); audioDisplay->SetFocus();
Options.SetBool(_T("Audio Autocommit"),AutoCommit->GetValue()); Options.SetBool(_T("Audio Autocommit"),AutoCommit->GetValue());
@ -625,8 +682,10 @@ void AudioBox::OnAutoCommit(wxCommandEvent &event) {
} }
//////////////////////
// Next line on Commit /// @brief Next line on Commit
/// @param event
///
void AudioBox::OnNextLineCommit(wxCommandEvent &event) { void AudioBox::OnNextLineCommit(wxCommandEvent &event) {
audioDisplay->SetFocus(); audioDisplay->SetFocus();
Options.SetBool(_T("Audio Next Line on Commit"),NextCommit->GetValue()); Options.SetBool(_T("Audio Next Line on Commit"),NextCommit->GetValue());
@ -634,8 +693,10 @@ void AudioBox::OnNextLineCommit(wxCommandEvent &event) {
} }
///////////////
// Medusa Mode /// @brief Medusa Mode
/// @param event
///
void AudioBox::OnMedusaMode(wxCommandEvent &event) { void AudioBox::OnMedusaMode(wxCommandEvent &event) {
audioDisplay->SetFocus(); audioDisplay->SetFocus();
Options.SetBool(_T("Audio Medusa Timing Hotkeys"),MedusaMode->GetValue()); Options.SetBool(_T("Audio Medusa Timing Hotkeys"),MedusaMode->GetValue());
@ -644,8 +705,10 @@ void AudioBox::OnMedusaMode(wxCommandEvent &event) {
} }
//////////////////////////
// Spectrum Analyzer Mode /// @brief Spectrum Analyzer Mode
/// @param event
///
void AudioBox::OnSpectrumMode(wxCommandEvent &event) { void AudioBox::OnSpectrumMode(wxCommandEvent &event) {
Options.SetBool(_T("Audio Spectrum"),SpectrumMode->GetValue()); Options.SetBool(_T("Audio Spectrum"),SpectrumMode->GetValue());
Options.Save(); Options.Save();
@ -655,13 +718,19 @@ void AudioBox::OnSpectrumMode(wxCommandEvent &event) {
} }
///////////////
// Lead in/out /// @brief Lead in/out
/// @param event
///
void AudioBox::OnLeadIn(wxCommandEvent &event) { void AudioBox::OnLeadIn(wxCommandEvent &event) {
audioDisplay->SetFocus(); audioDisplay->SetFocus();
audioDisplay->AddLead(true,false); audioDisplay->AddLead(true,false);
} }
/// @brief DOCME
/// @param event
///
void AudioBox::OnLeadOut(wxCommandEvent &event) { void AudioBox::OnLeadOut(wxCommandEvent &event) {
audioDisplay->SetFocus(); audioDisplay->SetFocus();
audioDisplay->AddLead(false,true); audioDisplay->AddLead(false,true);
@ -674,6 +743,10 @@ BEGIN_EVENT_TABLE(FocusEvent,wxEvtHandler)
EVT_SET_FOCUS(FocusEvent::OnSetFocus) EVT_SET_FOCUS(FocusEvent::OnSetFocus)
END_EVENT_TABLE() END_EVENT_TABLE()
/// @brief DOCME
/// @param event
///
void FocusEvent::OnSetFocus(wxFocusEvent &event) { void FocusEvent::OnSetFocus(wxFocusEvent &event) {
wxWindow *previous = event.GetWindow(); wxWindow *previous = event.GetWindow();
if (previous) previous->SetFocus(); if (previous) previous->SetFocus();
@ -681,3 +754,4 @@ void FocusEvent::OnSetFocus(wxFocusEvent &event) {

View file

@ -36,6 +36,8 @@
#ifndef AUDIO_BOX_H #ifndef AUDIO_BOX_H
/// DOCME
#define AUDIO_BOX_H #define AUDIO_BOX_H
@ -63,29 +65,67 @@ class wxToggleButton;
class ToggleBitmap; class ToggleBitmap;
///////////////////
// Audio box class /// DOCME
/// @class AudioBox
/// @brief DOCME
///
/// DOCME
class AudioBox : public wxPanel { class AudioBox : public wxPanel {
friend class AudioDisplay; friend class AudioDisplay;
private: private:
/// DOCME
wxScrollBar *audioScroll; wxScrollBar *audioScroll;
/// DOCME
wxSlider *HorizontalZoom; wxSlider *HorizontalZoom;
/// DOCME
wxSlider *VerticalZoom; wxSlider *VerticalZoom;
/// DOCME
wxSlider *VolumeBar; wxSlider *VolumeBar;
/// DOCME
wxSizer *MainSizer; wxSizer *MainSizer;
/// DOCME
wxSizer *TopSizer; wxSizer *TopSizer;
/// DOCME
wxSizer *sashSizer; wxSizer *sashSizer;
/// DOCME
wxSizer *DisplaySizer; wxSizer *DisplaySizer;
/// DOCME
wxSashWindow *Sash; wxSashWindow *Sash;
/// DOCME
ToggleBitmap *VerticalLink; ToggleBitmap *VerticalLink;
/// DOCME
wxButton *SplitButton; wxButton *SplitButton;
/// DOCME
wxButton *JoinButton; wxButton *JoinButton;
/// DOCME
ToggleBitmap *AutoScroll; ToggleBitmap *AutoScroll;
/// DOCME
ToggleBitmap *NextCommit; ToggleBitmap *NextCommit;
/// DOCME
ToggleBitmap *MedusaMode; ToggleBitmap *MedusaMode;
/// DOCME
ToggleBitmap *AutoCommit; ToggleBitmap *AutoCommit;
/// DOCME
ToggleBitmap *SpectrumMode; ToggleBitmap *SpectrumMode;
void OnScrollbar(wxScrollEvent &event); void OnScrollbar(wxScrollEvent &event);
@ -120,12 +160,26 @@ private:
void OnNextLineCommit(wxCommandEvent &event); void OnNextLineCommit(wxCommandEvent &event);
public: public:
/// DOCME
AudioDisplay *audioDisplay; AudioDisplay *audioDisplay;
/// DOCME
AudioKaraoke *audioKaraoke; AudioKaraoke *audioKaraoke;
/// DOCME
wxToggleButton *KaraokeButton; wxToggleButton *KaraokeButton;
/// DOCME
FrameMain *frameMain; FrameMain *frameMain;
/// DOCME
wxString audioName; wxString audioName;
/// DOCME
bool loaded; bool loaded;
/// DOCME
bool karaokeMode; bool karaokeMode;
AudioBox(wxWindow *parent); AudioBox(wxWindow *parent);
@ -138,6 +192,12 @@ public:
}; };
/// DOCME
/// @class FocusEvent
/// @brief DOCME
///
/// DOCME
class FocusEvent : public wxEvtHandler { class FocusEvent : public wxEvtHandler {
private: private:
@ -149,38 +209,95 @@ private:
/////// ///////
// IDs // IDs
enum { enum {
/// DOCME
Audio_Scrollbar = 1600, Audio_Scrollbar = 1600,
/// DOCME
Audio_Horizontal_Zoom, Audio_Horizontal_Zoom,
/// DOCME
Audio_Vertical_Zoom, Audio_Vertical_Zoom,
/// DOCME
Audio_Volume, Audio_Volume,
/// DOCME
Audio_Sash, Audio_Sash,
/// DOCME
Audio_Vertical_Link, Audio_Vertical_Link,
/// DOCME
Audio_Button_Play, Audio_Button_Play,
/// DOCME
Audio_Button_Stop, Audio_Button_Stop,
/// DOCME
Audio_Button_Prev, Audio_Button_Prev,
/// DOCME
Audio_Button_Next, Audio_Button_Next,
/// DOCME
Audio_Button_Play_500ms_Before, Audio_Button_Play_500ms_Before,
/// DOCME
Audio_Button_Play_500ms_After, Audio_Button_Play_500ms_After,
/// DOCME
Audio_Button_Play_500ms_First, Audio_Button_Play_500ms_First,
/// DOCME
Audio_Button_Play_500ms_Last, Audio_Button_Play_500ms_Last,
/// DOCME
Audio_Button_Play_Row, Audio_Button_Play_Row,
/// DOCME
Audio_Button_Play_To_End, Audio_Button_Play_To_End,
/// DOCME
Audio_Button_Commit, Audio_Button_Commit,
/// DOCME
Audio_Button_Karaoke, Audio_Button_Karaoke,
/// DOCME
Audio_Button_Goto, Audio_Button_Goto,
/// DOCME
Audio_Button_Join, Audio_Button_Join,
/// DOCME
Audio_Button_Split, Audio_Button_Split,
/// DOCME
Audio_Button_Leadin, Audio_Button_Leadin,
/// DOCME
Audio_Button_Leadout, Audio_Button_Leadout,
/// DOCME
Audio_Check_AutoCommit, Audio_Check_AutoCommit,
/// DOCME
Audio_Check_NextCommit, Audio_Check_NextCommit,
/// DOCME
Audio_Check_AutoGoto, Audio_Check_AutoGoto,
/// DOCME
Audio_Check_Medusa, Audio_Check_Medusa,
/// DOCME
Audio_Check_Spectrum Audio_Check_Spectrum
}; };
#endif #endif

View file

@ -67,13 +67,19 @@
#ifdef __WXMAC__ #ifdef __WXMAC__
/// DOCME
# define AudioDisplayWindowStyle wxWANTS_CHARS # define AudioDisplayWindowStyle wxWANTS_CHARS
#else #else
/// DOCME
# define AudioDisplayWindowStyle wxSUNKEN_BORDER | wxWANTS_CHARS # define AudioDisplayWindowStyle wxSUNKEN_BORDER | wxWANTS_CHARS
#endif #endif
///////////////
// Constructor /// @brief Constructor
/// @param parent
///
AudioDisplay::AudioDisplay(wxWindow *parent) AudioDisplay::AudioDisplay(wxWindow *parent)
: wxWindow (parent, -1, wxDefaultPosition, wxSize(200,Options.AsInt(_T("Audio Display Height"))), AudioDisplayWindowStyle , _T("Audio Display")) : wxWindow (parent, -1, wxDefaultPosition, wxSize(200,Options.AsInt(_T("Audio Display Height"))), AudioDisplayWindowStyle , _T("Audio Display"))
{ {
@ -125,8 +131,9 @@ AudioDisplay::AudioDisplay(wxWindow *parent)
} }
//////////////
// Destructor /// @brief Destructor
///
AudioDisplay::~AudioDisplay() { AudioDisplay::~AudioDisplay() {
if (player) player->CloseStream(); if (player) player->CloseStream();
delete provider; delete provider;
@ -148,8 +155,9 @@ AudioDisplay::~AudioDisplay() {
} }
/////////
// Reset /// @brief Reset
///
void AudioDisplay::Reset() { void AudioDisplay::Reset() {
wxLogDebug(_T("AudioDisplay::Reset")); wxLogDebug(_T("AudioDisplay::Reset"));
hasSel = false; hasSel = false;
@ -163,8 +171,10 @@ void AudioDisplay::Reset() {
} }
////////////////
// Update image /// @brief Update image
/// @param weak
///
void AudioDisplay::UpdateImage(bool weak) { void AudioDisplay::UpdateImage(bool weak) {
// Update samples // Update samples
UpdateSamples(); UpdateSamples();
@ -177,6 +187,10 @@ void AudioDisplay::UpdateImage(bool weak) {
Refresh(false); Refresh(false);
} }
/// @brief DOCME
/// @return
///
void AudioDisplay::DoUpdateImage() { void AudioDisplay::DoUpdateImage() {
// Loaded? // Loaded?
if (!loaded || !provider) return; if (!loaded || !provider) return;
@ -397,8 +411,11 @@ void AudioDisplay::DoUpdateImage() {
} }
///////////////////////
// Draw Inactive Lines /// @brief Draw Inactive Lines
/// @param dc
/// @return
///
void AudioDisplay::DrawInactiveLines(wxDC &dc) { void AudioDisplay::DrawInactiveLines(wxDC &dc) {
// Check if there is anything to do // Check if there is anything to do
int shadeType = Options.AsInt(_T("Audio Inactive Lines Display Mode")); int shadeType = Options.AsInt(_T("Audio Inactive Lines Display Mode"));
@ -471,8 +488,10 @@ void AudioDisplay::DrawInactiveLines(wxDC &dc) {
} }
//////////////////
// Draw keyframes /// @brief Draw keyframes
/// @param dc
///
void AudioDisplay::DrawKeyframes(wxDC &dc) { void AudioDisplay::DrawKeyframes(wxDC &dc) {
wxArrayInt KeyFrames = VideoContext::Get()->GetKeyFrames(); wxArrayInt KeyFrames = VideoContext::Get()->GetKeyFrames();
int nKeys = (int)KeyFrames.Count(); int nKeys = (int)KeyFrames.Count();
@ -494,8 +513,10 @@ void AudioDisplay::DrawKeyframes(wxDC &dc) {
} }
//////////////////
// Draw timescale /// @brief Draw timescale
/// @param dc
///
void AudioDisplay::DrawTimescale(wxDC &dc) { void AudioDisplay::DrawTimescale(wxDC &dc) {
// Set size // Set size
int timelineHeight = Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0; int timelineHeight = Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0;
@ -559,8 +580,11 @@ void AudioDisplay::DrawTimescale(wxDC &dc) {
} }
////////////
// Waveform /// @brief Waveform
/// @param dc
/// @param weak
///
void AudioDisplay::DrawWaveform(wxDC &dc,bool weak) { void AudioDisplay::DrawWaveform(wxDC &dc,bool weak) {
// Prepare Waveform // Prepare Waveform
if (!weak || peak == NULL || min == NULL) { if (!weak || peak == NULL || min == NULL) {
@ -601,8 +625,11 @@ void AudioDisplay::DrawWaveform(wxDC &dc,bool weak) {
} }
//////////////////////////
// Draw spectrum analyzer /// @brief Draw spectrum analyzer
/// @param finaldc
/// @param weak
///
void AudioDisplay::DrawSpectrum(wxDC &finaldc,bool weak) { void AudioDisplay::DrawSpectrum(wxDC &finaldc,bool weak) {
if (!weak || !spectrumDisplay || spectrumDisplay->GetWidth() != w || spectrumDisplay->GetHeight() != h) { if (!weak || !spectrumDisplay || spectrumDisplay->GetWidth() != w || spectrumDisplay->GetHeight() != h) {
if (spectrumDisplay) { if (spectrumDisplay) {
@ -653,8 +680,12 @@ void AudioDisplay::DrawSpectrum(wxDC &finaldc,bool weak) {
} }
} }
//////////////////////////
// Get selection position /// @brief Get selection position
/// @param selStart
/// @param selEnd
/// @param cap
///
void AudioDisplay::GetDialoguePos(int64_t &selStart,int64_t &selEnd, bool cap) { void AudioDisplay::GetDialoguePos(int64_t &selStart,int64_t &selEnd, bool cap) {
selStart = GetXAtMS(curStartMS); selStart = GetXAtMS(curStartMS);
selEnd = GetXAtMS(curEndMS); selEnd = GetXAtMS(curEndMS);
@ -668,8 +699,12 @@ void AudioDisplay::GetDialoguePos(int64_t &selStart,int64_t &selEnd, bool cap) {
} }
////////////////////////
// Get karaoke position /// @brief Get karaoke position
/// @param karStart
/// @param karEnd
/// @param cap
///
void AudioDisplay::GetKaraokePos(int64_t &karStart,int64_t &karEnd, bool cap) { void AudioDisplay::GetKaraokePos(int64_t &karStart,int64_t &karEnd, bool cap) {
try { try {
// Wrap around // Wrap around
@ -698,8 +733,10 @@ void AudioDisplay::GetKaraokePos(int64_t &karStart,int64_t &karEnd, bool cap) {
} }
//////////
// Update /// @brief Update
/// @return
///
void AudioDisplay::Update() { void AudioDisplay::Update() {
if (blockUpdate) return; if (blockUpdate) return;
if (loaded) { if (loaded) {
@ -711,8 +748,9 @@ void AudioDisplay::Update() {
} }
//////////////////////
// Recreate the image /// @brief Recreate the image
///
void AudioDisplay::RecreateImage() { void AudioDisplay::RecreateImage() {
GetClientSize(&w,&h); GetClientSize(&w,&h);
h -= Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0; h -= Options.AsBool(_T("Audio Draw Timeline")) ? 20 : 0;
@ -722,8 +760,10 @@ void AudioDisplay::RecreateImage() {
} }
/////////////////////////
// Make dialogue visible /// @brief Make dialogue visible
/// @param force
///
void AudioDisplay::MakeDialogueVisible(bool force) { void AudioDisplay::MakeDialogueVisible(bool force) {
wxLogDebug(_T("AudioDisplay::MakeDialogueVisible(force=%d)"), force?1:0); wxLogDebug(_T("AudioDisplay::MakeDialogueVisible(force=%d)"), force?1:0);
// Variables // Variables
@ -756,8 +796,10 @@ void AudioDisplay::MakeDialogueVisible(bool force) {
} }
////////////////
// Set position /// @brief Set position
/// @param pos
///
void AudioDisplay::SetPosition(int pos) { void AudioDisplay::SetPosition(int pos) {
wxLogDebug(_T("AudioDisplay::SetPosition(pos=%d)"), pos); wxLogDebug(_T("AudioDisplay::SetPosition(pos=%d)"), pos);
Position = pos; Position = pos;
@ -766,8 +808,12 @@ void AudioDisplay::SetPosition(int pos) {
} }
///////////////////
// Update position /// @brief Update position
/// @param pos
/// @param IsSample
/// @return
///
void AudioDisplay::UpdatePosition (int pos,bool IsSample) { void AudioDisplay::UpdatePosition (int pos,bool IsSample) {
// Safeguards // Safeguards
if (!provider) return; if (!provider) return;
@ -783,9 +829,13 @@ void AudioDisplay::UpdatePosition (int pos,bool IsSample) {
} }
/////////////////////////////
// Set samples in percentage /// @brief Note: aka Horizontal Zoom Set samples in percentage
// Note: aka Horizontal Zoom /// @param percent
/// @param update
/// @param pivot
/// @return
///
void AudioDisplay::SetSamplesPercent(int percent,bool update,float pivot) { void AudioDisplay::SetSamplesPercent(int percent,bool update,float pivot) {
// Calculate // Calculate
if (percent < 1) percent = 1; if (percent < 1) percent = 1;
@ -810,8 +860,10 @@ void AudioDisplay::SetSamplesPercent(int percent,bool update,float pivot) {
} }
//////////////////
// Update samples /// @brief Update samples
/// @return
///
void AudioDisplay::UpdateSamples() { void AudioDisplay::UpdateSamples() {
// Set samples // Set samples
if (!provider) return; if (!provider) return;
@ -836,8 +888,11 @@ void AudioDisplay::UpdateSamples() {
} }
/////////////
// Set scale /// @brief Set scale
/// @param _scale
/// @return
///
void AudioDisplay::SetScale(float _scale) { void AudioDisplay::SetScale(float _scale) {
if (scale == _scale) return; if (scale == _scale) return;
scale = _scale; scale = _scale;
@ -845,8 +900,11 @@ void AudioDisplay::SetScale(float _scale) {
} }
//////////////////
// Load from file /// @brief Load from file
/// @param file
/// @return
///
void AudioDisplay::SetFile(wxString file) { void AudioDisplay::SetFile(wxString file) {
wxLogDebug(_T("AudioDisplay::SetFile(file=%s)"), file.c_str()); wxLogDebug(_T("AudioDisplay::SetFile(file=%s)"), file.c_str());
// Unload // Unload
@ -956,8 +1014,9 @@ void AudioDisplay::SetFile(wxString file) {
} }
///////////////////
// Load from video /// @brief Load from video
///
void AudioDisplay::SetFromVideo() { void AudioDisplay::SetFromVideo() {
wxLogDebug(_T("AudioDisplay::SetFromVideo")); wxLogDebug(_T("AudioDisplay::SetFromVideo"));
if (VideoContext::Get()->IsLoaded()) { if (VideoContext::Get()->IsLoaded()) {
@ -969,16 +1028,19 @@ void AudioDisplay::SetFromVideo() {
} }
////////////////
// Reload audio /// @brief Reload audio
///
void AudioDisplay::Reload() { void AudioDisplay::Reload() {
wxLogDebug(_T("AudioDisplay::Reload")); wxLogDebug(_T("AudioDisplay::Reload"));
if (provider) SetFile(provider->GetFilename()); if (provider) SetFile(provider->GetFilename());
} }
////////////////////
// Update scrollbar /// @brief Update scrollbar
/// @return
///
void AudioDisplay::UpdateScrollbar() { void AudioDisplay::UpdateScrollbar() {
if (!provider) return; if (!provider) return;
int page = w/12; int page = w/12;
@ -988,50 +1050,72 @@ void AudioDisplay::UpdateScrollbar() {
} }
//////////////////////////////////////////////
// Gets the sample number at the x coordinate /// @brief Gets the sample number at the x coordinate
/// @param x
/// @return
///
int64_t AudioDisplay::GetSampleAtX(int x) { int64_t AudioDisplay::GetSampleAtX(int x) {
return (x+Position)*samples; return (x+Position)*samples;
} }
/////////////////////////////////////////////////
// Gets the x coordinate corresponding to sample /// @brief Gets the x coordinate corresponding to sample
/// @param n
/// @return
///
int AudioDisplay::GetXAtSample(int64_t n) { int AudioDisplay::GetXAtSample(int64_t n) {
return samples ? (n/samples)-Position : 0; return samples ? (n/samples)-Position : 0;
} }
/////////////////
// Get MS from X /// @brief Get MS from X
/// @param x
/// @return
///
int AudioDisplay::GetMSAtX(int64_t x) { int AudioDisplay::GetMSAtX(int64_t x) {
return (PositionSample+(x*samples)) * 1000 / provider->GetSampleRate(); return (PositionSample+(x*samples)) * 1000 / provider->GetSampleRate();
} }
/////////////////
// Get X from MS /// @brief Get X from MS
/// @param ms
/// @return
///
int AudioDisplay::GetXAtMS(int64_t ms) { int AudioDisplay::GetXAtMS(int64_t ms) {
return ((ms * provider->GetSampleRate() / 1000)-PositionSample)/samples; return ((ms * provider->GetSampleRate() / 1000)-PositionSample)/samples;
} }
////////////////////
// Get MS At sample /// @brief Get MS At sample
/// @param x
/// @return
///
int AudioDisplay::GetMSAtSample(int64_t x) { int AudioDisplay::GetMSAtSample(int64_t x) {
return x * 1000 / provider->GetSampleRate(); return x * 1000 / provider->GetSampleRate();
} }
////////////////////
// Get Sample at MS /// @brief Get Sample at MS
/// @param ms
/// @return
///
int64_t AudioDisplay::GetSampleAtMS(int64_t ms) { int64_t AudioDisplay::GetSampleAtMS(int64_t ms) {
return ms * provider->GetSampleRate() / 1000; return ms * provider->GetSampleRate() / 1000;
} }
////////
// Play /// @brief Play
/// @param start
/// @param end
/// @return
///
void AudioDisplay::Play(int start,int end) { void AudioDisplay::Play(int start,int end) {
wxLogDebug(_T("AudioDisplay::Play")); wxLogDebug(_T("AudioDisplay::Play"));
Stop(); Stop();
@ -1092,8 +1176,9 @@ void AudioDisplay::Play(int start,int end) {
} }
////////
// Stop /// @brief Stop
///
void AudioDisplay::Stop() { void AudioDisplay::Stop() {
wxLogDebug(_T("AudioDisplay::Stop")); wxLogDebug(_T("AudioDisplay::Stop"));
if (VideoContext::Get()->IsPlaying()) VideoContext::Get()->Stop(); if (VideoContext::Get()->IsPlaying()) VideoContext::Get()->Stop();
@ -1101,8 +1186,12 @@ void AudioDisplay::Stop() {
} }
///////////////////////////
// Get samples of dialogue /// @brief Get samples of dialogue
/// @param start
/// @param end
/// @return
///
void AudioDisplay::GetTimesDialogue(int &start,int &end) { void AudioDisplay::GetTimesDialogue(int &start,int &end) {
wxLogDebug(_T("AudioDisplay::GetTimesDialogue")); wxLogDebug(_T("AudioDisplay::GetTimesDialogue"));
if (!dialogue) { if (!dialogue) {
@ -1116,8 +1205,12 @@ void AudioDisplay::GetTimesDialogue(int &start,int &end) {
} }
////////////////////////////
// Get samples of selection /// @brief Get samples of selection
/// @param start
/// @param end
/// @return
///
void AudioDisplay::GetTimesSelection(int &start,int &end) { void AudioDisplay::GetTimesSelection(int &start,int &end) {
wxLogDebug(_T("AudioDisplay::GetTimesSelection")); wxLogDebug(_T("AudioDisplay::GetTimesSelection"));
start = 0; start = 0;
@ -1140,8 +1233,11 @@ void AudioDisplay::GetTimesSelection(int &start,int &end) {
} }
/////////////////////////////
// Set the current selection /// @brief Set the current selection
/// @param start
/// @param end
///
void AudioDisplay::SetSelection(int start, int end) { void AudioDisplay::SetSelection(int start, int end) {
wxLogDebug(_T("AudioDisplay::SetSelection(start=%d, end=%d)"), start, end); wxLogDebug(_T("AudioDisplay::SetSelection(start=%d, end=%d)"), start, end);
curStartMS = start; curStartMS = start;
@ -1150,8 +1246,13 @@ void AudioDisplay::SetSelection(int start, int end) {
} }
////////////////
// Set dialogue /// @brief Set dialogue
/// @param _grid
/// @param diag
/// @param n
/// @return
///
void AudioDisplay::SetDialogue(SubtitlesGrid *_grid,AssDialogue *diag,int n) { void AudioDisplay::SetDialogue(SubtitlesGrid *_grid,AssDialogue *diag,int n) {
wxLogDebug(_T("AudioDisplay::SetDialogue")); wxLogDebug(_T("AudioDisplay::SetDialogue"));
// Actual parameters // Actual parameters
@ -1197,8 +1298,11 @@ void AudioDisplay::SetDialogue(SubtitlesGrid *_grid,AssDialogue *diag,int n) {
} }
//////////////////
// Commit changes /// @brief Commit changes
/// @param nextLine
/// @return
///
void AudioDisplay::CommitChanges (bool nextLine) { void AudioDisplay::CommitChanges (bool nextLine) {
wxLogDebug(_T("AudioDisplay::CommitChanges(nextLine=%d)"), nextLine?1:0); wxLogDebug(_T("AudioDisplay::CommitChanges(nextLine=%d)"), nextLine?1:0);
// Loaded? // Loaded?
@ -1311,8 +1415,11 @@ void AudioDisplay::CommitChanges (bool nextLine) {
} }
////////////
// Add lead /// @brief Add lead
/// @param in
/// @param out
///
void AudioDisplay::AddLead(bool in,bool out) { void AudioDisplay::AddLead(bool in,bool out) {
// Lead in // Lead in
if (in) { if (in) {
@ -1346,8 +1453,11 @@ BEGIN_EVENT_TABLE(AudioDisplay, wxWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
/////////
// Paint /// @brief Paint
/// @param event
/// @return
///
void AudioDisplay::OnPaint(wxPaintEvent& event) { void AudioDisplay::OnPaint(wxPaintEvent& event) {
if (w == 0 || h == 0) return; if (w == 0 || h == 0) return;
DoUpdateImage(); DoUpdateImage();
@ -1357,8 +1467,11 @@ void AudioDisplay::OnPaint(wxPaintEvent& event) {
} }
///////////////
// Mouse event /// @brief Mouse event
/// @param event
/// @return
///
void AudioDisplay::OnMouseEvent(wxMouseEvent& event) { void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
// Get x,y // Get x,y
int64_t x = event.GetX(); int64_t x = event.GetX();
@ -1764,8 +1877,14 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
} }
////////////////////////
// Get snap to boundary /// @brief Get snap to boundary
/// @param ms
/// @param rangeX
/// @param shiftHeld
/// @param start
/// @return
///
int AudioDisplay::GetBoundarySnap(int ms,int rangeX,bool shiftHeld,bool start) { int AudioDisplay::GetBoundarySnap(int ms,int rangeX,bool shiftHeld,bool start) {
// Range? // Range?
if (rangeX <= 0) return ms; if (rangeX <= 0) return ms;
@ -1954,8 +2073,10 @@ int AudioDisplay::GetBoundarySnap(int ms,int rangeX,bool shiftHeld,bool start) {
*/ */
//////////////
// Size event /// @brief Size event
/// @param event
///
void AudioDisplay::OnSize(wxSizeEvent &event) { void AudioDisplay::OnSize(wxSizeEvent &event) {
// Set size // Set size
GetClientSize(&w,&h); GetClientSize(&w,&h);
@ -1973,8 +2094,11 @@ void AudioDisplay::OnSize(wxSizeEvent &event) {
} }
///////////////
// Timer event /// @brief Timer event
/// @param event
/// @return
///
void AudioDisplay::OnUpdateTimer(wxTimerEvent &event) { void AudioDisplay::OnUpdateTimer(wxTimerEvent &event) {
if (!origImage) if (!origImage)
return; return;
@ -2060,8 +2184,10 @@ void AudioDisplay::OnUpdateTimer(wxTimerEvent &event) {
} }
////////////
// Key down /// @brief Key down
/// @param event
///
void AudioDisplay::OnKeyDown(wxKeyEvent &event) { void AudioDisplay::OnKeyDown(wxKeyEvent &event) {
int key = event.GetKeyCode(); int key = event.GetKeyCode();
#ifdef __APPLE__ #ifdef __APPLE__
@ -2229,8 +2355,12 @@ void AudioDisplay::OnKeyDown(wxKeyEvent &event) {
} }
///////////////
// Change line /// @brief Change line
/// @param delta
/// @param block
/// @return
///
void AudioDisplay::ChangeLine(int delta, bool block) { void AudioDisplay::ChangeLine(int delta, bool block) {
wxLogDebug(_T("AudioDisplay::ChangeLine(delta=%d)"), delta); wxLogDebug(_T("AudioDisplay::ChangeLine(delta=%d)"), delta);
if (dialogue) { if (dialogue) {
@ -2258,8 +2388,11 @@ void AudioDisplay::ChangeLine(int delta, bool block) {
} }
////////
// Next /// @brief Next
/// @param play
/// @return
///
void AudioDisplay::Next(bool play) { void AudioDisplay::Next(bool play) {
wxLogDebug(_T("AudioDisplay::Next")); wxLogDebug(_T("AudioDisplay::Next"));
// Karaoke // Karaoke
@ -2313,8 +2446,11 @@ void AudioDisplay::Next(bool play) {
} }
////////////
// Previous /// @brief Previous
/// @param play
/// @return
///
void AudioDisplay::Prev(bool play) { void AudioDisplay::Prev(bool play) {
wxLogDebug(_T("AudioDisplay::Prev")); wxLogDebug(_T("AudioDisplay::Prev"));
// Karaoke // Karaoke
@ -2366,8 +2502,11 @@ void AudioDisplay::Prev(bool play) {
} }
///////////////////////////////
// Gets syllable at x position /// @brief Gets syllable at x position
/// @param x
/// @return
///
int AudioDisplay::GetSyllableAtX(int x) { int AudioDisplay::GetSyllableAtX(int x) {
if (!karaoke->enabled) return -1; if (!karaoke->enabled) return -1;
int ms = GetMSAtX(x); int ms = GetMSAtX(x);
@ -2386,8 +2525,10 @@ int AudioDisplay::GetSyllableAtX(int x) {
} }
////////////////
// Focus events /// @brief Focus events
/// @param event
///
void AudioDisplay::OnGetFocus(wxFocusEvent &event) { void AudioDisplay::OnGetFocus(wxFocusEvent &event) {
if (!hasFocus) { if (!hasFocus) {
hasFocus = true; hasFocus = true;
@ -2395,6 +2536,10 @@ void AudioDisplay::OnGetFocus(wxFocusEvent &event) {
} }
} }
/// @brief DOCME
/// @param event
///
void AudioDisplay::OnLoseFocus(wxFocusEvent &event) { void AudioDisplay::OnLoseFocus(wxFocusEvent &event) {
if (hasFocus && loaded) { if (hasFocus && loaded) {
hasFocus = false; hasFocus = false;
@ -2404,11 +2549,13 @@ void AudioDisplay::OnLoseFocus(wxFocusEvent &event) {
} }
//////////////////////////////
// Update time edit controls /// @brief Update time edit controls
///
void AudioDisplay::UpdateTimeEditCtrls() { void AudioDisplay::UpdateTimeEditCtrls() {
grid->editBox->StartTime->SetTime(curStartMS,true); grid->editBox->StartTime->SetTime(curStartMS,true);
grid->editBox->EndTime->SetTime(curEndMS,true); grid->editBox->EndTime->SetTime(curEndMS,true);
grid->editBox->Duration->SetTime(curEndMS-curStartMS,true); grid->editBox->Duration->SetTime(curEndMS-curStartMS,true);
} }

View file

@ -36,6 +36,8 @@
#ifndef AUDIO_DISPLAY_H #ifndef AUDIO_DISPLAY_H
/// DOCME
#define AUDIO_DISPLAY_H #define AUDIO_DISPLAY_H
@ -61,58 +63,146 @@ class VideoProvider;
class FrameMain; class FrameMain;
/////////////////
// Display class /// DOCME
/// @class AudioDisplay
/// @brief DOCME
///
/// DOCME
class AudioDisplay: public wxWindow { class AudioDisplay: public wxWindow {
friend class FrameMain; friend class FrameMain;
private: private:
/// DOCME
SubtitlesGrid *grid; SubtitlesGrid *grid;
/// DOCME
int line_n; int line_n;
/// DOCME
AssDialogue *dialogue; AssDialogue *dialogue;
/// DOCME
AudioSpectrum *spectrumRenderer; AudioSpectrum *spectrumRenderer;
/// DOCME
wxBitmap *origImage; wxBitmap *origImage;
/// DOCME
wxBitmap *spectrumDisplay; wxBitmap *spectrumDisplay;
/// DOCME
wxBitmap *spectrumDisplaySelected; wxBitmap *spectrumDisplaySelected;
/// DOCME
int64_t PositionSample; int64_t PositionSample;
/// DOCME
float scale; float scale;
/// DOCME
int samples; int samples;
/// DOCME
int64_t Position; int64_t Position;
/// DOCME
int samplesPercent; int samplesPercent;
/// DOCME
int oldCurPos; int oldCurPos;
/// DOCME
bool hasFocus; bool hasFocus;
/// DOCME
bool blockUpdate; bool blockUpdate;
/// DOCME
bool dontReadTimes; bool dontReadTimes;
/// DOCME
bool playingToEnd; bool playingToEnd;
/// DOCME
bool needImageUpdate; bool needImageUpdate;
/// DOCME
bool needImageUpdateWeak; bool needImageUpdateWeak;
/// DOCME
bool hasSel; bool hasSel;
/// DOCME
bool hasKaraoke; bool hasKaraoke;
/// DOCME
bool diagUpdated; bool diagUpdated;
/// DOCME
bool holding; bool holding;
/// DOCME
bool draggingScale; bool draggingScale;
/// DOCME
int64_t selStart; int64_t selStart;
/// DOCME
int64_t selEnd; int64_t selEnd;
/// DOCME
int64_t lineStart; int64_t lineStart;
/// DOCME
int64_t lineEnd; int64_t lineEnd;
/// DOCME
int64_t selStartCap; int64_t selStartCap;
/// DOCME
int64_t selEndCap; int64_t selEndCap;
/// DOCME
int hold; int hold;
/// DOCME
int lastX; int lastX;
/// DOCME
int lastDragX; int lastDragX;
/// DOCME
int curStartMS; int curStartMS;
/// DOCME
int curEndMS; int curEndMS;
/// DOCME
int holdSyl; int holdSyl;
/// DOCME
int *peak; int *peak;
/// DOCME
int *min; int *min;
/// DOCME
int scrubTime; int scrubTime;
/// DOCME
int64_t scrubLastPos; int64_t scrubLastPos;
/// DOCME
bool scrubbing; bool scrubbing;
/// DOCME
int scrubLastRate; int scrubLastRate;
void OnPaint(wxPaintEvent &event); void OnPaint(wxPaintEvent &event);
@ -138,17 +228,41 @@ private:
void DoUpdateImage(); void DoUpdateImage();
public: public:
/// DOCME
AudioProvider *provider; AudioProvider *provider;
/// DOCME
StreamAudioProvider *scrubProvider; StreamAudioProvider *scrubProvider;
/// DOCME
AudioPlayer *player; AudioPlayer *player;
/// DOCME
bool NeedCommit; bool NeedCommit;
/// DOCME
bool loaded; bool loaded;
/// DOCME
bool temporary; bool temporary;
/// DOCME
/// DOCME
int w,h; int w,h;
/// DOCME
AudioBox *box; AudioBox *box;
/// DOCME
AudioKaraoke *karaoke; AudioKaraoke *karaoke;
/// DOCME
wxScrollBar *ScrollBar; wxScrollBar *ScrollBar;
/// DOCME
wxTimer UpdateTimer; wxTimer UpdateTimer;
AudioDisplay(wxWindow *parent); AudioDisplay(wxWindow *parent);
@ -197,9 +311,12 @@ public:
/////// ///////
// IDs // IDs
enum { enum {
/// DOCME
Audio_Update_Timer = 1700 Audio_Update_Timer = 1700
}; };
#endif #endif

View file

@ -52,8 +52,9 @@
#include <algorithm> #include <algorithm>
/////////////////////
// Empty constructor /// @brief Empty constructor
///
AudioKaraokeSyllable::AudioKaraokeSyllable() AudioKaraokeSyllable::AudioKaraokeSyllable()
: AssKaraokeSyllable() : AssKaraokeSyllable()
, start_time(0), selected(false) , start_time(0), selected(false)
@ -61,8 +62,10 @@ AudioKaraokeSyllable::AudioKaraokeSyllable()
{ {
} }
//////////////////////////////
// Copy-from-base constructor /// @brief Copy-from-base constructor
/// @param base
///
AudioKaraokeSyllable::AudioKaraokeSyllable(const AssKaraokeSyllable &base) AudioKaraokeSyllable::AudioKaraokeSyllable(const AssKaraokeSyllable &base)
: AssKaraokeSyllable(base) : AssKaraokeSyllable(base)
, start_time(0), selected(false) , start_time(0), selected(false)
@ -72,8 +75,10 @@ AudioKaraokeSyllable::AudioKaraokeSyllable(const AssKaraokeSyllable &base)
///////////////
// Constructor /// @brief Constructor
/// @param parent
///
AudioKaraoke::AudioKaraoke(wxWindow *parent) AudioKaraoke::AudioKaraoke(wxWindow *parent)
: wxWindow (parent,-1,wxDefaultPosition,wxSize(10,5),wxTAB_TRAVERSAL|wxBORDER_SUNKEN) : wxWindow (parent,-1,wxDefaultPosition,wxSize(10,5),wxTAB_TRAVERSAL|wxBORDER_SUNKEN)
{ {
@ -87,15 +92,19 @@ AudioKaraoke::AudioKaraoke(wxWindow *parent)
} }
//////////////
// Destructor /// @brief Destructor
///
AudioKaraoke::~AudioKaraoke() { AudioKaraoke::~AudioKaraoke() {
delete workDiag; delete workDiag;
} }
//////////////////////
// Load from dialogue /// @brief Load from dialogue
/// @param _diag
/// @return
///
bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) { bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) {
wxLogDebug(_T("AudioKaraoke::LoadFromDialogue(diag=%p)"), _diag); wxLogDebug(_T("AudioKaraoke::LoadFromDialogue(diag=%p)"), _diag);
// Make sure we're not in splitting-mode // Make sure we're not in splitting-mode
@ -137,8 +146,10 @@ bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) {
} }
////////////////////
// Writes line back /// @brief Writes line back
/// @return
///
void AudioKaraoke::Commit() { void AudioKaraoke::Commit() {
wxLogDebug(_T("AudioKaraoke::Commit")); wxLogDebug(_T("AudioKaraoke::Commit"));
if (splitting) { if (splitting) {
@ -182,8 +193,10 @@ void AudioKaraoke::Commit() {
} }
//////////////////
// Autosplit line /// @brief Autosplit line
/// @return
///
void AudioKaraoke::AutoSplit() { void AudioKaraoke::AutoSplit() {
wxLogDebug(_T("AudioKaraoke::AutoSplit")); wxLogDebug(_T("AudioKaraoke::AutoSplit"));
@ -237,8 +250,11 @@ void AudioKaraoke::AutoSplit() {
} }
//////////////////////////////////
// Parses text to extract karaoke /// @brief Parses text to extract karaoke
/// @param curDiag
/// @return
///
bool AudioKaraoke::ParseDialogue(AssDialogue *curDiag) { bool AudioKaraoke::ParseDialogue(AssDialogue *curDiag) {
// parse the tagdata // parse the tagdata
AssKaraokeVector tempsyls; AssKaraokeVector tempsyls;
@ -268,8 +284,11 @@ bool AudioKaraoke::ParseDialogue(AssDialogue *curDiag) {
} }
////////////////
// Set syllable /// @brief Set syllable
/// @param n
/// @return
///
void AudioKaraoke::SetSyllable(int n) { void AudioKaraoke::SetSyllable(int n) {
wxLogDebug(_T("AudioKaraoke::SetSyllable(n=%d)"), n); wxLogDebug(_T("AudioKaraoke::SetSyllable(n=%d)"), n);
if (n == -1) n = syllables.size()-1; if (n == -1) n = syllables.size()-1;
@ -291,8 +310,10 @@ BEGIN_EVENT_TABLE(AudioKaraoke,wxWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
///////////////
// Paint event /// @brief Paint event
/// @param event
///
void AudioKaraoke::OnPaint(wxPaintEvent &event) { void AudioKaraoke::OnPaint(wxPaintEvent &event) {
// Get dimensions // Get dimensions
int w,h; int w,h;
@ -401,15 +422,20 @@ void AudioKaraoke::OnPaint(wxPaintEvent &event) {
} }
//////////////
// Size event /// @brief Size event
/// @param event
///
void AudioKaraoke::OnSize(wxSizeEvent &event) { void AudioKaraoke::OnSize(wxSizeEvent &event) {
Refresh(false); Refresh(false);
} }
///////////////
// Mouse event /// @brief Mouse event
/// @param event
/// @return
///
void AudioKaraoke::OnMouse(wxMouseEvent &event) { void AudioKaraoke::OnMouse(wxMouseEvent &event) {
// Get coordinates // Get coordinates
int x = event.GetX(); int x = event.GetX();
@ -542,8 +568,11 @@ void AudioKaraoke::OnMouse(wxMouseEvent &event) {
} }
//////////////////////////////
// Get Syllable at position X /// @brief Get Syllable at position X
/// @param x
/// @return
///
int AudioKaraoke::GetSylAtX(int x) { int AudioKaraoke::GetSylAtX(int x) {
int dx,dw; int dx,dw;
size_t syln = syllables.size(); size_t syln = syllables.size();
@ -558,8 +587,11 @@ int AudioKaraoke::GetSylAtX(int x) {
} }
/////////////////
// Set selection /// @brief Set selection
/// @param start
/// @param end
///
void AudioKaraoke::SetSelection(int start,int end) { void AudioKaraoke::SetSelection(int start,int end) {
wxLogDebug(_T("AudioKaraoke::SetSelection(start=%d, end=%d)"), start, end); wxLogDebug(_T("AudioKaraoke::SetSelection(start=%d, end=%d)"), start, end);
// Default end // Default end
@ -593,8 +625,10 @@ void AudioKaraoke::SetSelection(int start,int end) {
} }
//////////////////
// Join syllables /// @brief Join syllables
/// @return
///
void AudioKaraoke::Join() { void AudioKaraoke::Join() {
wxLogDebug(_T("AudioKaraoke::Join")); wxLogDebug(_T("AudioKaraoke::Join"));
// Variables // Variables
@ -638,8 +672,9 @@ void AudioKaraoke::Join() {
} }
////////////////////////
// Enter splitting-mode /// @brief Enter splitting-mode
///
void AudioKaraoke::BeginSplit() { void AudioKaraoke::BeginSplit() {
wxLogDebug(_T("AudioKaraoke::BeginSplit")); wxLogDebug(_T("AudioKaraoke::BeginSplit"));
splitting = true; splitting = true;
@ -650,8 +685,11 @@ void AudioKaraoke::BeginSplit() {
} }
////////////////////////////////////////////
// Leave splitting-mode, committing changes /// @brief Leave splitting-mode, committing changes
/// @param commit
/// @return
///
void AudioKaraoke::EndSplit(bool commit) { void AudioKaraoke::EndSplit(bool commit) {
wxLogDebug(_T("AudioKaraoke::EndSplit(commit=%d)"), commit?1:0); wxLogDebug(_T("AudioKaraoke::EndSplit(commit=%d)"), commit?1:0);
splitting = false; splitting = false;
@ -686,8 +724,11 @@ void AudioKaraoke::EndSplit(bool commit) {
} }
/////////////////////////////////////////////////
// Split a syllable using the pending_slits data /// @brief Split a syllable using the pending_slits data
/// @param n
/// @return
///
int AudioKaraoke::SplitSyl (unsigned int n) { int AudioKaraoke::SplitSyl (unsigned int n) {
wxLogDebug(_T("AudioKaraoke::SplitSyl(n=%u)"), n); wxLogDebug(_T("AudioKaraoke::SplitSyl(n=%u)"), n);
@ -755,8 +796,13 @@ int AudioKaraoke::SplitSyl (unsigned int n) {
} }
//////////////////////////////////
// Apply delta length to syllable /// @brief Apply delta length to syllable
/// @param n
/// @param delta
/// @param mode
/// @return
///
bool AudioKaraoke::SyllableDelta(int n,int delta,int mode) { bool AudioKaraoke::SyllableDelta(int n,int delta,int mode) {
wxLogDebug(_T("AudioKaraoke::SyllableDelta(n=%d, delta=%d, mode=%d)"), n, delta, mode); wxLogDebug(_T("AudioKaraoke::SyllableDelta(n=%d, delta=%d, mode=%d)"), n, delta, mode);
// Get syllable and next // Get syllable and next
@ -806,8 +852,10 @@ bool AudioKaraoke::SyllableDelta(int n,int delta,int mode) {
} }
////////////////////////////////
// Karaoke tag menu constructor /// @brief Karaoke tag menu constructor
/// @param _kara
///
AudioKaraokeTagMenu::AudioKaraokeTagMenu(AudioKaraoke *_kara) AudioKaraokeTagMenu::AudioKaraokeTagMenu(AudioKaraoke *_kara)
: wxMenu(_("Karaoke tag")) : wxMenu(_("Karaoke tag"))
, kara(_kara) , kara(_kara)
@ -833,8 +881,9 @@ AudioKaraokeTagMenu::AudioKaraokeTagMenu(AudioKaraoke *_kara)
} }
///////////////////////////////
// Karaoke tag menu destructor /// @brief Karaoke tag menu destructor
///
AudioKaraokeTagMenu::~AudioKaraokeTagMenu() { AudioKaraokeTagMenu::~AudioKaraokeTagMenu() {
} }
@ -846,8 +895,10 @@ BEGIN_EVENT_TABLE(AudioKaraokeTagMenu,wxMenu)
END_EVENT_TABLE() END_EVENT_TABLE()
//////////////////////////////////
// Karaoke tag menu event handler /// @brief Karaoke tag menu event handler
/// @param event
///
void AudioKaraokeTagMenu::OnSelectItem(wxCommandEvent &event) { void AudioKaraokeTagMenu::OnSelectItem(wxCommandEvent &event) {
// Select the new tag for the syllables // Select the new tag for the syllables
wxString newtag; wxString newtag;
@ -881,3 +932,4 @@ void AudioKaraokeTagMenu::OnSelectItem(wxCommandEvent &event) {

View file

@ -36,6 +36,8 @@
#ifndef AUDIO_KARAOKE_H #ifndef AUDIO_KARAOKE_H
/// DOCME
#define AUDIO_KARAOKE_H #define AUDIO_KARAOKE_H
@ -59,32 +61,60 @@ class AudioDisplay;
class AudioBox; class AudioBox;
class AudioKaraokeTagMenu; class AudioKaraokeTagMenu;
///////////////////////////////////
// Karaoke syllable with more info /// DOCME
struct AudioKaraokeSyllable : AssKaraokeSyllable { struct AudioKaraokeSyllable : AssKaraokeSyllable {
/// DOCME
int start_time; // centiseconds int start_time; // centiseconds
/// DOCME
bool selected; bool selected;
/// DOCME
std::vector<int> pending_splits; std::vector<int> pending_splits;
/// DOCME
int display_w; int display_w;
/// DOCME
int display_x; int display_x;
AudioKaraokeSyllable(); AudioKaraokeSyllable();
AudioKaraokeSyllable(const AssKaraokeSyllable &base); AudioKaraokeSyllable(const AssKaraokeSyllable &base);
}; };
/// DOCME
typedef std::vector<AudioKaraokeSyllable> AudioKaraokeVector; typedef std::vector<AudioKaraokeSyllable> AudioKaraokeVector;
/////////
// Class /// DOCME
/// @class AudioKaraoke
/// @brief DOCME
///
/// DOCME
class AudioKaraoke : public wxWindow { class AudioKaraoke : public wxWindow {
friend class AudioKaraokeTagMenu; friend class AudioKaraokeTagMenu;
private: private:
/// DOCME
AssDialogue *diag; AssDialogue *diag;
/// DOCME
AssDialogue *workDiag; AssDialogue *workDiag;
/// DOCME
int startClickSyl; int startClickSyl;
/// DOCME
bool must_rebuild; bool must_rebuild;
/// DOCME
int split_cursor_syl; int split_cursor_syl;
/// DOCME
int split_cursor_x; int split_cursor_x;
void AutoSplit(); void AutoSplit();
@ -98,13 +128,27 @@ private:
void OnMouse(wxMouseEvent &event); void OnMouse(wxMouseEvent &event);
public: public:
/// DOCME
AudioDisplay *display; AudioDisplay *display;
/// DOCME
AudioBox *box; AudioBox *box;
/// DOCME
int curSyllable; int curSyllable;
/// DOCME
int selectionCount; int selectionCount;
/// DOCME
bool enabled; bool enabled;
/// DOCME
bool splitting; bool splitting;
/// DOCME
AudioKaraokeVector syllables; AudioKaraokeVector syllables;
AudioKaraoke(wxWindow *parent); AudioKaraoke(wxWindow *parent);
@ -124,10 +168,16 @@ public:
}; };
///////////////
// Helper menu /// DOCME
/// @class AudioKaraokeTagMenu
/// @brief DOCME
///
/// DOCME
class AudioKaraokeTagMenu : public wxMenu { class AudioKaraokeTagMenu : public wxMenu {
private: private:
/// DOCME
AudioKaraoke *kara; AudioKaraoke *kara;
void OnSelectItem(wxCommandEvent &event); void OnSelectItem(wxCommandEvent &event);
@ -141,3 +191,4 @@ public:
#endif #endif

View file

@ -60,16 +60,18 @@
#endif #endif
///////////////
// Constructor /// @brief Constructor
///
AudioPlayer::AudioPlayer() { AudioPlayer::AudioPlayer() {
provider = NULL; provider = NULL;
displayTimer = NULL; displayTimer = NULL;
} }
//////////////
// Destructor /// @brief Destructor
///
AudioPlayer::~AudioPlayer() { AudioPlayer::~AudioPlayer() {
if (displayTimer) { if (displayTimer) {
displayTimer->Stop(); displayTimer->Stop();
@ -78,36 +80,45 @@ AudioPlayer::~AudioPlayer() {
} }
////////////////
// Set provider /// @brief Set provider
/// @param _provider
///
void AudioPlayer::SetProvider(AudioProvider *_provider) { void AudioPlayer::SetProvider(AudioProvider *_provider) {
provider = _provider; provider = _provider;
} }
////////////////
// Get provider /// @brief Get provider
/// @return
///
AudioProvider *AudioPlayer::GetProvider() { AudioProvider *AudioPlayer::GetProvider() {
return provider; return provider;
} }
/////////////
// Get mutex /// @brief Get mutex
/// @return
///
wxMutex *AudioPlayer::GetMutex() { wxMutex *AudioPlayer::GetMutex() {
return NULL; return NULL;
} }
/////////////
// Set timer /// @brief Set timer
/// @param timer
///
void AudioPlayer::SetDisplayTimer(wxTimer *timer) { void AudioPlayer::SetDisplayTimer(wxTimer *timer) {
displayTimer = timer; displayTimer = timer;
} }
/////////////////////
// Ask to stop later /// @brief Ask to stop later
///
void AudioPlayer::RequestStop() { void AudioPlayer::RequestStop() {
wxCommandEvent event(wxEVT_STOP_AUDIO, 1000); wxCommandEvent event(wxEVT_STOP_AUDIO, 1000);
event.SetEventObject(this); event.SetEventObject(this);
@ -123,13 +134,19 @@ BEGIN_EVENT_TABLE(AudioPlayer, wxEvtHandler)
EVT_COMMAND (1000, wxEVT_STOP_AUDIO, AudioPlayer::OnStopAudio) EVT_COMMAND (1000, wxEVT_STOP_AUDIO, AudioPlayer::OnStopAudio)
END_EVENT_TABLE() END_EVENT_TABLE()
/// @brief DOCME
/// @param event
///
void AudioPlayer::OnStopAudio(wxCommandEvent &event) { void AudioPlayer::OnStopAudio(wxCommandEvent &event) {
Stop(false); Stop(false);
} }
//////////////
// Get player /// @brief Get player
/// @return
///
AudioPlayer* AudioPlayerFactoryManager::GetAudioPlayer() { AudioPlayer* AudioPlayerFactoryManager::GetAudioPlayer() {
// List of providers // List of providers
wxArrayString list = GetFactoryList(Options.AsText(_T("Audio player"))); wxArrayString list = GetFactoryList(Options.AsText(_T("Audio player")));
@ -154,8 +171,9 @@ AudioPlayer* AudioPlayerFactoryManager::GetAudioPlayer() {
} }
//////////////////////////
// Register all factories /// @brief Register all factories
///
void AudioPlayerFactoryManager::RegisterProviders() { void AudioPlayerFactoryManager::RegisterProviders() {
#ifdef WITH_ALSA #ifdef WITH_ALSA
RegisterFactory(new AlsaPlayerFactory(),_T("ALSA")); RegisterFactory(new AlsaPlayerFactory(),_T("ALSA"));
@ -176,15 +194,17 @@ void AudioPlayerFactoryManager::RegisterProviders() {
} }
///////////////////////
// Clear all factories /// @brief Clear all factories
///
void AudioPlayerFactoryManager::ClearProviders() { void AudioPlayerFactoryManager::ClearProviders() {
ClearFactories(); ClearFactories();
} }
//////////
// Static /// DOCME
template <class AudioPlayerFactory> std::map<wxString,AudioPlayerFactory*>* FactoryManager<AudioPlayerFactory>::factories=NULL; template <class AudioPlayerFactory> std::map<wxString,AudioPlayerFactory*>* FactoryManager<AudioPlayerFactory>::factories=NULL;

View file

@ -52,8 +52,9 @@
#include "options.h" #include "options.h"
///////////////
// Constructor /// @brief Constructor
///
AlsaPlayer::AlsaPlayer() AlsaPlayer::AlsaPlayer()
{ {
volume = 1.0f; volume = 1.0f;
@ -64,16 +65,18 @@ AlsaPlayer::AlsaPlayer()
} }
//////////////
// Destructor /// @brief Destructor
///
AlsaPlayer::~AlsaPlayer() AlsaPlayer::~AlsaPlayer()
{ {
CloseStream(); CloseStream();
} }
///////////////
// Open stream /// @brief Open stream
///
void AlsaPlayer::OpenStream() void AlsaPlayer::OpenStream()
{ {
CloseStream(); CloseStream();
@ -102,6 +105,9 @@ void AlsaPlayer::OpenStream()
} }
/// @brief DOCME
///
void AlsaPlayer::SetUpHardware() void AlsaPlayer::SetUpHardware()
{ {
int dir; int dir;
@ -195,6 +201,9 @@ void AlsaPlayer::SetUpHardware()
} }
/// @brief DOCME
///
void AlsaPlayer::SetUpAsync() void AlsaPlayer::SetUpAsync()
{ {
// Prepare software params struct // Prepare software params struct
@ -231,8 +240,10 @@ void AlsaPlayer::SetUpAsync()
} }
////////////////
// Close stream /// @brief Close stream
/// @return
///
void AlsaPlayer::CloseStream() void AlsaPlayer::CloseStream()
{ {
if (!open) return; if (!open) return;
@ -250,8 +261,11 @@ void AlsaPlayer::CloseStream()
} }
////////
// Play /// @brief Play
/// @param start
/// @param count
///
void AlsaPlayer::Play(int64_t start,int64_t count) void AlsaPlayer::Play(int64_t start,int64_t count)
{ {
if (playing) { if (playing) {
@ -278,8 +292,11 @@ void AlsaPlayer::Play(int64_t start,int64_t count)
} }
////////
// Stop /// @brief Stop
/// @param timerToo
/// @return
///
void AlsaPlayer::Stop(bool timerToo) void AlsaPlayer::Stop(bool timerToo)
{ {
if (!open) return; if (!open) return;
@ -300,42 +317,60 @@ void AlsaPlayer::Stop(bool timerToo)
} }
/// @brief DOCME
/// @return
///
bool AlsaPlayer::IsPlaying() bool AlsaPlayer::IsPlaying()
{ {
return playing; return playing;
} }
///////////
// Set end /// @brief Set end
/// @param pos
///
void AlsaPlayer::SetEndPosition(int64_t pos) void AlsaPlayer::SetEndPosition(int64_t pos)
{ {
end_frame = pos; end_frame = pos;
} }
////////////////////////
// Set current position /// @brief Set current position
/// @param pos
///
void AlsaPlayer::SetCurrentPosition(int64_t pos) void AlsaPlayer::SetCurrentPosition(int64_t pos)
{ {
cur_frame = pos; cur_frame = pos;
} }
/// @brief DOCME
/// @return
///
int64_t AlsaPlayer::GetStartPosition() int64_t AlsaPlayer::GetStartPosition()
{ {
return start_frame; return start_frame;
} }
/// @brief DOCME
/// @return
///
int64_t AlsaPlayer::GetEndPosition() int64_t AlsaPlayer::GetEndPosition()
{ {
return end_frame; return end_frame;
} }
////////////////////////
// Get current position /// @brief Get current position
/// @return
///
int64_t AlsaPlayer::GetCurrentPosition() int64_t AlsaPlayer::GetCurrentPosition()
{ {
// FIXME: this should be based on not duration played but actual sample being heard // FIXME: this should be based on not duration played but actual sample being heard
@ -346,6 +381,10 @@ int64_t AlsaPlayer::GetCurrentPosition()
} }
/// @brief DOCME
/// @param pcm_callback
///
void AlsaPlayer::async_write_handler(snd_async_handler_t *pcm_callback) void AlsaPlayer::async_write_handler(snd_async_handler_t *pcm_callback)
{ {
// TODO: check for broken pipes in here and restore as needed // TODO: check for broken pipes in here and restore as needed
@ -393,3 +432,4 @@ void AlsaPlayer::async_write_handler(snd_async_handler_t *pcm_callback)
#endif // WITH_ALSA #endif // WITH_ALSA

View file

@ -50,30 +50,70 @@
#include "options.h" #include "options.h"
///////////////
// Alsa player /// DOCME
/// @class AlsaPlayer
/// @brief DOCME
///
/// DOCME
class AlsaPlayer : public AudioPlayer { class AlsaPlayer : public AudioPlayer {
private: private:
/// DOCME
bool open; bool open;
/// DOCME
volatile bool playing; volatile bool playing;
/// DOCME
volatile float volume; volatile float volume;
/// DOCME
volatile unsigned long start_frame; // first frame of playback volatile unsigned long start_frame; // first frame of playback
/// DOCME
volatile unsigned long cur_frame; // last written frame + 1 volatile unsigned long cur_frame; // last written frame + 1
/// DOCME
volatile unsigned long end_frame; // last frame to play volatile unsigned long end_frame; // last frame to play
/// DOCME
unsigned long bpf; // bytes per frame unsigned long bpf; // bytes per frame
/// DOCME
AudioProvider *provider; AudioProvider *provider;
/// DOCME
snd_pcm_t *pcm_handle; // device handle snd_pcm_t *pcm_handle; // device handle
/// DOCME
snd_pcm_stream_t stream; // stream direction snd_pcm_stream_t stream; // stream direction
/// DOCME
snd_async_handler_t *pcm_callback; snd_async_handler_t *pcm_callback;
/// DOCME
snd_pcm_format_t sample_format; snd_pcm_format_t sample_format;
/// DOCME
unsigned int rate; // sample rate of audio unsigned int rate; // sample rate of audio
/// DOCME
unsigned int real_rate; // actual sample rate played back unsigned int real_rate; // actual sample rate played back
/// DOCME
unsigned int period_len; // length of period in microseconds unsigned int period_len; // length of period in microseconds
/// DOCME
unsigned int buflen; // length of buffer in microseconds unsigned int buflen; // length of buffer in microseconds
/// DOCME
snd_pcm_uframes_t period; // size of period in frames snd_pcm_uframes_t period; // size of period in frames
/// DOCME
snd_pcm_uframes_t bufsize; // size of buffer in frames snd_pcm_uframes_t bufsize; // size of buffer in frames
void SetUpHardware(); void SetUpHardware();
@ -98,18 +138,35 @@ public:
void SetEndPosition(int64_t pos); void SetEndPosition(int64_t pos);
void SetCurrentPosition(int64_t pos); void SetCurrentPosition(int64_t pos);
/// @brief DOCME
/// @param vol
/// @return
///
void SetVolume(double vol) { volume = vol; } void SetVolume(double vol) { volume = vol; }
/// @brief DOCME
/// @return
///
double GetVolume() { return volume; } double GetVolume() { return volume; }
}; };
///////////
// Factory /// DOCME
/// @class AlsaPlayerFactory
/// @brief DOCME
///
/// DOCME
class AlsaPlayerFactory : public AudioPlayerFactory { class AlsaPlayerFactory : public AudioPlayerFactory {
public: public:
/// @brief DOCME
///
AudioPlayer *CreatePlayer() { return new AlsaPlayer(); } AudioPlayer *CreatePlayer() { return new AlsaPlayer(); }
}; };
#endif #endif

View file

@ -48,8 +48,9 @@
#include "audio_player_dsound.h" #include "audio_player_dsound.h"
///////////////
// Constructor /// @brief Constructor
///
DirectSoundPlayer::DirectSoundPlayer() { DirectSoundPlayer::DirectSoundPlayer() {
playing = false; playing = false;
volume = 1.0f; volume = 1.0f;
@ -64,15 +65,17 @@ DirectSoundPlayer::DirectSoundPlayer() {
} }
//////////////
// Destructor /// @brief Destructor
///
DirectSoundPlayer::~DirectSoundPlayer() { DirectSoundPlayer::~DirectSoundPlayer() {
CloseStream(); CloseStream();
} }
///////////////
// Open stream /// @brief Open stream
///
void DirectSoundPlayer::OpenStream() { void DirectSoundPlayer::OpenStream() {
// Get provider // Get provider
AudioProvider *provider = GetProvider(); AudioProvider *provider = GetProvider();
@ -123,8 +126,9 @@ void DirectSoundPlayer::OpenStream() {
} }
////////////////
// Close stream /// @brief Close stream
///
void DirectSoundPlayer::CloseStream() { void DirectSoundPlayer::CloseStream() {
// Stop it // Stop it
Stop(); Stop();
@ -143,8 +147,11 @@ void DirectSoundPlayer::CloseStream() {
} }
///////////////
// Fill buffer /// @brief Fill buffer
/// @param fill
/// @return
///
bool DirectSoundPlayer::FillBuffer(bool fill) { bool DirectSoundPlayer::FillBuffer(bool fill) {
if (playPos >= endPos) return false; if (playPos >= endPos) return false;
@ -231,8 +238,11 @@ RetryLock:
} }
////////
// Play /// @brief Play
/// @param start
/// @param count
///
void DirectSoundPlayer::Play(int64_t start,int64_t count) { void DirectSoundPlayer::Play(int64_t start,int64_t count) {
// Make sure that it's stopped // Make sure that it's stopped
Stop(); Stop();
@ -272,8 +282,10 @@ void DirectSoundPlayer::Play(int64_t start,int64_t count) {
} }
////////
// Stop /// @brief Stop
/// @param timerToo
///
void DirectSoundPlayer::Stop(bool timerToo) { void DirectSoundPlayer::Stop(bool timerToo) {
// Stop the thread // Stop the thread
if (thread) { if (thread) {
@ -302,23 +314,29 @@ void DirectSoundPlayer::Stop(bool timerToo) {
} }
///////////
// Set end /// @brief Set end
/// @param pos
///
void DirectSoundPlayer::SetEndPosition(int64_t pos) { void DirectSoundPlayer::SetEndPosition(int64_t pos) {
if (playing) endPos = pos; if (playing) endPos = pos;
} }
////////////////////////
// Set current position /// @brief Set current position
/// @param pos
///
void DirectSoundPlayer::SetCurrentPosition(int64_t pos) { void DirectSoundPlayer::SetCurrentPosition(int64_t pos) {
startPos = playPos = pos; startPos = playPos = pos;
startTime = GetTickCount(); startTime = GetTickCount();
} }
////////////////////////
// Get current position /// @brief Get current position
/// @return
///
int64_t DirectSoundPlayer::GetCurrentPosition() { int64_t DirectSoundPlayer::GetCurrentPosition() {
// Check if buffer is loaded // Check if buffer is loaded
if (!buffer || !playing) return 0; if (!buffer || !playing) return 0;
@ -331,23 +349,28 @@ int64_t DirectSoundPlayer::GetCurrentPosition() {
} }
//////////////////////
// Thread constructor /// @brief Thread constructor
/// @param par
///
DirectSoundPlayerThread::DirectSoundPlayerThread(DirectSoundPlayer *par) : wxThread(wxTHREAD_JOINABLE) { DirectSoundPlayerThread::DirectSoundPlayerThread(DirectSoundPlayer *par) : wxThread(wxTHREAD_JOINABLE) {
parent = par; parent = par;
stopnotify = CreateEvent(NULL, true, false, NULL); stopnotify = CreateEvent(NULL, true, false, NULL);
} }
/////////////////////
// Thread destructor /// @brief Thread destructor
///
DirectSoundPlayerThread::~DirectSoundPlayerThread() { DirectSoundPlayerThread::~DirectSoundPlayerThread() {
CloseHandle(stopnotify); CloseHandle(stopnotify);
} }
//////////////////////
// Thread entry point /// @brief Thread entry point
/// @return
///
wxThread::ExitCode DirectSoundPlayerThread::Entry() { wxThread::ExitCode DirectSoundPlayerThread::Entry() {
CoInitialize(0); CoInitialize(0);
@ -396,8 +419,9 @@ wxThread::ExitCode DirectSoundPlayerThread::Entry() {
} }
////////////////////////
// Stop playback thread /// @brief Stop playback thread
///
void DirectSoundPlayerThread::Stop() { void DirectSoundPlayerThread::Stop() {
// Increase the stopnotify by one, causing a wait for it to succeed // Increase the stopnotify by one, causing a wait for it to succeed
SetEvent(stopnotify); SetEvent(stopnotify);
@ -405,3 +429,4 @@ void DirectSoundPlayerThread::Stop() {
#endif // WITH_DIRECTSOUND #endif // WITH_DIRECTSOUND

View file

@ -54,11 +54,19 @@
class DirectSoundPlayer; class DirectSoundPlayer;
//////////
// Thread /// DOCME
/// @class DirectSoundPlayerThread
/// @brief DOCME
///
/// DOCME
class DirectSoundPlayerThread : public wxThread { class DirectSoundPlayerThread : public wxThread {
private: private:
/// DOCME
DirectSoundPlayer *parent; DirectSoundPlayer *parent;
/// DOCME
HANDLE stopnotify; HANDLE stopnotify;
public: public:
@ -85,27 +93,53 @@ All but GetPosition() set appropriate fields and then raise the parameters chang
*/ */
////////////////////
// Portaudio player /// DOCME
/// @class DirectSoundPlayer
/// @brief DOCME
///
/// DOCME
class DirectSoundPlayer : public AudioPlayer { class DirectSoundPlayer : public AudioPlayer {
friend class DirectSoundPlayerThread; friend class DirectSoundPlayerThread;
private: private:
/// DOCME
volatile bool playing; volatile bool playing;
/// DOCME
float volume; float volume;
/// DOCME
int offset; int offset;
/// DOCME
DWORD bufSize; DWORD bufSize;
/// DOCME
volatile int64_t playPos; volatile int64_t playPos;
/// DOCME
int64_t startPos; int64_t startPos;
/// DOCME
volatile int64_t endPos; volatile int64_t endPos;
/// DOCME
DWORD startTime; DWORD startTime;
/// DOCME
IDirectSound8 *directSound; IDirectSound8 *directSound;
/// DOCME
IDirectSoundBuffer8 *buffer; IDirectSoundBuffer8 *buffer;
bool FillBuffer(bool fill); bool FillBuffer(bool fill);
/// DOCME
DirectSoundPlayerThread *thread; DirectSoundPlayerThread *thread;
public: public:
@ -117,27 +151,56 @@ public:
void Play(int64_t start,int64_t count); void Play(int64_t start,int64_t count);
void Stop(bool timerToo=true); void Stop(bool timerToo=true);
/// @brief DOCME
/// @return
///
bool IsPlaying() { return playing; } bool IsPlaying() { return playing; }
/// @brief DOCME
/// @return
///
int64_t GetStartPosition() { return startPos; } int64_t GetStartPosition() { return startPos; }
/// @brief DOCME
/// @return
///
int64_t GetEndPosition() { return endPos; } int64_t GetEndPosition() { return endPos; }
int64_t GetCurrentPosition(); int64_t GetCurrentPosition();
void SetEndPosition(int64_t pos); void SetEndPosition(int64_t pos);
void SetCurrentPosition(int64_t pos); void SetCurrentPosition(int64_t pos);
/// @brief DOCME
/// @param vol
/// @return
///
void SetVolume(double vol) { volume = vol; } void SetVolume(double vol) { volume = vol; }
/// @brief DOCME
/// @return
///
double GetVolume() { return volume; } double GetVolume() { return volume; }
//wxMutex *GetMutex() { return &DSMutex; } //wxMutex *GetMutex() { return &DSMutex; }
}; };
///////////
// Factory /// DOCME
/// @class DirectSoundPlayerFactory
/// @brief DOCME
///
/// DOCME
class DirectSoundPlayerFactory : public AudioPlayerFactory { class DirectSoundPlayerFactory : public AudioPlayerFactory {
public: public:
/// @brief DOCME
///
AudioPlayer *CreatePlayer() { return new DirectSoundPlayer(); } AudioPlayer *CreatePlayer() { return new DirectSoundPlayer(); }
}; };
#endif #endif

View file

@ -53,19 +53,32 @@
#include "audio_player_dsound2.h" #include "audio_player_dsound2.h"
/// DOCME
struct COMInitialization { struct COMInitialization {
/// DOCME
bool inited; bool inited;
/// @brief DOCME
///
COMInitialization() COMInitialization()
{ {
inited = false; inited = false;
} }
/// @brief DOCME
///
~COMInitialization() ~COMInitialization()
{ {
if (inited) CoUninitialize(); if (inited) CoUninitialize();
} }
/// @brief DOCME
///
void Init() void Init()
{ {
if (!inited) if (!inited)
@ -79,24 +92,42 @@ struct COMInitialization {
template<class T> template<class T>
/// DOCME
struct COMObjectRetainer { struct COMObjectRetainer {
/// DOCME
T *obj; T *obj;
/// @brief DOCME
///
COMObjectRetainer() COMObjectRetainer()
{ {
obj = 0; obj = 0;
} }
/// @brief DOCME
/// @param _obj
///
COMObjectRetainer(T *_obj) COMObjectRetainer(T *_obj)
{ {
obj = _obj; obj = _obj;
} }
/// @brief DOCME
///
~COMObjectRetainer() ~COMObjectRetainer()
{ {
if (obj) obj->Release(); if (obj) obj->Release();
} }
/// @brief DOCME
/// @return
///
T * operator -> () T * operator -> ()
{ {
return obj; return obj;
@ -104,6 +135,12 @@ struct COMObjectRetainer {
}; };
/// DOCME
/// @class DirectSoundPlayer2Thread
/// @brief DOCME
///
/// DOCME
class DirectSoundPlayer2Thread { class DirectSoundPlayer2Thread {
static unsigned int __stdcall ThreadProc(void *parameter); static unsigned int __stdcall ThreadProc(void *parameter);
void Run(); void Run();
@ -112,32 +149,66 @@ class DirectSoundPlayer2Thread {
void CheckError(); void CheckError();
/// DOCME
HANDLE thread_handle; HANDLE thread_handle;
// Used to signal state-changes to thread // Used to signal state-changes to thread
HANDLE HANDLE
/// DOCME
event_start_playback, event_start_playback,
/// DOCME
event_stop_playback, event_stop_playback,
/// DOCME
event_update_end_time, event_update_end_time,
/// DOCME
event_set_volume, event_set_volume,
/// DOCME
event_kill_self; event_kill_self;
// Thread communicating back // Thread communicating back
HANDLE HANDLE
/// DOCME
thread_running, thread_running,
/// DOCME
is_playing, is_playing,
/// DOCME
error_happened; error_happened;
/// DOCME
wxChar *error_message; wxChar *error_message;
/// DOCME
double volume; double volume;
/// DOCME
int64_t start_frame; int64_t start_frame;
/// DOCME
int64_t end_frame; int64_t end_frame;
/// DOCME
int wanted_latency; int wanted_latency;
/// DOCME
int buffer_length; int buffer_length;
/// DOCME
DWORD last_playback_restart; DWORD last_playback_restart;
/// DOCME
AudioProvider *provider; AudioProvider *provider;
public: public:
@ -158,6 +229,11 @@ public:
}; };
/// @brief DOCME
/// @param parameter
/// @return
///
unsigned int __stdcall DirectSoundPlayer2Thread::ThreadProc(void *parameter) unsigned int __stdcall DirectSoundPlayer2Thread::ThreadProc(void *parameter)
{ {
static_cast<DirectSoundPlayer2Thread*>(parameter)->Run(); static_cast<DirectSoundPlayer2Thread*>(parameter)->Run();
@ -165,8 +241,14 @@ unsigned int __stdcall DirectSoundPlayer2Thread::ThreadProc(void *parameter)
} }
/// @brief DOCME
/// @return
///
void DirectSoundPlayer2Thread::Run() void DirectSoundPlayer2Thread::Run()
{ {
/// DOCME
#define REPORT_ERROR(msg) { error_message = _T("DirectSoundPlayer2Thread: ") _T(msg); SetEvent(error_happened); return; } #define REPORT_ERROR(msg) { error_message = _T("DirectSoundPlayer2Thread: ") _T(msg); SetEvent(error_happened); return; }
COMInitialization COM_library; COMInitialization COM_library;
@ -433,10 +515,22 @@ void DirectSoundPlayer2Thread::Run()
} }
} }
/// DOCME
#undef REPORT_ERROR #undef REPORT_ERROR
} }
/// @brief DOCME
/// @param buf1
/// @param buf1sz
/// @param buf2
/// @param buf2sz
/// @param input_frame
/// @param bfr
/// @return
///
DWORD DirectSoundPlayer2Thread::FillAndUnlockBuffers(void *buf1, DWORD buf1sz, void *buf2, DWORD buf2sz, int64_t &input_frame, IDirectSoundBuffer8 *bfr) DWORD DirectSoundPlayer2Thread::FillAndUnlockBuffers(void *buf1, DWORD buf1sz, void *buf2, DWORD buf2sz, int64_t &input_frame, IDirectSoundBuffer8 *bfr)
{ {
// Assume buffers have been locked and are ready to be filled // Assume buffers have been locked and are ready to be filled
@ -496,6 +590,10 @@ DWORD DirectSoundPlayer2Thread::FillAndUnlockBuffers(void *buf1, DWORD buf1sz, v
} }
/// @brief DOCME
/// @return
///
void DirectSoundPlayer2Thread::CheckError() void DirectSoundPlayer2Thread::CheckError()
{ {
try try
@ -525,6 +623,12 @@ void DirectSoundPlayer2Thread::CheckError()
} }
/// @brief DOCME
/// @param provider
/// @param _WantedLatency
/// @param _BufferLength
///
DirectSoundPlayer2Thread::DirectSoundPlayer2Thread(AudioProvider *provider, int _WantedLatency, int _BufferLength) DirectSoundPlayer2Thread::DirectSoundPlayer2Thread(AudioProvider *provider, int _WantedLatency, int _BufferLength)
{ {
event_start_playback = CreateEvent(0, FALSE, FALSE, 0); event_start_playback = CreateEvent(0, FALSE, FALSE, 0);
@ -558,6 +662,9 @@ DirectSoundPlayer2Thread::DirectSoundPlayer2Thread(AudioProvider *provider, int
} }
/// @brief DOCME
///
DirectSoundPlayer2Thread::~DirectSoundPlayer2Thread() DirectSoundPlayer2Thread::~DirectSoundPlayer2Thread()
{ {
SetEvent(event_kill_self); SetEvent(event_kill_self);
@ -565,6 +672,11 @@ DirectSoundPlayer2Thread::~DirectSoundPlayer2Thread()
} }
/// @brief DOCME
/// @param start
/// @param count
///
void DirectSoundPlayer2Thread::Play(int64_t start, int64_t count) void DirectSoundPlayer2Thread::Play(int64_t start, int64_t count)
{ {
CheckError(); CheckError();
@ -577,6 +689,9 @@ void DirectSoundPlayer2Thread::Play(int64_t start, int64_t count)
} }
/// @brief DOCME
///
void DirectSoundPlayer2Thread::Stop() void DirectSoundPlayer2Thread::Stop()
{ {
CheckError(); CheckError();
@ -585,6 +700,10 @@ void DirectSoundPlayer2Thread::Stop()
} }
/// @brief DOCME
/// @param new_end_frame
///
void DirectSoundPlayer2Thread::SetEndFrame(int64_t new_end_frame) void DirectSoundPlayer2Thread::SetEndFrame(int64_t new_end_frame)
{ {
CheckError(); CheckError();
@ -594,6 +713,10 @@ void DirectSoundPlayer2Thread::SetEndFrame(int64_t new_end_frame)
} }
/// @brief DOCME
/// @param new_volume
///
void DirectSoundPlayer2Thread::SetVolume(double new_volume) void DirectSoundPlayer2Thread::SetVolume(double new_volume)
{ {
CheckError(); CheckError();
@ -603,6 +726,10 @@ void DirectSoundPlayer2Thread::SetVolume(double new_volume)
} }
/// @brief DOCME
/// @return
///
bool DirectSoundPlayer2Thread::IsPlaying() bool DirectSoundPlayer2Thread::IsPlaying()
{ {
CheckError(); CheckError();
@ -625,6 +752,10 @@ bool DirectSoundPlayer2Thread::IsPlaying()
} }
/// @brief DOCME
/// @return
///
int64_t DirectSoundPlayer2Thread::GetStartFrame() int64_t DirectSoundPlayer2Thread::GetStartFrame()
{ {
CheckError(); CheckError();
@ -633,6 +764,10 @@ int64_t DirectSoundPlayer2Thread::GetStartFrame()
} }
/// @brief DOCME
/// @return
///
int64_t DirectSoundPlayer2Thread::GetCurrentFrame() int64_t DirectSoundPlayer2Thread::GetCurrentFrame()
{ {
CheckError(); CheckError();
@ -645,6 +780,10 @@ int64_t DirectSoundPlayer2Thread::GetCurrentFrame()
} }
/// @brief DOCME
/// @return
///
int64_t DirectSoundPlayer2Thread::GetEndFrame() int64_t DirectSoundPlayer2Thread::GetEndFrame()
{ {
CheckError(); CheckError();
@ -653,6 +792,10 @@ int64_t DirectSoundPlayer2Thread::GetEndFrame()
} }
/// @brief DOCME
/// @return
///
double DirectSoundPlayer2Thread::GetVolume() double DirectSoundPlayer2Thread::GetVolume()
{ {
CheckError(); CheckError();
@ -661,6 +804,10 @@ double DirectSoundPlayer2Thread::GetVolume()
} }
/// @brief DOCME
/// @return
///
bool DirectSoundPlayer2Thread::IsDead() bool DirectSoundPlayer2Thread::IsDead()
{ {
switch (WaitForSingleObject(thread_running, 0)) switch (WaitForSingleObject(thread_running, 0))
@ -676,6 +823,9 @@ bool DirectSoundPlayer2Thread::IsDead()
/// @brief DOCME
///
DirectSoundPlayer2::DirectSoundPlayer2() DirectSoundPlayer2::DirectSoundPlayer2()
{ {
thread = 0; thread = 0;
@ -692,12 +842,19 @@ DirectSoundPlayer2::DirectSoundPlayer2()
} }
/// @brief DOCME
///
DirectSoundPlayer2::~DirectSoundPlayer2() DirectSoundPlayer2::~DirectSoundPlayer2()
{ {
CloseStream(); CloseStream();
} }
/// @brief DOCME
/// @return
///
bool DirectSoundPlayer2::IsThreadAlive() bool DirectSoundPlayer2::IsThreadAlive()
{ {
if (!thread) return false; if (!thread) return false;
@ -713,6 +870,10 @@ bool DirectSoundPlayer2::IsThreadAlive()
} }
/// @brief DOCME
/// @return
///
void DirectSoundPlayer2::OpenStream() void DirectSoundPlayer2::OpenStream()
{ {
if (IsThreadAlive()) return; if (IsThreadAlive()) return;
@ -729,6 +890,10 @@ void DirectSoundPlayer2::OpenStream()
} }
/// @brief DOCME
/// @return
///
void DirectSoundPlayer2::CloseStream() void DirectSoundPlayer2::CloseStream()
{ {
if (!IsThreadAlive()) return; if (!IsThreadAlive()) return;
@ -745,6 +910,10 @@ void DirectSoundPlayer2::CloseStream()
} }
/// @brief DOCME
/// @param provider
///
void DirectSoundPlayer2::SetProvider(AudioProvider *provider) void DirectSoundPlayer2::SetProvider(AudioProvider *provider)
{ {
try try
@ -764,6 +933,11 @@ void DirectSoundPlayer2::SetProvider(AudioProvider *provider)
} }
/// @brief DOCME
/// @param start
/// @param count
///
void DirectSoundPlayer2::Play(int64_t start,int64_t count) void DirectSoundPlayer2::Play(int64_t start,int64_t count)
{ {
try try
@ -780,6 +954,10 @@ void DirectSoundPlayer2::Play(int64_t start,int64_t count)
} }
/// @brief DOCME
/// @param timerToo
///
void DirectSoundPlayer2::Stop(bool timerToo) void DirectSoundPlayer2::Stop(bool timerToo)
{ {
try try
@ -797,6 +975,10 @@ void DirectSoundPlayer2::Stop(bool timerToo)
} }
/// @brief DOCME
/// @return
///
bool DirectSoundPlayer2::IsPlaying() bool DirectSoundPlayer2::IsPlaying()
{ {
try try
@ -812,6 +994,10 @@ bool DirectSoundPlayer2::IsPlaying()
} }
/// @brief DOCME
/// @return
///
int64_t DirectSoundPlayer2::GetStartPosition() int64_t DirectSoundPlayer2::GetStartPosition()
{ {
try try
@ -827,6 +1013,10 @@ int64_t DirectSoundPlayer2::GetStartPosition()
} }
/// @brief DOCME
/// @return
///
int64_t DirectSoundPlayer2::GetEndPosition() int64_t DirectSoundPlayer2::GetEndPosition()
{ {
try try
@ -842,6 +1032,10 @@ int64_t DirectSoundPlayer2::GetEndPosition()
} }
/// @brief DOCME
/// @return
///
int64_t DirectSoundPlayer2::GetCurrentPosition() int64_t DirectSoundPlayer2::GetCurrentPosition()
{ {
try try
@ -857,6 +1051,10 @@ int64_t DirectSoundPlayer2::GetCurrentPosition()
} }
/// @brief DOCME
/// @param pos
///
void DirectSoundPlayer2::SetEndPosition(int64_t pos) void DirectSoundPlayer2::SetEndPosition(int64_t pos)
{ {
try try
@ -870,6 +1068,10 @@ void DirectSoundPlayer2::SetEndPosition(int64_t pos)
} }
/// @brief DOCME
/// @param pos
///
void DirectSoundPlayer2::SetCurrentPosition(int64_t pos) void DirectSoundPlayer2::SetCurrentPosition(int64_t pos)
{ {
try try
@ -883,6 +1085,10 @@ void DirectSoundPlayer2::SetCurrentPosition(int64_t pos)
} }
/// @brief DOCME
/// @param vol
///
void DirectSoundPlayer2::SetVolume(double vol) void DirectSoundPlayer2::SetVolume(double vol)
{ {
try try
@ -896,6 +1102,9 @@ void DirectSoundPlayer2::SetVolume(double vol)
} }
/// @brief DOCME
///
double DirectSoundPlayer2::GetVolume() double DirectSoundPlayer2::GetVolume()
{ {
try try
@ -913,3 +1122,4 @@ double DirectSoundPlayer2::GetVolume()
#endif // WITH_DIRECTSOUND #endif // WITH_DIRECTSOUND

View file

@ -43,11 +43,23 @@
class DirectSoundPlayer2Thread; class DirectSoundPlayer2Thread;
/// DOCME
/// @class DirectSoundPlayer2
/// @brief DOCME
///
/// DOCME
class DirectSoundPlayer2 : public AudioPlayer { class DirectSoundPlayer2 : public AudioPlayer {
/// DOCME
DirectSoundPlayer2Thread *thread; DirectSoundPlayer2Thread *thread;
protected: protected:
/// DOCME
int WantedLatency; int WantedLatency;
/// DOCME
int BufferLength; int BufferLength;
bool IsThreadAlive(); bool IsThreadAlive();
@ -76,10 +88,20 @@ public:
}; };
/// DOCME
/// @class DirectSoundPlayer2Factory
/// @brief DOCME
///
/// DOCME
class DirectSoundPlayer2Factory : public AudioPlayerFactory { class DirectSoundPlayer2Factory : public AudioPlayerFactory {
public: public:
/// @brief DOCME
///
AudioPlayer *CreatePlayer() { return new DirectSoundPlayer2(); } AudioPlayer *CreatePlayer() { return new DirectSoundPlayer2(); }
}; };
#endif #endif

View file

@ -54,8 +54,12 @@
class AudioProvider; class AudioProvider;
///////////////////
// Factory Manager /// DOCME
/// @class AudioPlayerFactoryManager
/// @brief DOCME
///
/// DOCME
class AudioPlayerFactoryManager : public FactoryManager<AudioPlayerFactory> { class AudioPlayerFactoryManager : public FactoryManager<AudioPlayerFactory> {
public: public:
static AudioPlayer *GetAudioPlayer(); static AudioPlayer *GetAudioPlayer();
@ -71,3 +75,4 @@ DECLARE_EVENT_TYPE(wxEVT_STOP_AUDIO, -1)

View file

@ -69,8 +69,9 @@
#endif #endif
///////////////
// Constructor /// @brief Constructor
///
OpenALPlayer::OpenALPlayer() OpenALPlayer::OpenALPlayer()
{ {
volume = 1.0f; volume = 1.0f;
@ -81,16 +82,18 @@ OpenALPlayer::OpenALPlayer()
} }
//////////////
// Destructor /// @brief Destructor
///
OpenALPlayer::~OpenALPlayer() OpenALPlayer::~OpenALPlayer()
{ {
CloseStream(); CloseStream();
} }
///////////////
// Open stream /// @brief Open stream
///
void OpenALPlayer::OpenStream() void OpenALPlayer::OpenStream()
{ {
CloseStream(); CloseStream();
@ -145,8 +148,10 @@ void OpenALPlayer::OpenStream()
} }
////////////////
// Close stream /// @brief Close stream
/// @return
///
void OpenALPlayer::CloseStream() void OpenALPlayer::CloseStream()
{ {
if (!open) return; if (!open) return;
@ -163,8 +168,11 @@ void OpenALPlayer::CloseStream()
} }
////////
// Play /// @brief Play
/// @param start
/// @param count
///
void OpenALPlayer::Play(int64_t start,int64_t count) void OpenALPlayer::Play(int64_t start,int64_t count)
{ {
if (playing) { if (playing) {
@ -197,8 +205,11 @@ void OpenALPlayer::Play(int64_t start,int64_t count)
} }
////////
// Stop /// @brief Stop
/// @param timerToo
/// @return
///
void OpenALPlayer::Stop(bool timerToo) void OpenALPlayer::Stop(bool timerToo)
{ {
if (!open) return; if (!open) return;
@ -221,6 +232,10 @@ void OpenALPlayer::Stop(bool timerToo)
} }
/// @brief DOCME
/// @param count
///
void OpenALPlayer::FillBuffers(ALsizei count) void OpenALPlayer::FillBuffers(ALsizei count)
{ {
wxLogDebug(_T("FillBuffers: count=%d, buffers_free=%d"), count, buffers_free); wxLogDebug(_T("FillBuffers: count=%d, buffers_free=%d"), count, buffers_free);
@ -259,6 +274,9 @@ void OpenALPlayer::FillBuffers(ALsizei count)
} }
/// @brief DOCME
///
void OpenALPlayer::Notify() void OpenALPlayer::Notify()
{ {
ALsizei newplayed; ALsizei newplayed;
@ -295,42 +313,59 @@ void OpenALPlayer::Notify()
} }
/// @brief DOCME
/// @return
///
bool OpenALPlayer::IsPlaying() bool OpenALPlayer::IsPlaying()
{ {
return playing; return playing;
} }
///////////
// Set end /// @brief Set end
/// @param pos
///
void OpenALPlayer::SetEndPosition(int64_t pos) void OpenALPlayer::SetEndPosition(int64_t pos)
{ {
end_frame = pos; end_frame = pos;
} }
////////////////////////
// Set current position /// @brief Set current position
/// @param pos
///
void OpenALPlayer::SetCurrentPosition(int64_t pos) void OpenALPlayer::SetCurrentPosition(int64_t pos)
{ {
cur_frame = pos; cur_frame = pos;
} }
/// @brief DOCME
/// @return
///
int64_t OpenALPlayer::GetStartPosition() int64_t OpenALPlayer::GetStartPosition()
{ {
return start_frame; return start_frame;
} }
/// @brief DOCME
/// @return
///
int64_t OpenALPlayer::GetEndPosition() int64_t OpenALPlayer::GetEndPosition()
{ {
return end_frame; return end_frame;
} }
////////////////////////
// Get current position /// @brief Get current position
///
int64_t OpenALPlayer::GetCurrentPosition() int64_t OpenALPlayer::GetCurrentPosition()
{ {
// FIXME: this should be based on not duration played but actual sample being heard // FIXME: this should be based on not duration played but actual sample being heard
@ -343,3 +378,4 @@ int64_t OpenALPlayer::GetCurrentPosition()
#endif // WITH_OPENAL #endif // WITH_OPENAL

View file

@ -61,33 +61,77 @@
#endif #endif
/////////////////
// OpenAL player /// DOCME
/// @class OpenALPlayer
/// @brief DOCME
///
/// DOCME
class OpenALPlayer : public AudioPlayer, wxTimer { class OpenALPlayer : public AudioPlayer, wxTimer {
private: private:
/// DOCME
bool open; bool open;
/// DOCME
volatile bool playing; volatile bool playing;
/// DOCME
volatile float volume; volatile float volume;
/// DOCME
static const ALsizei num_buffers = 8; static const ALsizei num_buffers = 8;
/// DOCME
ALsizei buffer_length; ALsizei buffer_length;
/// DOCME
ALsizei samplerate; ALsizei samplerate;
/// DOCME
volatile unsigned long start_frame; // first frame of playback volatile unsigned long start_frame; // first frame of playback
/// DOCME
volatile unsigned long cur_frame; // last written frame + 1 volatile unsigned long cur_frame; // last written frame + 1
/// DOCME
volatile unsigned long end_frame; // last frame to play volatile unsigned long end_frame; // last frame to play
/// DOCME
unsigned long bpf; // bytes per frame unsigned long bpf; // bytes per frame
/// DOCME
AudioProvider *provider; AudioProvider *provider;
/// DOCME
ALCdevice *device; // device handle ALCdevice *device; // device handle
/// DOCME
ALCcontext *context; // sound context ALCcontext *context; // sound context
/// DOCME
ALuint buffers[num_buffers]; // sound buffers ALuint buffers[num_buffers]; // sound buffers
/// DOCME
ALuint source; // playback source ALuint source; // playback source
/// DOCME
ALsizei buf_first_free; // index into buffers, first free (unqueued) buffer ALsizei buf_first_free; // index into buffers, first free (unqueued) buffer
/// DOCME
ALsizei buf_first_queued; // index into buffers, first queued (non-free) buffer ALsizei buf_first_queued; // index into buffers, first queued (non-free) buffer
/// DOCME
ALsizei buffers_free; // number of free buffers ALsizei buffers_free; // number of free buffers
/// DOCME
ALsizei buffers_played; ALsizei buffers_played;
/// DOCME
wxStopWatch playback_segment_timer; wxStopWatch playback_segment_timer;
void FillBuffers(ALsizei count); void FillBuffers(ALsizei count);
@ -112,18 +156,35 @@ public:
void SetEndPosition(int64_t pos); void SetEndPosition(int64_t pos);
void SetCurrentPosition(int64_t pos); void SetCurrentPosition(int64_t pos);
/// @brief DOCME
/// @param vol
/// @return
///
void SetVolume(double vol) { volume = vol; } void SetVolume(double vol) { volume = vol; }
/// @brief DOCME
/// @return
///
double GetVolume() { return volume; } double GetVolume() { return volume; }
}; };
///////////
// Factory /// DOCME
/// @class OpenALPlayerFactory
/// @brief DOCME
///
/// DOCME
class OpenALPlayerFactory : public AudioPlayerFactory { class OpenALPlayerFactory : public AudioPlayerFactory {
public: public:
/// @brief DOCME
///
AudioPlayer *CreatePlayer() { return new OpenALPlayer(); } AudioPlayer *CreatePlayer() { return new OpenALPlayer(); }
}; };
#endif #endif

View file

@ -51,13 +51,14 @@
// Uncomment to enable debug features. // Uncomment to enable debug features.
//#define PORTAUDIO_DEBUG //#define PORTAUDIO_DEBUG
/////////////////////
// Reference counter /// DOCME
int PortAudioPlayer::pa_refcount = 0; int PortAudioPlayer::pa_refcount = 0;
///////////////
// Constructor /// @brief Constructor
///
PortAudioPlayer::PortAudioPlayer() { PortAudioPlayer::PortAudioPlayer() {
// Initialize portaudio // Initialize portaudio
if (!pa_refcount) { if (!pa_refcount) {
@ -80,16 +81,18 @@ PortAudioPlayer::PortAudioPlayer() {
} }
//////////////
// Destructor /// @brief Destructor
///
PortAudioPlayer::~PortAudioPlayer() { PortAudioPlayer::~PortAudioPlayer() {
// Deinit portaudio // Deinit portaudio
if (!--pa_refcount) Pa_Terminate(); if (!--pa_refcount) Pa_Terminate();
} }
///////////////
// Open stream /// @brief Open stream
///
void PortAudioPlayer::OpenStream() { void PortAudioPlayer::OpenStream() {
// Open stream // Open stream
PaStreamParameters pa_output_p; PaStreamParameters pa_output_p;
@ -127,8 +130,9 @@ void PortAudioPlayer::OpenStream() {
} }
///////////////
// Close stream /// @brief Close stream
///
void PortAudioPlayer::CloseStream() { void PortAudioPlayer::CloseStream() {
try { try {
Stop(false); Stop(false);
@ -136,7 +140,10 @@ void PortAudioPlayer::CloseStream() {
} catch (...) {} } catch (...) {}
} }
// Called when the callback has finished.
/// @brief Called when the callback has finished.
/// @param userData
///
void PortAudioPlayer::paStreamFinishedCallback(void *userData) { void PortAudioPlayer::paStreamFinishedCallback(void *userData) {
PortAudioPlayer *player = (PortAudioPlayer *) userData; PortAudioPlayer *player = (PortAudioPlayer *) userData;
@ -150,8 +157,12 @@ void PortAudioPlayer::paStreamFinishedCallback(void *userData) {
} }
////////
// Play /// @brief Play
/// @param start
/// @param count
/// @return
///
void PortAudioPlayer::Play(int64_t start,int64_t count) { void PortAudioPlayer::Play(int64_t start,int64_t count) {
PaError err; PaError err;
@ -187,8 +198,10 @@ void PortAudioPlayer::Play(int64_t start,int64_t count) {
} }
////////
// Stop /// @brief Stop
/// @param timerToo
///
void PortAudioPlayer::Stop(bool timerToo) { void PortAudioPlayer::Stop(bool timerToo) {
//wxMutexLocker locker(PAMutex); //wxMutexLocker locker(PAMutex);
//softStop = false; //softStop = false;
@ -204,8 +217,16 @@ void PortAudioPlayer::Stop(bool timerToo) {
} }
//////////////////////
/// PortAudio callback /// @brief PortAudio callback
/// @param inputBuffer
/// @param outputBuffer
/// @param framesPerBuffer
/// @param timeInfo
/// @param statusFlags
/// @param userData
/// @return
///
int PortAudioPlayer::paCallback(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData) { int PortAudioPlayer::paCallback(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData) {
// Get provider // Get provider
@ -238,8 +259,10 @@ int PortAudioPlayer::paCallback(const void *inputBuffer, void *outputBuffer, uns
} }
////////////////////////
/// Get current stream position. /// @brief Get current stream position.
/// @return
///
int64_t PortAudioPlayer::GetCurrentPosition() int64_t PortAudioPlayer::GetCurrentPosition()
{ {
@ -261,9 +284,10 @@ int64_t PortAudioPlayer::GetCurrentPosition()
} }
///////////////
/// Return a list of available output devices. /// @brief @param Setting from config file. Return a list of available output devices.
/// @param Setting from config file. /// @param favorite
///
wxArrayString PortAudioPlayer::GetOutputDevices(wxString favorite) { wxArrayString PortAudioPlayer::GetOutputDevices(wxString favorite) {
wxArrayString list; wxArrayString list;
int devices = Pa_GetDeviceCount(); int devices = Pa_GetDeviceCount();
@ -284,3 +308,4 @@ wxArrayString PortAudioPlayer::GetOutputDevices(wxString favorite) {
#endif // WITH_PORTAUDIO #endif // WITH_PORTAUDIO

View file

@ -49,21 +49,44 @@ extern "C" {
////////////////////
// Portaudio player /// DOCME
/// @class PortAudioPlayer
/// @brief DOCME
///
/// DOCME
class PortAudioPlayer : public AudioPlayer { class PortAudioPlayer : public AudioPlayer {
private: private:
/// DOCME
static int pa_refcount; static int pa_refcount;
/// DOCME
wxMutex PAMutex; wxMutex PAMutex;
/// DOCME
volatile bool stopping; volatile bool stopping;
//bool softStop;
/// DOCME
bool playing; bool playing;
/// DOCME
float volume; float volume;
/// DOCME
volatile int64_t playPos; volatile int64_t playPos;
/// DOCME
volatile int64_t startPos; volatile int64_t startPos;
/// DOCME
volatile int64_t endPos; volatile int64_t endPos;
/// DOCME
void *stream; void *stream;
/// DOCME
PaTime paStart; PaTime paStart;
static int paCallback( static int paCallback(
@ -87,28 +110,69 @@ public:
void Play(int64_t start,int64_t count); void Play(int64_t start,int64_t count);
void Stop(bool timerToo=true); void Stop(bool timerToo=true);
/// @brief DOCME
/// @return
///
bool IsPlaying() { return playing; } bool IsPlaying() { return playing; }
/// @brief DOCME
/// @return
///
int64_t GetStartPosition() { return startPos; } int64_t GetStartPosition() { return startPos; }
/// @brief DOCME
/// @return
///
int64_t GetEndPosition() { return endPos; } int64_t GetEndPosition() { return endPos; }
int64_t GetCurrentPosition(); int64_t GetCurrentPosition();
/// @brief DOCME
/// @param pos
///
void SetEndPosition(int64_t pos) { endPos = pos; } void SetEndPosition(int64_t pos) { endPos = pos; }
/// @brief DOCME
/// @param pos
///
void SetCurrentPosition(int64_t pos) { playPos = pos; } void SetCurrentPosition(int64_t pos) { playPos = pos; }
/// @brief DOCME
/// @param vol
/// @return
///
void SetVolume(double vol) { volume = vol; } void SetVolume(double vol) { volume = vol; }
/// @brief DOCME
/// @return
///
double GetVolume() { return volume; } double GetVolume() { return volume; }
wxArrayString GetOutputDevices(wxString favorite); wxArrayString GetOutputDevices(wxString favorite);
/// @brief DOCME
/// @return
///
wxMutex *GetMutex() { return &PAMutex; } wxMutex *GetMutex() { return &PAMutex; }
}; };
///////////
// Factory /// DOCME
/// @class PortAudioPlayerFactory
/// @brief DOCME
///
/// DOCME
class PortAudioPlayerFactory : public AudioPlayerFactory { class PortAudioPlayerFactory : public AudioPlayerFactory {
public: public:
/// @brief DOCME
///
AudioPlayer *CreatePlayer() { return new PortAudioPlayer(); } AudioPlayer *CreatePlayer() { return new PortAudioPlayer(); }
}; };
#endif //ifdef WITH_PORTAUDIO #endif //ifdef WITH_PORTAUDIO

View file

@ -50,8 +50,9 @@
#include "options.h" #include "options.h"
///////////////
// Constructor /// @brief Constructor
///
PulseAudioPlayer::PulseAudioPlayer() PulseAudioPlayer::PulseAudioPlayer()
: context_notify(0, 1) : context_notify(0, 1)
, context_success(0, 1) , context_success(0, 1)
@ -65,16 +66,18 @@ PulseAudioPlayer::PulseAudioPlayer()
} }
//////////////
// Destructor /// @brief Destructor
///
PulseAudioPlayer::~PulseAudioPlayer() PulseAudioPlayer::~PulseAudioPlayer()
{ {
if (open) CloseStream(); if (open) CloseStream();
} }
///////////////
// Open stream /// @brief Open stream
///
void PulseAudioPlayer::OpenStream() void PulseAudioPlayer::OpenStream()
{ {
//printf("Opening PulseAudio stream\n"); //printf("Opening PulseAudio stream\n");
@ -171,8 +174,10 @@ void PulseAudioPlayer::OpenStream()
} }
////////////////
// Close stream /// @brief Close stream
/// @return
///
void PulseAudioPlayer::CloseStream() void PulseAudioPlayer::CloseStream()
{ {
if (!open) return; if (!open) return;
@ -193,8 +198,11 @@ void PulseAudioPlayer::CloseStream()
} }
////////
// Play /// @brief Play
/// @param start
/// @param count
///
void PulseAudioPlayer::Play(int64_t start,int64_t count) void PulseAudioPlayer::Play(int64_t start,int64_t count)
{ {
//printf("Starting PulseAudio playback\n"); //printf("Starting PulseAudio playback\n");
@ -247,8 +255,11 @@ void PulseAudioPlayer::Play(int64_t start,int64_t count)
} }
////////
// Stop /// @brief Stop
/// @param timerToo
/// @return
///
void PulseAudioPlayer::Stop(bool timerToo) void PulseAudioPlayer::Stop(bool timerToo)
{ {
if (!is_playing) return; if (!is_playing) return;
@ -281,42 +292,60 @@ void PulseAudioPlayer::Stop(bool timerToo)
} }
/// @brief DOCME
/// @return
///
bool PulseAudioPlayer::IsPlaying() bool PulseAudioPlayer::IsPlaying()
{ {
return is_playing; return is_playing;
} }
///////////
// Set end /// @brief Set end
/// @param pos
///
void PulseAudioPlayer::SetEndPosition(int64_t pos) void PulseAudioPlayer::SetEndPosition(int64_t pos)
{ {
end_frame = pos; end_frame = pos;
} }
////////////////////////
// Set current position /// @brief Set current position
/// @param pos
///
void PulseAudioPlayer::SetCurrentPosition(int64_t pos) void PulseAudioPlayer::SetCurrentPosition(int64_t pos)
{ {
cur_frame = pos; cur_frame = pos;
} }
/// @brief DOCME
/// @return
///
int64_t PulseAudioPlayer::GetStartPosition() int64_t PulseAudioPlayer::GetStartPosition()
{ {
return start_frame; return start_frame;
} }
/// @brief DOCME
/// @return
///
int64_t PulseAudioPlayer::GetEndPosition() int64_t PulseAudioPlayer::GetEndPosition()
{ {
return end_frame; return end_frame;
} }
////////////////////////
// Get current position /// @brief Get current position
/// @return
///
int64_t PulseAudioPlayer::GetCurrentPosition() int64_t PulseAudioPlayer::GetCurrentPosition()
{ {
if (!is_playing) return 0; if (!is_playing) return 0;
@ -333,7 +362,12 @@ int64_t PulseAudioPlayer::GetCurrentPosition()
} }
// Called by PA to notify about contetxt operation completion
/// @brief Called by PA to notify about contetxt operation completion
/// @param c
/// @param success
/// @param thread
///
void PulseAudioPlayer::pa_context_success(pa_context *c, int success, PulseAudioPlayer *thread) void PulseAudioPlayer::pa_context_success(pa_context *c, int success, PulseAudioPlayer *thread)
{ {
thread->context_success_val = success; thread->context_success_val = success;
@ -341,7 +375,11 @@ void PulseAudioPlayer::pa_context_success(pa_context *c, int success, PulseAudio
} }
// Called by PA to notify about other context-related stuff
/// @brief Called by PA to notify about other context-related stuff
/// @param c
/// @param thread
///
void PulseAudioPlayer::pa_context_notify(pa_context *c, PulseAudioPlayer *thread) void PulseAudioPlayer::pa_context_notify(pa_context *c, PulseAudioPlayer *thread)
{ {
thread->cstate = pa_context_get_state(thread->context); thread->cstate = pa_context_get_state(thread->context);
@ -349,7 +387,12 @@ void PulseAudioPlayer::pa_context_notify(pa_context *c, PulseAudioPlayer *thread
} }
// Called by PA when an operation completes
/// @brief Called by PA when an operation completes
/// @param p
/// @param success
/// @param thread
///
void PulseAudioPlayer::pa_stream_success(pa_stream *p, int success, PulseAudioPlayer *thread) void PulseAudioPlayer::pa_stream_success(pa_stream *p, int success, PulseAudioPlayer *thread)
{ {
thread->stream_success_val = success; thread->stream_success_val = success;
@ -357,7 +400,13 @@ void PulseAudioPlayer::pa_stream_success(pa_stream *p, int success, PulseAudioPl
} }
// Called by PA to request more data (and other things?)
/// @brief Called by PA to request more data (and other things?)
/// @param p
/// @param length
/// @param thread
/// @return
///
void PulseAudioPlayer::pa_stream_write(pa_stream *p, size_t length, PulseAudioPlayer *thread) void PulseAudioPlayer::pa_stream_write(pa_stream *p, size_t length, PulseAudioPlayer *thread)
{ {
if (!thread->is_playing) return; if (!thread->is_playing) return;
@ -391,7 +440,11 @@ void PulseAudioPlayer::pa_stream_write(pa_stream *p, size_t length, PulseAudioPl
} }
// Called by PA to notify about other stuff
/// @brief Called by PA to notify about other stuff
/// @param p
/// @param thread
///
void PulseAudioPlayer::pa_stream_notify(pa_stream *p, PulseAudioPlayer *thread) void PulseAudioPlayer::pa_stream_notify(pa_stream *p, PulseAudioPlayer *thread)
{ {
thread->sstate = pa_stream_get_state(thread->stream); thread->sstate = pa_stream_get_state(thread->stream);
@ -401,3 +454,4 @@ void PulseAudioPlayer::pa_stream_notify(pa_stream *p, PulseAudioPlayer *thread)
#endif // WITH_PULSEAUDIO #endif // WITH_PULSEAUDIO

View file

@ -55,35 +55,76 @@ class PulseAudioPlayer;
//////////////////////
// Pulse Audio player /// DOCME
/// @class PulseAudioPlayer
/// @brief DOCME
///
/// DOCME
class PulseAudioPlayer : public AudioPlayer { class PulseAudioPlayer : public AudioPlayer {
private: private:
/// DOCME
float volume; float volume;
/// DOCME
bool open; bool open;
/// DOCME
bool is_playing; bool is_playing;
// Audio data info
/// DOCME
volatile unsigned long start_frame; volatile unsigned long start_frame;
/// DOCME
volatile unsigned long cur_frame; volatile unsigned long cur_frame;
/// DOCME
volatile unsigned long end_frame; volatile unsigned long end_frame;
/// DOCME
unsigned long bpf; // bytes per frame unsigned long bpf; // bytes per frame
// Used for synchronising with async events
/// DOCME
wxSemaphore context_notify; wxSemaphore context_notify;
/// DOCME
wxSemaphore context_success; wxSemaphore context_success;
/// DOCME
volatile int context_success_val; volatile int context_success_val;
/// DOCME
wxSemaphore stream_notify; wxSemaphore stream_notify;
/// DOCME
wxSemaphore stream_success; wxSemaphore stream_success;
/// DOCME
volatile int stream_success_val; volatile int stream_success_val;
// PulseAudio data
/// DOCME
pa_threaded_mainloop *mainloop; // pulseaudio mainloop handle pa_threaded_mainloop *mainloop; // pulseaudio mainloop handle
/// DOCME
pa_context *context; // connection context pa_context *context; // connection context
/// DOCME
volatile pa_context_state_t cstate; volatile pa_context_state_t cstate;
/// DOCME
pa_stream *stream; pa_stream *stream;
/// DOCME
volatile pa_stream_state_t sstate; volatile pa_stream_state_t sstate;
/// DOCME
volatile pa_usec_t play_start_time; // timestamp when playback was started volatile pa_usec_t play_start_time; // timestamp when playback was started
/// DOCME
int paerror; int paerror;
// Called by PA to notify about contetxt operation completion // Called by PA to notify about contetxt operation completion
@ -114,18 +155,35 @@ public:
void SetEndPosition(int64_t pos); void SetEndPosition(int64_t pos);
void SetCurrentPosition(int64_t pos); void SetCurrentPosition(int64_t pos);
/// @brief DOCME
/// @param vol
/// @return
///
void SetVolume(double vol) { volume = vol; } void SetVolume(double vol) { volume = vol; }
/// @brief DOCME
/// @return
///
double GetVolume() { return volume; } double GetVolume() { return volume; }
}; };
///////////
// Factory /// DOCME
/// @class PulseAudioPlayerFactory
/// @brief DOCME
///
/// DOCME
class PulseAudioPlayerFactory : public AudioPlayerFactory { class PulseAudioPlayerFactory : public AudioPlayerFactory {
public: public:
/// @brief DOCME
///
AudioPlayer *CreatePlayer() { return new PulseAudioPlayer(); } AudioPlayer *CreatePlayer() { return new PulseAudioPlayer(); }
}; };
#endif #endif

View file

@ -58,58 +58,78 @@
#include "audio_display.h" #include "audio_display.h"
///////////////
// Constructor /// @brief Constructor
///
AudioProvider::AudioProvider() { AudioProvider::AudioProvider() {
raw = NULL; raw = NULL;
} }
//////////////
// Destructor /// @brief Destructor
///
AudioProvider::~AudioProvider() { AudioProvider::~AudioProvider() {
// Clear buffers // Clear buffers
delete[] raw; delete[] raw;
} }
//////////////////////////
// Get number of channels /// @brief Get number of channels
/// @return
///
int AudioProvider::GetChannels() { int AudioProvider::GetChannels() {
return channels; return channels;
} }
//////////////////////////
// Get number of samples /// @brief Get number of samples
/// @return
///
int64_t AudioProvider::GetNumSamples() { int64_t AudioProvider::GetNumSamples() {
return num_samples; return num_samples;
} }
///////////////////
// Get sample rate /// @brief Get sample rate
/// @return
///
int AudioProvider::GetSampleRate() { int AudioProvider::GetSampleRate() {
return sample_rate; return sample_rate;
} }
////////////////////////
// Get bytes per sample /// @brief Get bytes per sample
/// @return
///
int AudioProvider::GetBytesPerSample() { int AudioProvider::GetBytesPerSample() {
return bytes_per_sample; return bytes_per_sample;
} }
////////////////
// Get filename /// @brief Get filename
/// @return
///
wxString AudioProvider::GetFilename() { wxString AudioProvider::GetFilename() {
return filename; return filename;
} }
////////////////
// Get waveform /// @brief Get waveform
/// @param min
/// @param peak
/// @param start
/// @param w
/// @param h
/// @param samples
/// @param scale
///
void AudioProvider::GetWaveForm(int *min,int *peak,int64_t start,int w,int h,int samples,float scale) { void AudioProvider::GetWaveForm(int *min,int *peak,int64_t start,int w,int h,int samples,float scale) {
// Setup // Setup
int channels = GetChannels(); int channels = GetChannels();
@ -173,8 +193,14 @@ void AudioProvider::GetWaveForm(int *min,int *peak,int64_t start,int w,int h,int
} }
/////////////////////////
// Get audio with volume /// @brief Get audio with volume
/// @param buf
/// @param start
/// @param count
/// @param volume
/// @return
///
void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count, double volume) { void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count, double volume) {
try { try {
GetAudio(buf,start,count); GetAudio(buf,start,count);
@ -204,8 +230,12 @@ void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count,
} }
////////////////
// Get provider /// @brief Get provider
/// @param filename
/// @param cache
/// @return
///
AudioProvider *AudioProviderFactoryManager::GetAudioProvider(wxString filename, int cache) { AudioProvider *AudioProviderFactoryManager::GetAudioProvider(wxString filename, int cache) {
// Prepare provider // Prepare provider
AudioProvider *provider = NULL; AudioProvider *provider = NULL;
@ -274,8 +304,9 @@ AudioProvider *AudioProviderFactoryManager::GetAudioProvider(wxString filename,
} }
///////////////////////////
// Register all providers /// @brief Register all providers
///
void AudioProviderFactoryManager::RegisterProviders() { void AudioProviderFactoryManager::RegisterProviders() {
#ifdef WITH_AVISYNTH #ifdef WITH_AVISYNTH
RegisterFactory(new AvisynthAudioProviderFactory(),_T("Avisynth")); RegisterFactory(new AvisynthAudioProviderFactory(),_T("Avisynth"));
@ -289,14 +320,16 @@ void AudioProviderFactoryManager::RegisterProviders() {
} }
///////////////////////
// Clear all providers /// @brief Clear all providers
///
void AudioProviderFactoryManager::ClearProviders() { void AudioProviderFactoryManager::ClearProviders() {
ClearFactories(); ClearFactories();
} }
//////////
// Static /// DOCME
template <class AudioProviderFactory> std::map<wxString,AudioProviderFactory*>* FactoryManager<AudioProviderFactory>::factories=NULL; template <class AudioProviderFactory> std::map<wxString,AudioProviderFactory*>* FactoryManager<AudioProviderFactory>::factories=NULL;

View file

@ -51,8 +51,10 @@
#include "charset_conv.h" #include "charset_conv.h"
//////////////
// Constructor /// @brief Constructor
/// @param _filename
///
AvisynthAudioProvider::AvisynthAudioProvider(wxString _filename) { AvisynthAudioProvider::AvisynthAudioProvider(wxString _filename) {
filename = _filename; filename = _filename;
@ -66,23 +68,26 @@ AvisynthAudioProvider::AvisynthAudioProvider(wxString _filename) {
} }
//////////////
// Destructor /// @brief Destructor
///
AvisynthAudioProvider::~AvisynthAudioProvider() { AvisynthAudioProvider::~AvisynthAudioProvider() {
Unload(); Unload();
} }
////////////////
// Unload audio /// @brief Unload audio
///
void AvisynthAudioProvider::Unload() { void AvisynthAudioProvider::Unload() {
// Clean up avisynth // Clean up avisynth
clip = NULL; clip = NULL;
} }
////////////////////////////
// Load audio from avisynth /// @brief Load audio from avisynth
///
void AvisynthAudioProvider::OpenAVSAudio() { void AvisynthAudioProvider::OpenAVSAudio() {
// Set variables // Set variables
AVSValue script; AVSValue script;
@ -129,8 +134,10 @@ void AvisynthAudioProvider::OpenAVSAudio() {
} }
/////////////////////////
// Read from environment /// @brief Read from environment
/// @param _clip
///
void AvisynthAudioProvider::LoadFromClip(AVSValue _clip) { void AvisynthAudioProvider::LoadFromClip(AVSValue _clip) {
// Prepare avisynth // Prepare avisynth
AVSValue script; AVSValue script;
@ -171,14 +178,20 @@ void AvisynthAudioProvider::LoadFromClip(AVSValue _clip) {
} }
////////////////
// Get filename /// @brief Get filename
/// @return
///
wxString AvisynthAudioProvider::GetFilename() { wxString AvisynthAudioProvider::GetFilename() {
return filename; return filename;
} }
/////////////
// Get audio /// @brief Get audio
/// @param buf
/// @param start
/// @param count
///
void AvisynthAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) { void AvisynthAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
// Requested beyond the length of audio // Requested beyond the length of audio
if (start+count > num_samples) { if (start+count > num_samples) {
@ -208,3 +221,4 @@ void AvisynthAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
#endif #endif

View file

@ -44,11 +44,19 @@
#include "avisynth_wrap.h" #include "avisynth_wrap.h"
////////////////////////
// Audio provider class /// DOCME
/// @class AvisynthAudioProvider
/// @brief DOCME
///
/// DOCME
class AvisynthAudioProvider : public AudioProvider, public AviSynthWrapper { class AvisynthAudioProvider : public AudioProvider, public AviSynthWrapper {
private: private:
/// DOCME
wxString filename; wxString filename;
/// DOCME
PClip clip; PClip clip;
void LoadFromClip(AVSValue clip); void LoadFromClip(AVSValue clip);
@ -62,7 +70,10 @@ public:
wxString GetFilename(); wxString GetFilename();
// Only exists for x86 Windows, always delivers machine (little) endian
/// @brief // Only exists for x86 Windows, always delivers machine (little) endian
/// @return
///
bool AreSamplesNativeEndian() { return true; } bool AreSamplesNativeEndian() { return true; }
void GetAudio(void *buf, int64_t start, int64_t count); void GetAudio(void *buf, int64_t start, int64_t count);
@ -70,12 +81,21 @@ public:
}; };
///////////
// Factory /// DOCME
/// @class AvisynthAudioProviderFactory
/// @brief DOCME
///
/// DOCME
class AvisynthAudioProviderFactory : public AudioProviderFactory { class AvisynthAudioProviderFactory : public AudioProviderFactory {
public: public:
/// @brief DOCME
/// @param file
///
AudioProvider *CreateProvider(wxString file) { return new AvisynthAudioProvider(file); } AudioProvider *CreateProvider(wxString file) { return new AvisynthAudioProvider(file); }
}; };
#endif #endif

View file

@ -44,8 +44,10 @@
#include "aegisub_endian.h" #include "aegisub_endian.h"
///////////////
// Constructor /// @brief Constructor
/// @param src
///
ConvertAudioProvider::ConvertAudioProvider(AudioProvider *src) { ConvertAudioProvider::ConvertAudioProvider(AudioProvider *src) {
source = src; source = src;
channels = source->GetChannels(); channels = source->GetChannels();
@ -61,15 +63,20 @@ ConvertAudioProvider::ConvertAudioProvider(AudioProvider *src) {
} }
//////////////
// Destructor /// @brief Destructor
///
ConvertAudioProvider::~ConvertAudioProvider() { ConvertAudioProvider::~ConvertAudioProvider() {
delete source; delete source;
} }
/////////////////////
// Convert to 16-bit /// @brief Convert to 16-bit
/// @param src
/// @param dst
/// @param count
///
void ConvertAudioProvider::Make16Bit(const char *src, short *dst, int64_t count) { void ConvertAudioProvider::Make16Bit(const char *src, short *dst, int64_t count) {
for (int64_t i=0;i<count;i++) { for (int64_t i=0;i<count;i++) {
dst[i] = (short(src[i])-128)*255; dst[i] = (short(src[i])-128)*255;
@ -82,6 +89,13 @@ void ConvertAudioProvider::Make16Bit(const char *src, short *dst, int64_t count)
// This requres 16-bit input // This requres 16-bit input
// The SampleConverter is a class overloading operator() with a function from short to short // The SampleConverter is a class overloading operator() with a function from short to short
template<class SampleConverter> template<class SampleConverter>
/// @brief DOCME
/// @param src
/// @param dst
/// @param count
/// @param converter
///
void ConvertAudioProvider::ChangeSampleRate(const short *src, short *dst, int64_t count, const SampleConverter &converter) { void ConvertAudioProvider::ChangeSampleRate(const short *src, short *dst, int64_t count, const SampleConverter &converter) {
// Upsample by 2 // Upsample by 2
if (sampleMult == 2) { if (sampleMult == 2) {
@ -122,23 +136,39 @@ void ConvertAudioProvider::ChangeSampleRate(const short *src, short *dst, int64_
} }
// Do-nothing sample converter for ChangeSampleRate
/// DOCME
struct NullSampleConverter { struct NullSampleConverter {
/// @brief DOCME
/// @param val
/// @return
///
inline short operator()(const short val) const { inline short operator()(const short val) const {
return val; return val;
} }
}; };
// Endian-swapping sample converter for ChangeSampleRate
/// DOCME
struct EndianSwapSampleConverter { struct EndianSwapSampleConverter {
/// @brief DOCME
/// @param val
/// @return
///
inline short operator()(const short val) const { inline short operator()(const short val) const {
return (short)Endian::Reverse((uint16_t)val); return (short)Endian::Reverse((uint16_t)val);
}; };
}; };
/////////////
// Get audio /// @brief Get audio
/// @param destination
/// @param start
/// @param count
///
void ConvertAudioProvider::GetAudio(void *destination, int64_t start, int64_t count) { void ConvertAudioProvider::GetAudio(void *destination, int64_t start, int64_t count) {
// Bits per sample // Bits per sample
int srcBps = source->GetBytesPerSample(); int srcBps = source->GetBytesPerSample();
@ -189,7 +219,10 @@ void ConvertAudioProvider::GetAudio(void *destination, int64_t start, int64_t co
} }
} }
// See if we need to downmix the number of channels
/// @brief See if we need to downmix the number of channels
/// @param source_provider
///
AudioProvider *CreateConvertAudioProvider(AudioProvider *source_provider) { AudioProvider *CreateConvertAudioProvider(AudioProvider *source_provider) {
AudioProvider *provider = source_provider; AudioProvider *provider = source_provider;
@ -212,3 +245,4 @@ AudioProvider *CreateConvertAudioProvider(AudioProvider *source_provider) {
return provider; return provider;
} }

View file

@ -43,12 +43,20 @@
#include "include/aegisub/audio_provider.h" #include "include/aegisub/audio_provider.h"
////////////////////////
// Audio provider class /// DOCME
/// @class ConvertAudioProvider
/// @brief DOCME
///
/// DOCME
class ConvertAudioProvider : public AudioProvider { class ConvertAudioProvider : public AudioProvider {
private: private:
/// DOCME
int sampleMult; int sampleMult;
/// DOCME
AudioProvider *source; AudioProvider *source;
void Make16Bit(const char *src, short *dst, int64_t count); void Make16Bit(const char *src, short *dst, int64_t count);
template<class SampleConverter> template<class SampleConverter>
@ -58,14 +66,20 @@ public:
ConvertAudioProvider(AudioProvider *source); ConvertAudioProvider(AudioProvider *source);
~ConvertAudioProvider(); ~ConvertAudioProvider();
// By its nature, the ConvertAudioProvider always delivers machine endian:
// That's one of the points of it! /// @brief // That's one of the points of it! // By its nature, the ConvertAudioProvider always delivers machine endian:
/// @return
///
bool AreSamplesNativeEndian() { return true; } bool AreSamplesNativeEndian() { return true; }
void GetAudio(void *buf, int64_t start, int64_t count); void GetAudio(void *buf, int64_t start, int64_t count);
/// @brief DOCME
///
wxString GetFilename() { return source->GetFilename(); } wxString GetFilename() { return source->GetFilename(); }
}; };
AudioProvider *CreateConvertAudioProvider(AudioProvider *source_provider); AudioProvider *CreateConvertAudioProvider(AudioProvider *source_provider);

View file

@ -42,8 +42,10 @@
#include "audio_provider_downmix.h" #include "audio_provider_downmix.h"
//////////////////
// Constructor /// @brief Constructor
/// @param source
///
DownmixingAudioProvider::DownmixingAudioProvider(AudioProvider *source) { DownmixingAudioProvider::DownmixingAudioProvider(AudioProvider *source) {
filename = source->GetFilename(); filename = source->GetFilename();
channels = 1; // target channels = 1; // target
@ -61,14 +63,19 @@ DownmixingAudioProvider::DownmixingAudioProvider(AudioProvider *source) {
throw _T("Downmixing Audio Provider: Source must have machine endian samples"); throw _T("Downmixing Audio Provider: Source must have machine endian samples");
} }
/////////////////
// Destructor /// @brief Destructor
///
DownmixingAudioProvider::~DownmixingAudioProvider() { DownmixingAudioProvider::~DownmixingAudioProvider() {
delete provider; delete provider;
} }
////////////////
// Actual work happens here /// @brief Actual work happens here
/// @param buf
/// @param start
/// @param count
///
void DownmixingAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) { void DownmixingAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
if (count == 0) return; if (count == 0) return;
@ -123,3 +130,4 @@ void DownmixingAudioProvider::GetAudio(void *buf, int64_t start, int64_t count)
delete[] tmp; delete[] tmp;
} }

View file

@ -36,16 +36,28 @@
#include "include/aegisub/audio_provider.h" #include "include/aegisub/audio_provider.h"
/// DOCME
/// @class DownmixingAudioProvider
/// @brief DOCME
///
/// DOCME
class DownmixingAudioProvider : public AudioProvider { class DownmixingAudioProvider : public AudioProvider {
private: private:
/// DOCME
AudioProvider *provider; AudioProvider *provider;
/// DOCME
int src_channels; int src_channels;
public: public:
DownmixingAudioProvider(AudioProvider *source); DownmixingAudioProvider(AudioProvider *source);
~DownmixingAudioProvider(); ~DownmixingAudioProvider();
// Downmixing requires samples to be native endian beforehand
/// @brief // Downmixing requires samples to be native endian beforehand
///
bool AreSamplesNativeEndian() { return true; } bool AreSamplesNativeEndian() { return true; }
void GetAudio(void *buf, int64_t start, int64_t count); void GetAudio(void *buf, int64_t start, int64_t count);
@ -53,3 +65,4 @@ public:
}; };

View file

@ -43,8 +43,11 @@
#include "utils.h" #include "utils.h"
///////////////
// Constructor /// @brief Constructor
/// @param dur_ms
/// @param _noise
///
DummyAudioProvider::DummyAudioProvider(unsigned long dur_ms, bool _noise) { DummyAudioProvider::DummyAudioProvider(unsigned long dur_ms, bool _noise) {
noise = _noise; noise = _noise;
channels = 1; channels = 1;
@ -54,14 +57,19 @@ DummyAudioProvider::DummyAudioProvider(unsigned long dur_ms, bool _noise) {
} }
//////////////
// Destructor /// @brief Destructor
///
DummyAudioProvider::~DummyAudioProvider() { DummyAudioProvider::~DummyAudioProvider() {
} }
/////////////
// Get audio /// @brief Get audio
/// @param buf
/// @param start
/// @param count
///
void DummyAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) { void DummyAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
short *workbuf = (short*)buf; short *workbuf = (short*)buf;
@ -75,3 +83,4 @@ void DummyAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
} }
} }

View file

@ -43,18 +43,28 @@
#include "include/aegisub/audio_provider.h" #include "include/aegisub/audio_provider.h"
////////////////////////
// Audio provider class /// DOCME
/// @class DummyAudioProvider
/// @brief DOCME
///
/// DOCME
class DummyAudioProvider : public AudioProvider { class DummyAudioProvider : public AudioProvider {
private: private:
/// DOCME
bool noise; bool noise;
public: public:
DummyAudioProvider(unsigned long dur_ms, bool _noise); DummyAudioProvider(unsigned long dur_ms, bool _noise);
~DummyAudioProvider(); ~DummyAudioProvider();
/// @brief DOCME
///
bool AreSamplesNativeEndian() { return true; } bool AreSamplesNativeEndian() { return true; }
void GetAudio(void *buf, int64_t start, int64_t count); void GetAudio(void *buf, int64_t start, int64_t count);
}; };

View file

@ -49,8 +49,10 @@
#endif #endif
///////////
// Constructor /// @brief Constructor
/// @param filename
///
FFmpegSourceAudioProvider::FFmpegSourceAudioProvider(wxString filename) { FFmpegSourceAudioProvider::FFmpegSourceAudioProvider(wxString filename) {
COMInited = false; COMInited = false;
#ifdef WIN32 #ifdef WIN32
@ -79,8 +81,10 @@ FFmpegSourceAudioProvider::FFmpegSourceAudioProvider(wxString filename) {
} }
///////////
// Load audio file /// @brief Load audio file
/// @param filename
///
void FFmpegSourceAudioProvider::LoadAudio(wxString filename) { void FFmpegSourceAudioProvider::LoadAudio(wxString filename) {
// clean up // clean up
Close(); Close();
@ -198,8 +202,9 @@ void FFmpegSourceAudioProvider::LoadAudio(wxString filename) {
} }
///////////
// Destructor /// @brief Destructor
///
FFmpegSourceAudioProvider::~FFmpegSourceAudioProvider() { FFmpegSourceAudioProvider::~FFmpegSourceAudioProvider() {
Close(); Close();
#ifdef WIN32 #ifdef WIN32
@ -209,16 +214,21 @@ FFmpegSourceAudioProvider::~FFmpegSourceAudioProvider() {
} }
///////////
// Clean up /// @brief Clean up
///
void FFmpegSourceAudioProvider::Close() { void FFmpegSourceAudioProvider::Close() {
FFMS_DestroyAudioSource(AudioSource); FFMS_DestroyAudioSource(AudioSource);
AudioSource = NULL; AudioSource = NULL;
} }
///////////
// Get audio /// @brief Get audio
/// @param Buf
/// @param Start
/// @param Count
///
void FFmpegSourceAudioProvider::GetAudio(void *Buf, int64_t Start, int64_t Count) { void FFmpegSourceAudioProvider::GetAudio(void *Buf, int64_t Start, int64_t Count) {
if (FFMS_GetAudio(AudioSource, Buf, Start, Count, FFMSErrMsg, MsgSize)) { if (FFMS_GetAudio(AudioSource, Buf, Start, Count, FFMSErrMsg, MsgSize)) {
ErrorMsg.Append(wxString::Format(_T("Failed to get audio samples: %s"), FFMSErrMsg)); ErrorMsg.Append(wxString::Format(_T("Failed to get audio samples: %s"), FFMSErrMsg));
@ -229,3 +239,4 @@ void FFmpegSourceAudioProvider::GetAudio(void *Buf, int64_t Start, int64_t Count
#endif /* WITH_FFMPEGSOURCE */ #endif /* WITH_FFMPEGSOURCE */

View file

@ -42,16 +42,30 @@
#include "ffmpegsource_common.h" #include "ffmpegsource_common.h"
///////////////////////
// FFmpegSource audio provider /// DOCME
/// @class FFmpegSourceAudioProvider
/// @brief DOCME
///
/// DOCME
class FFmpegSourceAudioProvider : public AudioProvider, FFmpegSourceProvider { class FFmpegSourceAudioProvider : public AudioProvider, FFmpegSourceProvider {
private: private:
/// DOCME
FFAudio *AudioSource; FFAudio *AudioSource;
/// DOCME
char FFMSErrMsg[1024]; char FFMSErrMsg[1024];
/// DOCME
unsigned MsgSize; unsigned MsgSize;
/// DOCME
wxString ErrorMsg; wxString ErrorMsg;
/// DOCME
bool COMInited; bool COMInited;
void Close(); void Close();
@ -61,7 +75,10 @@ public:
FFmpegSourceAudioProvider(wxString filename); FFmpegSourceAudioProvider(wxString filename);
virtual ~FFmpegSourceAudioProvider(); virtual ~FFmpegSourceAudioProvider();
// FFMS always delivers samples in machine endian
/// @brief // FFMS always delivers samples in machine endian
/// @return
///
bool AreSamplesNativeEndian() { return true; } bool AreSamplesNativeEndian() { return true; }
virtual void GetAudio(void *buf, int64_t start, int64_t count); virtual void GetAudio(void *buf, int64_t start, int64_t count);
@ -69,13 +86,22 @@ public:
}; };
///////////////////////
// Factory /// DOCME
/// @class FFmpegSourceAudioProviderFactory
/// @brief DOCME
///
/// DOCME
class FFmpegSourceAudioProviderFactory : public AudioProviderFactory { class FFmpegSourceAudioProviderFactory : public AudioProviderFactory {
public: public:
/// @brief DOCME
/// @param file
///
AudioProvider *CreateProvider(wxString file) { return new FFmpegSourceAudioProvider(file); } AudioProvider *CreateProvider(wxString file) { return new FFmpegSourceAudioProvider(file); }
}; };
#endif /* WITH_FFMPEGSOURCE */ #endif /* WITH_FFMPEGSOURCE */

View file

@ -51,8 +51,10 @@
#include "main.h" #include "main.h"
///////////////
// Constructor /// @brief Constructor
/// @param source
///
HDAudioProvider::HDAudioProvider(AudioProvider *source) { HDAudioProvider::HDAudioProvider(AudioProvider *source) {
// Copy parameters // Copy parameters
bytes_per_sample = source->GetBytesPerSample(); bytes_per_sample = source->GetBytesPerSample();
@ -104,8 +106,9 @@ HDAudioProvider::HDAudioProvider(AudioProvider *source) {
} }
//////////////
// Destructor /// @brief Destructor
///
HDAudioProvider::~HDAudioProvider() { HDAudioProvider::~HDAudioProvider() {
file_cache.Close(); file_cache.Close();
wxRemoveFile(diskCacheFilename); wxRemoveFile(diskCacheFilename);
@ -113,8 +116,12 @@ HDAudioProvider::~HDAudioProvider() {
} }
/////////////
// Get audio /// @brief Get audio
/// @param buf
/// @param start
/// @param count
///
void HDAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) { void HDAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
// Requested beyond the length of audio // Requested beyond the length of audio
if (start+count > num_samples) { if (start+count > num_samples) {
@ -145,8 +152,10 @@ void HDAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
} }
///////////////////////////
// Get disk cache path /// @brief Get disk cache path
/// @return
///
wxString HDAudioProvider::DiskCachePath() { wxString HDAudioProvider::DiskCachePath() {
// Default // Default
wxString path = Options.AsText(_T("Audio HD Cache Location")); wxString path = Options.AsText(_T("Audio HD Cache Location"));
@ -157,8 +166,9 @@ wxString HDAudioProvider::DiskCachePath() {
} }
///////////////////////////
// Get disk cache filename /// @brief Get disk cache filename
///
wxString HDAudioProvider::DiskCacheName() { wxString HDAudioProvider::DiskCacheName() {
// Get pattern // Get pattern
wxString pattern = Options.AsText(_T("Audio HD Cache Name")); wxString pattern = Options.AsText(_T("Audio HD Cache Name"));
@ -182,3 +192,4 @@ wxString HDAudioProvider::DiskCacheName() {
return _T(""); return _T("");
} }

View file

@ -44,14 +44,28 @@
#include <wx/file.h> #include <wx/file.h>
////////////////////////
// Audio provider class /// DOCME
/// @class HDAudioProvider
/// @brief DOCME
///
/// DOCME
class HDAudioProvider : public AudioProvider { class HDAudioProvider : public AudioProvider {
private: private:
/// DOCME
wxMutex diskmutex; wxMutex diskmutex;
/// DOCME
wxFile file_cache; wxFile file_cache;
/// DOCME
wxString diskCacheFilename; wxString diskCacheFilename;
/// DOCME
bool samples_native_endian; bool samples_native_endian;
/// DOCME
char *data; char *data;
static wxString DiskCachePath(); static wxString DiskCachePath();
@ -61,8 +75,12 @@ public:
HDAudioProvider(AudioProvider *source); HDAudioProvider(AudioProvider *source);
~HDAudioProvider(); ~HDAudioProvider();
/// @brief DOCME
///
bool AreSamplesNativeEndian() { return samples_native_endian; } bool AreSamplesNativeEndian() { return samples_native_endian; }
void GetAudio(void *buf, int64_t start, int64_t count); void GetAudio(void *buf, int64_t start, int64_t count);
}; };

View file

@ -46,8 +46,12 @@
#include "include/aegisub/audio_provider.h" #include "include/aegisub/audio_provider.h"
///////////////////
// Factory Manager /// DOCME
/// @class AudioProviderFactoryManager
/// @brief DOCME
///
/// DOCME
class AudioProviderFactoryManager : public FactoryManager<AudioProviderFactory> { class AudioProviderFactoryManager : public FactoryManager<AudioProviderFactory> {
public: public:
static void RegisterProviders(); static void RegisterProviders();
@ -55,3 +59,4 @@ public:
static void ClearProviders(); static void ClearProviders();
}; };

View file

@ -53,6 +53,10 @@
/// @brief DOCME
/// @param filename
///
PCMAudioProvider::PCMAudioProvider(const wxString &filename) PCMAudioProvider::PCMAudioProvider(const wxString &filename)
{ {
#ifdef _WINDOWS #ifdef _WINDOWS
@ -114,6 +118,9 @@ PCMAudioProvider::PCMAudioProvider(const wxString &filename)
} }
/// @brief DOCME
///
PCMAudioProvider::~PCMAudioProvider() PCMAudioProvider::~PCMAudioProvider()
{ {
#ifdef _WINDOWS #ifdef _WINDOWS
@ -137,6 +144,12 @@ PCMAudioProvider::~PCMAudioProvider()
} }
/// @brief DOCME
/// @param range_start
/// @param range_length
/// @return
///
char * PCMAudioProvider::EnsureRangeAccessible(int64_t range_start, int64_t range_length) char * PCMAudioProvider::EnsureRangeAccessible(int64_t range_start, int64_t range_length)
{ {
if (range_start + range_length > file_size) { if (range_start + range_length > file_size) {
@ -210,6 +223,12 @@ char * PCMAudioProvider::EnsureRangeAccessible(int64_t range_start, int64_t rang
} }
/// @brief DOCME
/// @param buf
/// @param start
/// @param count
///
void PCMAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) void PCMAudioProvider::GetAudio(void *buf, int64_t start, int64_t count)
{ {
// Read blocks from the file // Read blocks from the file
@ -254,29 +273,66 @@ void PCMAudioProvider::GetAudio(void *buf, int64_t start, int64_t count)
// RIFF WAV PCM provider // RIFF WAV PCM provider
// Overview of RIFF WAV: <http://www.sonicspot.com/guide/wavefiles.html> // Overview of RIFF WAV: <http://www.sonicspot.com/guide/wavefiles.html>
/// DOCME
/// @class RiffWavPCMAudioProvider
/// @brief DOCME
///
/// DOCME
class RiffWavPCMAudioProvider : public PCMAudioProvider { class RiffWavPCMAudioProvider : public PCMAudioProvider {
private: private:
/// DOCME
struct ChunkHeader { struct ChunkHeader {
/// DOCME
char type[4]; char type[4];
/// DOCME
uint32_t size; uint32_t size;
}; };
/// DOCME
struct RIFFChunk { struct RIFFChunk {
/// DOCME
ChunkHeader ch; ChunkHeader ch;
/// DOCME
char format[4]; char format[4];
}; };
/// DOCME
struct fmtChunk { struct fmtChunk {
// Skip the chunk header here, it's processed separately
/// DOCME
uint16_t compression; // compression format used -- 0x0001 = PCM uint16_t compression; // compression format used -- 0x0001 = PCM
/// DOCME
uint16_t channels; uint16_t channels;
/// DOCME
uint32_t samplerate; uint32_t samplerate;
/// DOCME
uint32_t avg_bytes_sec; // can't always be trusted uint32_t avg_bytes_sec; // can't always be trusted
/// DOCME
uint16_t block_align; uint16_t block_align;
/// DOCME
uint16_t significant_bits_sample; uint16_t significant_bits_sample;
// Here was supposed to be some more fields but we don't need them // Here was supposed to be some more fields but we don't need them
// and just skipping by the size of the struct wouldn't be safe // and just skipping by the size of the struct wouldn't be safe
// either way, as the fields can depend on the compression. // either way, as the fields can depend on the compression.
}; };
/// @brief DOCME
/// @param str1[]
/// @param str2[]
/// @return
///
static bool CheckFourcc(const char str1[], const char str2[]) static bool CheckFourcc(const char str1[], const char str2[])
{ {
assert(str1); assert(str1);
@ -289,6 +345,10 @@ private:
} }
public: public:
/// @brief DOCME
/// @param _filename
///
RiffWavPCMAudioProvider(const wxString &_filename) RiffWavPCMAudioProvider(const wxString &_filename)
: PCMAudioProvider(_filename) : PCMAudioProvider(_filename)
{ {
@ -368,6 +428,10 @@ public:
} }
/// @brief DOCME
/// @return
///
bool AreSamplesNativeEndian() bool AreSamplesNativeEndian()
{ {
// 8 bit samples don't consider endianness // 8 bit samples don't consider endianness
@ -383,64 +447,128 @@ public:
// Sony Wave64 audio provider // Sony Wave64 audio provider
// Specs obtained at: <http://www.vcs.de/fileadmin/user_upload/MBS/PDF/Whitepaper/Informations_about_Sony_Wave64.pdf> // Specs obtained at: <http://www.vcs.de/fileadmin/user_upload/MBS/PDF/Whitepaper/Informations_about_Sony_Wave64.pdf>
/// DOCME
static const uint8_t w64GuidRIFF[16] = { static const uint8_t w64GuidRIFF[16] = {
// {66666972-912E-11CF-A5D6-28DB04C10000} // {66666972-912E-11CF-A5D6-28DB04C10000}
0x72, 0x69, 0x66, 0x66, 0x2E, 0x91, 0xCF, 0x11, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00 0x72, 0x69, 0x66, 0x66, 0x2E, 0x91, 0xCF, 0x11, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00
}; };
/// DOCME
static const uint8_t w64GuidWAVE[16] = { static const uint8_t w64GuidWAVE[16] = {
// {65766177-ACF3-11D3-8CD1-00C04F8EDB8A} // {65766177-ACF3-11D3-8CD1-00C04F8EDB8A}
0x77, 0x61, 0x76, 0x65, 0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A 0x77, 0x61, 0x76, 0x65, 0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A
}; };
/// DOCME
static const uint8_t w64Guidfmt[16] = { static const uint8_t w64Guidfmt[16] = {
// {20746D66-ACF3-11D3-8CD1-00C04F8EDB8A} // {20746D66-ACF3-11D3-8CD1-00C04F8EDB8A}
0x66, 0x6D, 0x74, 0x20, 0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A 0x66, 0x6D, 0x74, 0x20, 0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A
}; };
/// DOCME
static const uint8_t w64Guiddata[16] = { static const uint8_t w64Guiddata[16] = {
// {61746164-ACF3-11D3-8CD1-00C04F8EDB8A} // {61746164-ACF3-11D3-8CD1-00C04F8EDB8A}
0x64, 0x61, 0x74, 0x61, 0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A 0x64, 0x61, 0x74, 0x61, 0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A
}; };
/// DOCME
/// @class Wave64AudioProvider
/// @brief DOCME
///
/// DOCME
class Wave64AudioProvider : public PCMAudioProvider { class Wave64AudioProvider : public PCMAudioProvider {
private: private:
// Here's some copy-paste from the FFmpegSource2 code // Here's some copy-paste from the FFmpegSource2 code
/// DOCME
struct WaveFormatEx { struct WaveFormatEx {
/// DOCME
uint16_t wFormatTag; uint16_t wFormatTag;
/// DOCME
uint16_t nChannels; uint16_t nChannels;
/// DOCME
uint32_t nSamplesPerSec; uint32_t nSamplesPerSec;
/// DOCME
uint32_t nAvgBytesPerSec; uint32_t nAvgBytesPerSec;
/// DOCME
uint16_t nBlockAlign; uint16_t nBlockAlign;
/// DOCME
uint16_t wBitsPerSample; uint16_t wBitsPerSample;
/// DOCME
uint16_t cbSize; uint16_t cbSize;
}; };
/// DOCME
struct RiffChunk { struct RiffChunk {
/// DOCME
uint8_t riff_guid[16]; uint8_t riff_guid[16];
/// DOCME
uint64_t file_size; uint64_t file_size;
/// DOCME
uint8_t format_guid[16]; uint8_t format_guid[16];
}; };
/// DOCME
struct FormatChunk { struct FormatChunk {
/// DOCME
uint8_t chunk_guid[16]; uint8_t chunk_guid[16];
/// DOCME
uint64_t chunk_size; uint64_t chunk_size;
/// DOCME
WaveFormatEx format; WaveFormatEx format;
/// DOCME
uint8_t padding[6]; uint8_t padding[6];
}; };
/// DOCME
struct DataChunk { struct DataChunk {
/// DOCME
uint8_t chunk_guid[16]; uint8_t chunk_guid[16];
/// DOCME
uint64_t chunk_size; uint64_t chunk_size;
}; };
/// @brief DOCME
/// @param guid1
/// @param guid2
/// @return
///
inline bool CheckGuid(const uint8_t *guid1, const uint8_t *guid2) inline bool CheckGuid(const uint8_t *guid1, const uint8_t *guid2)
{ {
return memcmp(guid1, guid2, 16) == 0; return memcmp(guid1, guid2, 16) == 0;
} }
public: public:
/// @brief DOCME
/// @param _filename
///
Wave64AudioProvider(const wxString &_filename) Wave64AudioProvider(const wxString &_filename)
: PCMAudioProvider(_filename) : PCMAudioProvider(_filename)
{ {
@ -521,6 +649,10 @@ public:
} }
/// @brief DOCME
/// @return
///
bool AreSamplesNativeEndian() bool AreSamplesNativeEndian()
{ {
// 8 bit samples don't consider endianness // 8 bit samples don't consider endianness
@ -532,6 +664,10 @@ public:
}; };
/// @brief DOCME
/// @param filename
///
AudioProvider *CreatePCMAudioProvider(const wxString &filename) AudioProvider *CreatePCMAudioProvider(const wxString &filename)
{ {
AudioProvider *provider = 0; AudioProvider *provider = 0;
@ -561,3 +697,4 @@ AudioProvider *CreatePCMAudioProvider(const wxString &filename)
return NULL; return NULL;
} }

View file

@ -50,18 +50,29 @@
#endif #endif
/////////////////////////////
// Audio provider base class /// DOCME
/// @class PCMAudioProvider
/// @brief DOCME
///
/// DOCME
class PCMAudioProvider : public AudioProvider { class PCMAudioProvider : public AudioProvider {
private: private:
#ifdef _WINDOWS #ifdef _WINDOWS
// File handle and file mapping handle from Win32
/// DOCME
HANDLE file_handle; HANDLE file_handle;
/// DOCME
HANDLE file_mapping; HANDLE file_mapping;
// Pointer to current area mapped into memory
/// DOCME
void *current_mapping; void *current_mapping;
// Byte indices in the file that the current mapping covers
/// DOCME
int64_t mapping_start; int64_t mapping_start;
/// DOCME
size_t mapping_length; size_t mapping_length;
#else #else
int file_handle; int file_handle;
@ -75,19 +86,28 @@ protected:
virtual ~PCMAudioProvider(); // Closes the file mapping virtual ~PCMAudioProvider(); // Closes the file mapping
char * EnsureRangeAccessible(int64_t range_start, int64_t range_length); // Ensure that the given range of bytes are accessible in the file mapping and return a pointer to the first byte of the requested range char * EnsureRangeAccessible(int64_t range_start, int64_t range_length); // Ensure that the given range of bytes are accessible in the file mapping and return a pointer to the first byte of the requested range
/// DOCME
int64_t file_size; // Size of the opened file int64_t file_size; // Size of the opened file
// Hold data for an index point,
// to support files where audio data are /// DOCME
// split into multiple blocks.
// Using int64_t's should be safe on most compilers,
// wx defines wxFileOffset as int64 when possible
struct IndexPoint { struct IndexPoint {
/// DOCME
int64_t start_byte; int64_t start_byte;
/// DOCME
int64_t start_sample; int64_t start_sample;
/// DOCME
int64_t num_samples; int64_t num_samples;
}; };
/// DOCME
typedef std::vector<IndexPoint> IndexVector; typedef std::vector<IndexPoint> IndexVector;
/// DOCME
IndexVector index_points; IndexVector index_points;
public: public:
@ -99,3 +119,4 @@ AudioProvider *CreatePCMAudioProvider(const wxString &filename);

View file

@ -39,6 +39,10 @@
#ifdef WITH_QUICKTIME #ifdef WITH_QUICKTIME
/// @brief DOCME
/// @param filename
///
QuickTimeAudioProvider::QuickTimeAudioProvider(wxString filename) { QuickTimeAudioProvider::QuickTimeAudioProvider(wxString filename) {
movie = NULL; movie = NULL;
in_dataref = NULL; in_dataref = NULL;
@ -74,12 +78,18 @@ QuickTimeAudioProvider::QuickTimeAudioProvider(wxString filename) {
} }
/// @brief DOCME
///
QuickTimeAudioProvider::~QuickTimeAudioProvider() { QuickTimeAudioProvider::~QuickTimeAudioProvider() {
Close(); Close();
DeInitQuickTime(); DeInitQuickTime();
} }
/// @brief DOCME
///
void QuickTimeAudioProvider::Close() { void QuickTimeAudioProvider::Close() {
if (movie) if (movie)
DisposeMovie(movie); DisposeMovie(movie);
@ -93,6 +103,10 @@ void QuickTimeAudioProvider::Close() {
} }
/// @brief DOCME
/// @param filename
///
void QuickTimeAudioProvider::LoadAudio(wxString filename) { void QuickTimeAudioProvider::LoadAudio(wxString filename) {
OSType in_dataref_type; OSType in_dataref_type;
wxStringToDataRef(filename, &in_dataref, &in_dataref_type); wxStringToDataRef(filename, &in_dataref, &in_dataref_type);
@ -148,6 +162,12 @@ void QuickTimeAudioProvider::LoadAudio(wxString filename) {
} }
/// @brief DOCME
/// @param buf
/// @param start
/// @param count
///
void QuickTimeAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) { void QuickTimeAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
TimeRecord trec; TimeRecord trec;
trec.scale = GetMovieTimeScale(movie); trec.scale = GetMovieTimeScale(movie);
@ -180,3 +200,4 @@ void QuickTimeAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
#endif /* WITH_QUICKTIME */ #endif /* WITH_QUICKTIME */

View file

@ -45,16 +45,36 @@
#include "include/aegisub/audio_provider.h" #include "include/aegisub/audio_provider.h"
/// DOCME
/// @class QuickTimeAudioProvider
/// @brief DOCME
///
/// DOCME
class QuickTimeAudioProvider : public AudioProvider, QuickTimeProvider { class QuickTimeAudioProvider : public AudioProvider, QuickTimeProvider {
private: private:
/// DOCME
Movie movie; // input file Movie movie; // input file
/// DOCME
Handle in_dataref; // input file handle Handle in_dataref; // input file handle
/// DOCME
MovieAudioExtractionRef extract_ref; // extraction session object MovieAudioExtractionRef extract_ref; // extraction session object
/// DOCME
bool inited; bool inited;
/// DOCME
OSErr qt_err; // quicktime error code OSErr qt_err; // quicktime error code
/// DOCME
OSStatus qt_status; // another quicktime error code OSStatus qt_status; // another quicktime error code
/// DOCME
wxString errmsg; // aegisub error messages wxString errmsg; // aegisub error messages
void Close(); void Close();
@ -64,17 +84,32 @@ public:
QuickTimeAudioProvider(wxString filename); QuickTimeAudioProvider(wxString filename);
virtual ~QuickTimeAudioProvider(); virtual ~QuickTimeAudioProvider();
/// @brief DOCME
/// @return
///
bool AreSamplesNativeEndian() { return true; } bool AreSamplesNativeEndian() { return true; }
virtual void GetAudio(void *buf, int64_t start, int64_t count); virtual void GetAudio(void *buf, int64_t start, int64_t count);
}; };
/// DOCME
/// @class QuickTimeAudioProviderFactory
/// @brief DOCME
///
/// DOCME
class QuickTimeAudioProviderFactory : public AudioProviderFactory { class QuickTimeAudioProviderFactory : public AudioProviderFactory {
public: public:
/// @brief DOCME
/// @param file
///
AudioProvider *CreateProvider(wxString file) { return new QuickTimeAudioProvider(file); } AudioProvider *CreateProvider(wxString file) { return new QuickTimeAudioProvider(file); }
}; };
#endif /* WITH_QUICKTIME */ #endif /* WITH_QUICKTIME */

View file

@ -46,14 +46,18 @@
#include "main.h" #include "main.h"
///////////
// Defines /// DOCME
#define CacheBits ((22)) #define CacheBits ((22))
/// DOCME
#define CacheBlockSize ((1 << CacheBits)) #define CacheBlockSize ((1 << CacheBits))
///////////////
// Constructor /// @brief Constructor
/// @param source
///
RAMAudioProvider::RAMAudioProvider(AudioProvider *source) { RAMAudioProvider::RAMAudioProvider(AudioProvider *source) {
// Init // Init
blockcache = NULL; blockcache = NULL;
@ -109,15 +113,17 @@ RAMAudioProvider::RAMAudioProvider(AudioProvider *source) {
} }
//////////////
// Destructor /// @brief Destructor
///
RAMAudioProvider::~RAMAudioProvider() { RAMAudioProvider::~RAMAudioProvider() {
Clear(); Clear();
} }
/////////
// Clear /// @brief Clear
///
void RAMAudioProvider::Clear() { void RAMAudioProvider::Clear() {
// Free ram cache // Free ram cache
if (blockcache) { if (blockcache) {
@ -131,8 +137,12 @@ void RAMAudioProvider::Clear() {
} }
/////////////
// Get audio /// @brief Get audio
/// @param buf
/// @param start
/// @param count
///
void RAMAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) { void RAMAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
// Requested beyond the length of audio // Requested beyond the length of audio
if (start+count > num_samples) { if (start+count > num_samples) {
@ -177,3 +187,4 @@ void RAMAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
} }
} }

View file

@ -43,12 +43,22 @@
#include "include/aegisub/audio_provider.h" #include "include/aegisub/audio_provider.h"
////////////////////////
// Audio provider class /// DOCME
/// @class RAMAudioProvider
/// @brief DOCME
///
/// DOCME
class RAMAudioProvider : public AudioProvider { class RAMAudioProvider : public AudioProvider {
private: private:
/// DOCME
char** blockcache; char** blockcache;
/// DOCME
int blockcount; int blockcount;
/// DOCME
bool samples_native_endian; bool samples_native_endian;
void Clear(); void Clear();
@ -57,8 +67,12 @@ public:
RAMAudioProvider(AudioProvider *source); RAMAudioProvider(AudioProvider *source);
~RAMAudioProvider(); ~RAMAudioProvider();
/// @brief DOCME
///
bool AreSamplesNativeEndian() { return samples_native_endian; } bool AreSamplesNativeEndian() { return samples_native_endian; }
void GetAudio(void *buf, int64_t start, int64_t count); void GetAudio(void *buf, int64_t start, int64_t count);
}; };

View file

@ -43,11 +43,14 @@
#include "utils.h" #include "utils.h"
/// DOCME
#define BUFSIZE 65536 #define BUFSIZE 65536
///////////////
// Constructor /// @brief Constructor
///
StreamAudioProvider::StreamAudioProvider() { StreamAudioProvider::StreamAudioProvider() {
bufLen = 8192; bufLen = 8192;
startPos = 0; startPos = 0;
@ -58,8 +61,9 @@ StreamAudioProvider::StreamAudioProvider() {
} }
//////////////
// Destructor /// @brief Destructor
///
StreamAudioProvider::~StreamAudioProvider() { StreamAudioProvider::~StreamAudioProvider() {
for (std::list<BufferChunk*>::iterator cur=buffer.begin();cur!=buffer.end();cur++) { for (std::list<BufferChunk*>::iterator cur=buffer.begin();cur!=buffer.end();cur++) {
delete *cur; delete *cur;
@ -68,8 +72,12 @@ StreamAudioProvider::~StreamAudioProvider() {
} }
/////////////
// Get audio /// @brief Get audio
/// @param buf
/// @param start
/// @param count
///
void StreamAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) { void StreamAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
// Write // Write
int64_t left = count; int64_t left = count;
@ -111,8 +119,11 @@ void StreamAudioProvider::GetAudio(void *buf, int64_t start, int64_t count) {
} }
//////////////////////////
// Append audio to stream /// @brief Append audio to stream
/// @param voidptr
/// @param count
///
void StreamAudioProvider::Append(void *voidptr, int64_t count) { void StreamAudioProvider::Append(void *voidptr, int64_t count) {
// Read // Read
int64_t left = count; int64_t left = count;
@ -140,8 +151,12 @@ void StreamAudioProvider::Append(void *voidptr, int64_t count) {
} }
//////////////////
// Set parameters /// @brief Set parameters
/// @param chan
/// @param rate
/// @param bps
///
void StreamAudioProvider::SetParams(int chan,int rate,int bps) { void StreamAudioProvider::SetParams(int chan,int rate,int bps) {
channels = chan; channels = chan;
sample_rate = rate; sample_rate = rate;
@ -149,10 +164,12 @@ void StreamAudioProvider::SetParams(int chan,int rate,int bps) {
} }
////////////////////////////
// Buffer chunk constructor /// @brief Buffer chunk constructor
///
StreamAudioProvider::BufferChunk::BufferChunk() { StreamAudioProvider::BufferChunk::BufferChunk() {
buf.resize(BUFSIZE); buf.resize(BUFSIZE);
isFree = true; isFree = true;
} }

View file

@ -45,24 +45,49 @@
#include "include/aegisub/audio_provider.h" #include "include/aegisub/audio_provider.h"
////////////////////////
// Audio provider class /// DOCME
/// @class StreamAudioProvider
/// @brief DOCME
///
/// DOCME
class StreamAudioProvider : public AudioProvider { class StreamAudioProvider : public AudioProvider {
private: private:
// Buffer chunk subclass
/// DOCME
/// @class BufferChunk
/// @brief DOCME
///
/// DOCME
class BufferChunk { class BufferChunk {
public: public:
/// DOCME
std::vector<short> buf; std::vector<short> buf;
/// DOCME
bool isFree; bool isFree;
BufferChunk(); BufferChunk();
}; };
/// DOCME
std::list<BufferChunk*> buffer; std::list<BufferChunk*> buffer;
/// DOCME
int startPos; int startPos;
/// DOCME
int endPos; int endPos;
/// DOCME
int bufLen; int bufLen;
/// DOCME
int buffered; int buffered;
/// DOCME
bool hasBuf; bool hasBuf;
public: public:
@ -80,3 +105,4 @@ public:
void SetParams(int channels,int rate,int bps); void SetParams(int channels,int rate,int bps);
}; };

View file

@ -55,21 +55,49 @@
// Audio spectrum FFT data cache // Audio spectrum FFT data cache
// Spectrum cache basically caches the raw result of FFT
/// DOCME
/// @class AudioSpectrumCache
/// @brief DOCME
///
/// DOCME
class AudioSpectrumCache { class AudioSpectrumCache {
public: public:
// Type of a single FFT result line
/// DOCME
typedef std::vector<float> CacheLine; typedef std::vector<float> CacheLine;
// Types for cache aging
/// DOCME
typedef unsigned int CacheAccessTime; typedef unsigned int CacheAccessTime;
/// DOCME
struct CacheAgeData { struct CacheAgeData {
/// DOCME
CacheAccessTime access_time; CacheAccessTime access_time;
/// DOCME
unsigned long first_line; unsigned long first_line;
/// DOCME
unsigned long num_lines; // includes overlap-lines unsigned long num_lines; // includes overlap-lines
/// @brief DOCME
/// @param second
/// @return
///
bool operator< (const CacheAgeData& second) const { return access_time < second.access_time; } bool operator< (const CacheAgeData& second) const { return access_time < second.access_time; }
/// @brief DOCME
/// @param t
/// @param first
/// @param num
///
CacheAgeData(CacheAccessTime t, unsigned long first, unsigned long num) : access_time(t), first_line(first), num_lines(num) { } CacheAgeData(CacheAccessTime t, unsigned long first, unsigned long num) : access_time(t), first_line(first), num_lines(num) { }
}; };
/// DOCME
typedef std::vector<CacheAgeData> CacheAgeList; typedef std::vector<CacheAgeData> CacheAgeList;
// Get the overlap'th overlapping FFT in FFT group i, generating it if needed // Get the overlap'th overlapping FFT in FFT group i, generating it if needed
@ -85,37 +113,73 @@ public:
// Return true if the object called on is empty and can safely be deleted too // Return true if the object called on is empty and can safely be deleted too
virtual bool KillLine(unsigned long line_id) = 0; virtual bool KillLine(unsigned long line_id) = 0;
// Set the FFT size used
/// @brief // Set the FFT size used
/// @param new_length
///
static void SetLineLength(unsigned long new_length) static void SetLineLength(unsigned long new_length)
{ {
line_length = new_length; line_length = new_length;
null_line.resize(new_length, 0); null_line.resize(new_length, 0);
} }
/// @brief DOCME
///
virtual ~AudioSpectrumCache() {}; virtual ~AudioSpectrumCache() {};
protected: protected:
// A cache line containing only zero-values
/// DOCME
static CacheLine null_line; static CacheLine null_line;
// The FFT size
/// DOCME
static unsigned long line_length; static unsigned long line_length;
}; };
/// DOCME
AudioSpectrumCache::CacheLine AudioSpectrumCache::null_line; AudioSpectrumCache::CacheLine AudioSpectrumCache::null_line;
/// DOCME
unsigned long AudioSpectrumCache::line_length; unsigned long AudioSpectrumCache::line_length;
// Bottom level FFT cache, holds actual power data itself // Bottom level FFT cache, holds actual power data itself
/// DOCME
/// @class FinalSpectrumCache
/// @brief DOCME
///
/// DOCME
class FinalSpectrumCache : public AudioSpectrumCache { class FinalSpectrumCache : public AudioSpectrumCache {
private: private:
/// DOCME
std::vector<CacheLine> data; std::vector<CacheLine> data;
/// DOCME
/// DOCME
unsigned long start, length; // start and end of range unsigned long start, length; // start and end of range
/// DOCME
unsigned int overlaps; unsigned int overlaps;
/// DOCME
CacheAccessTime last_access; CacheAccessTime last_access;
public: public:
/// @brief DOCME
/// @param i
/// @param overlap
/// @param created
/// @param access_time
/// @return
///
CacheLine& GetLine(unsigned long i, unsigned int overlap, bool &created, CacheAccessTime access_time) CacheLine& GetLine(unsigned long i, unsigned int overlap, bool &created, CacheAccessTime access_time)
{ {
last_access = access_time; last_access = access_time;
@ -127,21 +191,41 @@ public:
return null_line; return null_line;
} }
/// @brief DOCME
/// @return
///
size_t GetManagedLineCount() size_t GetManagedLineCount()
{ {
return data.size(); return data.size();
} }
/// @brief DOCME
/// @param ages
///
void GetLineAccessTimes(CacheAgeList &ages) void GetLineAccessTimes(CacheAgeList &ages)
{ {
ages.push_back(CacheAgeData(last_access, start, data.size())); ages.push_back(CacheAgeData(last_access, start, data.size()));
} }
/// @brief DOCME
/// @param line_id
/// @return
///
bool KillLine(unsigned long line_id) bool KillLine(unsigned long line_id)
{ {
return start == line_id; return start == line_id;
} }
/// @brief DOCME
/// @param provider
/// @param _start
/// @param _length
/// @param _overlaps
///
FinalSpectrumCache(AudioProvider *provider, unsigned long _start, unsigned long _length, unsigned int _overlaps) FinalSpectrumCache(AudioProvider *provider, unsigned long _start, unsigned long _length, unsigned int _overlaps)
{ {
start = _start; start = _start;
@ -210,6 +294,9 @@ public:
} }
} }
/// @brief DOCME
///
virtual ~FinalSpectrumCache() virtual ~FinalSpectrumCache()
{ {
} }
@ -219,16 +306,46 @@ public:
// Non-bottom-level cache, refers to other caches to do the work // Non-bottom-level cache, refers to other caches to do the work
/// DOCME
/// @class IntermediateSpectrumCache
/// @brief DOCME
///
/// DOCME
class IntermediateSpectrumCache : public AudioSpectrumCache { class IntermediateSpectrumCache : public AudioSpectrumCache {
private: private:
/// DOCME
std::vector<AudioSpectrumCache*> sub_caches; std::vector<AudioSpectrumCache*> sub_caches;
/// DOCME
/// DOCME
/// DOCME
unsigned long start, length, subcache_length; unsigned long start, length, subcache_length;
/// DOCME
unsigned int overlaps; unsigned int overlaps;
/// DOCME
bool subcaches_are_final; bool subcaches_are_final;
/// DOCME
int depth; int depth;
/// DOCME
AudioProvider *provider; AudioProvider *provider;
public: public:
/// @brief DOCME
/// @param i
/// @param overlap
/// @param created
/// @param access_time
/// @return
///
CacheLine &GetLine(unsigned long i, unsigned int overlap, bool &created, CacheAccessTime access_time) CacheLine &GetLine(unsigned long i, unsigned int overlap, bool &created, CacheAccessTime access_time)
{ {
if (i >= start && i-start <= length) { if (i >= start && i-start <= length) {
@ -251,6 +368,10 @@ public:
} }
} }
/// @brief DOCME
/// @return
///
size_t GetManagedLineCount() size_t GetManagedLineCount()
{ {
size_t res = 0; size_t res = 0;
@ -261,6 +382,10 @@ public:
return res; return res;
} }
/// @brief DOCME
/// @param ages
///
void GetLineAccessTimes(CacheAgeList &ages) void GetLineAccessTimes(CacheAgeList &ages)
{ {
for (size_t i = 0; i < sub_caches.size(); ++i) { for (size_t i = 0; i < sub_caches.size(); ++i) {
@ -269,6 +394,11 @@ public:
} }
} }
/// @brief DOCME
/// @param line_id
/// @return
///
bool KillLine(unsigned long line_id) bool KillLine(unsigned long line_id)
{ {
int sub_caches_left = 0; int sub_caches_left = 0;
@ -285,6 +415,14 @@ public:
return sub_caches_left == 0; return sub_caches_left == 0;
} }
/// @brief DOCME
/// @param _provider
/// @param _start
/// @param _length
/// @param _overlaps
/// @param _depth
///
IntermediateSpectrumCache(AudioProvider *_provider, unsigned long _start, unsigned long _length, unsigned int _overlaps, int _depth) IntermediateSpectrumCache(AudioProvider *_provider, unsigned long _start, unsigned long _length, unsigned int _overlaps, int _depth)
{ {
provider = _provider; provider = _provider;
@ -307,6 +445,9 @@ public:
sub_caches.resize(num_subcaches, 0); sub_caches.resize(num_subcaches, 0);
} }
/// @brief DOCME
///
virtual ~IntermediateSpectrumCache() virtual ~IntermediateSpectrumCache()
{ {
for (size_t i = 0; i < sub_caches.size(); ++i) for (size_t i = 0; i < sub_caches.size(); ++i)
@ -318,15 +459,37 @@ public:
/// DOCME
/// @class AudioSpectrumCacheManager
/// @brief DOCME
///
/// DOCME
class AudioSpectrumCacheManager { class AudioSpectrumCacheManager {
private: private:
/// DOCME
IntermediateSpectrumCache *cache_root; IntermediateSpectrumCache *cache_root;
/// DOCME
/// DOCME
unsigned long cache_hits, cache_misses; unsigned long cache_hits, cache_misses;
/// DOCME
AudioSpectrumCache::CacheAccessTime cur_time; AudioSpectrumCache::CacheAccessTime cur_time;
/// DOCME
unsigned long max_lines_cached; unsigned long max_lines_cached;
public: public:
/// @brief DOCME
/// @param i
/// @param overlap
/// @return
///
AudioSpectrumCache::CacheLine &GetLine(unsigned long i, unsigned int overlap) AudioSpectrumCache::CacheLine &GetLine(unsigned long i, unsigned int overlap)
{ {
bool created = false; bool created = false;
@ -338,6 +501,10 @@ public:
return res; return res;
} }
/// @brief DOCME
/// @return
///
void Age() void Age()
{ {
wxLogDebug(_T("AudioSpectrumCacheManager stats: hits=%u, misses=%u, misses%%=%f, managed lines=%u (max=%u)"), cache_hits, cache_misses, cache_misses/float(cache_hits+cache_misses)*100, cache_root->GetManagedLineCount(), max_lines_cached); wxLogDebug(_T("AudioSpectrumCacheManager stats: hits=%u, misses=%u, misses%%=%f, managed lines=%u (max=%u)"), cache_hits, cache_misses, cache_misses/float(cache_hits+cache_misses)*100, cache_root->GetManagedLineCount(), max_lines_cached);
@ -383,6 +550,13 @@ public:
assert(cache_root->GetManagedLineCount() < max_lines_cached); assert(cache_root->GetManagedLineCount() < max_lines_cached);
} }
/// @brief DOCME
/// @param provider
/// @param line_length
/// @param num_lines
/// @param num_overlaps
///
AudioSpectrumCacheManager(AudioProvider *provider, unsigned long line_length, unsigned long num_lines, unsigned int num_overlaps) AudioSpectrumCacheManager(AudioProvider *provider, unsigned long line_length, unsigned long num_lines, unsigned int num_overlaps)
{ {
cache_hits = cache_misses = 0; cache_hits = cache_misses = 0;
@ -398,6 +572,9 @@ public:
max_lines_cached = max_cache_size / line_size; max_lines_cached = max_cache_size / line_size;
} }
/// @brief DOCME
///
~AudioSpectrumCacheManager() ~AudioSpectrumCacheManager()
{ {
delete cache_root; delete cache_root;
@ -407,6 +584,10 @@ public:
// AudioSpectrum // AudioSpectrum
/// @brief DOCME
/// @param _provider
///
AudioSpectrum::AudioSpectrum(AudioProvider *_provider) AudioSpectrum::AudioSpectrum(AudioProvider *_provider)
{ {
provider = _provider; provider = _provider;
@ -496,12 +677,26 @@ AudioSpectrum::AudioSpectrum(AudioProvider *_provider)
} }
/// @brief DOCME
///
AudioSpectrum::~AudioSpectrum() AudioSpectrum::~AudioSpectrum()
{ {
delete cache; delete cache;
} }
/// @brief DOCME
/// @param range_start
/// @param range_end
/// @param selected
/// @param img
/// @param imgleft
/// @param imgwidth
/// @param imgpitch
/// @param imgheight
///
void AudioSpectrum::RenderRange(int64_t range_start, int64_t range_end, bool selected, unsigned char *img, int imgleft, int imgwidth, int imgpitch, int imgheight) void AudioSpectrum::RenderRange(int64_t range_start, int64_t range_end, bool selected, unsigned char *img, int imgleft, int imgwidth, int imgpitch, int imgheight)
{ {
unsigned long first_line = (unsigned long)(fft_overlaps * range_start / line_length / 2); unsigned long first_line = (unsigned long)(fft_overlaps * range_start / line_length / 2);
@ -551,6 +746,8 @@ void AudioSpectrum::RenderRange(int64_t range_start, int64_t range_end, bool sel
} }
} }
/// DOCME
#define WRITE_PIXEL \ #define WRITE_PIXEL \
if (intensity < 0) intensity = 0; \ if (intensity < 0) intensity = 0; \
if (intensity > 255) intensity = 255; \ if (intensity > 255) intensity = 255; \
@ -599,6 +796,8 @@ void AudioSpectrum::RenderRange(int64_t range_start, int64_t range_end, bool sel
} }
} }
/// DOCME
#undef WRITE_PIXEL #undef WRITE_PIXEL
} }
@ -609,6 +808,10 @@ void AudioSpectrum::RenderRange(int64_t range_start, int64_t range_end, bool sel
} }
/// @brief DOCME
/// @param _power_scale
///
void AudioSpectrum::SetScaling(float _power_scale) void AudioSpectrum::SetScaling(float _power_scale)
{ {
power_scale = _power_scale; power_scale = _power_scale;
@ -616,3 +819,4 @@ void AudioSpectrum::SetScaling(float _power_scale)

View file

@ -36,6 +36,8 @@
/// ///
#ifndef AUDIO_SPECTRUM_H #ifndef AUDIO_SPECTRUM_H
/// DOCME
#define AUDIO_SPECTRUM_H #define AUDIO_SPECTRUM_H
#include <wx/wxprec.h> #include <wx/wxprec.h>
@ -47,22 +49,46 @@
class AudioSpectrumCacheManager; class AudioSpectrumCacheManager;
/// DOCME
/// @class AudioSpectrum
/// @brief DOCME
///
/// DOCME
class AudioSpectrum { class AudioSpectrum {
private: private:
// Data provider
/// DOCME
AudioSpectrumCacheManager *cache; AudioSpectrumCacheManager *cache;
// Colour pallettes
/// DOCME
unsigned char colours_normal[256*3]; unsigned char colours_normal[256*3];
/// DOCME
unsigned char colours_selected[256*3]; unsigned char colours_selected[256*3];
/// DOCME
AudioProvider *provider; AudioProvider *provider;
/// DOCME
unsigned long line_length; // number of frequency components per line (half of number of samples) unsigned long line_length; // number of frequency components per line (half of number of samples)
/// DOCME
unsigned long num_lines; // number of lines needed for the audio unsigned long num_lines; // number of lines needed for the audio
/// DOCME
unsigned int fft_overlaps; // number of overlaps used in FFT unsigned int fft_overlaps; // number of overlaps used in FFT
/// DOCME
float power_scale; // amplification of displayed power float power_scale; // amplification of displayed power
/// DOCME
int minband; // smallest frequency band displayed int minband; // smallest frequency band displayed
/// DOCME
int maxband; // largest frequency band displayed int maxband; // largest frequency band displayed
public: public:
@ -77,3 +103,4 @@ public:
#endif #endif

View file

@ -68,8 +68,20 @@
#include FT_FREETYPE_H #include FT_FREETYPE_H
#endif #endif
/// DOCME
namespace Automation4 { namespace Automation4 {
/// @brief DOCME
/// @param style
/// @param text
/// @param width
/// @param height
/// @param descent
/// @param extlead
/// @return
///
bool CalculateTextExtents(AssStyle *style, wxString &text, double &width, double &height, double &descent, double &extlead) bool CalculateTextExtents(AssStyle *style, wxString &text, double &width, double &height, double &descent, double &extlead)
{ {
width = height = descent = extlead = 0; width = height = descent = extlead = 0;
@ -183,6 +195,11 @@ namespace Automation4 {
// Feature // Feature
/// @brief DOCME
/// @param _featureclass
/// @param _name
///
Feature::Feature(ScriptFeatureClass _featureclass, const wxString &_name) Feature::Feature(ScriptFeatureClass _featureclass, const wxString &_name)
: featureclass(_featureclass) : featureclass(_featureclass)
, name(_name) , name(_name)
@ -190,11 +207,19 @@ namespace Automation4 {
// nothing to do // nothing to do
} }
/// @brief DOCME
/// @return
///
ScriptFeatureClass Feature::GetClass() const ScriptFeatureClass Feature::GetClass() const
{ {
return featureclass; return featureclass;
} }
/// @brief DOCME
/// @return
///
FeatureMacro* Feature::AsMacro() FeatureMacro* Feature::AsMacro()
{ {
if (featureclass == SCRIPTFEATURE_MACRO) if (featureclass == SCRIPTFEATURE_MACRO)
@ -203,6 +228,10 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @return
///
FeatureFilter* Feature::AsFilter() FeatureFilter* Feature::AsFilter()
{ {
if (featureclass == SCRIPTFEATURE_FILTER) if (featureclass == SCRIPTFEATURE_FILTER)
@ -210,6 +239,10 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @return
///
FeatureSubtitleFormat* Feature::AsSubFormat() FeatureSubtitleFormat* Feature::AsSubFormat()
{ {
if (featureclass == SCRIPTFEATURE_SUBFORMAT) if (featureclass == SCRIPTFEATURE_SUBFORMAT)
@ -217,6 +250,10 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @return
///
const wxString& Feature::GetName() const const wxString& Feature::GetName() const
{ {
return name; return name;
@ -225,6 +262,11 @@ namespace Automation4 {
// FeatureMacro // FeatureMacro
/// @brief DOCME
/// @param _name
/// @param _description
///
FeatureMacro::FeatureMacro(const wxString &_name, const wxString &_description) FeatureMacro::FeatureMacro(const wxString &_name, const wxString &_description)
: Feature(SCRIPTFEATURE_MACRO, _name) : Feature(SCRIPTFEATURE_MACRO, _name)
, description(_description) , description(_description)
@ -232,6 +274,10 @@ namespace Automation4 {
// nothing to do // nothing to do
} }
/// @brief DOCME
/// @return
///
const wxString& FeatureMacro::GetDescription() const const wxString& FeatureMacro::GetDescription() const
{ {
return description; return description;
@ -240,6 +286,12 @@ namespace Automation4 {
// FeatureFilter // FeatureFilter
/// @brief DOCME
/// @param _name
/// @param _description
/// @param _priority
///
FeatureFilter::FeatureFilter(const wxString &_name, const wxString &_description, int _priority) FeatureFilter::FeatureFilter(const wxString &_name, const wxString &_description, int _priority)
: Feature(SCRIPTFEATURE_FILTER, _name) : Feature(SCRIPTFEATURE_FILTER, _name)
, AssExportFilter() , AssExportFilter()
@ -249,16 +301,28 @@ namespace Automation4 {
Register(_name, _priority); Register(_name, _priority);
} }
/// @brief DOCME
///
FeatureFilter::~FeatureFilter() FeatureFilter::~FeatureFilter()
{ {
Unregister(); Unregister();
} }
/// @brief DOCME
/// @return
///
wxString FeatureFilter::GetScriptSettingsIdentifier() wxString FeatureFilter::GetScriptSettingsIdentifier()
{ {
return inline_string_encode(wxString::Format(_T("Automation Settings %s"), GetName().c_str())); return inline_string_encode(wxString::Format(_T("Automation Settings %s"), GetName().c_str()));
} }
/// @brief DOCME
/// @param parent
/// @return
///
wxWindow* FeatureFilter::GetConfigDialogWindow(wxWindow *parent) { wxWindow* FeatureFilter::GetConfigDialogWindow(wxWindow *parent) {
if (config_dialog) { if (config_dialog) {
delete config_dialog; delete config_dialog;
@ -275,6 +339,10 @@ namespace Automation4 {
} }
} }
/// @brief DOCME
/// @param IsDefault
///
void FeatureFilter::LoadSettings(bool IsDefault) { void FeatureFilter::LoadSettings(bool IsDefault) {
if (config_dialog) { if (config_dialog) {
config_dialog->ReadBack(); config_dialog->ReadBack();
@ -289,6 +357,11 @@ namespace Automation4 {
// FeatureSubtitleFormat // FeatureSubtitleFormat
/// @brief DOCME
/// @param _name
/// @param _extension
///
FeatureSubtitleFormat::FeatureSubtitleFormat(const wxString &_name, const wxString &_extension) FeatureSubtitleFormat::FeatureSubtitleFormat(const wxString &_name, const wxString &_extension)
: Feature(SCRIPTFEATURE_SUBFORMAT, _name) : Feature(SCRIPTFEATURE_SUBFORMAT, _name)
, extension(_extension) , extension(_extension)
@ -296,16 +369,30 @@ namespace Automation4 {
// nothing to do // nothing to do
} }
/// @brief DOCME
/// @return
///
const wxString& FeatureSubtitleFormat::GetExtension() const const wxString& FeatureSubtitleFormat::GetExtension() const
{ {
return extension; return extension;
} }
/// @brief DOCME
/// @param filename
/// @return
///
bool FeatureSubtitleFormat::CanWriteFile(wxString filename) bool FeatureSubtitleFormat::CanWriteFile(wxString filename)
{ {
return !filename.Right(extension.Length()).CmpNoCase(extension); return !filename.Right(extension.Length()).CmpNoCase(extension);
} }
/// @brief DOCME
/// @param filename
/// @return
///
bool FeatureSubtitleFormat::CanReadFile(wxString filename) bool FeatureSubtitleFormat::CanReadFile(wxString filename)
{ {
return !filename.Right(extension.Length()).CmpNoCase(extension); return !filename.Right(extension.Length()).CmpNoCase(extension);
@ -314,23 +401,37 @@ namespace Automation4 {
// ShowConfigDialogEvent // ShowConfigDialogEvent
/// DOCME
const wxEventType EVT_SHOW_CONFIG_DIALOG_t = wxNewEventType(); const wxEventType EVT_SHOW_CONFIG_DIALOG_t = wxNewEventType();
// ScriptConfigDialog // ScriptConfigDialog
/// @brief DOCME
/// @param parent
/// @return
///
wxWindow* ScriptConfigDialog::GetWindow(wxWindow *parent) wxWindow* ScriptConfigDialog::GetWindow(wxWindow *parent)
{ {
if (win) return win; if (win) return win;
return win = CreateWindow(parent); return win = CreateWindow(parent);
} }
/// @brief DOCME
///
void ScriptConfigDialog::DeleteWindow() void ScriptConfigDialog::DeleteWindow()
{ {
if (win) delete win; if (win) delete win;
win = 0; win = 0;
} }
/// @brief DOCME
/// @return
///
wxString ScriptConfigDialog::Serialise() wxString ScriptConfigDialog::Serialise()
{ {
return _T(""); return _T("");
@ -339,6 +440,10 @@ namespace Automation4 {
// ProgressSink // ProgressSink
/// @brief DOCME
/// @param parent
///
ProgressSink::ProgressSink(wxWindow *parent) ProgressSink::ProgressSink(wxWindow *parent)
: wxDialog(parent, -1, _T("Automation"), wxDefaultPosition, wxDefaultSize, wxBORDER_RAISED) : wxDialog(parent, -1, _T("Automation"), wxDefaultPosition, wxDefaultSize, wxBORDER_RAISED)
, debug_visible(false) , debug_visible(false)
@ -384,11 +489,18 @@ namespace Automation4 {
trace_level = Options.AsInt(_T("Automation Trace Level")); trace_level = Options.AsInt(_T("Automation Trace Level"));
} }
/// @brief DOCME
///
ProgressSink::~ProgressSink() ProgressSink::~ProgressSink()
{ {
delete update_timer; delete update_timer;
} }
/// @brief DOCME
/// @param evt
///
void ProgressSink::OnIdle(wxIdleEvent &evt) void ProgressSink::OnIdle(wxIdleEvent &evt)
{ {
// The big glossy "update display" event // The big glossy "update display" event
@ -406,6 +518,10 @@ namespace Automation4 {
} }
} }
/// @brief DOCME
/// @return
///
void ProgressSink::DoUpdateDisplay() void ProgressSink::DoUpdateDisplay()
{ {
// If debug output isn't handled before the test for script_finished later, // If debug output isn't handled before the test for script_finished later,
@ -434,6 +550,10 @@ namespace Automation4 {
data_updated = false; data_updated = false;
} }
/// @brief DOCME
/// @param _progress
///
void ProgressSink::SetProgress(float _progress) void ProgressSink::SetProgress(float _progress)
{ {
wxMutexLocker lock(data_mutex); wxMutexLocker lock(data_mutex);
@ -441,6 +561,10 @@ namespace Automation4 {
data_updated = true; data_updated = true;
} }
/// @brief DOCME
/// @param _task
///
void ProgressSink::SetTask(const wxString &_task) void ProgressSink::SetTask(const wxString &_task)
{ {
wxMutexLocker lock(data_mutex); wxMutexLocker lock(data_mutex);
@ -448,6 +572,10 @@ namespace Automation4 {
data_updated = true; data_updated = true;
} }
/// @brief DOCME
/// @param _title
///
void ProgressSink::SetTitle(const wxString &_title) void ProgressSink::SetTitle(const wxString &_title)
{ {
wxMutexLocker lock(data_mutex); wxMutexLocker lock(data_mutex);
@ -455,6 +583,10 @@ namespace Automation4 {
data_updated = true; data_updated = true;
} }
/// @brief DOCME
/// @param msg
///
void ProgressSink::AddDebugOutput(const wxString &msg) void ProgressSink::AddDebugOutput(const wxString &msg)
{ {
wxMutexLocker lock(data_mutex); wxMutexLocker lock(data_mutex);
@ -469,11 +601,19 @@ namespace Automation4 {
EVT_SHOW_CONFIG_DIALOG(ProgressSink::OnConfigDialog) EVT_SHOW_CONFIG_DIALOG(ProgressSink::OnConfigDialog)
END_EVENT_TABLE() END_EVENT_TABLE()
/// @brief DOCME
/// @param evt
///
void ProgressSink::OnInit(wxInitDialogEvent &evt) void ProgressSink::OnInit(wxInitDialogEvent &evt)
{ {
has_inited = true; has_inited = true;
} }
/// @brief DOCME
/// @param evt
///
void ProgressSink::OnCancel(wxCommandEvent &evt) void ProgressSink::OnCancel(wxCommandEvent &evt)
{ {
if (!script_finished) { if (!script_finished) {
@ -484,6 +624,10 @@ namespace Automation4 {
} }
} }
/// @brief DOCME
/// @param evt
///
void ProgressSink::OnConfigDialog(ShowConfigDialogEvent &evt) void ProgressSink::OnConfigDialog(ShowConfigDialogEvent &evt)
{ {
// assume we're in the GUI thread here // assume we're in the GUI thread here
@ -514,6 +658,10 @@ namespace Automation4 {
// Script // Script
/// @brief DOCME
/// @param _filename
///
Script::Script(const wxString &_filename) Script::Script(const wxString &_filename)
: filename(_filename) : filename(_filename)
, name(_T("")) , name(_T(""))
@ -536,6 +684,9 @@ namespace Automation4 {
} }
} }
/// @brief DOCME
///
Script::~Script() Script::~Script()
{ {
for (std::vector<Feature*>::iterator f = features.begin(); f != features.end(); ++f) { for (std::vector<Feature*>::iterator f = features.begin(); f != features.end(); ++f) {
@ -543,42 +694,74 @@ namespace Automation4 {
} }
} }
/// @brief DOCME
/// @return
///
wxString Script::GetPrettyFilename() const wxString Script::GetPrettyFilename() const
{ {
wxFileName fn(filename); wxFileName fn(filename);
return fn.GetFullName(); return fn.GetFullName();
} }
/// @brief DOCME
/// @return
///
const wxString& Script::GetFilename() const const wxString& Script::GetFilename() const
{ {
return filename; return filename;
} }
/// @brief DOCME
/// @return
///
const wxString& Script::GetName() const const wxString& Script::GetName() const
{ {
return name; return name;
} }
/// @brief DOCME
/// @return
///
const wxString& Script::GetDescription() const const wxString& Script::GetDescription() const
{ {
return description; return description;
} }
/// @brief DOCME
/// @return
///
const wxString& Script::GetAuthor() const const wxString& Script::GetAuthor() const
{ {
return author; return author;
} }
/// @brief DOCME
/// @return
///
const wxString& Script::GetVersion() const const wxString& Script::GetVersion() const
{ {
return version; return version;
} }
/// @brief DOCME
/// @return
///
bool Script::GetLoadedState() const bool Script::GetLoadedState() const
{ {
return loaded; return loaded;
} }
/// @brief DOCME
/// @return
///
std::vector<Feature*>& Script::GetFeatures() std::vector<Feature*>& Script::GetFeatures()
{ {
return features; return features;
@ -587,16 +770,27 @@ namespace Automation4 {
// ScriptManager // ScriptManager
/// @brief DOCME
///
ScriptManager::ScriptManager() ScriptManager::ScriptManager()
{ {
// do nothing...? // do nothing...?
} }
/// @brief DOCME
///
ScriptManager::~ScriptManager() ScriptManager::~ScriptManager()
{ {
RemoveAll(); RemoveAll();
} }
/// @brief DOCME
/// @param script
/// @return
///
void ScriptManager::Add(Script *script) void ScriptManager::Add(Script *script)
{ {
for (std::vector<Script*>::iterator i = scripts.begin(); i != scripts.end(); ++i) { for (std::vector<Script*>::iterator i = scripts.begin(); i != scripts.end(); ++i) {
@ -605,6 +799,11 @@ namespace Automation4 {
scripts.push_back(script); scripts.push_back(script);
} }
/// @brief DOCME
/// @param script
/// @return
///
void ScriptManager::Remove(Script *script) void ScriptManager::Remove(Script *script)
{ {
for (std::vector<Script*>::iterator i = scripts.begin(); i != scripts.end(); ++i) { for (std::vector<Script*>::iterator i = scripts.begin(); i != scripts.end(); ++i) {
@ -616,6 +815,9 @@ namespace Automation4 {
} }
} }
/// @brief DOCME
///
void ScriptManager::RemoveAll() void ScriptManager::RemoveAll()
{ {
for (std::vector<Script*>::iterator i = scripts.begin(); i != scripts.end(); ++i) { for (std::vector<Script*>::iterator i = scripts.begin(); i != scripts.end(); ++i) {
@ -624,11 +826,19 @@ namespace Automation4 {
scripts.clear(); scripts.clear();
} }
/// @brief DOCME
/// @return
///
const std::vector<Script*>& ScriptManager::GetScripts() const const std::vector<Script*>& ScriptManager::GetScripts() const
{ {
return scripts; return scripts;
} }
/// @brief DOCME
/// @return
///
const std::vector<FeatureMacro*>& ScriptManager::GetMacros() const std::vector<FeatureMacro*>& ScriptManager::GetMacros()
{ {
macros.clear(); macros.clear();
@ -646,12 +856,19 @@ namespace Automation4 {
// AutoloadScriptManager // AutoloadScriptManager
/// @brief DOCME
/// @param _path
///
AutoloadScriptManager::AutoloadScriptManager(const wxString &_path) AutoloadScriptManager::AutoloadScriptManager(const wxString &_path)
: path(_path) : path(_path)
{ {
Reload(); Reload();
} }
/// @brief DOCME
///
void AutoloadScriptManager::Reload() void AutoloadScriptManager::Reload()
{ {
RemoveAll(); RemoveAll();
@ -704,18 +921,32 @@ namespace Automation4 {
// ScriptFactory // ScriptFactory
/// DOCME
std::vector<ScriptFactory*> *ScriptFactory::factories = 0; std::vector<ScriptFactory*> *ScriptFactory::factories = 0;
/// @brief DOCME
/// @return
///
const wxString& ScriptFactory::GetEngineName() const const wxString& ScriptFactory::GetEngineName() const
{ {
return engine_name; return engine_name;
} }
/// @brief DOCME
/// @return
///
const wxString& ScriptFactory::GetFilenamePattern() const const wxString& ScriptFactory::GetFilenamePattern() const
{ {
return filename_pattern; return filename_pattern;
} }
/// @brief DOCME
/// @param factory
///
void ScriptFactory::Register(ScriptFactory *factory) void ScriptFactory::Register(ScriptFactory *factory)
{ {
if (!factories) if (!factories)
@ -729,6 +960,11 @@ namespace Automation4 {
factories->push_back(factory); factories->push_back(factory);
} }
/// @brief DOCME
/// @param factory
/// @return
///
void ScriptFactory::Unregister(ScriptFactory *factory) void ScriptFactory::Unregister(ScriptFactory *factory)
{ {
if (!factories) if (!factories)
@ -743,6 +979,12 @@ namespace Automation4 {
} }
} }
/// @brief DOCME
/// @param filename
/// @param log_errors
/// @return
///
Script* ScriptFactory::CreateFromFile(const wxString &filename, bool log_errors) Script* ScriptFactory::CreateFromFile(const wxString &filename, bool log_errors)
{ {
if (!factories) if (!factories)
@ -771,6 +1013,11 @@ namespace Automation4 {
return new UnknownScript(filename); return new UnknownScript(filename);
} }
/// @brief DOCME
/// @param filename
/// @return
///
bool ScriptFactory::CanHandleScriptFormat(const wxString &filename) bool ScriptFactory::CanHandleScriptFormat(const wxString &filename)
{ {
// Just make this always return true to bitch about unknown script formats in autoload // Just make this always return true to bitch about unknown script formats in autoload
@ -786,6 +1033,10 @@ namespace Automation4 {
return false; return false;
} }
/// @brief DOCME
/// @return
///
const std::vector<ScriptFactory*>& ScriptFactory::GetFactories() const std::vector<ScriptFactory*>& ScriptFactory::GetFactories()
{ {
if (!factories) if (!factories)
@ -797,6 +1048,10 @@ namespace Automation4 {
// UnknownScript // UnknownScript
/// @brief DOCME
/// @param filename
///
UnknownScript::UnknownScript(const wxString &filename) UnknownScript::UnknownScript(const wxString &filename)
: Script(filename) : Script(filename)
{ {
@ -810,3 +1065,4 @@ namespace Automation4 {
#endif // WITH_AUTOMATION #endif // WITH_AUTOMATION

View file

@ -37,6 +37,8 @@
#pragma once #pragma once
#ifndef _AUTO4_BASE_H #ifndef _AUTO4_BASE_H
/// DOCME
#define _AUTO4_BASE_H #define _AUTO4_BASE_H
#include <wx/string.h> #include <wx/string.h>
@ -62,18 +64,29 @@ class wxPathList;
DECLARE_EVENT_TYPE(wxEVT_AUTOMATION_SCRIPT_COMPLETED, -1) DECLARE_EVENT_TYPE(wxEVT_AUTOMATION_SCRIPT_COMPLETED, -1)
/// DOCME
namespace Automation4 { namespace Automation4 {
// Calculate the extents of a text string given a style // Calculate the extents of a text string given a style
bool CalculateTextExtents(AssStyle *style, wxString &text, double &width, double &height, double &descent, double &extlead); bool CalculateTextExtents(AssStyle *style, wxString &text, double &width, double &height, double &descent, double &extlead);
// The class of a Feature...
/// DOCME
enum ScriptFeatureClass { enum ScriptFeatureClass {
/// DOCME
SCRIPTFEATURE_MACRO = 0, SCRIPTFEATURE_MACRO = 0,
/// DOCME
SCRIPTFEATURE_FILTER, SCRIPTFEATURE_FILTER,
/// DOCME
SCRIPTFEATURE_SUBFORMAT, SCRIPTFEATURE_SUBFORMAT,
/// DOCME
SCRIPTFEATURE_MAX // must be last SCRIPTFEATURE_MAX // must be last
}; };
@ -83,15 +96,28 @@ namespace Automation4 {
class FeatureMacro; class FeatureMacro;
class FeatureFilter; class FeatureFilter;
class FeatureSubtitleFormat; class FeatureSubtitleFormat;
/// DOCME
/// @class Feature
/// @brief DOCME
///
/// DOCME
class Feature { class Feature {
private: private:
/// DOCME
ScriptFeatureClass featureclass; ScriptFeatureClass featureclass;
/// DOCME
wxString name; wxString name;
protected: protected:
Feature(ScriptFeatureClass _featureclass, const wxString &_name); Feature(ScriptFeatureClass _featureclass, const wxString &_name);
public: public:
/// @brief DOCME
///
virtual ~Feature() { } virtual ~Feature() { }
ScriptFeatureClass GetClass() const; ScriptFeatureClass GetClass() const;
@ -103,15 +129,25 @@ namespace Automation4 {
}; };
// The Macro feature; adds a menu item that runs script code
/// DOCME
/// @class FeatureMacro
/// @brief DOCME
///
/// DOCME
class FeatureMacro : public virtual Feature { class FeatureMacro : public virtual Feature {
private: private:
/// DOCME
wxString description; wxString description;
protected: protected:
FeatureMacro(const wxString &_name, const wxString &_description); FeatureMacro(const wxString &_name, const wxString &_description);
public: public:
/// @brief DOCME
///
virtual ~FeatureMacro() { } virtual ~FeatureMacro() { }
const wxString& GetDescription() const; const wxString& GetDescription() const;
@ -122,9 +158,16 @@ namespace Automation4 {
class ScriptConfigDialog; class ScriptConfigDialog;
// The Export Filter feature; adds a new export filter
/// DOCME
/// @class FeatureFilter
/// @brief DOCME
///
/// DOCME
class FeatureFilter : public virtual Feature, public AssExportFilter { class FeatureFilter : public virtual Feature, public AssExportFilter {
private: private:
/// DOCME
ScriptConfigDialog *config_dialog; ScriptConfigDialog *config_dialog;
protected: protected:
@ -146,15 +189,26 @@ namespace Automation4 {
}; };
// The Subtitle Format feature; adds new subtitle format readers/writers
/// DOCME
/// @class FeatureSubtitleFormat
/// @brief DOCME
///
/// DOCME
class FeatureSubtitleFormat : public virtual Feature, public SubtitleFormat { class FeatureSubtitleFormat : public virtual Feature, public SubtitleFormat {
private: private:
/// DOCME
wxString extension; wxString extension;
protected: protected:
FeatureSubtitleFormat(const wxString &_name, const wxString &_extension); FeatureSubtitleFormat(const wxString &_name, const wxString &_extension);
public: public:
/// @brief DOCME
/// @return
///
virtual ~FeatureSubtitleFormat() { } virtual ~FeatureSubtitleFormat() { }
const wxString& GetExtension() const; const wxString& GetExtension() const;
@ -169,22 +223,39 @@ namespace Automation4 {
}; };
// Base class for script-provided config dialogs
/// DOCME
/// @class ScriptConfigDialog
/// @brief DOCME
///
/// DOCME
class ScriptConfigDialog { class ScriptConfigDialog {
private: private:
/// DOCME
wxWindow *win; wxWindow *win;
protected: protected:
virtual wxWindow* CreateWindow(wxWindow *parent) = 0; virtual wxWindow* CreateWindow(wxWindow *parent) = 0;
public: public:
/// @brief DOCME
///
ScriptConfigDialog() : win(0) { } ScriptConfigDialog() : win(0) { }
/// @brief DOCME
///
virtual ~ScriptConfigDialog() { } virtual ~ScriptConfigDialog() { }
wxWindow* GetWindow(wxWindow *parent); wxWindow* GetWindow(wxWindow *parent);
void DeleteWindow(); void DeleteWindow();
virtual void ReadBack() = 0; virtual void ReadBack() = 0;
virtual wxString Serialise(); virtual wxString Serialise();
/// @brief DOCME
/// @param serialised
///
virtual void Unserialise(const wxString &serialised) { } virtual void Unserialise(const wxString &serialised) { }
}; };
@ -192,51 +263,99 @@ namespace Automation4 {
// Config dialog event class and related stuff (wx </3) // Config dialog event class and related stuff (wx </3)
extern const wxEventType EVT_SHOW_CONFIG_DIALOG_t; extern const wxEventType EVT_SHOW_CONFIG_DIALOG_t;
/// DOCME
/// @class ShowConfigDialogEvent
/// @brief DOCME
///
/// DOCME
class ShowConfigDialogEvent : public wxCommandEvent { class ShowConfigDialogEvent : public wxCommandEvent {
public: public:
/// @brief DOCME
/// @param EVT_SHOW_CONFIG_DIALOG_t
/// @return
///
ShowConfigDialogEvent(const wxEventType &event = EVT_SHOW_CONFIG_DIALOG_t) ShowConfigDialogEvent(const wxEventType &event = EVT_SHOW_CONFIG_DIALOG_t)
: wxCommandEvent(event) : wxCommandEvent(event)
, config_dialog(0) , config_dialog(0)
, sync_sema(0) { }; , sync_sema(0) { };
/// @brief DOCME
/// @return
///
virtual wxEvent *Clone() const { return new ShowConfigDialogEvent(*this); } virtual wxEvent *Clone() const { return new ShowConfigDialogEvent(*this); }
/// DOCME
ScriptConfigDialog *config_dialog; ScriptConfigDialog *config_dialog;
// Synchronisation for config dialog events:
// You don't want the script asynchronically continue executing while the dialog /// DOCME
// is displaying, so a synchronisation mechanism is used.
// The poster of the event should supply a semaphore object with an initial count
// of zero. After posting the event, the poster should wait for the semaphore.
// When the dialog is finished, the semaphore is posted, and the poster can
// continue.
// The poster is responsible for cleaning up the semaphore.
wxSemaphore *sync_sema; wxSemaphore *sync_sema;
}; };
/// DOCME
typedef void (wxEvtHandler::*ShowConfigDialogEventFunction)(ShowConfigDialogEvent&); typedef void (wxEvtHandler::*ShowConfigDialogEventFunction)(ShowConfigDialogEvent&);
/// DOCME
#define EVT_SHOW_CONFIG_DIALOG(fn) DECLARE_EVENT_TABLE_ENTRY( EVT_SHOW_CONFIG_DIALOG_t, -1, -1, (wxObjectEventFunction)(wxEventFunction)(ShowConfigDialogEventFunction)&fn, (wxObject*)0 ), #define EVT_SHOW_CONFIG_DIALOG(fn) DECLARE_EVENT_TABLE_ENTRY( EVT_SHOW_CONFIG_DIALOG_t, -1, -1, (wxObjectEventFunction)(wxEventFunction)(ShowConfigDialogEventFunction)&fn, (wxObject*)0 ),
// Base class for progress reporting/other output
/// DOCME
/// @class ProgressSink
/// @brief DOCME
///
/// DOCME
class ProgressSink : public wxDialog { class ProgressSink : public wxDialog {
private: private:
/// DOCME
wxBoxSizer *sizer; wxBoxSizer *sizer;
/// DOCME
wxGauge *progress_display; wxGauge *progress_display;
/// DOCME
wxButton *cancel_button; wxButton *cancel_button;
/// DOCME
wxStaticText *title_display; wxStaticText *title_display;
/// DOCME
wxStaticText *task_display; wxStaticText *task_display;
/// DOCME
wxTextCtrl *debug_output; wxTextCtrl *debug_output;
/// DOCME
volatile bool debug_visible; volatile bool debug_visible;
/// DOCME
volatile bool data_updated; volatile bool data_updated;
/// DOCME
float progress; float progress;
/// DOCME
wxString task; wxString task;
/// DOCME
wxString title; wxString title;
/// DOCME
wxString pending_debug_output; wxString pending_debug_output;
/// DOCME
wxMutex data_mutex; wxMutex data_mutex;
/// DOCME
wxTimer *update_timer; wxTimer *update_timer;
void OnCancel(wxCommandEvent &evt); void OnCancel(wxCommandEvent &evt);
@ -247,7 +366,11 @@ namespace Automation4 {
void DoUpdateDisplay(); void DoUpdateDisplay();
protected: protected:
/// DOCME
volatile bool cancelled; volatile bool cancelled;
/// DOCME
int trace_level; int trace_level;
ProgressSink(wxWindow *parent); ProgressSink(wxWindow *parent);
@ -259,27 +382,52 @@ namespace Automation4 {
void SetTitle(const wxString &_title); void SetTitle(const wxString &_title);
void AddDebugOutput(const wxString &msg); void AddDebugOutput(const wxString &msg);
/// DOCME
volatile bool has_inited; volatile bool has_inited;
/// DOCME
volatile bool script_finished; volatile bool script_finished;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
// Base class for Scripts
/// DOCME
/// @class Script
/// @brief DOCME
///
/// DOCME
class Script { class Script {
private: private:
/// DOCME
wxString filename; wxString filename;
protected: protected:
/// DOCME
wxString name; wxString name;
/// DOCME
wxString description; wxString description;
/// DOCME
wxString author; wxString author;
/// DOCME
wxString version; wxString version;
/// DOCME
bool loaded; // is the script properly loaded? bool loaded; // is the script properly loaded?
/// DOCME
wxPathList include_path; wxPathList include_path;
/// DOCME
std::vector<Feature*> features; std::vector<Feature*> features;
Script(const wxString &_filename); Script(const wxString &_filename);
@ -301,13 +449,20 @@ namespace Automation4 {
}; };
// Manages loaded scripts; for whatever reason, multiple managers might be instantiated. In truth, this is more
// like a macro manager at the moment, since Export Filter and Subtitle Format are already managed by other /// DOCME
// classes. /// @class ScriptManager
/// @brief DOCME
///
/// DOCME
class ScriptManager { class ScriptManager {
private: private:
/// DOCME
std::vector<Script*> scripts; std::vector<Script*> scripts;
/// DOCME
std::vector<FeatureMacro*> macros; std::vector<FeatureMacro*> macros;
public: public:
@ -325,9 +480,16 @@ namespace Automation4 {
}; };
// Scans a directory for scripts and attempts to load all of them
/// DOCME
/// @class AutoloadScriptManager
/// @brief DOCME
///
/// DOCME
class AutoloadScriptManager : public ScriptManager { class AutoloadScriptManager : public ScriptManager {
private: private:
/// DOCME
wxString path; wxString path;
public: public:
AutoloadScriptManager(const wxString &_path); AutoloadScriptManager(const wxString &_path);
@ -335,15 +497,31 @@ namespace Automation4 {
}; };
// Script factory; each scripting engine should create exactly one instance of this object and register it.
// This is used to create Script objects from a file. /// DOCME
/// @class ScriptFactory
/// @brief DOCME
///
/// DOCME
class ScriptFactory { class ScriptFactory {
private: private:
/// DOCME
static std::vector<ScriptFactory*> *factories; static std::vector<ScriptFactory*> *factories;
protected: protected:
/// @brief DOCME
///
ScriptFactory() { } ScriptFactory() { }
/// @brief DOCME
///
virtual ~ScriptFactory() { } virtual ~ScriptFactory() { }
/// DOCME
wxString engine_name; wxString engine_name;
/// DOCME
wxString filename_pattern; wxString filename_pattern;
public: public:
virtual Script* Produce(const wxString &filename) const = 0; virtual Script* Produce(const wxString &filename) const = 0;
@ -357,10 +535,18 @@ namespace Automation4 {
static const std::vector<ScriptFactory*>& GetFactories(); static const std::vector<ScriptFactory*>& GetFactories();
}; };
// Dummy class for scripts that could not be loaded by the ScriptFactory
/// DOCME
/// @class UnknownScript
/// @brief DOCME
///
/// DOCME
class UnknownScript : public Script { class UnknownScript : public Script {
public: public:
UnknownScript(const wxString &filename); UnknownScript(const wxString &filename);
/// @brief DOCME
///
void Reload() { }; void Reload() { };
}; };
@ -368,3 +554,4 @@ namespace Automation4 {
#endif #endif

View file

@ -66,6 +66,8 @@
#include <assert.h> #include <assert.h>
#include <algorithm> #include <algorithm>
/// DOCME
namespace Automation4 { namespace Automation4 {
// LuaStackcheck // LuaStackcheck
@ -104,10 +106,26 @@ namespace Automation4 {
~LuaStackcheck() { check_stack(0); } ~LuaStackcheck() { check_stack(0); }
}; };
#else #else
/// DOCME
struct LuaStackcheck { struct LuaStackcheck {
/// @brief DOCME
/// @param additional
///
void check_stack(int additional) { } void check_stack(int additional) { }
/// @brief DOCME
///
void dump() { } void dump() { }
/// @brief DOCME
/// @param L
///
LuaStackcheck(lua_State *L) { } LuaStackcheck(lua_State *L) { }
/// @brief DOCME
///
~LuaStackcheck() { } ~LuaStackcheck() { }
}; };
#endif #endif
@ -115,6 +133,10 @@ namespace Automation4 {
// LuaScript // LuaScript
/// @brief DOCME
/// @param filename
///
LuaScript::LuaScript(const wxString &filename) LuaScript::LuaScript(const wxString &filename)
: Script(filename) : Script(filename)
, L(0) , L(0)
@ -122,11 +144,17 @@ namespace Automation4 {
Create(); Create();
} }
/// @brief DOCME
///
LuaScript::~LuaScript() LuaScript::~LuaScript()
{ {
if (L) Destroy(); if (L) Destroy();
} }
/// @brief DOCME
///
void LuaScript::Create() void LuaScript::Create()
{ {
Destroy(); Destroy();
@ -265,6 +293,10 @@ namespace Automation4 {
} }
} }
/// @brief DOCME
/// @return
///
void LuaScript::Destroy() void LuaScript::Destroy()
{ {
// Assume the script object is clean if there's no Lua state // Assume the script object is clean if there's no Lua state
@ -284,12 +316,20 @@ namespace Automation4 {
loaded = false; loaded = false;
} }
/// @brief DOCME
///
void LuaScript::Reload() void LuaScript::Reload()
{ {
Destroy(); Destroy();
Create(); Create();
} }
/// @brief DOCME
/// @param L
/// @return
///
LuaScript* LuaScript::GetScriptObject(lua_State *L) LuaScript* LuaScript::GetScriptObject(lua_State *L)
{ {
lua_getfield(L, LUA_REGISTRYINDEX, "aegisub"); lua_getfield(L, LUA_REGISTRYINDEX, "aegisub");
@ -298,6 +338,11 @@ namespace Automation4 {
return (LuaScript*)ptr; return (LuaScript*)ptr;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaScript::LuaTextExtents(lua_State *L) int LuaScript::LuaTextExtents(lua_State *L)
{ {
if (!lua_istable(L, 1)) { if (!lua_istable(L, 1)) {
@ -336,6 +381,11 @@ namespace Automation4 {
return 4; return 4;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaScript::LuaInclude(lua_State *L) int LuaScript::LuaInclude(lua_State *L)
{ {
LuaScript *s = GetScriptObject(L); LuaScript *s = GetScriptObject(L);
@ -374,6 +424,11 @@ namespace Automation4 {
return lua_gettop(L) - pretop; return lua_gettop(L) - pretop;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaScript::LuaFrameFromMs(lua_State *L) int LuaScript::LuaFrameFromMs(lua_State *L)
{ {
int ms = (int)lua_tonumber(L, -1); int ms = (int)lua_tonumber(L, -1);
@ -387,6 +442,11 @@ namespace Automation4 {
} }
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaScript::LuaMsFromFrame(lua_State *L) int LuaScript::LuaMsFromFrame(lua_State *L)
{ {
int frame = (int)lua_tonumber(L, -1); int frame = (int)lua_tonumber(L, -1);
@ -400,6 +460,11 @@ namespace Automation4 {
} }
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaScript::LuaVideoSize(lua_State *L) int LuaScript::LuaVideoSize(lua_State *L)
{ {
VideoContext *ctx = VideoContext::Get(); VideoContext *ctx = VideoContext::Get();
@ -418,6 +483,12 @@ namespace Automation4 {
// LuaThreadedCall // LuaThreadedCall
/// @brief DOCME
/// @param _L
/// @param _nargs
/// @param _nresults
///
LuaThreadedCall::LuaThreadedCall(lua_State *_L, int _nargs, int _nresults) LuaThreadedCall::LuaThreadedCall(lua_State *_L, int _nargs, int _nresults)
: wxThread(wxTHREAD_JOINABLE) : wxThread(wxTHREAD_JOINABLE)
, L(_L) , L(_L)
@ -434,6 +505,10 @@ namespace Automation4 {
Run(); Run();
} }
/// @brief DOCME
/// @return
///
wxThread::ExitCode LuaThreadedCall::Entry() wxThread::ExitCode LuaThreadedCall::Entry()
{ {
int result = lua_pcall(L, nargs, nresults, 0); int result = lua_pcall(L, nargs, nresults, 0);
@ -466,12 +541,21 @@ namespace Automation4 {
// LuaFeature // LuaFeature
/// @brief DOCME
/// @param _L
/// @param _featureclass
/// @param _name
///
LuaFeature::LuaFeature(lua_State *_L, ScriptFeatureClass _featureclass, const wxString &_name) LuaFeature::LuaFeature(lua_State *_L, ScriptFeatureClass _featureclass, const wxString &_name)
: Feature(_featureclass, _name) : Feature(_featureclass, _name)
, L(_L) , L(_L)
{ {
} }
/// @brief DOCME
///
void LuaFeature::RegisterFeature() void LuaFeature::RegisterFeature()
{ {
// get the LuaScript objects // get the LuaScript objects
@ -493,6 +577,10 @@ namespace Automation4 {
lua_pop(L, 1); lua_pop(L, 1);
} }
/// @brief DOCME
/// @param functionid
///
void LuaFeature::GetFeatureFunction(int functionid) void LuaFeature::GetFeatureFunction(int functionid)
{ {
// get feature table // get feature table
@ -505,6 +593,10 @@ namespace Automation4 {
lua_remove(L, -2); lua_remove(L, -2);
} }
/// @brief DOCME
/// @param ints
///
void LuaFeature::CreateIntegerArray(const std::vector<int> &ints) void LuaFeature::CreateIntegerArray(const std::vector<int> &ints)
{ {
// create an array-style table with an integer vector in it // create an array-style table with an integer vector in it
@ -516,6 +608,9 @@ namespace Automation4 {
} }
} }
/// @brief DOCME
///
void LuaFeature::ThrowError() void LuaFeature::ThrowError()
{ {
wxString err(lua_tostring(L, -1), wxConvUTF8); wxString err(lua_tostring(L, -1), wxConvUTF8);
@ -526,6 +621,11 @@ namespace Automation4 {
// LuaFeatureMacro // LuaFeatureMacro
/// @brief DOCME
/// @param L
/// @return
///
int LuaFeatureMacro::LuaRegister(lua_State *L) int LuaFeatureMacro::LuaRegister(lua_State *L)
{ {
wxString _name(lua_tostring(L, 1), wxConvUTF8); wxString _name(lua_tostring(L, 1), wxConvUTF8);
@ -537,6 +637,12 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @param _name
/// @param _description
/// @param _L
///
LuaFeatureMacro::LuaFeatureMacro(const wxString &_name, const wxString &_description, lua_State *_L) LuaFeatureMacro::LuaFeatureMacro(const wxString &_name, const wxString &_description, lua_State *_L)
: Feature(SCRIPTFEATURE_MACRO, _name) : Feature(SCRIPTFEATURE_MACRO, _name)
, FeatureMacro(_name, _description) , FeatureMacro(_name, _description)
@ -561,6 +667,13 @@ namespace Automation4 {
lua_pop(L, 1); lua_pop(L, 1);
} }
/// @brief DOCME
/// @param subs
/// @param selected
/// @param active
/// @return
///
bool LuaFeatureMacro::Validate(AssFile *subs, const std::vector<int> &selected, int active) bool LuaFeatureMacro::Validate(AssFile *subs, const std::vector<int> &selected, int active)
{ {
if (no_validate) if (no_validate)
@ -591,6 +704,14 @@ namespace Automation4 {
return result; return result;
} }
/// @brief DOCME
/// @param subs
/// @param selected
/// @param active
/// @param progress_parent
/// @return
///
void LuaFeatureMacro::Process(AssFile *subs, std::vector<int> &selected, int active, wxWindow * const progress_parent) void LuaFeatureMacro::Process(AssFile *subs, std::vector<int> &selected, int active, wxWindow * const progress_parent)
{ {
GetFeatureFunction(1); // 1 = processing function GetFeatureFunction(1); // 1 = processing function
@ -636,6 +757,13 @@ namespace Automation4 {
// LuaFeatureFilter // LuaFeatureFilter
/// @brief DOCME
/// @param _name
/// @param _description
/// @param merit
/// @param _L
///
LuaFeatureFilter::LuaFeatureFilter(const wxString &_name, const wxString &_description, int merit, lua_State *_L) LuaFeatureFilter::LuaFeatureFilter(const wxString &_name, const wxString &_description, int merit, lua_State *_L)
: Feature(SCRIPTFEATURE_FILTER, _name) : Feature(SCRIPTFEATURE_FILTER, _name)
, FeatureFilter(_name, _description, merit) , FeatureFilter(_name, _description, merit)
@ -656,11 +784,19 @@ namespace Automation4 {
lua_pop(L, 1); lua_pop(L, 1);
} }
/// @brief DOCME
///
void LuaFeatureFilter::Init() void LuaFeatureFilter::Init()
{ {
// Don't think there's anything to do here... (empty in auto3) // Don't think there's anything to do here... (empty in auto3)
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaFeatureFilter::LuaRegister(lua_State *L) int LuaFeatureFilter::LuaRegister(lua_State *L)
{ {
wxString _name(lua_tostring(L, 1), wxConvUTF8); wxString _name(lua_tostring(L, 1), wxConvUTF8);
@ -673,6 +809,11 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @param subs
/// @param export_dialog
///
void LuaFeatureFilter::ProcessSubs(AssFile *subs, wxWindow *export_dialog) void LuaFeatureFilter::ProcessSubs(AssFile *subs, wxWindow *export_dialog)
{ {
LuaStackcheck stackcheck(L); LuaStackcheck stackcheck(L);
@ -719,6 +860,11 @@ namespace Automation4 {
delete ps; delete ps;
} }
/// @brief DOCME
/// @param parent
/// @return
///
ScriptConfigDialog* LuaFeatureFilter::GenerateConfigDialog(wxWindow *parent) ScriptConfigDialog* LuaFeatureFilter::GenerateConfigDialog(wxWindow *parent)
{ {
if (!has_config) if (!has_config)
@ -749,6 +895,12 @@ namespace Automation4 {
// LuaProgressSink // LuaProgressSink
/// @brief DOCME
/// @param _L
/// @param parent
/// @param allow_config_dialog
///
LuaProgressSink::LuaProgressSink(lua_State *_L, wxWindow *parent, bool allow_config_dialog) LuaProgressSink::LuaProgressSink(lua_State *_L, wxWindow *parent, bool allow_config_dialog)
: ProgressSink(parent) : ProgressSink(parent)
, L(_L) , L(_L)
@ -802,6 +954,9 @@ namespace Automation4 {
lua_pop(L, 2); lua_pop(L, 2);
} }
/// @brief DOCME
///
LuaProgressSink::~LuaProgressSink() LuaProgressSink::~LuaProgressSink()
{ {
// remove progress reporting stuff // remove progress reporting stuff
@ -815,6 +970,12 @@ namespace Automation4 {
lua_setfield(L, LUA_REGISTRYINDEX, "progress_sink"); lua_setfield(L, LUA_REGISTRYINDEX, "progress_sink");
} }
/// @brief DOCME
/// @param L
/// @param idx
/// @return
///
LuaProgressSink* LuaProgressSink::GetObjPointer(lua_State *L, int idx) LuaProgressSink* LuaProgressSink::GetObjPointer(lua_State *L, int idx)
{ {
assert(lua_type(L, idx) == LUA_TUSERDATA); assert(lua_type(L, idx) == LUA_TUSERDATA);
@ -822,6 +983,11 @@ namespace Automation4 {
return *((LuaProgressSink**)ud); return *((LuaProgressSink**)ud);
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaProgressSink::LuaSetProgress(lua_State *L) int LuaProgressSink::LuaSetProgress(lua_State *L)
{ {
LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1)); LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
@ -830,6 +996,11 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaProgressSink::LuaSetTask(lua_State *L) int LuaProgressSink::LuaSetTask(lua_State *L)
{ {
LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1)); LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
@ -838,6 +1009,11 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaProgressSink::LuaSetTitle(lua_State *L) int LuaProgressSink::LuaSetTitle(lua_State *L)
{ {
LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1)); LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
@ -846,6 +1022,11 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaProgressSink::LuaGetCancelled(lua_State *L) int LuaProgressSink::LuaGetCancelled(lua_State *L)
{ {
LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1)); LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
@ -853,6 +1034,11 @@ namespace Automation4 {
return 1; return 1;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaProgressSink::LuaDebugOut(lua_State *L) int LuaProgressSink::LuaDebugOut(lua_State *L)
{ {
LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1)); LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
@ -887,6 +1073,11 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaProgressSink::LuaDisplayDialog(lua_State *L) int LuaProgressSink::LuaDisplayDialog(lua_State *L)
{ {
LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1)); LuaProgressSink *ps = GetObjPointer(L, lua_upvalueindex(1));
@ -919,10 +1110,18 @@ namespace Automation4 {
return dlg.LuaReadBack(L); return dlg.LuaReadBack(L);
} }
// Factory methods
/// @brief // Factory methods
///
LuaScriptFactory::LuaScriptFactory() {} LuaScriptFactory::LuaScriptFactory() {}
/// @brief DOCME
///
LuaScriptFactory::~LuaScriptFactory() {} LuaScriptFactory::~LuaScriptFactory() {}
/// @brief DOCME
///
void LuaScriptFactory::RegisterFactory () void LuaScriptFactory::RegisterFactory ()
{ {
engine_name = _T("Lua"); engine_name = _T("Lua");
@ -930,6 +1129,10 @@ namespace Automation4 {
Register(this); Register(this);
} }
/// @brief DOCME
/// @param filename
///
Script* LuaScriptFactory::Produce(const wxString &filename) const Script* LuaScriptFactory::Produce(const wxString &filename) const
{ {
// Just check if file extension is .lua // Just check if file extension is .lua
@ -945,3 +1148,4 @@ namespace Automation4 {
#endif // WITH_AUTO4_LUA #endif // WITH_AUTO4_LUA

View file

@ -37,6 +37,8 @@
#pragma once #pragma once
#ifndef _AUTO4_LUA_H #ifndef _AUTO4_LUA_H
/// DOCME
#define _AUTO4_LUA_H #define _AUTO4_LUA_H
#include "auto4_base.h" #include "auto4_base.h"
@ -52,20 +54,38 @@
class wxWindow; class wxWindow;
/// DOCME
namespace Automation4 { namespace Automation4 {
// Provides access to an AssFile object (and all lines contained) for a Lua script
/// DOCME
/// @class LuaAssFile
/// @brief DOCME
///
/// DOCME
class LuaAssFile { class LuaAssFile {
private: private:
/// DOCME
AssFile *ass; AssFile *ass;
/// DOCME
lua_State *L; lua_State *L;
/// DOCME
bool can_modify; bool can_modify;
/// DOCME
bool can_set_undo; bool can_set_undo;
void CheckAllowModify(); // throws an error if modification is disallowed void CheckAllowModify(); // throws an error if modification is disallowed
// keep a cursor of last accessed item to avoid walking over the entire file on every access
/// DOCME
std::list<AssEntry*>::iterator last_entry_ptr; std::list<AssEntry*>::iterator last_entry_ptr;
/// DOCME
int last_entry_id; int last_entry_id;
void GetAssEntry(int n); // set last_entry_ptr to point to item n void GetAssEntry(int n); // set last_entry_ptr to point to item n
@ -94,9 +114,16 @@ namespace Automation4 {
}; };
// Provides progress UI and control functions for a Lua script
/// DOCME
/// @class LuaProgressSink
/// @brief DOCME
///
/// DOCME
class LuaProgressSink : public ProgressSink { class LuaProgressSink : public ProgressSink {
private: private:
/// DOCME
lua_State *L; lua_State *L;
static int LuaSetProgress(lua_State *L); static int LuaSetProgress(lua_State *L);
@ -114,38 +141,96 @@ namespace Automation4 {
}; };
// Provides Config UI functions for a Lua script
/// DOCME
/// @class LuaConfigDialogControl
/// @brief DOCME
///
/// DOCME
class LuaConfigDialogControl { class LuaConfigDialogControl {
public: public:
/// DOCME
wxControl *cw; // control window wxControl *cw; // control window
/// DOCME
/// DOCME
wxString name, hint; wxString name, hint;
/// DOCME
/// DOCME
/// DOCME
/// DOCME
int x, y, width, height; int x, y, width, height;
virtual wxControl *Create(wxWindow *parent) = 0; virtual wxControl *Create(wxWindow *parent) = 0;
virtual void ControlReadBack() = 0; virtual void ControlReadBack() = 0;
virtual void LuaReadBack(lua_State *L) = 0; virtual void LuaReadBack(lua_State *L) = 0;
/// @brief DOCME
/// @return
///
virtual bool CanSerialiseValue() { return false; } virtual bool CanSerialiseValue() { return false; }
/// @brief DOCME
/// @return
///
virtual wxString SerialiseValue() { return _T(""); } virtual wxString SerialiseValue() { return _T(""); }
/// @brief DOCME
/// @param serialised
///
virtual void UnserialiseValue(const wxString &serialised) { } virtual void UnserialiseValue(const wxString &serialised) { }
LuaConfigDialogControl(lua_State *L); LuaConfigDialogControl(lua_State *L);
/// @brief DOCME
///
virtual ~LuaConfigDialogControl() { } virtual ~LuaConfigDialogControl() { }
}; };
/// DOCME
/// @class LuaConfigDialog
/// @brief DOCME
///
/// DOCME
class LuaConfigDialog : public ScriptConfigDialog { class LuaConfigDialog : public ScriptConfigDialog {
private: private:
/// DOCME
std::vector<LuaConfigDialogControl*> controls; std::vector<LuaConfigDialogControl*> controls;
/// DOCME
std::vector<wxString> buttons; std::vector<wxString> buttons;
/// DOCME
bool use_buttons; bool use_buttons;
/// DOCME
/// @class ButtonEventHandler
/// @brief DOCME
///
/// DOCME
class ButtonEventHandler : public wxEvtHandler { class ButtonEventHandler : public wxEvtHandler {
public: public:
/// DOCME
int *button_pushed; int *button_pushed;
void OnButtonPush(wxCommandEvent &evt); void OnButtonPush(wxCommandEvent &evt);
}; };
/// DOCME
ButtonEventHandler *button_event; ButtonEventHandler *button_event;
/// DOCME
int button_pushed; int button_pushed;
protected: protected:
@ -163,10 +248,19 @@ namespace Automation4 {
}; };
// Second base-class for Lua implemented Features
/// DOCME
/// @class LuaFeature
/// @brief DOCME
///
/// DOCME
class LuaFeature : public virtual Feature { class LuaFeature : public virtual Feature {
protected: protected:
/// DOCME
lua_State *L; lua_State *L;
/// DOCME
int myid; int myid;
LuaFeature(lua_State *_L, ScriptFeatureClass _featureclass, const wxString &_name); LuaFeature(lua_State *_L, ScriptFeatureClass _featureclass, const wxString &_name);
@ -179,11 +273,18 @@ namespace Automation4 {
}; };
// Class of Lua scripts
/// DOCME
/// @class LuaScript
/// @brief DOCME
///
/// DOCME
class LuaScript : public Script { class LuaScript : public Script {
friend class LuaFeature; friend class LuaFeature;
private: private:
/// DOCME
lua_State *L; lua_State *L;
void Create(); // load script and create internal structures etc. void Create(); // load script and create internal structures etc.
@ -205,12 +306,22 @@ namespace Automation4 {
}; };
// A single call to a Lua function, run inside a separate thread.
// This object should be created on the stack in the function that does the call. /// DOCME
/// @class LuaThreadedCall
/// @brief DOCME
///
/// DOCME
class LuaThreadedCall : public wxThread { class LuaThreadedCall : public wxThread {
private: private:
/// DOCME
lua_State *L; lua_State *L;
/// DOCME
int nargs; int nargs;
/// DOCME
int nresults; int nresults;
public: public:
LuaThreadedCall(lua_State *_L, int _nargs, int _nresults); LuaThreadedCall(lua_State *_L, int _nargs, int _nresults);
@ -218,14 +329,24 @@ namespace Automation4 {
}; };
// Implementation of the Macro Feature for Lua scripts
/// DOCME
/// @class LuaFeatureMacro
/// @brief DOCME
///
/// DOCME
class LuaFeatureMacro : public FeatureMacro, LuaFeature { class LuaFeatureMacro : public FeatureMacro, LuaFeature {
private: private:
/// DOCME
bool no_validate; bool no_validate;
protected: protected:
LuaFeatureMacro(const wxString &_name, const wxString &_description, lua_State *_L); LuaFeatureMacro(const wxString &_name, const wxString &_description, lua_State *_L);
public: public:
static int LuaRegister(lua_State *L); static int LuaRegister(lua_State *L);
/// @brief DOCME
///
virtual ~LuaFeatureMacro() { } virtual ~LuaFeatureMacro() { }
virtual bool Validate(AssFile *subs, const std::vector<int> &selected, int active); virtual bool Validate(AssFile *subs, const std::vector<int> &selected, int active);
@ -233,10 +354,19 @@ namespace Automation4 {
}; };
// Implementation of the Export Filter Feature for Lua scripts
/// DOCME
/// @class LuaFeatureFilter
/// @brief DOCME
///
/// DOCME
class LuaFeatureFilter : public FeatureFilter, LuaFeature { class LuaFeatureFilter : public FeatureFilter, LuaFeature {
private: private:
/// DOCME
bool has_config; bool has_config;
/// DOCME
LuaConfigDialog *config_dialog; LuaConfigDialog *config_dialog;
protected: protected:
@ -248,6 +378,9 @@ namespace Automation4 {
public: public:
static int LuaRegister(lua_State *L); static int LuaRegister(lua_State *L);
/// @brief DOCME
///
virtual ~LuaFeatureFilter() { } virtual ~LuaFeatureFilter() { }
void ProcessSubs(AssFile *subs, wxWindow *export_dialog); void ProcessSubs(AssFile *subs, wxWindow *export_dialog);
@ -257,3 +390,4 @@ namespace Automation4 {
#endif #endif

View file

@ -56,10 +56,16 @@
#include <assert.h> #include <assert.h>
#include <algorithm> #include <algorithm>
/// DOCME
namespace Automation4 { namespace Automation4 {
// LuaAssFile // LuaAssFile
/// @brief DOCME
/// @return
///
void LuaAssFile::CheckAllowModify() void LuaAssFile::CheckAllowModify()
{ {
if (can_modify) if (can_modify)
@ -68,6 +74,11 @@ namespace Automation4 {
lua_error(L); lua_error(L);
} }
/// @brief DOCME
/// @param L
/// @param e
///
void LuaAssFile::AssEntryToLua(lua_State *L, AssEntry *e) void LuaAssFile::AssEntryToLua(lua_State *L, AssEntry *e)
{ {
lua_newtable(L); lua_newtable(L);
@ -231,6 +242,11 @@ namespace Automation4 {
lua_setfield(L, -2, "class"); lua_setfield(L, -2, "class");
} }
/// @brief DOCME
/// @param L
/// @return
///
AssEntry *LuaAssFile::LuaToAssEntry(lua_State *L) AssEntry *LuaAssFile::LuaToAssEntry(lua_State *L)
{ {
// assume an assentry table is on the top of the stack // assume an assentry table is on the top of the stack
@ -254,6 +270,8 @@ namespace Automation4 {
AssEntry *result; AssEntry *result;
/// DOCME
#define GETSTRING(varname, fieldname, lineclass) \ #define GETSTRING(varname, fieldname, lineclass) \
lua_getfield(L, -1, fieldname); \ lua_getfield(L, -1, fieldname); \
if (!lua_isstring(L, -1)) { \ if (!lua_isstring(L, -1)) { \
@ -263,6 +281,8 @@ namespace Automation4 {
} \ } \
wxString varname (lua_tostring(L, -1), wxConvUTF8); \ wxString varname (lua_tostring(L, -1), wxConvUTF8); \
lua_pop(L, 1); lua_pop(L, 1);
/// DOCME
#define GETFLOAT(varname, fieldname, lineclass) \ #define GETFLOAT(varname, fieldname, lineclass) \
lua_getfield(L, -1, fieldname); \ lua_getfield(L, -1, fieldname); \
if (!lua_isnumber(L, -1)) { \ if (!lua_isnumber(L, -1)) { \
@ -272,6 +292,8 @@ namespace Automation4 {
} \ } \
float varname = lua_tonumber(L, -1); \ float varname = lua_tonumber(L, -1); \
lua_pop(L, 1); lua_pop(L, 1);
/// DOCME
#define GETINT(varname, fieldname, lineclass) \ #define GETINT(varname, fieldname, lineclass) \
lua_getfield(L, -1, fieldname); \ lua_getfield(L, -1, fieldname); \
if (!lua_isnumber(L, -1)) { \ if (!lua_isnumber(L, -1)) { \
@ -281,6 +303,8 @@ namespace Automation4 {
} \ } \
int varname = lua_tointeger(L, -1); \ int varname = lua_tointeger(L, -1); \
lua_pop(L, 1); lua_pop(L, 1);
/// DOCME
#define GETBOOL(varname, fieldname, lineclass) \ #define GETBOOL(varname, fieldname, lineclass) \
lua_getfield(L, -1, fieldname); \ lua_getfield(L, -1, fieldname); \
if (!lua_isboolean(L, -1)) { \ if (!lua_isboolean(L, -1)) { \
@ -418,15 +442,27 @@ namespace Automation4 {
return 0; return 0;
} }
/// DOCME
#undef GETSTRING #undef GETSTRING
/// DOCME
#undef GETFLOAT #undef GETFLOAT
/// DOCME
#undef GETINT #undef GETINT
/// DOCME
#undef GETBOOL #undef GETBOOL
//lua_pop(L, 1); // the function shouldn't eat the table it converted //lua_pop(L, 1); // the function shouldn't eat the table it converted
return result; return result;
} }
/// @brief DOCME
/// @param n
///
void LuaAssFile::GetAssEntry(int n) void LuaAssFile::GetAssEntry(int n)
{ {
entryIter e; entryIter e;
@ -460,6 +496,11 @@ namespace Automation4 {
} }
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaAssFile::ObjectIndexRead(lua_State *L) int LuaAssFile::ObjectIndexRead(lua_State *L)
{ {
LuaAssFile *laf = GetObjPointer(L, 1); LuaAssFile *laf = GetObjPointer(L, 1);
@ -538,6 +579,11 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaAssFile::ObjectIndexWrite(lua_State *L) int LuaAssFile::ObjectIndexWrite(lua_State *L)
{ {
// instead of implementing everything twice, just call the other modification-functions from here // instead of implementing everything twice, just call the other modification-functions from here
@ -593,6 +639,11 @@ namespace Automation4 {
} }
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaAssFile::ObjectGetLen(lua_State *L) int LuaAssFile::ObjectGetLen(lua_State *L)
{ {
LuaAssFile *laf = GetObjPointer(L, 1); LuaAssFile *laf = GetObjPointer(L, 1);
@ -600,6 +651,11 @@ namespace Automation4 {
return 1; return 1;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaAssFile::ObjectDelete(lua_State *L) int LuaAssFile::ObjectDelete(lua_State *L)
{ {
LuaAssFile *laf = GetObjPointer(L, lua_upvalueindex(1)); LuaAssFile *laf = GetObjPointer(L, lua_upvalueindex(1));
@ -648,6 +704,11 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaAssFile::ObjectDeleteRange(lua_State *L) int LuaAssFile::ObjectDeleteRange(lua_State *L)
{ {
LuaAssFile *laf = GetObjPointer(L, lua_upvalueindex(1)); LuaAssFile *laf = GetObjPointer(L, lua_upvalueindex(1));
@ -687,6 +748,11 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaAssFile::ObjectAppend(lua_State *L) int LuaAssFile::ObjectAppend(lua_State *L)
{ {
LuaAssFile *laf = GetObjPointer(L, lua_upvalueindex(1)); LuaAssFile *laf = GetObjPointer(L, lua_upvalueindex(1));
@ -709,6 +775,11 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaAssFile::ObjectInsert(lua_State *L) int LuaAssFile::ObjectInsert(lua_State *L)
{ {
LuaAssFile *laf = GetObjPointer(L, lua_upvalueindex(1)); LuaAssFile *laf = GetObjPointer(L, lua_upvalueindex(1));
@ -736,6 +807,11 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaAssFile::ObjectGarbageCollect(lua_State *L) int LuaAssFile::ObjectGarbageCollect(lua_State *L)
{ {
LuaAssFile *laf = GetObjPointer(L, 1); LuaAssFile *laf = GetObjPointer(L, 1);
@ -744,6 +820,11 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaAssFile::LuaParseTagData(lua_State *L) int LuaAssFile::LuaParseTagData(lua_State *L)
{ {
lua_newtable(L); lua_newtable(L);
@ -751,6 +832,11 @@ namespace Automation4 {
return 1; return 1;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaAssFile::LuaUnparseTagData(lua_State *L) int LuaAssFile::LuaUnparseTagData(lua_State *L)
{ {
lua_pushstring(L, ""); lua_pushstring(L, "");
@ -758,6 +844,11 @@ namespace Automation4 {
return 1; return 1;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaAssFile::LuaParseKaraokeData(lua_State *L) int LuaAssFile::LuaParseKaraokeData(lua_State *L)
{ {
AssEntry *e = LuaToAssEntry(L); AssEntry *e = LuaToAssEntry(L);
@ -887,6 +978,11 @@ namespace Automation4 {
return 1; return 1;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaAssFile::LuaSetUndoPoint(lua_State *L) int LuaAssFile::LuaSetUndoPoint(lua_State *L)
{ {
LuaAssFile *laf = GetObjPointer(L, lua_upvalueindex(1)); LuaAssFile *laf = GetObjPointer(L, lua_upvalueindex(1));
@ -907,6 +1003,12 @@ namespace Automation4 {
return 0; return 0;
} }
/// @brief DOCME
/// @param L
/// @param idx
/// @return
///
LuaAssFile *LuaAssFile::GetObjPointer(lua_State *L, int idx) LuaAssFile *LuaAssFile::GetObjPointer(lua_State *L, int idx)
{ {
assert(lua_type(L, idx) == LUA_TUSERDATA); assert(lua_type(L, idx) == LUA_TUSERDATA);
@ -914,10 +1016,20 @@ namespace Automation4 {
return *((LuaAssFile**)ud); return *((LuaAssFile**)ud);
} }
/// @brief DOCME
///
LuaAssFile::~LuaAssFile() LuaAssFile::~LuaAssFile()
{ {
} }
/// @brief DOCME
/// @param _L
/// @param _ass
/// @param _can_modify
/// @param _can_set_undo
///
LuaAssFile::LuaAssFile(lua_State *_L, AssFile *_ass, bool _can_modify, bool _can_set_undo) LuaAssFile::LuaAssFile(lua_State *_L, AssFile *_ass, bool _can_modify, bool _can_set_undo)
: ass(_ass) : ass(_ass)
, L(_L) , L(_L)
@ -971,3 +1083,4 @@ namespace Automation4 {
#endif // WITH_AUTO4_LUA #endif // WITH_AUTO4_LUA

View file

@ -61,11 +61,17 @@
#include "colour_button.h" #include "colour_button.h"
#include "ass_style.h" #include "ass_style.h"
/// DOCME
namespace Automation4 { namespace Automation4 {
// LuaConfigDialogControl // LuaConfigDialogControl
/// @brief DOCME
/// @param L
///
LuaConfigDialogControl::LuaConfigDialogControl(lua_State *L) LuaConfigDialogControl::LuaConfigDialogControl(lua_State *L)
{ {
// Assume top of stack is a control table (don't do checking) // Assume top of stack is a control table (don't do checking)
@ -125,14 +131,28 @@ namespace Automation4 {
wxLogDebug(_T("created control: '%s', (%d,%d)(%d,%d), '%s'"), name.c_str(), x, y, width, height, hint.c_str()); wxLogDebug(_T("created control: '%s', (%d,%d)(%d,%d), '%s'"), name.c_str(), x, y, width, height, hint.c_str());
} }
/// DOCME
namespace LuaControl { namespace LuaControl {
// Label // Label
/// DOCME
/// @class Label
/// @brief DOCME
///
/// DOCME
class Label : public LuaConfigDialogControl { class Label : public LuaConfigDialogControl {
public: public:
/// DOCME
wxString label; wxString label;
/// @brief DOCME
/// @param L
///
Label(lua_State *L) Label(lua_State *L)
: LuaConfigDialogControl(L) : LuaConfigDialogControl(L)
{ {
@ -141,20 +161,35 @@ namespace Automation4 {
lua_pop(L, 1); lua_pop(L, 1);
} }
/// @brief DOCME
///
virtual ~Label() { } virtual ~Label() { }
// Doesn't have a serialisable value so don't implement that sub-interface // Doesn't have a serialisable value so don't implement that sub-interface
/// @brief DOCME
/// @param parent
/// @return
///
wxControl *Create(wxWindow *parent) wxControl *Create(wxWindow *parent)
{ {
return cw = new wxStaticText(parent, -1, label); return cw = new wxStaticText(parent, -1, label);
} }
/// @brief DOCME
///
void ControlReadBack() void ControlReadBack()
{ {
// Nothing here // Nothing here
} }
/// @brief DOCME
/// @param L
///
void LuaReadBack(lua_State *L) void LuaReadBack(lua_State *L)
{ {
// Label doesn't produce output, so let it be nil // Label doesn't produce output, so let it be nil
@ -165,10 +200,22 @@ namespace Automation4 {
// Basic edit // Basic edit
/// DOCME
/// @class Edit
/// @brief DOCME
///
/// DOCME
class Edit : public LuaConfigDialogControl { class Edit : public LuaConfigDialogControl {
public: public:
/// DOCME
wxString text; wxString text;
/// @brief DOCME
/// @param L
///
Edit(lua_State *L) Edit(lua_State *L)
: LuaConfigDialogControl(L) : LuaConfigDialogControl(L)
{ {
@ -185,23 +232,43 @@ namespace Automation4 {
lua_pop(L, 1); lua_pop(L, 1);
} }
/// @brief DOCME
///
virtual ~Edit() { } virtual ~Edit() { }
/// @brief DOCME
/// @return
///
bool CanSerialiseValue() bool CanSerialiseValue()
{ {
return true; return true;
} }
/// @brief DOCME
/// @return
///
wxString SerialiseValue() wxString SerialiseValue()
{ {
return inline_string_encode(text); return inline_string_encode(text);
} }
/// @brief DOCME
/// @param serialised
///
void UnserialiseValue(const wxString &serialised) void UnserialiseValue(const wxString &serialised)
{ {
text = inline_string_decode(serialised); text = inline_string_decode(serialised);
} }
/// @brief DOCME
/// @param parent
/// @return
///
wxControl *Create(wxWindow *parent) wxControl *Create(wxWindow *parent)
{ {
cw = new wxTextCtrl(parent, -1, text, wxDefaultPosition, wxDefaultSize, 0); cw = new wxTextCtrl(parent, -1, text, wxDefaultPosition, wxDefaultSize, 0);
@ -209,11 +276,18 @@ namespace Automation4 {
return cw; return cw;
} }
/// @brief DOCME
///
void ControlReadBack() void ControlReadBack()
{ {
text = ((wxTextCtrl*)cw)->GetValue(); text = ((wxTextCtrl*)cw)->GetValue();
} }
/// @brief DOCME
/// @param L
///
void LuaReadBack(lua_State *L) void LuaReadBack(lua_State *L)
{ {
lua_pushstring(L, text.mb_str(wxConvUTF8)); lua_pushstring(L, text.mb_str(wxConvUTF8));
@ -222,10 +296,22 @@ namespace Automation4 {
}; };
/// DOCME
/// @class Color
/// @brief DOCME
///
/// DOCME
class Color : public LuaConfigDialogControl { class Color : public LuaConfigDialogControl {
public: public:
/// DOCME
wxString text; wxString text;
/// @brief DOCME
/// @param L
///
Color(lua_State *L) Color(lua_State *L)
: LuaConfigDialogControl(L) : LuaConfigDialogControl(L)
{ {
@ -234,23 +320,43 @@ namespace Automation4 {
lua_pop(L, 1); lua_pop(L, 1);
} }
/// @brief DOCME
///
virtual ~Color() { } virtual ~Color() { }
/// @brief DOCME
/// @return
///
bool CanSerialiseValue() bool CanSerialiseValue()
{ {
return true; return true;
} }
/// @brief DOCME
/// @return
///
wxString SerialiseValue() wxString SerialiseValue()
{ {
return inline_string_encode(text); return inline_string_encode(text);
} }
/// @brief DOCME
/// @param serialised
///
void UnserialiseValue(const wxString &serialised) void UnserialiseValue(const wxString &serialised)
{ {
text = inline_string_decode(serialised); text = inline_string_decode(serialised);
} }
/// @brief DOCME
/// @param parent
/// @return
///
wxControl *Create(wxWindow *parent) wxControl *Create(wxWindow *parent)
{ {
AssColor colour; AssColor colour;
@ -260,11 +366,18 @@ namespace Automation4 {
return cw; return cw;
} }
/// @brief DOCME
///
void ControlReadBack() void ControlReadBack()
{ {
text = ((ColourButton*)cw)->GetColour().GetAsString(wxC2S_HTML_SYNTAX); text = ((ColourButton*)cw)->GetColour().GetAsString(wxC2S_HTML_SYNTAX);
} }
/// @brief DOCME
/// @param L
///
void LuaReadBack(lua_State *L) void LuaReadBack(lua_State *L)
{ {
lua_pushstring(L, text.mb_str(wxConvUTF8)); lua_pushstring(L, text.mb_str(wxConvUTF8));
@ -276,19 +389,37 @@ namespace Automation4 {
// Multiline edit // Multiline edit
/// DOCME
/// @class Textbox
/// @brief DOCME
///
/// DOCME
class Textbox : public Edit { class Textbox : public Edit {
public: public:
/// @brief DOCME
/// @param L
///
Textbox(lua_State *L) Textbox(lua_State *L)
: Edit(L) : Edit(L)
{ {
// Nothing more // Nothing more
} }
/// @brief DOCME
///
virtual ~Textbox() { } virtual ~Textbox() { }
// Same serialisation interface as single-line edit // Same serialisation interface as single-line edit
/// @brief DOCME
/// @param parent
/// @return
///
wxControl *Create(wxWindow *parent) wxControl *Create(wxWindow *parent)
{ {
cw = new wxTextCtrl(parent, -1, text, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE); cw = new wxTextCtrl(parent, -1, text, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
@ -302,12 +433,30 @@ namespace Automation4 {
// Integer only edit // Integer only edit
/// DOCME
/// @class IntEdit
/// @brief DOCME
///
/// DOCME
class IntEdit : public Edit { class IntEdit : public Edit {
public: public:
/// DOCME
int value; int value;
/// DOCME
bool hasspin; bool hasspin;
/// DOCME
/// DOCME
int min, max; int min, max;
/// @brief DOCME
/// @param L
///
IntEdit(lua_State *L) IntEdit(lua_State *L)
: Edit(L) : Edit(L)
{ {
@ -341,18 +490,33 @@ nospin:
} }
} }
/// @brief DOCME
///
virtual ~IntEdit() { } virtual ~IntEdit() { }
/// @brief DOCME
/// @return
///
bool CanSerialiseValue() bool CanSerialiseValue()
{ {
return true; return true;
} }
/// @brief DOCME
/// @return
///
wxString SerialiseValue() wxString SerialiseValue()
{ {
return wxString::Format(_T("%d"), value); return wxString::Format(_T("%d"), value);
} }
/// @brief DOCME
/// @param serialised
///
void UnserialiseValue(const wxString &serialised) void UnserialiseValue(const wxString &serialised)
{ {
long tmp; long tmp;
@ -360,6 +524,11 @@ nospin:
value = tmp; value = tmp;
} }
/// @brief DOCME
/// @param parent
/// @return
///
wxControl *Create(wxWindow *parent) wxControl *Create(wxWindow *parent)
{ {
wxSpinCtrl *scw = new wxSpinCtrl(parent, -1, wxString::Format(_T("%d"), value), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, min, max, value); wxSpinCtrl *scw = new wxSpinCtrl(parent, -1, wxString::Format(_T("%d"), value), wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, min, max, value);
@ -368,11 +537,18 @@ nospin:
return cw; return cw;
} }
/// @brief DOCME
///
void ControlReadBack() void ControlReadBack()
{ {
value = ((wxSpinCtrl*)cw)->GetValue(); value = ((wxSpinCtrl*)cw)->GetValue();
} }
/// @brief DOCME
/// @param L
///
void LuaReadBack(lua_State *L) void LuaReadBack(lua_State *L)
{ {
lua_pushinteger(L, value); lua_pushinteger(L, value);
@ -383,13 +559,31 @@ nospin:
// Float only edit // Float only edit
/// DOCME
/// @class FloatEdit
/// @brief DOCME
///
/// DOCME
class FloatEdit : public Edit { class FloatEdit : public Edit {
public: public:
/// DOCME
float value; float value;
/// DOCME
bool hasspin; bool hasspin;
/// DOCME
/// DOCME
float min, max; float min, max;
// FIXME: Can't support spin button atm // FIXME: Can't support spin button atm
/// @brief DOCME
/// @param L
///
FloatEdit(lua_State *L) FloatEdit(lua_State *L)
: Edit(L) : Edit(L)
{ {
@ -400,18 +594,33 @@ nospin:
// TODO: spin button support // TODO: spin button support
} }
/// @brief DOCME
///
virtual ~FloatEdit() { } virtual ~FloatEdit() { }
/// @brief DOCME
/// @return
///
bool CanSerialiseValue() bool CanSerialiseValue()
{ {
return true; return true;
} }
/// @brief DOCME
/// @return
///
wxString SerialiseValue() wxString SerialiseValue()
{ {
return PrettyFloatF(value); return PrettyFloatF(value);
} }
/// @brief DOCME
/// @param serialised
///
void UnserialiseValue(const wxString &serialised) void UnserialiseValue(const wxString &serialised)
{ {
double tmp; double tmp;
@ -419,7 +628,14 @@ nospin:
value = (float)tmp; value = (float)tmp;
} }
/// DOCME
typedef wxValidator FloatTextValidator; typedef wxValidator FloatTextValidator;
/// @brief DOCME
/// @param parent
/// @return
///
wxControl *Create(wxWindow *parent) wxControl *Create(wxWindow *parent)
{ {
cw = new wxTextCtrl(parent, -1, PrettyFloatF(value), wxDefaultPosition, wxDefaultSize, 0); //, FloatTextValidator()); cw = new wxTextCtrl(parent, -1, PrettyFloatF(value), wxDefaultPosition, wxDefaultSize, 0); //, FloatTextValidator());
@ -427,6 +643,9 @@ nospin:
return cw; return cw;
} }
/// @brief DOCME
///
void ControlReadBack() void ControlReadBack()
{ {
double newval; double newval;
@ -436,6 +655,10 @@ nospin:
} }
} }
/// @brief DOCME
/// @param L
///
void LuaReadBack(lua_State *L) void LuaReadBack(lua_State *L)
{ {
lua_pushnumber(L, value); lua_pushnumber(L, value);
@ -446,11 +669,25 @@ nospin:
// Dropdown // Dropdown
/// DOCME
/// @class Dropdown
/// @brief DOCME
///
/// DOCME
class Dropdown : public LuaConfigDialogControl { class Dropdown : public LuaConfigDialogControl {
public: public:
/// DOCME
wxArrayString items; wxArrayString items;
/// DOCME
wxString value; wxString value;
/// @brief DOCME
/// @param L
///
Dropdown(lua_State *L) Dropdown(lua_State *L)
: LuaConfigDialogControl(L) : LuaConfigDialogControl(L)
{ {
@ -469,23 +706,43 @@ nospin:
lua_pop(L, 1); lua_pop(L, 1);
} }
/// @brief DOCME
///
virtual ~Dropdown() { } virtual ~Dropdown() { }
/// @brief DOCME
/// @return
///
bool CanSerialiseValue() bool CanSerialiseValue()
{ {
return true; return true;
} }
/// @brief DOCME
/// @return
///
wxString SerialiseValue() wxString SerialiseValue()
{ {
return inline_string_encode(value); return inline_string_encode(value);
} }
/// @brief DOCME
/// @param serialised
///
void UnserialiseValue(const wxString &serialised) void UnserialiseValue(const wxString &serialised)
{ {
value = inline_string_decode(serialised); value = inline_string_decode(serialised);
} }
/// @brief DOCME
/// @param parent
/// @return
///
wxControl *Create(wxWindow *parent) wxControl *Create(wxWindow *parent)
{ {
cw = new wxComboBox(parent, -1, value, wxDefaultPosition, wxDefaultSize, items, wxCB_READONLY); cw = new wxComboBox(parent, -1, value, wxDefaultPosition, wxDefaultSize, items, wxCB_READONLY);
@ -493,11 +750,18 @@ nospin:
return cw; return cw;
} }
/// @brief DOCME
///
void ControlReadBack() void ControlReadBack()
{ {
value = ((wxComboBox*)cw)->GetValue(); value = ((wxComboBox*)cw)->GetValue();
} }
/// @brief DOCME
/// @param L
///
void LuaReadBack(lua_State *L) void LuaReadBack(lua_State *L)
{ {
lua_pushstring(L, value.mb_str(wxConvUTF8)); lua_pushstring(L, value.mb_str(wxConvUTF8));
@ -508,11 +772,25 @@ nospin:
// Checkbox // Checkbox
/// DOCME
/// @class Checkbox
/// @brief DOCME
///
/// DOCME
class Checkbox : public LuaConfigDialogControl { class Checkbox : public LuaConfigDialogControl {
public: public:
/// DOCME
wxString label; wxString label;
/// DOCME
bool value; bool value;
/// @brief DOCME
/// @param L
///
Checkbox(lua_State *L) Checkbox(lua_State *L)
: LuaConfigDialogControl(L) : LuaConfigDialogControl(L)
{ {
@ -525,24 +803,44 @@ nospin:
lua_pop(L, 1); lua_pop(L, 1);
} }
/// @brief DOCME
///
virtual ~Checkbox() { } virtual ~Checkbox() { }
/// @brief DOCME
/// @return
///
bool CanSerialiseValue() bool CanSerialiseValue()
{ {
return true; return true;
} }
/// @brief DOCME
/// @return
///
wxString SerialiseValue() wxString SerialiseValue()
{ {
return value ? _T("1") : _T("0"); return value ? _T("1") : _T("0");
} }
/// @brief DOCME
/// @param serialised
///
void UnserialiseValue(const wxString &serialised) void UnserialiseValue(const wxString &serialised)
{ {
// fixme? should this allow more different "false" values? // fixme? should this allow more different "false" values?
value = (serialised == _T("0")) ? false : true; value = (serialised == _T("0")) ? false : true;
} }
/// @brief DOCME
/// @param parent
/// @return
///
wxControl *Create(wxWindow *parent) wxControl *Create(wxWindow *parent)
{ {
cw = new wxCheckBox(parent, -1, label); cw = new wxCheckBox(parent, -1, label);
@ -551,11 +849,18 @@ nospin:
return cw; return cw;
} }
/// @brief DOCME
///
void ControlReadBack() void ControlReadBack()
{ {
value = ((wxCheckBox*)cw)->GetValue(); value = ((wxCheckBox*)cw)->GetValue();
} }
/// @brief DOCME
/// @param L
///
void LuaReadBack(lua_State *L) void LuaReadBack(lua_State *L)
{ {
lua_pushboolean(L, value); lua_pushboolean(L, value);
@ -568,6 +873,11 @@ nospin:
// LuaConfigDialog // LuaConfigDialog
/// @brief DOCME
/// @param L
/// @param include_buttons
///
LuaConfigDialog::LuaConfigDialog(lua_State *L, bool include_buttons) LuaConfigDialog::LuaConfigDialog(lua_State *L, bool include_buttons)
: use_buttons(include_buttons) : use_buttons(include_buttons)
{ {
@ -653,12 +963,20 @@ badcontrol:
} }
} }
/// @brief DOCME
///
LuaConfigDialog::~LuaConfigDialog() LuaConfigDialog::~LuaConfigDialog()
{ {
for (size_t i = 0; i < controls.size(); ++i) for (size_t i = 0; i < controls.size(); ++i)
delete controls[i]; delete controls[i];
} }
/// @brief DOCME
/// @param parent
/// @return
///
wxWindow* LuaConfigDialog::CreateWindow(wxWindow *parent) wxWindow* LuaConfigDialog::CreateWindow(wxWindow *parent)
{ {
wxWindow *w = new wxPanel(parent); wxWindow *w = new wxPanel(parent);
@ -706,6 +1024,11 @@ badcontrol:
return w; return w;
} }
/// @brief DOCME
/// @param L
/// @return
///
int LuaConfigDialog::LuaReadBack(lua_State *L) int LuaConfigDialog::LuaReadBack(lua_State *L)
{ {
// First read back which button was pressed, if any // First read back which button was pressed, if any
@ -740,6 +1063,10 @@ badcontrol:
} }
} }
/// @brief DOCME
/// @return
///
wxString LuaConfigDialog::Serialise() wxString LuaConfigDialog::Serialise()
{ {
if (controls.size() == 0) if (controls.size() == 0)
@ -763,6 +1090,10 @@ badcontrol:
return res; return res;
} }
/// @brief DOCME
/// @param serialised
///
void LuaConfigDialog::Unserialise(const wxString &serialised) void LuaConfigDialog::Unserialise(const wxString &serialised)
{ {
// Split by pipe // Split by pipe
@ -782,6 +1113,9 @@ badcontrol:
} }
} }
/// @brief DOCME
///
void LuaConfigDialog::ReadBack() void LuaConfigDialog::ReadBack()
{ {
for (size_t i = 0; i < controls.size(); ++i) { for (size_t i = 0; i < controls.size(); ++i) {
@ -789,6 +1123,10 @@ badcontrol:
} }
} }
/// @brief DOCME
/// @param evt
///
void LuaConfigDialog::ButtonEventHandler::OnButtonPush(wxCommandEvent &evt) void LuaConfigDialog::ButtonEventHandler::OnButtonPush(wxCommandEvent &evt)
{ {
// Let button_pushed == 0 mean "cancelled", such that pushing Cancel or closing the dialog // Let button_pushed == 0 mean "cancelled", such that pushing Cancel or closing the dialog
@ -818,3 +1156,4 @@ badcontrol:
#endif // WITH_AUTO4_LUA #endif // WITH_AUTO4_LUA

View file

@ -37,13 +37,22 @@
#pragma once #pragma once
#ifndef _AUTO4_LUA_FACTORY_H #ifndef _AUTO4_LUA_FACTORY_H
/// DOCME
#define _AUTO4_LUA_FACTORY_H #define _AUTO4_LUA_FACTORY_H
#include "auto4_base.h" #include "auto4_base.h"
/// DOCME
namespace Automation4 { namespace Automation4 {
// Factory class for Lua scripts
/// DOCME
/// @class LuaScriptFactory
/// @brief DOCME
///
/// DOCME
class LuaScriptFactory : public ScriptFactory { class LuaScriptFactory : public ScriptFactory {
public: public:
LuaScriptFactory(); LuaScriptFactory();
@ -56,3 +65,4 @@ namespace Automation4 {
#endif #endif

View file

@ -40,9 +40,14 @@
#include "auto4_lua_scriptreader.h" #include "auto4_lua_scriptreader.h"
/// DOCME
namespace Automation4 { namespace Automation4 {
// LuaScriptReader
/// @brief // LuaScriptReader
/// @param filename
///
LuaScriptReader::LuaScriptReader(const wxString &filename) LuaScriptReader::LuaScriptReader(const wxString &filename)
{ {
#ifdef WIN32 #ifdef WIN32
@ -56,6 +61,9 @@ namespace Automation4 {
databuf = new char[bufsize]; databuf = new char[bufsize];
} }
/// @brief DOCME
///
LuaScriptReader::~LuaScriptReader() LuaScriptReader::~LuaScriptReader()
{ {
if (databuf) if (databuf)
@ -63,6 +71,12 @@ namespace Automation4 {
fclose(f); fclose(f);
} }
/// @brief DOCME
/// @param L
/// @param data
/// @param size
///
const char* LuaScriptReader::reader_func(lua_State *L, void *data, size_t *size) const char* LuaScriptReader::reader_func(lua_State *L, void *data, size_t *size)
{ {
LuaScriptReader *self = (LuaScriptReader*)(data); LuaScriptReader *self = (LuaScriptReader*)(data);
@ -113,3 +127,4 @@ namespace Automation4 {
#endif // WITH_AUTO4_LUA #endif // WITH_AUTO4_LUA

View file

@ -43,13 +43,24 @@
#include "lua.hpp" #include "lua.hpp"
#endif #endif
/// DOCME
namespace Automation4 { namespace Automation4 {
// Manage reading in a Lua script file
/// DOCME
struct LuaScriptReader { struct LuaScriptReader {
/// DOCME
FILE *f; FILE *f;
/// DOCME
bool first; bool first;
/// DOCME
char *databuf; char *databuf;
/// DOCME
static const size_t bufsize = 512; static const size_t bufsize = 512;
LuaScriptReader(const wxString &filename); LuaScriptReader(const wxString &filename);
~LuaScriptReader(); ~LuaScriptReader();
@ -61,3 +72,4 @@ namespace Automation4 {

View file

@ -47,7 +47,13 @@
#ifdef DEBUG_AVISYNTH_CODE #ifdef DEBUG_AVISYNTH_CODE
#include "main.h" #include "main.h"
#include "wx/textfile.h" #include "wx/textfile.h"
/// DOCME
wxTextFile avs_trace_file; wxTextFile avs_trace_file;
/// @brief DOCME
/// @param s
///
void DoAvsTrace(const wxString &s) void DoAvsTrace(const wxString &s)
{ {
if (!avs_trace_file.IsOpened()) { if (!avs_trace_file.IsOpened()) {
@ -63,16 +69,23 @@ void DoAvsTrace(const wxString &s)
#endif #endif
///////////////////////////////
// Static field initialization /// DOCME
int AviSynthWrapper::avs_refcount = 0; int AviSynthWrapper::avs_refcount = 0;
/// DOCME
HINSTANCE AviSynthWrapper::hLib = NULL; HINSTANCE AviSynthWrapper::hLib = NULL;
/// DOCME
IScriptEnvironment *AviSynthWrapper::env = NULL; IScriptEnvironment *AviSynthWrapper::env = NULL;
/// DOCME
wxMutex AviSynthWrapper::AviSynthMutex; wxMutex AviSynthWrapper::AviSynthMutex;
////////////////////////
// AviSynth constructor /// @brief AviSynth constructor
///
AviSynthWrapper::AviSynthWrapper() { AviSynthWrapper::AviSynthWrapper() {
if (!avs_refcount) { if (!avs_refcount) {
AVSTRACE(_T("Avisynth not loaded, trying to load it now...")); AVSTRACE(_T("Avisynth not loaded, trying to load it now..."));
@ -116,8 +129,9 @@ AviSynthWrapper::AviSynthWrapper() {
} }
///////////////////////
// AviSynth destructor /// @brief AviSynth destructor
///
AviSynthWrapper::~AviSynthWrapper() { AviSynthWrapper::~AviSynthWrapper() {
AVSTRACE(_T("Decreasing reference count")); AVSTRACE(_T("Decreasing reference count"));
if (!--avs_refcount) { if (!--avs_refcount) {
@ -130,11 +144,13 @@ AviSynthWrapper::~AviSynthWrapper() {
} }
///////////////////
// Get environment /// @brief Get environment
///
IScriptEnvironment *AviSynthWrapper::GetEnv() { IScriptEnvironment *AviSynthWrapper::GetEnv() {
return env; return env;
} }
#endif #endif

View file

@ -36,6 +36,8 @@
#ifndef AVISYNTH_WRAP_H #ifndef AVISYNTH_WRAP_H
/// DOCME
#define AVISYNTH_WRAP_H #define AVISYNTH_WRAP_H
@ -48,8 +50,8 @@
#include "avisynth.h" #include "avisynth.h"
//////////////////////////////////
// Typedef to make my life easier /// DOCME
typedef IScriptEnvironment* __stdcall FUNC(int); typedef IScriptEnvironment* __stdcall FUNC(int);
@ -57,21 +59,37 @@ typedef IScriptEnvironment* __stdcall FUNC(int);
// Avisynth debugging stuff // Avisynth debugging stuff
#ifdef DEBUG_AVISYNTH_CODE #ifdef DEBUG_AVISYNTH_CODE
void DoAvsTrace(const wxString &s); void DoAvsTrace(const wxString &s);
/// DOCME
#define AVSTRACE(s) DoAvsTrace(s) #define AVSTRACE(s) DoAvsTrace(s)
#else #else
/// DOCME
#define AVSTRACE(s) #define AVSTRACE(s)
#endif #endif
///////////////////////////
// AviSynth wrapping class /// DOCME
/// @class AviSynthWrapper
/// @brief DOCME
///
/// DOCME
class AviSynthWrapper { class AviSynthWrapper {
private: private:
/// DOCME
static int avs_refcount; static int avs_refcount;
/// DOCME
static HINSTANCE hLib; static HINSTANCE hLib;
protected: protected:
/// DOCME
static IScriptEnvironment *env; static IScriptEnvironment *env;
public: public:
/// DOCME
static wxMutex AviSynthMutex; static wxMutex AviSynthMutex;
IScriptEnvironment *GetEnv(); IScriptEnvironment *GetEnv();
@ -82,3 +100,4 @@ public:
#endif #endif
#endif #endif

View file

@ -55,8 +55,15 @@
#include "audio_display.h" #include "audio_display.h"
///////////////
// Constructor /// @brief Constructor
/// @param parent
/// @param id
/// @param pos
/// @param size
/// @param style
/// @param name
///
BaseGrid::BaseGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) BaseGrid::BaseGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
: wxWindow(parent, id, pos, size, style, name) : wxWindow(parent, id, pos, size, style, name)
{ {
@ -84,15 +91,17 @@ BaseGrid::BaseGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wx
} }
//////////////
// Destructor /// @brief Destructor
///
BaseGrid::~BaseGrid() { BaseGrid::~BaseGrid() {
delete bmp; delete bmp;
} }
////////////////
// Update style /// @brief Update style
///
void BaseGrid::UpdateStyle() { void BaseGrid::UpdateStyle() {
// Set font // Set font
wxString fontname = Options.AsText(_T("Grid Font Face")); wxString fontname = Options.AsText(_T("Grid Font Face"));
@ -120,8 +129,9 @@ void BaseGrid::UpdateStyle() {
} }
///////////////
// Clears grid /// @brief Clears grid
///
void BaseGrid::Clear () { void BaseGrid::Clear () {
diagMap.clear(); diagMap.clear();
diagPtrMap.clear(); diagPtrMap.clear();
@ -131,23 +141,29 @@ void BaseGrid::Clear () {
} }
///////////////
// Begin batch /// @brief Begin batch
///
void BaseGrid::BeginBatch() { void BaseGrid::BeginBatch() {
//Freeze(); //Freeze();
} }
/////////////
// End batch /// @brief End batch
///
void BaseGrid::EndBatch() { void BaseGrid::EndBatch() {
//Thaw(); //Thaw();
AdjustScrollbar(); AdjustScrollbar();
} }
//////////////////////
// Makes cell visible /// @brief Makes cell visible
/// @param row
/// @param col
/// @param center
///
void BaseGrid::MakeCellVisible(int row, int col,bool center) { void BaseGrid::MakeCellVisible(int row, int col,bool center) {
// Update last row selection // Update last row selection
lastRow = row; lastRow = row;
@ -176,8 +192,12 @@ void BaseGrid::MakeCellVisible(int row, int col,bool center) {
} }
////////////////
// Select a row /// @brief Select a row
/// @param row
/// @param addToSelected
/// @param select
///
void BaseGrid::SelectRow(int row, bool addToSelected, bool select) { void BaseGrid::SelectRow(int row, bool addToSelected, bool select) {
// Sanity checking // Sanity checking
if (row >= GetRows()) row = GetRows()-1; if (row >= GetRows()) row = GetRows()-1;
@ -203,8 +223,9 @@ void BaseGrid::SelectRow(int row, bool addToSelected, bool select) {
} }
/////////////////////////
// Selects visible lines /// @brief Selects visible lines
///
void BaseGrid::SelectVisible() { void BaseGrid::SelectVisible() {
int rows = GetRows(); int rows = GetRows();
bool selectedOne = false; bool selectedOne = false;
@ -223,8 +244,9 @@ void BaseGrid::SelectVisible() {
} }
///////////////////////
// Unselects all cells /// @brief Unselects all cells
///
void BaseGrid::ClearSelection() { void BaseGrid::ClearSelection() {
int rows = selMap.size(); int rows = selMap.size();
for (int i=0;i<rows;i++) { for (int i=0;i<rows;i++) {
@ -234,8 +256,12 @@ void BaseGrid::ClearSelection() {
} }
/////////////////////////
// Is cell in selection? /// @brief Is cell in selection?
/// @param row
/// @param col
/// @return
///
bool BaseGrid::IsInSelection(int row, int col) const { bool BaseGrid::IsInSelection(int row, int col) const {
if (row >= GetRows() || row < 0) return false; if (row >= GetRows() || row < 0) return false;
(void) col; (void) col;
@ -248,8 +274,10 @@ bool BaseGrid::IsInSelection(int row, int col) const {
} }
///////////////////////////
// Number of selected rows /// @brief Number of selected rows
/// @return
///
int BaseGrid::GetNumberSelection() { int BaseGrid::GetNumberSelection() {
int count = 0; int count = 0;
int rows = selMap.size(); int rows = selMap.size();
@ -260,8 +288,10 @@ int BaseGrid::GetNumberSelection() {
} }
///////////////////////////
// Gets first selected row /// @brief Gets first selected row
/// @return
///
int BaseGrid::GetFirstSelRow() { int BaseGrid::GetFirstSelRow() {
int nrows = GetRows(); int nrows = GetRows();
for (int i=0;i<nrows;i++) { for (int i=0;i<nrows;i++) {
@ -273,8 +303,10 @@ int BaseGrid::GetFirstSelRow() {
} }
/////////////////////////////////////////////////////
// Gets last selected row from first block selection /// @brief Gets last selected row from first block selection
/// @return
///
int BaseGrid::GetLastSelRow() { int BaseGrid::GetLastSelRow() {
int frow = GetFirstSelRow(); int frow = GetFirstSelRow();
while (IsInSelection(frow)) { while (IsInSelection(frow)) {
@ -284,8 +316,11 @@ int BaseGrid::GetLastSelRow() {
} }
//////////////////////////
// Gets all selected rows /// @brief Gets all selected rows
/// @param cont
/// @return
///
wxArrayInt BaseGrid::GetSelection(bool *cont) { wxArrayInt BaseGrid::GetSelection(bool *cont) {
// Prepare // Prepare
int nrows = GetRows(); int nrows = GetRows();
@ -308,8 +343,10 @@ wxArrayInt BaseGrid::GetSelection(bool *cont) {
} }
//////////////////////
// Get number of rows /// @brief Get number of rows
/// @return
///
int BaseGrid::GetRows() const { int BaseGrid::GetRows() const {
return diagMap.size(); return diagMap.size();
} }
@ -326,8 +363,10 @@ BEGIN_EVENT_TABLE(BaseGrid,wxWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
///////////////
// Paint event /// @brief Paint event
/// @param event
///
void BaseGrid::OnPaint (wxPaintEvent &event) { void BaseGrid::OnPaint (wxPaintEvent &event) {
// Prepare // Prepare
wxPaintDC dc(this); wxPaintDC dc(this);
@ -362,8 +401,10 @@ void BaseGrid::OnPaint (wxPaintEvent &event) {
} }
//////////////
// Draw image /// @brief Draw image
/// @param dc
///
void BaseGrid::DrawImage(wxDC &dc) { void BaseGrid::DrawImage(wxDC &dc) {
// Get size and pos // Get size and pos
int w = 0; int w = 0;
@ -578,8 +619,10 @@ void BaseGrid::DrawImage(wxDC &dc) {
} }
///////////
// On size /// @brief On size
/// @param event
///
void BaseGrid::OnSize(wxSizeEvent &event) { void BaseGrid::OnSize(wxSizeEvent &event) {
AdjustScrollbar(); AdjustScrollbar();
SetColumnWidths(); SetColumnWidths();
@ -587,8 +630,10 @@ void BaseGrid::OnSize(wxSizeEvent &event) {
} }
/////////////
// On scroll /// @brief On scroll
/// @param event
///
void BaseGrid::OnScroll(wxScrollEvent &event) { void BaseGrid::OnScroll(wxScrollEvent &event) {
int newPos = event.GetPosition(); int newPos = event.GetPosition();
if (yPos != newPos) { if (yPos != newPos) {
@ -598,8 +643,11 @@ void BaseGrid::OnScroll(wxScrollEvent &event) {
} }
////////////////
// Mouse events /// @brief Mouse events
/// @param event
/// @return
///
void BaseGrid::OnMouseEvent(wxMouseEvent &event) { void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
// Window size // Window size
int w,h; int w,h;
@ -733,8 +781,10 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
} }
/////////////
// Scroll to /// @brief Scroll to
/// @param y
///
void BaseGrid::ScrollTo(int y) { void BaseGrid::ScrollTo(int y) {
int w,h; int w,h;
GetClientSize(&w,&h); GetClientSize(&w,&h);
@ -747,8 +797,9 @@ void BaseGrid::ScrollTo(int y) {
} }
////////////////////
// Adjust scrollbar /// @brief Adjust scrollbar
///
void BaseGrid::AdjustScrollbar() { void BaseGrid::AdjustScrollbar() {
// Variables // Variables
int w,h,sw,sh; int w,h,sw,sh;
@ -775,8 +826,10 @@ void BaseGrid::AdjustScrollbar() {
} }
/////////////////////
// Set column widths /// @brief Set column widths
/// @return
///
void BaseGrid::SetColumnWidths() { void BaseGrid::SetColumnWidths() {
if (!IsShownOnScreen()) return; if (!IsShownOnScreen()) return;
@ -909,8 +962,11 @@ void BaseGrid::SetColumnWidths() {
} }
//////////////////////////
// Gets dialogue from map /// @brief Gets dialogue from map
/// @param n
/// @return
///
AssDialogue *BaseGrid::GetDialogue(int n) { AssDialogue *BaseGrid::GetDialogue(int n) {
try { try {
if (n < 0) return NULL; if (n < 0) return NULL;
@ -924,8 +980,11 @@ AssDialogue *BaseGrid::GetDialogue(int n) {
} }
////////////////////////////////////
// Check if line is being displayed /// @brief Check if line is being displayed
/// @param line
/// @return
///
bool BaseGrid::IsDisplayed(AssDialogue *line) { bool BaseGrid::IsDisplayed(AssDialogue *line) {
if (!VideoContext::Get()->IsLoaded()) return false; if (!VideoContext::Get()->IsLoaded()) return false;
int f1 = VFR_Output.GetFrameAtTime(line->Start.GetMS(),true); int f1 = VFR_Output.GetFrameAtTime(line->Start.GetMS(),true);
@ -935,8 +994,9 @@ bool BaseGrid::IsDisplayed(AssDialogue *line) {
} }
///////////////
// Update maps /// @brief Update maps
///
void BaseGrid::UpdateMaps() { void BaseGrid::UpdateMaps() {
// Store old // Store old
int len = diagMap.size(); int len = diagMap.size();
@ -981,8 +1041,11 @@ void BaseGrid::UpdateMaps() {
} }
/////////////
// Key press /// @brief Key press
/// @param event
/// @return
///
void BaseGrid::OnKeyPress(wxKeyEvent &event) { void BaseGrid::OnKeyPress(wxKeyEvent &event) {
// Get size // Get size
int w,h; int w,h;
@ -1099,8 +1162,11 @@ void BaseGrid::OnKeyPress(wxKeyEvent &event) {
} }
////////////////////////////////
// Sets display by frame or not /// @brief Sets display by frame or not
/// @param state
/// @return
///
void BaseGrid::SetByFrame (bool state) { void BaseGrid::SetByFrame (bool state) {
// Check if it's already the same // Check if it's already the same
if (byFrame == state) return; if (byFrame == state) return;
@ -1110,8 +1176,11 @@ void BaseGrid::SetByFrame (bool state) {
} }
///////////////////////////////////////////////
// Generates an array covering inclusive range /// @brief Generates an array covering inclusive range
/// @param n1
/// @param n2
///
wxArrayInt BaseGrid::GetRangeArray(int n1,int n2) { wxArrayInt BaseGrid::GetRangeArray(int n1,int n2) {
// Swap if in wrong order // Swap if in wrong order
if (n2 < n1) { if (n2 < n1) {
@ -1128,3 +1197,4 @@ wxArrayInt BaseGrid::GetRangeArray(int n1,int n2) {
return target; return target;
} }

View file

@ -52,20 +52,42 @@ class AssEntry;
class AssDialogue; class AssDialogue;
class SubsEditBox; class SubsEditBox;
class FrameMain; class FrameMain;
/// DOCME
typedef std::list<AssEntry*>::iterator entryIter; typedef std::list<AssEntry*>::iterator entryIter;
///////////////////
// Base grid class /// DOCME
/// @class BaseGrid
/// @brief DOCME
///
/// DOCME
class BaseGrid : public wxWindow { class BaseGrid : public wxWindow {
private: private:
/// DOCME
int lineHeight; int lineHeight;
/// DOCME
int colWidth[16]; int colWidth[16];
/// DOCME
int lastRow; int lastRow;
/// DOCME
int extendRow; int extendRow;
/// DOCME
bool holding; bool holding;
/// DOCME
wxFont font; wxFont font;
/// DOCME
wxScrollBar *scrollBar; wxScrollBar *scrollBar;
/// DOCME
wxBitmap *bmp; wxBitmap *bmp;
void OnPaint(wxPaintEvent &event); void OnPaint(wxPaintEvent &event);
@ -77,19 +99,39 @@ private:
void DrawImage(wxDC &dc); void DrawImage(wxDC &dc);
protected: protected:
/// DOCME
FrameMain *parentFrame; FrameMain *parentFrame;
/// DOCME
bool showCol[16]; bool showCol[16];
/// @brief DOCME
/// @param alternate=false
///
virtual void OnPopupMenu(bool alternate=false) {} virtual void OnPopupMenu(bool alternate=false) {}
void ScrollTo(int y); void ScrollTo(int y);
/// DOCME
int yPos; int yPos;
public: public:
/// DOCME
SubsEditBox *editBox; SubsEditBox *editBox;
/// DOCME
bool byFrame; bool byFrame;
/// DOCME
std::vector<entryIter> diagMap; std::vector<entryIter> diagMap;
/// DOCME
std::vector<AssDialogue *> diagPtrMap; std::vector<AssDialogue *> diagPtrMap;
/// DOCME
std::vector<bool> selMap; std::vector<bool> selMap;
void AdjustScrollbar(); void AdjustScrollbar();
@ -128,6 +170,9 @@ public:
/////// ///////
// IDs // IDs
enum { enum {
/// DOCME
GRID_SCROLLBAR = 1730 GRID_SCROLLBAR = 1730
}; };

View file

@ -47,8 +47,15 @@
#include "standard_paths.h" #include "standard_paths.h"
///////////////
// Constructor /// @brief Constructor
/// @param parent
/// @param id
/// @param text
/// @param _type
/// @param position
/// @param size
///
BrowseButton::BrowseButton(wxWindow *parent,int id,wxString text,BrowseType _type,wxPoint position,wxSize size) BrowseButton::BrowseButton(wxWindow *parent,int id,wxString text,BrowseType _type,wxPoint position,wxSize size)
: wxButton (parent,id,text == wxString(_T("")) ? wxString(_("Browse...")) : text,position,size) : wxButton (parent,id,text == wxString(_T("")) ? wxString(_("Browse...")) : text,position,size)
{ {
@ -59,15 +66,20 @@ BrowseButton::BrowseButton(wxWindow *parent,int id,wxString text,BrowseType _typ
} }
////////
// Bind /// @brief Bind
/// @param control
/// @param pos
///
void BrowseButton::Bind(wxTextCtrl *control,int pos) { void BrowseButton::Bind(wxTextCtrl *control,int pos) {
ctrl[pos] = control; ctrl[pos] = control;
} }
///////////
// Pressed /// @brief Pressed
/// @param event
///
void BrowseButton::OnPressed(wxCommandEvent &event) { void BrowseButton::OnPressed(wxCommandEvent &event) {
// Folder // Folder
if (type == BROWSE_FOLDER) { if (type == BROWSE_FOLDER) {
@ -103,3 +115,4 @@ void BrowseButton::OnPressed(wxCommandEvent &event) {

View file

@ -45,20 +45,34 @@
#include <wx/textctrl.h> #include <wx/textctrl.h>
///////////////
// Browse type /// DOCME
enum BrowseType { enum BrowseType {
/// DOCME
BROWSE_FILE, BROWSE_FILE,
/// DOCME
BROWSE_FOLDER, BROWSE_FOLDER,
/// DOCME
BROWSE_FONT BROWSE_FONT
}; };
///////////////////////
// Browse button class /// DOCME
/// @class BrowseButton
/// @brief DOCME
///
/// DOCME
class BrowseButton : public wxButton { class BrowseButton : public wxButton {
private: private:
/// DOCME
wxTextCtrl *ctrl[2]; wxTextCtrl *ctrl[2];
/// DOCME
BrowseType type; BrowseType type;
void OnPressed(wxCommandEvent &event); void OnPressed(wxCommandEvent &event);
@ -68,3 +82,4 @@ public:
void Bind(wxTextCtrl *control,int pos=0); void Bind(wxTextCtrl *control,int pos=0);
}; };

View file

@ -44,20 +44,39 @@
WX_DECLARE_STRING_HASH_MAP(wxString, PrettyNamesHash); WX_DECLARE_STRING_HASH_MAP(wxString, PrettyNamesHash);
#if wxUSE_THREADS #if wxUSE_THREADS
/// DOCME
static wxMutex encodingListMutex; static wxMutex encodingListMutex;
#endif #endif
/// DOCME
static const iconv_t iconv_invalid = (iconv_t)-1; static const iconv_t iconv_invalid = (iconv_t)-1;
/// DOCME
static const size_t iconv_failed = (size_t)-1; static const size_t iconv_failed = (size_t)-1;
/// DOCME
#define ICONV_CONST_CAST(a) const_cast<ICONV_CONST char *>(a) #define ICONV_CONST_CAST(a) const_cast<ICONV_CONST char *>(a)
#ifndef ICONV_POSIX #ifndef ICONV_POSIX
static int addEncoding(unsigned int namescount, const char * const * names, void* data); static int addEncoding(unsigned int namescount, const char * const * names, void* data);
#endif #endif
/// DOCME
static wxArrayString *supportedEncodings = NULL; static wxArrayString *supportedEncodings = NULL;
/// DOCME
static wxArrayString *prettyEncodingList = NULL; static wxArrayString *prettyEncodingList = NULL;
/// DOCME
static PrettyNamesHash *prettyEncodingHash = NULL; static PrettyNamesHash *prettyEncodingHash = NULL;
/// @brief DOCME
/// @param mbEncName
/// @param enableSubst
///
AegisubCSConv::AegisubCSConv(const wxChar *mbEncName, bool enableSubst) AegisubCSConv::AegisubCSConv(const wxChar *mbEncName, bool enableSubst)
: mbCharsetName(GetRealEncodingName(mbEncName)), mbNulLen(0), enableSubst(enableSubst) : mbCharsetName(GetRealEncodingName(mbEncName)), mbNulLen(0), enableSubst(enableSubst)
{ {
@ -85,17 +104,27 @@ AegisubCSConv::AegisubCSConv(const wxChar *mbEncName, bool enableSubst)
#endif #endif
} }
} }
/// @brief DOCME
///
AegisubCSConv::~AegisubCSConv() { AegisubCSConv::~AegisubCSConv() {
if (m2w != iconv_invalid) iconv_close(m2w); if (m2w != iconv_invalid) iconv_close(m2w);
if (w2m != iconv_invalid) iconv_close(w2m); if (w2m != iconv_invalid) iconv_close(w2m);
} }
/// @brief DOCME
/// @return
///
wxMBConv * AegisubCSConv::Clone() const { wxMBConv * AegisubCSConv::Clone() const {
AegisubCSConv *c = new AegisubCSConv(mbCharsetName); AegisubCSConv *c = new AegisubCSConv(mbCharsetName);
c->mbNulLen = mbNulLen; c->mbNulLen = mbNulLen;
return c; return c;
} }
// Calculate the size of NUL in the target encoding via iconv
/// @brief Calculate the size of NUL in the target encoding via iconv
/// @return
///
size_t AegisubCSConv::GetMBNulLen() const { size_t AegisubCSConv::GetMBNulLen() const {
if (mbNulLen == 0) { if (mbNulLen == 0) {
const wchar_t nulStr[] = L""; const wchar_t nulStr[] = L"";
@ -115,7 +144,11 @@ size_t AegisubCSConv::GetMBNulLen() const {
return mbNulLen; return mbNulLen;
} }
// Calculate the length (in bytes) of a MB string, not including the terminator
/// @brief Calculate the length (in bytes) of a MB string, not including the terminator
/// @param str
/// @return
///
size_t AegisubCSConv::MBBuffLen(const char * str) const { size_t AegisubCSConv::MBBuffLen(const char * str) const {
size_t nulLen = GetMBNulLen(); size_t nulLen = GetMBNulLen();
const char *ptr; const char *ptr;
@ -133,6 +166,14 @@ size_t AegisubCSConv::MBBuffLen(const char * str) const {
} }
} }
/// @brief DOCME
/// @param dst
/// @param dstSize
/// @param src
/// @param srcLen
/// @return
///
size_t AegisubCSConv::ToWChar(wchar_t *dst, size_t dstSize, const char *src, size_t srcLen) const { size_t AegisubCSConv::ToWChar(wchar_t *dst, size_t dstSize, const char *src, size_t srcLen) const {
return doConversion( return doConversion(
m2w, m2w,
@ -143,6 +184,14 @@ size_t AegisubCSConv::ToWChar(wchar_t *dst, size_t dstSize, const char *src, siz
) / sizeof(wchar_t); ) / sizeof(wchar_t);
} }
/// @brief DOCME
/// @param dst
/// @param dstSize
/// @param src
/// @param srcLen
/// @return
///
size_t AegisubCSConv::FromWChar(char *dst, size_t dstSize, const wchar_t *src, size_t srcLen) const { size_t AegisubCSConv::FromWChar(char *dst, size_t dstSize, const wchar_t *src, size_t srcLen) const {
return doConversion( return doConversion(
w2m, w2m,
@ -153,6 +202,15 @@ size_t AegisubCSConv::FromWChar(char *dst, size_t dstSize, const wchar_t *src, s
); );
} }
/// @brief DOCME
/// @param cd
/// @param dst
/// @param dstSize
/// @param src
/// @param srcSize
/// @return
///
size_t AegisubCSConv::doConversion(iconv_t cd, char *dst, size_t dstSize, char *src, size_t srcSize) const { size_t AegisubCSConv::doConversion(iconv_t cd, char *dst, size_t dstSize, char *src, size_t srcSize) const {
if (dstSize > 0) { if (dstSize > 0) {
return iconvWrapper(cd, &src, &srcSize, &dst, &dstSize); return iconvWrapper(cd, &src, &srcSize, &dst, &dstSize);
@ -176,6 +234,15 @@ size_t AegisubCSConv::doConversion(iconv_t cd, char *dst, size_t dstSize, char *
return charsWritten; return charsWritten;
} }
/// @brief DOCME
/// @param cd
/// @param inbuf
/// @param inbytesleft
/// @param outbuf
/// @param outbytesleft
/// @return
///
size_t AegisubCSConv::iconvWrapper(iconv_t cd, char **inbuf, size_t *inbytesleft, size_t AegisubCSConv::iconvWrapper(iconv_t cd, char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft) const { char **outbuf, size_t *outbytesleft) const {
@ -236,6 +303,16 @@ size_t AegisubCSConv::iconvWrapper(iconv_t cd, char **inbuf, size_t *inbytesleft
#endif #endif
} }
/// @brief DOCME
/// @param code
/// @param buf
/// @param buflen
/// @param callback_arg)
/// @param callback_arg
/// @param convPtr
/// @return
///
void AegisubCSConv::ucToMbFallback( void AegisubCSConv::ucToMbFallback(
unsigned int code, unsigned int code,
void (*callback) (const char *buf, size_t buflen, void* callback_arg), void (*callback) (const char *buf, size_t buflen, void* callback_arg),
@ -253,6 +330,13 @@ void AegisubCSConv::ucToMbFallback(
} }
#ifndef ICONV_POSIX #ifndef ICONV_POSIX
/// @brief DOCME
/// @param namescount
/// @param names
/// @param data
/// @return
///
int addEncoding(unsigned int namescount, const char * const * names, void* data) { int addEncoding(unsigned int namescount, const char * const * names, void* data) {
for (unsigned int i = 0; i < namescount; i++) { for (unsigned int i = 0; i < namescount; i++) {
supportedEncodings->Add(wxString::FromAscii(names[i])); supportedEncodings->Add(wxString::FromAscii(names[i]));
@ -261,6 +345,10 @@ int addEncoding(unsigned int namescount, const char * const * names, void* data)
} }
#endif #endif
/// @brief DOCME
/// @return
///
wxArrayString AegisubCSConv::GetAllSupportedEncodings() { wxArrayString AegisubCSConv::GetAllSupportedEncodings() {
#if wxUSE_THREADS #if wxUSE_THREADS
wxMutexLocker lock(encodingListMutex); wxMutexLocker lock(encodingListMutex);
@ -275,7 +363,11 @@ wxArrayString AegisubCSConv::GetAllSupportedEncodings() {
return *supportedEncodings; return *supportedEncodings;
} }
// Map pretty names to the real encoding names
/// @brief Map pretty names to the real encoding names
/// @param name
/// @return
///
wxString AegisubCSConv::GetRealEncodingName(wxString name) { wxString AegisubCSConv::GetRealEncodingName(wxString name) {
if (name.Lower() == _T("local")) return wxLocale::GetSystemEncodingName(); if (name.Lower() == _T("local")) return wxLocale::GetSystemEncodingName();
if (prettyEncodingList == NULL) return name; if (prettyEncodingList == NULL) return name;
@ -287,6 +379,9 @@ wxString AegisubCSConv::GetRealEncodingName(wxString name) {
return name; return name;
} }
/// @brief DOCME
///
wxArrayString AegisubCSConv::GetEncodingsList() { wxArrayString AegisubCSConv::GetEncodingsList() {
#if wxUSE_THREADS #if wxUSE_THREADS
wxMutexLocker lock(encodingListMutex); wxMutexLocker lock(encodingListMutex);
@ -438,3 +533,4 @@ wxArrayString AegisubCSConv::GetEncodingsList() {
static AegisubCSConv localConv(_T("Local"), false); static AegisubCSConv localConv(_T("Local"), false);
AegisubCSConv& csConvLocal(localConv); AegisubCSConv& csConvLocal(localConv);

View file

@ -35,6 +35,8 @@
/// ///
#ifndef AEGISUB_CHARSET_CONV_H #ifndef AEGISUB_CHARSET_CONV_H
/// DOCME
#define AEGISUB_CHARSET_CONV_H #define AEGISUB_CHARSET_CONV_H
#include <iconv.h> #include <iconv.h>
@ -47,9 +49,17 @@
#include "aegisub_endian.h" #include "aegisub_endian.h"
#if !defined(_LIBICONV_VERSION) || _LIBICONV_VERSION < 0x010A || defined(LIBICONV_PLUG) #if !defined(_LIBICONV_VERSION) || _LIBICONV_VERSION < 0x010A || defined(LIBICONV_PLUG)
/// DOCME
#define ICONV_POSIX #define ICONV_POSIX
#endif #endif
/// DOCME
/// @class AegisubCSConv
/// @brief DOCME
///
/// DOCME
class AegisubCSConv : public wxMBConv { class AegisubCSConv : public wxMBConv {
public: public:
// By default, any conversion that would be lossy will fail // By default, any conversion that would be lossy will fail
@ -76,12 +86,24 @@ public:
static wxString GetRealEncodingName(wxString name); static wxString GetRealEncodingName(wxString name);
protected: protected:
/// DOCME
/// DOCME
iconv_t m2w, w2m; iconv_t m2w, w2m;
private: private:
/// DOCME
wxString wcCharsetName; wxString wcCharsetName;
/// DOCME
wxString mbCharsetName; wxString mbCharsetName;
/// DOCME
size_t mbNulLen; size_t mbNulLen;
/// DOCME
bool enableSubst; bool enableSubst;
size_t doConversion(iconv_t cd, char *dst, size_t dstSize, char *src, size_t srcSize) const; size_t doConversion(iconv_t cd, char *dst, size_t dstSize, char *src, size_t srcSize) const;
@ -92,15 +114,22 @@ private:
void (*callback) (const char *buf, size_t buflen, void* callback_arg), void (*callback) (const char *buf, size_t buflen, void* callback_arg),
void *callback_arg, void *callback_arg,
void *convPtr); void *convPtr);
/// DOCME
char invalidRep[8]; char invalidRep[8];
/// DOCME
size_t invalidRepSize; size_t invalidRepSize;
#ifndef ICONV_POSIX #ifndef ICONV_POSIX
/// DOCME
iconv_fallbacks fallbacks; iconv_fallbacks fallbacks;
#endif #endif
#if wxUSE_THREADS #if wxUSE_THREADS
// While iconv itself is thread-safe, using the same iconv_t on multiple threads is not
/// DOCME
wxMutex iconvMutex; wxMutex iconvMutex;
#endif #endif
}; };
@ -110,23 +139,36 @@ extern AegisubCSConv& csConvLocal;
#ifdef HAVE_BIG_ENDIAN #ifdef HAVE_BIG_ENDIAN
# if SIZEOF_WCHAR_T == 4 # if SIZEOF_WCHAR_T == 4
/// DOCME
# define WCHAR_T_ENCODING "UTF-32BE" # define WCHAR_T_ENCODING "UTF-32BE"
# elif SIZEOF_WCHAR_T == 2 # elif SIZEOF_WCHAR_T == 2
/// DOCME
# define WCHAR_T_ENCODING "UTF-16BE" # define WCHAR_T_ENCODING "UTF-16BE"
# endif # endif
#elif defined(HAVE_LITTLE_ENDIAN) #elif defined(HAVE_LITTLE_ENDIAN)
# if SIZEOF_WCHAR_T == 4 # if SIZEOF_WCHAR_T == 4
/// DOCME
# define WCHAR_T_ENCODING "UTF-32LE" # define WCHAR_T_ENCODING "UTF-32LE"
# elif SIZEOF_WCHAR_T == 2 # elif SIZEOF_WCHAR_T == 2
/// DOCME
# define WCHAR_T_ENCODING "UTF-16LE" # define WCHAR_T_ENCODING "UTF-16LE"
# endif # endif
#else #else
# if SIZEOF_WCHAR_T == 4 # if SIZEOF_WCHAR_T == 4
/// DOCME
# define WCHAR_T_ENCODING ((Endian::MachineToBig((uint32_t)1) == 1) ? "UTF-32BE" : "UTF-32LE") # define WCHAR_T_ENCODING ((Endian::MachineToBig((uint32_t)1) == 1) ? "UTF-32BE" : "UTF-32LE")
# elif SIZEOF_WCHAR_T == 2 # elif SIZEOF_WCHAR_T == 2
/// DOCME
# define WCHAR_T_ENCODING ((Endian::MachineToBig((uint32_t)1) == 1) ? "UTF-16BE" : "UTF-16LE") # define WCHAR_T_ENCODING ((Endian::MachineToBig((uint32_t)1) == 1) ? "UTF-16BE" : "UTF-16LE")
# endif # endif
#endif #endif
#endif #endif

View file

@ -48,15 +48,29 @@
#include <wx/choicdlg.h> #include <wx/choicdlg.h>
/// DOCME
struct CharDetResult { struct CharDetResult {
/// DOCME
float confidence; float confidence;
/// DOCME
wxString name; wxString name;
/// @brief DOCME
/// @param par
/// @return
///
bool operator < (CharDetResult &par) { return confidence > par.confidence; } bool operator < (CharDetResult &par) { return confidence > par.confidence; }
}; };
////////////////
// Get encoding /// @brief Get encoding
/// @param filename
/// @return
///
wxString CharSetDetect::GetEncoding(wxString filename) { wxString CharSetDetect::GetEncoding(wxString filename) {
std::ifstream file; std::ifstream file;
#ifdef __WINDOWS__ #ifdef __WINDOWS__
@ -148,8 +162,10 @@ wxString CharSetDetect::GetEncoding(wxString filename) {
return result; return result;
} }
//////////
// Report /// @brief Report
/// @param aCharset
///
void CharSetDetect::Report(const char* aCharset) { void CharSetDetect::Report(const char* aCharset) {
// Store the result reported // Store the result reported
result = wxString(aCharset,wxConvUTF8); result = wxString(aCharset,wxConvUTF8);
@ -157,3 +173,4 @@ void CharSetDetect::Report(const char* aCharset) {
#endif // WITH_UNIVCHARDET #endif // WITH_UNIVCHARDET

View file

@ -43,15 +43,25 @@
#include "../universalchardet/nsUniversalDetector.h" #include "../universalchardet/nsUniversalDetector.h"
/////////////////////////////////
// Character set detection class /// DOCME
/// @class CharSetDetect
/// @brief DOCME
///
/// DOCME
class CharSetDetect : public nsUniversalDetector { class CharSetDetect : public nsUniversalDetector {
private: private:
/// DOCME
wxString result; wxString result;
void Report(const char* aCharset); void Report(const char* aCharset);
public: public:
wxString GetEncoding(wxString filename); wxString GetEncoding(wxString filename);
/// @brief DOCME
///
PRBool done() const { return mDone; } PRBool done() const { return mDone; }
}; };

View file

@ -40,7 +40,15 @@
#include "utils.h" #include "utils.h"
// matrix from http://forum.doom9.org/showthread.php?p=684080#post684080
/// @brief matrix from http://forum.doom9.org/showthread.php?p=684080#post684080
/// @param Y
/// @param U
/// @param V
/// @param R
/// @param G
/// @param B
///
void yuv_to_rgb(int Y, int U, int V, unsigned char *R, unsigned char *G, unsigned char *B) void yuv_to_rgb(int Y, int U, int V, unsigned char *R, unsigned char *G, unsigned char *B)
{ {
U = U - 128; U = U - 128;
@ -51,8 +59,16 @@ void yuv_to_rgb(int Y, int U, int V, unsigned char *R, unsigned char *G, unsigne
} }
// algorithm from http://130.113.54.154/~monger/hsl-rgb.html
// making every value into 0..255 range though /// @brief making every value into 0..255 range though algorithm from http://130.113.54.154/~monger/hsl-rgb.html
/// @param H
/// @param S
/// @param L
/// @param R
/// @param G
/// @param B
/// @return
///
void hsl_to_rgb(int H, int S, int L, unsigned char *R, unsigned char *G, unsigned char *B) void hsl_to_rgb(int H, int S, int L, unsigned char *R, unsigned char *G, unsigned char *B)
{ {
if (S == 0) { if (S == 0) {
@ -153,8 +169,16 @@ void hsl_to_rgb(int H, int S, int L, unsigned char *R, unsigned char *G, unsigne
} }
// formulas taken from wikipedia: http://en.wikipedia.org/wiki/HSV_color_space
// the range for H is 0..255 instead of 0..359, so 60 degrees has been translated to 256/6 here /// @brief the range for H is 0..255 instead of 0..359, so 60 degrees has been translated to 256/6 here formulas taken from wikipedia: http://en.wikipedia.org/wiki/HSV_color_space
/// @param H
/// @param S
/// @param V
/// @param R
/// @param G
/// @param B
/// @return
///
void hsv_to_rgb(int H, int S, int V, unsigned char *R, unsigned char *G, unsigned char *B) void hsv_to_rgb(int H, int S, int V, unsigned char *R, unsigned char *G, unsigned char *B)
{ {
*R = *G = *B = 0; *R = *G = *B = 0;
@ -257,7 +281,15 @@ void hsv_to_rgb(int H, int S, int V, unsigned char *R, unsigned char *G, unsigne
} }
// matrix from http://forum.doom9.org/showthread.php?p=684080#post684080
/// @brief matrix from http://forum.doom9.org/showthread.php?p=684080#post684080
/// @param R
/// @param G
/// @param B
/// @param Y
/// @param U
/// @param V
///
void rgb_to_yuv(int R, int G, int B, unsigned char *Y, unsigned char *U, unsigned char *V) void rgb_to_yuv(int R, int G, int B, unsigned char *Y, unsigned char *U, unsigned char *V)
{ {
*Y = clip_colorval(( int(0.299*65536) * R + int(0.587*65536) * G + int(0.114*65536) * B) / 65536); *Y = clip_colorval(( int(0.299*65536) * R + int(0.587*65536) * G + int(0.114*65536) * B) / 65536);
@ -266,8 +298,15 @@ void rgb_to_yuv(int R, int G, int B, unsigned char *Y, unsigned char *U, unsigne
} }
// also from http://130.113.54.154/~monger/hsl-rgb.html
// still keeping everything integer /// @brief still keeping everything integer also from http://130.113.54.154/~monger/hsl-rgb.html
/// @param R
/// @param G
/// @param B
/// @param H
/// @param S
/// @param L
///
void rgb_to_hsl(int R, int G, int B, unsigned char *H, unsigned char *S, unsigned char *L) void rgb_to_hsl(int R, int G, int B, unsigned char *H, unsigned char *S, unsigned char *L)
{ {
float r = R/255.f, g = G/255.f, b = B/255.f; float r = R/255.f, g = G/255.f, b = B/255.f;
@ -304,7 +343,15 @@ void rgb_to_hsl(int R, int G, int B, unsigned char *H, unsigned char *S, unsigne
} }
// formulas from http://en.wikipedia.org/wiki/HSV_color_space
/// @brief formulas from http://en.wikipedia.org/wiki/HSV_color_space
/// @param R
/// @param G
/// @param B
/// @param H
/// @param S
/// @param V
///
void rgb_to_hsv(int R, int G, int B, unsigned char *H, unsigned char *S, unsigned char *V) void rgb_to_hsv(int R, int G, int B, unsigned char *H, unsigned char *S, unsigned char *V)
{ {
float r = R/255.f, g = G/255.f, b = B/255.f; float r = R/255.f, g = G/255.f, b = B/255.f;
@ -339,6 +386,15 @@ void rgb_to_hsv(int R, int G, int B, unsigned char *H, unsigned char *S, unsigne
} }
/// @brief DOCME
/// @param iH
/// @param iS
/// @param iV
/// @param oH
/// @param oS
/// @param oL
///
void hsv_to_hsl(int iH, int iS, int iV, unsigned char *oH, unsigned char *oS, unsigned char *oL) void hsv_to_hsl(int iH, int iS, int iV, unsigned char *oH, unsigned char *oS, unsigned char *oL)
{ {
int p = iV * (255 - iS); int p = iV * (255 - iS);
@ -354,6 +410,16 @@ void hsv_to_hsl(int iH, int iS, int iV, unsigned char *oH, unsigned char *oS, un
} }
/// @brief DOCME
/// @param iH
/// @param iS
/// @param iL
/// @param oH
/// @param oS
/// @param oV
/// @return
///
void hsl_to_hsv(int iH, int iS, int iL, unsigned char *oH, unsigned char *oS, unsigned char *oV) void hsl_to_hsv(int iH, int iS, int iL, unsigned char *oH, unsigned char *oS, unsigned char *oV)
{ {
*oH = iH; *oH = iH;
@ -374,12 +440,21 @@ void hsl_to_hsv(int iH, int iS, int iL, unsigned char *oH, unsigned char *oS, un
} }
/// @brief DOCME
/// @param color
/// @return
///
wxString color_to_html(wxColour color) wxString color_to_html(wxColour color)
{ {
return wxString::Format(_T("#%02X%02X%02X"), color.Red(), color.Green(), color.Blue()); return wxString::Format(_T("#%02X%02X%02X"), color.Red(), color.Green(), color.Blue());
} }
/// @brief DOCME
/// @param html
///
wxColour html_to_color(wxString html) wxColour html_to_color(wxString html)
{ {
html.Trim(true); html.Trim(true);
@ -418,3 +493,4 @@ wxColour html_to_color(wxString html)
} }

View file

@ -35,6 +35,8 @@
/// ///
#ifndef COLORSPACE_H #ifndef COLORSPACE_H
/// DOCME
#define COLORSPACE_H #define COLORSPACE_H
#include <wx/wxprec.h> #include <wx/wxprec.h>
@ -42,6 +44,10 @@
#include <wx/string.h> #include <wx/string.h>
/// @brief DOCME
/// @param val
///
inline unsigned int clip_colorval(int val) inline unsigned int clip_colorval(int val)
{ {
if (val < 0) return 0; if (val < 0) return 0;
@ -82,3 +88,4 @@ wxColour html_to_color(wxString html);
#endif #endif

View file

@ -44,8 +44,13 @@
#include "dialog_colorpicker.h" #include "dialog_colorpicker.h"
///////////////
// Constructor /// @brief Constructor
/// @param parent
/// @param id
/// @param size
/// @param col
///
ColourButton::ColourButton(wxWindow* parent, wxWindowID id, const wxSize& size, wxColour col) { ColourButton::ColourButton(wxWindow* parent, wxWindowID id, const wxSize& size, wxColour col) {
// Variables // Variables
linkColour = NULL; linkColour = NULL;
@ -62,14 +67,17 @@ ColourButton::ColourButton(wxWindow* parent, wxWindowID id, const wxSize& size,
} }
//////////////
// Destructor /// @brief Destructor
///
ColourButton::~ColourButton() { ColourButton::~ColourButton() {
} }
//////////////
// Set colour /// @brief Set colour
/// @param col
///
void ColourButton::SetColour(wxColour col) { void ColourButton::SetColour(wxColour col) {
// Set colour // Set colour
colour = col; colour = col;
@ -90,15 +98,19 @@ void ColourButton::SetColour(wxColour col) {
} }
//////////////
// Get Colour /// @brief Get Colour
/// @return
///
wxColour ColourButton::GetColour() { wxColour ColourButton::GetColour() {
return colour; return colour;
} }
/////////
// Click /// @brief Click
/// @param event
///
void ColourButton::OnClick(wxCommandEvent &event) { void ColourButton::OnClick(wxCommandEvent &event) {
DialogColorPicker dlg(GetParent(), colour); DialogColorPicker dlg(GetParent(), colour);
if (dlg.ShowModal() == wxID_OK) { if (dlg.ShowModal() == wxID_OK) {
@ -108,10 +120,13 @@ void ColourButton::OnClick(wxCommandEvent &event) {
} }
///////////////////
// Set Link Colour /// @brief Set Link Colour
/// @param col
///
void ColourButton::SetLinkColour(wxColour *col) { void ColourButton::SetLinkColour(wxColour *col) {
linkColour = col; linkColour = col;
if (linkColour) SetColour(*linkColour); if (linkColour) SetColour(*linkColour);
} }

View file

@ -44,12 +44,22 @@
#include <wx/bmpbuttn.h> #include <wx/bmpbuttn.h>
///////////////////////
// Colour Button class /// DOCME
/// @class ColourButton
/// @brief DOCME
///
/// DOCME
class ColourButton: public wxBitmapButton { class ColourButton: public wxBitmapButton {
private: private:
/// DOCME
wxBitmap bmp; wxBitmap bmp;
/// DOCME
wxColour colour; wxColour colour;
/// DOCME
wxColour *linkColour; wxColour *linkColour;
void OnClick(wxCommandEvent &event); void OnClick(wxCommandEvent &event);
@ -63,3 +73,4 @@ public:
void SetLinkColour(wxColour *colour); void SetLinkColour(wxColour *colour);
}; };

View file

@ -50,8 +50,10 @@
///////////////
// Constructor /// @brief Constructor
/// @param parent
///
AboutScreen::AboutScreen(wxWindow *parent) AboutScreen::AboutScreen(wxWindow *parent)
: wxDialog (parent, -1, _("About Aegisub"), wxDefaultPosition, wxSize(300,240), wxCAPTION | wxCLOSE_BOX , _("About Aegisub")) : wxDialog (parent, -1, _("About Aegisub"), wxDefaultPosition, wxSize(300,240), wxCAPTION | wxCLOSE_BOX , _("About Aegisub"))
{ {
@ -185,8 +187,10 @@ AboutScreen::AboutScreen(wxWindow *parent)
} }
//////////////
// Destructor /// @brief Destructor
///
AboutScreen::~AboutScreen () { AboutScreen::~AboutScreen () {
} }

View file

@ -45,11 +45,16 @@
#include "static_bmp.h" #include "static_bmp.h"
///////////////////////
// Splash screen class /// DOCME
/// @class AboutScreen
/// @brief DOCME
///
/// DOCME
class AboutScreen: public wxDialog { class AboutScreen: public wxDialog {
public: public:
AboutScreen(wxWindow *parent); AboutScreen(wxWindow *parent);
~AboutScreen(); ~AboutScreen();
}; };

View file

@ -45,8 +45,10 @@
#include "dialog_associations.h" #include "dialog_associations.h"
///////////////
// Constructor /// @brief Constructor
/// @param parent
///
DialogAssociations::DialogAssociations (wxWindow *parent) DialogAssociations::DialogAssociations (wxWindow *parent)
: wxDialog (parent,-1,_("Associate extensions"),wxDefaultPosition,wxDefaultSize) : wxDialog (parent,-1,_("Associate extensions"),wxDefaultPosition,wxDefaultSize)
{ {
@ -86,14 +88,17 @@ DialogAssociations::DialogAssociations (wxWindow *parent)
} }
//////////////
// Destructor /// @brief Destructor
///
DialogAssociations::~DialogAssociations() { DialogAssociations::~DialogAssociations() {
} }
/////////////////////////////////////
// Associates a type with Aegisub /// @brief Associates a type with Aegisub
/// @param type
///
void DialogAssociations::AssociateType(wxString type) { void DialogAssociations::AssociateType(wxString type) {
type.Lower(); type.Lower();
wxRegKey *key = new wxRegKey(_T("HKEY_CURRENT_USER\\Software\\Classes\\.") + type); wxRegKey *key = new wxRegKey(_T("HKEY_CURRENT_USER\\Software\\Classes\\.") + type);
@ -103,8 +108,11 @@ void DialogAssociations::AssociateType(wxString type) {
} }
//////////////////////////////////////////////////
// Checks if a type is associated with Aegisub /// @brief Checks if a type is associated with Aegisub
/// @param type
/// @return
///
bool DialogAssociations::CheckAssociation(wxString type) { bool DialogAssociations::CheckAssociation(wxString type) {
type.Lower(); type.Lower();
wxRegKey *key = new wxRegKey(_T("HKEY_CURRENT_USER\\Software\\Classes\\.") + type); wxRegKey *key = new wxRegKey(_T("HKEY_CURRENT_USER\\Software\\Classes\\.") + type);
@ -128,8 +136,10 @@ BEGIN_EVENT_TABLE(DialogAssociations, wxDialog)
END_EVENT_TABLE() END_EVENT_TABLE()
//////////////
// OK pressed /// @brief OK pressed
/// @param event
///
void DialogAssociations::OnOK(wxCommandEvent &event) { void DialogAssociations::OnOK(wxCommandEvent &event) {
if (ListBox->IsChecked(0)) AssociateType(_T("ass")); if (ListBox->IsChecked(0)) AssociateType(_T("ass"));
if (ListBox->IsChecked(1)) AssociateType(_T("ssa")); if (ListBox->IsChecked(1)) AssociateType(_T("ssa"));
@ -139,3 +149,4 @@ void DialogAssociations::OnOK(wxCommandEvent &event) {
event.Skip(); event.Skip();
} }

View file

@ -46,10 +46,16 @@
#include <wx/slider.h> #include <wx/slider.h>
//////////////////////////////////
// File associations dialog class /// DOCME
/// @class DialogAssociations
/// @brief DOCME
///
/// DOCME
class DialogAssociations : public wxDialog { class DialogAssociations : public wxDialog {
private: private:
/// DOCME
wxCheckListBox *ListBox; wxCheckListBox *ListBox;
void OnOK(wxCommandEvent &event); void OnOK(wxCommandEvent &event);
@ -63,3 +69,4 @@ public:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View file

@ -55,8 +55,10 @@
///////////////
// Constructor /// @brief Constructor
/// @param parent
///
DialogAttachments::DialogAttachments(wxWindow *parent) DialogAttachments::DialogAttachments(wxWindow *parent)
: wxDialog(parent,-1,_("Attachment List"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE) : wxDialog(parent,-1,_("Attachment List"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE)
{ {
@ -92,8 +94,9 @@ DialogAttachments::DialogAttachments(wxWindow *parent)
} }
///////////////
// Update list /// @brief Update list
///
void DialogAttachments::UpdateList() { void DialogAttachments::UpdateList() {
// Clear list // Clear list
listView->ClearAll(); listView->ClearAll();
@ -119,8 +122,9 @@ void DialogAttachments::UpdateList() {
} }
//////////////
// Destructor /// @brief Destructor
///
DialogAttachments::~DialogAttachments() { DialogAttachments::~DialogAttachments() {
} }
@ -138,8 +142,11 @@ BEGIN_EVENT_TABLE(DialogAttachments,wxDialog)
END_EVENT_TABLE() END_EVENT_TABLE()
///////////////
// Attach font /// @brief Attach font
/// @param event
/// @return
///
void DialogAttachments::OnAttachFont(wxCommandEvent &event) { void DialogAttachments::OnAttachFont(wxCommandEvent &event) {
// Pick files // Pick files
wxArrayString filenames; wxArrayString filenames;
@ -171,8 +178,11 @@ void DialogAttachments::OnAttachFont(wxCommandEvent &event) {
} }
///////////////////
// Attach graphics /// @brief Attach graphics
/// @param event
/// @return
///
void DialogAttachments::OnAttachGraphics(wxCommandEvent &event) { void DialogAttachments::OnAttachGraphics(wxCommandEvent &event) {
// Pick files // Pick files
wxArrayString filenames; wxArrayString filenames;
@ -204,8 +214,11 @@ void DialogAttachments::OnAttachGraphics(wxCommandEvent &event) {
} }
///////////
// Extract /// @brief Extract
/// @param event
/// @return
///
void DialogAttachments::OnExtract(wxCommandEvent &event) { void DialogAttachments::OnExtract(wxCommandEvent &event) {
// Check if there's a selection // Check if there's a selection
int i = listView->GetFirstSelected(); int i = listView->GetFirstSelected();
@ -237,8 +250,10 @@ void DialogAttachments::OnExtract(wxCommandEvent &event) {
} }
//////////
// Delete /// @brief Delete
/// @param event
///
void DialogAttachments::OnDelete(wxCommandEvent &event) { void DialogAttachments::OnDelete(wxCommandEvent &event) {
// Loop through items in list // Loop through items in list
int i = listView->GetFirstSelected(); int i = listView->GetFirstSelected();
@ -252,8 +267,10 @@ void DialogAttachments::OnDelete(wxCommandEvent &event) {
} }
//////////////////////////
// List selection changed /// @brief List selection changed
/// @param event
///
void DialogAttachments::OnListClick(wxListEvent &event) { void DialogAttachments::OnListClick(wxListEvent &event) {
// Check if any is selected // Check if any is selected
bool hasSel = listView->GetFirstSelected() != -1; bool hasSel = listView->GetFirstSelected() != -1;
@ -263,3 +280,4 @@ void DialogAttachments::OnListClick(wxListEvent &event) {
deleteButton->Enable(hasSel); deleteButton->Enable(hasSel);
} }

View file

@ -49,12 +49,22 @@ class wxListView;
class wxListEvent; class wxListEvent;
//////////////////////
// Attachments window /// DOCME
/// @class DialogAttachments
/// @brief DOCME
///
/// DOCME
class DialogAttachments : public wxDialog { class DialogAttachments : public wxDialog {
private: private:
/// DOCME
wxListView *listView; wxListView *listView;
/// DOCME
wxButton *extractButton; wxButton *extractButton;
/// DOCME
wxButton *deleteButton; wxButton *deleteButton;
void OnAttachFont(wxCommandEvent &event); void OnAttachFont(wxCommandEvent &event);
@ -76,10 +86,21 @@ public:
/////// ///////
// IDs // IDs
enum { enum {
/// DOCME
BUTTON_ATTACH_FONT = 1300, BUTTON_ATTACH_FONT = 1300,
/// DOCME
BUTTON_ATTACH_GRAPHICS, BUTTON_ATTACH_GRAPHICS,
/// DOCME
BUTTON_EXTRACT, BUTTON_EXTRACT,
/// DOCME
BUTTON_DELETE, BUTTON_DELETE,
/// DOCME
ATTACHMENT_LIST ATTACHMENT_LIST
}; };

View file

@ -53,6 +53,11 @@
/// @brief DOCME
/// @param parent
/// @param _local_manager
///
DialogAutomation::DialogAutomation(wxWindow *parent, Automation4::ScriptManager *_local_manager) DialogAutomation::DialogAutomation(wxWindow *parent, Automation4::ScriptManager *_local_manager)
: wxDialog(parent, -1, _("Automation Manager"), wxDefaultPosition, wxDefaultSize) : wxDialog(parent, -1, _("Automation Manager"), wxDefaultPosition, wxDefaultSize)
{ {
@ -111,6 +116,9 @@ DialogAutomation::DialogAutomation(wxWindow *parent, Automation4::ScriptManager
} }
/// @brief DOCME
///
void DialogAutomation::RebuildList() void DialogAutomation::RebuildList()
{ {
script_info.clear(); script_info.clear();
@ -135,6 +143,10 @@ void DialogAutomation::RebuildList()
} }
/// @brief DOCME
/// @param ei
///
void DialogAutomation::AddScript(ExtraScriptInfo &ei) void DialogAutomation::AddScript(ExtraScriptInfo &ei)
{ {
script_info.push_back(ei); script_info.push_back(ei);
@ -157,6 +169,9 @@ void DialogAutomation::AddScript(ExtraScriptInfo &ei)
} }
/// @brief DOCME
///
void DialogAutomation::UpdateDisplay() void DialogAutomation::UpdateDisplay()
{ {
int i = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); int i = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
@ -186,6 +201,10 @@ BEGIN_EVENT_TABLE(DialogAutomation, wxDialog)
END_EVENT_TABLE() END_EVENT_TABLE()
/// @brief DOCME
/// @param evt
///
void DialogAutomation::OnAdd(wxCommandEvent &evt) void DialogAutomation::OnAdd(wxCommandEvent &evt)
{ {
// build filename filter list // build filename filter list
@ -237,6 +256,11 @@ void DialogAutomation::OnAdd(wxCommandEvent &evt)
} }
} }
/// @brief DOCME
/// @param evt
/// @return
///
void DialogAutomation::OnRemove(wxCommandEvent &evt) void DialogAutomation::OnRemove(wxCommandEvent &evt)
{ {
int i = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); int i = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
@ -249,6 +273,11 @@ void DialogAutomation::OnRemove(wxCommandEvent &evt)
list->Select(i); list->Select(i);
} }
/// @brief DOCME
/// @param evt
/// @return
///
void DialogAutomation::OnReload(wxCommandEvent &evt) void DialogAutomation::OnReload(wxCommandEvent &evt)
{ {
int i = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); int i = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
@ -273,6 +302,10 @@ void DialogAutomation::OnReload(wxCommandEvent &evt)
} }
} }
/// @brief DOCME
/// @param evt
///
void DialogAutomation::OnInfo(wxCommandEvent &evt) void DialogAutomation::OnInfo(wxCommandEvent &evt)
{ {
int i = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); int i = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
@ -318,6 +351,10 @@ void DialogAutomation::OnInfo(wxCommandEvent &evt)
wxMessageBox(info, _("Automation Script Info")); wxMessageBox(info, _("Automation Script Info"));
} }
/// @brief DOCME
/// @param evt
///
void DialogAutomation::OnReloadAutoload(wxCommandEvent &evt) void DialogAutomation::OnReloadAutoload(wxCommandEvent &evt)
{ {
global_manager->Reload(); global_manager->Reload();
@ -325,6 +362,10 @@ void DialogAutomation::OnReloadAutoload(wxCommandEvent &evt)
UpdateDisplay(); UpdateDisplay();
} }
/// @brief DOCME
/// @param evt
///
void DialogAutomation::OnSelectionChange(wxListEvent &evt) void DialogAutomation::OnSelectionChange(wxListEvent &evt)
{ {
UpdateDisplay(); UpdateDisplay();
@ -332,3 +373,4 @@ void DialogAutomation::OnSelectionChange(wxListEvent &evt)
#endif // WITH_AUTOMATION #endif // WITH_AUTOMATION

View file

@ -37,6 +37,8 @@
#pragma once #pragma once
#ifndef DIALOG_AUTOMATION_H #ifndef DIALOG_AUTOMATION_H
/// DOCME
#define DIALOG_AUTOMATION_H #define DIALOG_AUTOMATION_H
#include <wx/dialog.h> #include <wx/dialog.h>
@ -44,25 +46,59 @@
#include <wx/button.h> #include <wx/button.h>
#include <vector> #include <vector>
/// DOCME
namespace Automation4 { class ScriptManager; class Script; }; namespace Automation4 { class ScriptManager; class Script; };
/// DOCME
/// @class DialogAutomation
/// @brief DOCME
///
/// DOCME
class DialogAutomation : public wxDialog { class DialogAutomation : public wxDialog {
private: private:
/// DOCME
struct ExtraScriptInfo { struct ExtraScriptInfo {
/// DOCME
Automation4::Script *script; Automation4::Script *script;
/// DOCME
bool is_global; bool is_global;
}; };
/// DOCME
std::vector<ExtraScriptInfo> script_info; std::vector<ExtraScriptInfo> script_info;
/// DOCME
Automation4::ScriptManager *local_manager; Automation4::ScriptManager *local_manager;
/// DOCME
Automation4::AutoloadScriptManager *global_manager; Automation4::AutoloadScriptManager *global_manager;
/// DOCME
wxListView *list; wxListView *list;
/// DOCME
wxButton *add_button; wxButton *add_button;
/// DOCME
wxButton *remove_button; wxButton *remove_button;
/// DOCME
wxButton *reload_button; wxButton *reload_button;
/// DOCME
wxButton *info_button; wxButton *info_button;
/// DOCME
wxButton *reload_autoload_button; wxButton *reload_autoload_button;
/// DOCME
wxButton *close_button; wxButton *close_button;
void RebuildList(); void RebuildList();
@ -83,13 +119,26 @@ public:
}; };
enum { enum {
/// DOCME
Automation_List_Box = 1000, Automation_List_Box = 1000,
/// DOCME
Automation_Add_Script, Automation_Add_Script,
/// DOCME
Automation_Remove_Script, Automation_Remove_Script,
/// DOCME
Automation_Reload_Script, Automation_Reload_Script,
/// DOCME
Automation_Show_Info, Automation_Show_Info,
/// DOCME
Automation_Reload_Autoload Automation_Reload_Autoload
}; };
#endif #endif

Some files were not shown because too many files have changed in this diff Show more