2006-02-25 07:52:07 +01:00
|
|
|
// Copyright (c) 2005-2006, Rodrigo Braz Monteiro
|
2006-01-16 22:02:54 +01:00
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
2006-01-16 22:02:54 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file audio_provider.cpp
|
|
|
|
/// @brief Baseclass for audio providers
|
|
|
|
/// @ingroup audio_input
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
///////////
|
|
|
|
// Headers
|
2009-01-04 07:31:48 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-09-10 15:06:40 +02:00
|
|
|
#ifndef AGI_PRE
|
2007-09-12 01:22:26 +02:00
|
|
|
#include <wx/thread.h>
|
2009-09-10 15:06:40 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "audio_display.h"
|
2008-03-05 03:19:50 +01:00
|
|
|
#ifdef WITH_AVISYNTH
|
|
|
|
#include "audio_provider_avs.h"
|
|
|
|
#endif
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "audio_provider_convert.h"
|
2008-09-23 22:02:21 +02:00
|
|
|
#ifdef WITH_FFMPEGSOURCE
|
|
|
|
#include "audio_provider_ffmpegsource.h"
|
|
|
|
#endif
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "audio_provider_hd.h"
|
|
|
|
#include "audio_provider_pcm.h"
|
2009-07-24 08:04:19 +02:00
|
|
|
#ifdef WITH_QUICKTIME
|
|
|
|
#include "audio_provider_quicktime.h"
|
|
|
|
#endif
|
2009-09-10 15:06:40 +02:00
|
|
|
#include "audio_provider_ram.h"
|
2006-01-16 22:02:54 +01:00
|
|
|
#include "options.h"
|
2009-09-10 15:06:40 +02:00
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2006-01-25 11:56:24 +01:00
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Constructor
|
|
|
|
///
|
2006-02-25 07:52:07 +01:00
|
|
|
AudioProvider::AudioProvider() {
|
2006-01-16 22:02:54 +01:00
|
|
|
raw = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Destructor
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
AudioProvider::~AudioProvider() {
|
|
|
|
// Clear buffers
|
2007-04-04 22:42:44 +02:00
|
|
|
delete[] raw;
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Get number of channels
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
int AudioProvider::GetChannels() {
|
|
|
|
return channels;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Get number of samples
|
|
|
|
/// @return
|
|
|
|
///
|
2007-08-31 16:11:35 +02:00
|
|
|
int64_t AudioProvider::GetNumSamples() {
|
2006-01-16 22:02:54 +01:00
|
|
|
return num_samples;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Get sample rate
|
|
|
|
/// @return
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
int AudioProvider::GetSampleRate() {
|
|
|
|
return sample_rate;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Get bytes per sample
|
|
|
|
/// @return
|
|
|
|
///
|
2006-02-25 07:52:07 +01:00
|
|
|
int AudioProvider::GetBytesPerSample() {
|
|
|
|
return bytes_per_sample;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Get filename
|
|
|
|
/// @return
|
|
|
|
///
|
2006-02-25 07:52:07 +01:00
|
|
|
wxString AudioProvider::GetFilename() {
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Get waveform
|
|
|
|
/// @param min
|
|
|
|
/// @param peak
|
|
|
|
/// @param start
|
|
|
|
/// @param w
|
|
|
|
/// @param h
|
|
|
|
/// @param samples
|
|
|
|
/// @param scale
|
|
|
|
///
|
2007-08-31 16:11:35 +02:00
|
|
|
void AudioProvider::GetWaveForm(int *min,int *peak,int64_t start,int w,int h,int samples,float scale) {
|
2006-01-16 22:02:54 +01:00
|
|
|
// Setup
|
|
|
|
int channels = GetChannels();
|
|
|
|
int n = w * samples;
|
|
|
|
for (int i=0;i<w;i++) {
|
|
|
|
peak[i] = 0;
|
|
|
|
min[i] = h;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prepare waveform
|
|
|
|
int cur;
|
|
|
|
int curvalue;
|
|
|
|
|
|
|
|
// Prepare buffers
|
|
|
|
int needLen = n*channels*bytes_per_sample;
|
|
|
|
if (raw) {
|
|
|
|
if (raw_len < needLen) {
|
2007-04-04 22:42:44 +02:00
|
|
|
delete[] raw;
|
2006-01-16 22:02:54 +01:00
|
|
|
raw = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!raw) {
|
|
|
|
raw_len = needLen;
|
2007-09-21 18:20:00 +02:00
|
|
|
raw = new char[raw_len];
|
2006-01-16 22:02:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bytes_per_sample == 1) {
|
|
|
|
// Read raw samples
|
|
|
|
unsigned char *raw_char = (unsigned char*) raw;
|
|
|
|
GetAudio(raw,start,n);
|
2007-04-04 22:42:44 +02:00
|
|
|
int amplitude = int(h*scale);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Calculate waveform
|
|
|
|
for (int i=0;i<n;i++) {
|
|
|
|
cur = i/samples;
|
|
|
|
curvalue = h - (int(raw_char[i*channels])*amplitude)/0xFF;
|
|
|
|
if (curvalue > h) curvalue = h;
|
|
|
|
if (curvalue < 0) curvalue = 0;
|
|
|
|
if (curvalue < min[cur]) min[cur] = curvalue;
|
|
|
|
if (curvalue > peak[cur]) peak[cur] = curvalue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bytes_per_sample == 2) {
|
|
|
|
// Read raw samples
|
|
|
|
short *raw_short = (short*) raw;
|
|
|
|
GetAudio(raw,start,n);
|
|
|
|
int half_h = h/2;
|
2007-04-04 22:42:44 +02:00
|
|
|
int half_amplitude = int(half_h * scale);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
|
|
|
// Calculate waveform
|
|
|
|
for (int i=0;i<n;i++) {
|
|
|
|
cur = i/samples;
|
|
|
|
curvalue = half_h - (int(raw_short[i*channels])*half_amplitude)/0x8000;
|
|
|
|
if (curvalue > h) curvalue = h;
|
|
|
|
if (curvalue < 0) curvalue = 0;
|
|
|
|
if (curvalue < min[cur]) min[cur] = curvalue;
|
|
|
|
if (curvalue > peak[cur]) peak[cur] = curvalue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Get audio with volume
|
|
|
|
/// @param buf
|
|
|
|
/// @param start
|
|
|
|
/// @param count
|
|
|
|
/// @param volume
|
|
|
|
/// @return
|
|
|
|
///
|
2007-08-31 16:11:35 +02:00
|
|
|
void AudioProvider::GetAudioWithVolume(void *buf, int64_t start, int64_t count, double volume) {
|
2009-04-29 21:30:02 +02:00
|
|
|
try {
|
|
|
|
GetAudio(buf,start,count);
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
// FIXME: Poor error handling though better than none, to patch issue #800.
|
|
|
|
// Just return blank audio if real provider fails.
|
|
|
|
memset(buf, 0, count*bytes_per_sample);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-01-23 05:42:08 +01:00
|
|
|
if (volume == 1.0) return;
|
|
|
|
|
|
|
|
if (bytes_per_sample == 2) {
|
|
|
|
// Read raw samples
|
|
|
|
short *buffer = (short*) buf;
|
|
|
|
int value;
|
|
|
|
|
|
|
|
// Modify
|
2007-08-31 16:11:35 +02:00
|
|
|
for (int64_t i=0;i<count;i++) {
|
2007-01-23 05:42:08 +01:00
|
|
|
value = (int)(buffer[i]*volume+0.5);
|
|
|
|
if (value < -0x8000) value = -0x8000;
|
|
|
|
if (value > 0x7FFF) value = 0x7FFF;
|
|
|
|
buffer[i] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Get provider
|
|
|
|
/// @param filename
|
|
|
|
/// @param cache
|
|
|
|
/// @return
|
|
|
|
///
|
2008-03-08 19:04:51 +01:00
|
|
|
AudioProvider *AudioProviderFactoryManager::GetAudioProvider(wxString filename, int cache) {
|
2006-02-25 07:52:07 +01:00
|
|
|
// Prepare provider
|
|
|
|
AudioProvider *provider = NULL;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2008-07-04 05:24:25 +02:00
|
|
|
if (!Options.AsBool(_T("Audio Disable PCM Provider"))) {
|
|
|
|
// Try a PCM provider first
|
|
|
|
provider = CreatePCMAudioProvider(filename);
|
|
|
|
if (provider) {
|
2008-07-16 15:22:06 +02:00
|
|
|
if (provider->GetBytesPerSample() == 2 && provider->GetSampleRate() >= 32000 && provider->GetChannels() == 1)
|
|
|
|
return provider;
|
|
|
|
else {
|
|
|
|
provider = CreateConvertAudioProvider(provider);
|
|
|
|
return provider;
|
|
|
|
}
|
2008-07-04 05:24:25 +02:00
|
|
|
}
|
2008-01-19 03:18:08 +01:00
|
|
|
}
|
2007-08-22 22:58:53 +02:00
|
|
|
|
2007-01-23 05:42:08 +01:00
|
|
|
// List of providers
|
|
|
|
wxArrayString list = GetFactoryList(Options.AsText(_T("Audio provider")));
|
|
|
|
|
|
|
|
// None available
|
|
|
|
if (list.Count() == 0) throw _T("No audio providers are available.");
|
|
|
|
|
|
|
|
// Get provider
|
|
|
|
wxString error;
|
|
|
|
for (unsigned int i=0;i<list.Count();i++) {
|
|
|
|
try {
|
2009-06-12 01:30:33 +02:00
|
|
|
AudioProvider *prov = GetFactory(list[i])->CreateProvider(filename.wc_str());
|
2007-01-23 05:42:08 +01:00
|
|
|
if (prov) {
|
|
|
|
provider = prov;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (wxString err) { error += list[i] + _T(" factory: ") + err + _T("\n"); }
|
|
|
|
catch (const wxChar *err) { error += list[i] + _T(" factory: ") + wxString(err) + _T("\n"); }
|
|
|
|
catch (...) { error += list[i] + _T(" factory: Unknown error\n"); }
|
2006-02-25 07:52:07 +01:00
|
|
|
}
|
|
|
|
|
2007-01-23 05:42:08 +01:00
|
|
|
// Failed
|
|
|
|
if (!provider) throw error;
|
|
|
|
|
2008-01-19 03:38:31 +01:00
|
|
|
// Give it a conversor if needed
|
2008-07-16 15:22:06 +02:00
|
|
|
if (provider->GetBytesPerSample() != 2 || provider->GetSampleRate() < 32000 || provider->GetChannels() != 1)
|
|
|
|
provider = CreateConvertAudioProvider(provider);
|
2008-01-19 03:38:31 +01:00
|
|
|
|
2006-02-25 08:41:18 +01:00
|
|
|
// Change provider to RAM/HD cache if needed
|
2006-07-01 08:32:11 +02:00
|
|
|
if (cache == -1) cache = Options.AsInt(_T("Audio Cache"));
|
|
|
|
if (cache) {
|
2006-02-25 08:41:18 +01:00
|
|
|
AudioProvider *final = NULL;
|
2006-07-01 08:32:11 +02:00
|
|
|
|
2006-02-25 09:26:29 +01:00
|
|
|
// Convert to RAM
|
2006-07-01 08:32:11 +02:00
|
|
|
if (cache == 1) final = new RAMAudioProvider(provider);
|
2006-02-25 09:26:29 +01:00
|
|
|
|
|
|
|
// Convert to HD
|
2006-07-01 08:32:11 +02:00
|
|
|
if (cache == 2) final = new HDAudioProvider(provider);
|
2006-02-25 08:41:18 +01:00
|
|
|
|
|
|
|
// Reassign
|
|
|
|
if (final) {
|
|
|
|
delete provider;
|
|
|
|
provider = final;
|
|
|
|
}
|
|
|
|
}
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2006-02-25 07:52:07 +01:00
|
|
|
// Return
|
|
|
|
return provider;
|
|
|
|
}
|
2007-01-05 19:27:15 +01:00
|
|
|
|
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Register all providers
|
|
|
|
///
|
2008-03-07 03:32:29 +01:00
|
|
|
void AudioProviderFactoryManager::RegisterProviders() {
|
2008-03-05 03:19:50 +01:00
|
|
|
#ifdef WITH_AVISYNTH
|
2008-03-07 03:32:29 +01:00
|
|
|
RegisterFactory(new AvisynthAudioProviderFactory(),_T("Avisynth"));
|
2008-03-05 03:19:50 +01:00
|
|
|
#endif
|
2008-09-23 22:02:21 +02:00
|
|
|
#ifdef WITH_FFMPEGSOURCE
|
|
|
|
RegisterFactory(new FFmpegSourceAudioProviderFactory(),_T("FFmpegSource"));
|
|
|
|
#endif
|
2009-07-24 08:04:19 +02:00
|
|
|
#ifdef WITH_QUICKTIME
|
|
|
|
RegisterFactory(new QuickTimeAudioProviderFactory(), _T("QuickTime"));
|
|
|
|
#endif
|
2008-03-05 03:19:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// @brief Clear all providers
|
|
|
|
///
|
2009-05-18 07:42:54 +02:00
|
|
|
void AudioProviderFactoryManager::ClearProviders() {
|
|
|
|
ClearFactories();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|
|
|
|
/// DOCME
|
2008-03-07 03:32:29 +01:00
|
|
|
template <class AudioProviderFactory> std::map<wxString,AudioProviderFactory*>* FactoryManager<AudioProviderFactory>::factories=NULL;
|
2009-07-29 07:43:02 +02:00
|
|
|
|
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.
2009-07-30 00:59:22 +02:00
|
|
|
|