本文整理汇总了C++中IODevice::m_info方法的典型用法代码示例。如果您正苦于以下问题:C++ IODevice::m_info方法的具体用法?C++ IODevice::m_info怎么用?C++ IODevice::m_info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IODevice
的用法示例。
在下文中一共展示了IODevice::m_info方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// ---------------------
// --- GenPeaks Main ---
// ---------------------
int main(int argc, char**argv)
{
int c;
string outdir("");
//
// parse program options
while ((c = getopt(argc , argv, "d:")) != -1) {
switch (c) {
case 'd': // service configuration file
outdir= optarg;
break;
case '?':
USAGE();
}
}
// -- Args Check --
if (optind >= argc )
{
USAGE();
}
// -- File Open --
string in_path = argv[optind];
IODevice* device = Guesser::open( in_path.c_str() );
if (device == NULL)
{
Log::err() << "Error --> Unable to open file " << in_path << endl;
return 1;
}
// -- Settings --
MediumInfo* info = device->m_info();
string peak_file;
if ( outdir.empty() ) {
unsigned long pos = in_path.rfind(".");
if ( pos > 0 && pos != string::npos )
peak_file = in_path.substr( 0, pos );
else peak_file = in_path;
} else {
unsigned long pos1 = in_path.rfind("/");
unsigned long pos2 = in_path.rfind(".");
if ( pos1 > pos2 ) pos2 = string::npos;
peak_file = outdir + in_path.substr(pos1, pos2 - pos1);
}
// -- Peaks processing (per channel) --
for(int i=0; i<info->audio_channels; i++)
{
ostringstream oss;
oss << peak_file << "_" << i << ".pks";
cout << "Processing & saving peaks : " << oss.str() << " SZ = " << sizeof(float) << endl;
float* tab = computeStreamPeaks(device, i);
int size = (int)(info->audio_duration / AUDIO_ZOOM_MAX);
FILE* fd = fopen(oss.str().c_str(), "wb");
if (fd != NULL)
{
int cur = 0;
while (cur < size)
{
int toRead = BUFFER_SIZE;
if (size-cur < BUFFER_SIZE)
toRead = size-cur;
int n = fwrite(tab + cur, sizeof(float), toRead, fd);
cur += n;
}
fflush(fd);
}
}
return 0;
}