本文整理汇总了C++中seek函数的典型用法代码示例。如果您正苦于以下问题:C++ seek函数的具体用法?C++ seek怎么用?C++ seek使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了seek函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: LogDebug
///Seeks to the specified seekTime
void CTsReaderFilter::Seek(CRefTime& seekTime, bool seekInfile)
{
//are we playing a rtsp:// stream?
if (m_fileDuration != NULL)
{
//no, do a seek in the local file
double startTime = m_seekTime.Millisecs();
double duration = m_duration.Duration().Millisecs();
startTime /= 1000.0f;
duration /= 1000.0f;
LogDebug("CTsReaderFilter:: Seek-> %f/%f", startTime, duration);
//if (seekTime >= m_duration.Duration())
// seekTime = m_duration.Duration();
CTsFileSeek seek(m_duration);
seek.SetFileReader(m_fileReader);
seek.Seek(seekTime);
}
else
{
//yes, we're playing a RTSP stream
//stop the RTSP steam
LogDebug("CTsReaderFilter:: Seek->stop rtsp");
m_rtspClient.Stop();
double startTime = m_seekTime.Millisecs();
startTime /= 1000.0;
double milli = m_duration.Duration().Millisecs();
milli /= 1000.0;
if (m_bLiveTv) startTime += 10.0; // If liveTv, it's a seek to end, force end of buffer.
LogDebug("CTsReaderFilter:: Seek->start client from %f/ %f",startTime,milli);
//clear the buffers
// m_demultiplexer.Flush();
m_buffer.Clear();
m_buffer.Run(true);
//start rtsp stream from the seek-time
long Old_rtspDuration = m_rtspClient.Duration();
if (m_rtspClient.Play(startTime, m_duration.Duration().Millisecs()/1000.0))
{
int loop = 0;
while (m_buffer.Size() == 0 && loop++ <= 50 ) // lets exit the loop if no data received for 5 secs.
{
LogDebug("CTsReaderFilter:: Seek-->buffer empty, sleep(100ms)");
Sleep(100);
}
if (loop >=50)
{
LogDebug("CTsReaderFilter:: Seek->start aborted");
return ;
}
//update the duration of the stream
CPcr pcrStart, pcrEnd, pcrMax ;
double duration = m_rtspClient.Duration() / 1000.0f ;
if (m_bTimeShifting)
{
// EndPcr is continuously increasing ( until ~26 hours for rollover that will fail ! )
// So, we refer duration to End, and just update start.
pcrEnd = m_duration.EndPcr() ;
double start = pcrEnd.ToClock() - duration;
if (start<0) start=0 ;
pcrStart.FromClock(start) ;
m_duration.Set( pcrStart, pcrEnd, pcrMax) ; // Seek()-RTSP
}
else
{
// It's a record, eventually end can increase if recording is in progress, let the end virtually updated by ThreadProc()
//m_bRecording = (Old_rtspDuration != m_rtspClient.Duration()) ;
m_bRecording = true; // duration may have not increased in such a short time
}
LogDebug("CTsReaderFilter:: Rtsp seek :Timeshift %d, Recording %d, StartPCR %f, EndPcr %f, Duration %f",m_bTimeShifting,m_bRecording,m_duration.StartPcr().ToClock(),m_duration.EndPcr().ToClock(),(float)m_duration.Duration().Millisecs()/1000.0f) ;
}
else
{
LogDebug("CTsReaderFilter:: Seek->start aborted");
}
}
}
开发者ID:SilentException,项目名称:MediaPortal-1,代码行数:84,代码来源:TsReader.cpp
示例2: CFStringCreateWithCString
//.........这里部分代码省略.........
outputFormat.mFormatFlags = kAudioFormatFlagsCanonical;
//kAudioFormatFlagsCanonical means Native endian, float, packed on Mac OS X,
//but signed int for iOS instead.
//Note iPhone/iOS only supports signed integers supposedly:
//outputFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger;
//Debugging:
//printf ("Source File format: "); inputFormat.Print();
//printf ("Dest File format: "); outputFormat.Print();
/*
switch(inputFormat.mBitsPerChannel) {
case 16:
outputFormat.mFormatFlags = kAppleLosslessFormatFlag_16BitSourceData;
break;
case 20:
outputFormat.mFormatFlags = kAppleLosslessFormatFlag_20BitSourceData;
break;
case 24:
outputFormat.mFormatFlags = kAppleLosslessFormatFlag_24BitSourceData;
break;
case 32:
outputFormat.mFormatFlags = kAppleLosslessFormatFlag_32BitSourceData;
break;
}*/
// get and set the client format - it should be lpcm
CAStreamBasicDescription clientFormat = outputFormat; //We're always telling the OS to do the conversion to floats for us now
clientFormat.mChannelsPerFrame = 2;
clientFormat.mBytesPerFrame = sizeof(SAMPLE)*clientFormat.mChannelsPerFrame;
clientFormat.mBitsPerChannel = sizeof(SAMPLE)*8; //16 for signed int, 32 for float;
clientFormat.mFramesPerPacket = 1;
clientFormat.mBytesPerPacket = clientFormat.mBytesPerFrame*clientFormat.mFramesPerPacket;
clientFormat.mReserved = 0;
m_clientFormat = clientFormat;
size = sizeof(clientFormat);
err = ExtAudioFileSetProperty(m_audioFile, kExtAudioFileProperty_ClientDataFormat, size, &clientFormat);
if (err != noErr)
{
//qDebug() << "SSCA: Error setting file property";
std::cerr << "AudioDecoderCoreAudio: Error setting file property." << std::endl;
return AUDIODECODER_ERROR;
}
//Set m_iChannels and m_iNumSamples;
m_iChannels = clientFormat.NumberChannels();
//get the total length in frames of the audio file - copypasta: http://discussions.apple.com/thread.jspa?threadID=2364583&tstart=47
UInt32 dataSize;
SInt64 totalFrameCount;
dataSize = sizeof(totalFrameCount); //XXX: This looks sketchy to me - Albert
err = ExtAudioFileGetProperty(m_audioFile, kExtAudioFileProperty_FileLengthFrames, &dataSize, &totalFrameCount);
if (err != noErr)
{
std::cerr << "AudioDecoderCoreAudio: Error getting number of frames." << std::endl;
return AUDIODECODER_ERROR;
}
//
// WORKAROUND for bug in ExtFileAudio
//
AudioConverterRef acRef;
UInt32 acrsize=sizeof(AudioConverterRef);
err = ExtAudioFileGetProperty(m_audioFile, kExtAudioFileProperty_AudioConverter, &acrsize, &acRef);
//_ThrowExceptionIfErr(@"kExtAudioFileProperty_AudioConverter", err);
AudioConverterPrimeInfo primeInfo;
UInt32 piSize=sizeof(AudioConverterPrimeInfo);
memset(&primeInfo, 0, piSize);
err = AudioConverterGetProperty(acRef, kAudioConverterPrimeInfo, &piSize, &primeInfo);
if(err != kAudioConverterErr_PropertyNotSupported) // Only if decompressing
{
//_ThrowExceptionIfErr(@"kAudioConverterPrimeInfo", err);
m_headerFrames=primeInfo.leadingFrames;
}
m_iNumSamples = (totalFrameCount/*-m_headerFrames*/)*m_iChannels;
m_iSampleRate = inputFormat.mSampleRate;
m_fDuration = m_iNumSamples / static_cast<float>(m_iSampleRate * m_iChannels);
//Convert mono files into stereo
if (inputFormat.NumberChannels() == 1)
{
SInt32 channelMap[2] = {0, 0}; // array size should match the number of output channels
AudioConverterSetProperty(acRef, kAudioConverterChannelMap,
sizeof(channelMap), channelMap);
}
//Seek to position 0, which forces us to skip over all the header frames.
//This makes sure we're ready to just let the Analyser rip and it'll
//get the number of samples it expects (ie. no header frames).
seek(0);
return AUDIODECODER_OK;
}
开发者ID:CLOUDS-Interactive-Documentary,项目名称:ofxAudioDecoder,代码行数:101,代码来源:audiodecodercoreaudio.cpp
示例3: asmb
void
asmb(void)
{
Prog *p;
long t, magic;
Optab *o;
vlong vl;
if(debug['v'])
Bprint(&bso, "%5.2f asm\n", cputime());
Bflush(&bso);
seek(cout, HEADR, 0);
pc = INITTEXT;
for(p = firstp; p != P; p = p->link) {
if(p->as == ATEXT) {
curtext = p;
autosize = p->to.offset + 8;
if(p->from3.type == D_CONST) {
for(; pc < p->pc; pc++)
CPUT(0);
}
}
if(p->pc != pc) {
diag("phase error %llux sb %llux",
p->pc, pc);
if(!debug['a'])
prasm(curp);
pc = p->pc;
}
curp = p;
o = oplook(p); /* could probably avoid this call */
if(asmout(p, o, 0)) {
p = p->link;
pc += 4;
}
pc += o->size;
}
if(debug['a'])
Bprint(&bso, "\n");
Bflush(&bso);
cflush();
curtext = P;
switch(HEADTYPE) {
case 0:
case 1:
case 2:
case 5:
case 9:
case 10:
seek(cout, HEADR+textsize, 0);
break;
case 3:
seek(cout, rnd(HEADR+textsize, 4), 0);
break;
}
if(dlm){
char buf[8];
write(cout, buf, INITDAT-textsize);
textsize = INITDAT;
}
for(t = 0; t < datsize; t += sizeof(buf)-100) {
if(datsize-t > sizeof(buf)-100)
datblk(t, sizeof(buf)-100);
else
datblk(t, datsize-t);
}
symsize = 0;
lcsize = 0;
if(!debug['s']) {
if(debug['v'])
Bprint(&bso, "%5.2f sym\n", cputime());
Bflush(&bso);
switch(HEADTYPE) {
case 0:
case 1:
case 2:
case 5:
case 9:
case 10:
seek(cout, HEADR+textsize+datsize, 0);
break;
case 3:
seek(cout, rnd(HEADR+textsize, 4)+datsize, 0);
break;
}
if(!debug['s'])
asmsym();
if(debug['v'])
Bprint(&bso, "%5.2f sp\n", cputime());
Bflush(&bso);
if(!debug['s'])
asmlc();
if(dlm)
asmdyn();
if(HEADTYPE == 0 || HEADTYPE == 1) /* round up file length for boot image */
//.........这里部分代码省略.........
开发者ID:lufia,项目名称:plan9-contrib,代码行数:101,代码来源:asm.c
示例4: seek
size_t BlockFileInputStream::seekAndRead(offset_t pos, void* buffer, size_t bufSize)
{
seek(pos);
return read(buffer, bufSize);
}
开发者ID:Web5design,项目名称:firtex2,代码行数:5,代码来源:BlockFileInputStream.cpp
示例5: seek
bool DhQIODevice::Dvhseek(qint64 x1) {
return seek(x1);
}
开发者ID:bennofs,项目名称:hsQt,代码行数:3,代码来源:QIODevice_DhClass.cpp
示例6: seek
// (virtual)
int64_t IStream::skip(
int count)
{
return seek(count, StreamSeekOrigin::current);
}
开发者ID:emileb,项目名称:bstone,代码行数:6,代码来源:bstone_istream.cpp
示例7: machdotout
static int
machdotout(int fd, Fhdr *fp, ExecHdr *hp)
{
uvlong (*swav)(uvlong);
uint32 (*swal)(uint32);
ushort (*swab)(ushort);
Machhdr *mp;
MachCmd **cmd;
MachSymSeg *symtab;
MachSymSeg *pclntab;
MachSeg64 *seg;
MachSect64 *sect;
MachSeg32 *seg32;
MachSect32 *sect32;
uvlong textsize, datasize, bsssize;
uchar *cmdbuf;
uchar *cmdp;
int i, hdrsize;
uint32 textva, textoff, datava, dataoff;
mp = &hp->e.machhdr;
if (leswal(mp->filetype) != MACH_EXECUTABLE_TYPE) {
werrstr("bad MACH executable type %#ux", leswal(mp->filetype));
return 0;
}
swab = leswab;
swal = leswal;
swav = leswav;
mp->magic = swal(mp->magic);
mp->cputype = swal(mp->cputype);
mp->cpusubtype = swal(mp->cpusubtype);
mp->filetype = swal(mp->filetype);
mp->ncmds = swal(mp->ncmds);
mp->sizeofcmds = swal(mp->sizeofcmds);
mp->flags = swal(mp->flags);
mp->reserved = swal(mp->reserved);
hdrsize = 0;
switch(mp->magic) {
case 0xFEEDFACE: // 32-bit mach
if (mp->cputype != MACH_CPU_TYPE_X86) {
werrstr("bad MACH cpu type - not 386");
return 0;
}
if (mp->cpusubtype != MACH_CPU_SUBTYPE_X86) {
werrstr("bad MACH cpu subtype - not 386");
return 0;
}
if (mp->filetype != MACH_EXECUTABLE_TYPE) {
werrstr("bad MACH executable type");
return 0;
}
mach = &mi386;
fp->type = FI386;
hdrsize = 28;
break;
case 0xFEEDFACF: // 64-bit mach
if (mp->cputype != MACH_CPU_TYPE_X86_64) {
werrstr("bad MACH cpu type - not amd64");
return 0;
}
if (mp->cpusubtype != MACH_CPU_SUBTYPE_X86) {
werrstr("bad MACH cpu subtype - not amd64");
return 0;
}
mach = &mamd64;
fp->type = FAMD64;
hdrsize = 32;
break;
default:
werrstr("not mach %#ux", mp->magic);
return 0;
}
cmdbuf = malloc(mp->sizeofcmds);
seek(fd, hdrsize, 0);
if(read(fd, cmdbuf, mp->sizeofcmds) != mp->sizeofcmds) {
free(cmdbuf);
return 0;
}
cmd = malloc(mp->ncmds * sizeof(MachCmd*));
cmdp = cmdbuf;
textva = 0;
textoff = 0;
dataoff = 0;
datava = 0;
symtab = 0;
pclntab = 0;
textsize = datasize = bsssize = 0;
for (i = 0; i < mp->ncmds; i++) {
MachCmd *c;
cmd[i] = (MachCmd*)cmdp;
c = cmd[i];
c->type = swal(c->type);
//.........这里部分代码省略.........
开发者ID:8l,项目名称:go-learn,代码行数:101,代码来源:executable.c
示例8: asmb
void
asmb(void)
{
Prog *p;
long v;
int a;
short *op1;
if(debug['v'])
Bprint(&bso, "%5.2f asmb\n", cputime());
Bflush(&bso);
seek(cout, HEADR, 0);
pc = INITTEXT;
curp = firstp;
for(p = firstp; p != P; p = p->link) {
if(p->as == ATEXT)
curtext = p;
if(p->pc != pc) {
if(!debug['a'])
print("%P\n", curp);
diag("phase error %.4lux sb %.4lux in %s", p->pc, pc, TNAME);
pc = p->pc;
}
curp = p;
if(debug['a'])
Bprint(&bso, "%lux:%P\n", pc, curp);
asmins(p);
if(cbc < sizeof(opa))
cflush();
for(op1 = opa; op1 < op; op1++) {
a = *op1;
*cbp++ = a >> 8;
*cbp++ = a;
}
a = 2*(op - opa);
pc += a;
cbc -= a;
if(debug['a']) {
for(op1 = opa; op1 < op; op1++)
if(op1 == opa)
Bprint(&bso, "\t\t%4ux", *op1 & 0xffff);
else
Bprint(&bso, " %4ux", *op1 & 0xffff);
if(op != opa)
Bprint(&bso, "\n");
}
}
cflush();
switch(HEADTYPE) {
case 0: /* this is garbage */
seek(cout, rnd(HEADR+textsize, 8192), 0);
break;
case 1: /* plan9 boot data goes into text */
seek(cout, rnd(HEADR+textsize, INITRND), 0);
break;
case 2: /* plan 9 */
seek(cout, HEADR+textsize, 0);
break;
case 3: /* next boot */
seek(cout, HEADR+rnd(textsize, INITRND), 0);
break;
case 4: /* preprocess pilot */
seek(cout, HEADR+textsize, 0);
break;
}
if(debug['v'])
Bprint(&bso, "%5.2f datblk\n", cputime());
Bflush(&bso);
for(v = 0; v < datsize; v += sizeof(buf)-100) {
if(datsize-v > sizeof(buf)-100)
datblk(v, sizeof(buf)-100);
else
datblk(v, datsize-v);
}
symsize = 0;
spsize = 0;
lcsize = 0;
relocsize = 0;
Bflush(&bso);
switch(HEADTYPE) {
default:
seek(cout, rnd(HEADR+textsize, 8192)+datsize, 0);
break;
case 1: /* plan9 boot data goes into text */
seek(cout, rnd(HEADR+textsize, INITRND)+datsize, 0);
break;
case 2: /* plan 9 */
seek(cout, HEADR+textsize+datsize, 0);
break;
case 3: /* next boot */
seek(cout, HEADR+rnd(textsize, INITRND)+datsize, 0);
break;
case 4: /* preprocess pilot */
seek(cout, HEADR+textsize+datsize, 0);
//.........这里部分代码省略.........
开发者ID:JehanneOS,项目名称:devtools-kencc,代码行数:101,代码来源:asm.c
示例9: crackhdr
int
crackhdr(int fd, Fhdr *fp)
{
ExecTable *mp;
ExecHdr d;
int nb, ret;
uint32 magic;
fp->type = FNONE;
nb = read(fd, (char *)&d.e, sizeof(d.e));
if (nb <= 0)
return 0;
ret = 0;
magic = beswal(d.e.exechdr.magic); /* big-endian */
for (mp = exectab; mp->magic; mp++) {
if (nb < mp->hsize)
continue;
/*
* The magic number has morphed into something
* with fields (the straw was DYN_MAGIC) so now
* a flag is needed in Fhdr to distinguish _MAGIC()
* magic numbers from foreign magic numbers.
*
* This code is creaking a bit and if it has to
* be modified/extended much more it's probably
* time to step back and redo it all.
*/
if(mp->_magic){
if(mp->magic != (magic & ~DYN_MAGIC))
continue;
if(mp->magic == V_MAGIC)
mp = couldbe4k(mp);
if ((magic & DYN_MAGIC) && mp->dlmname != nil)
fp->name = mp->dlmname;
else
fp->name = mp->name;
}
else{
if(mp->magic != magic)
continue;
fp->name = mp->name;
}
fp->type = mp->type;
fp->hdrsz = mp->hsize; /* will be zero on bootables */
fp->_magic = mp->_magic;
fp->magic = magic;
mach = mp->mach;
if(mp->swal != nil)
hswal(&d, sizeof(d.e)/sizeof(uint32), mp->swal);
ret = mp->hparse(fd, fp, &d);
seek(fd, mp->hsize, 0); /* seek to end of header */
break;
}
if(mp->magic == 0)
werrstr("unknown header type");
return ret;
}
开发者ID:8l,项目名称:go-learn,代码行数:62,代码来源:executable.c
示例10: elfdotout
static int
elfdotout(int fd, Fhdr *fp, ExecHdr *hp)
{
uint32 (*swal)(uint32);
ushort (*swab)(ushort);
Ehdr32 *ep;
Phdr32 *ph;
int i, it, id, is, phsz, shsz;
Shdr32 *sh;
/* bitswap the header according to the DATA format */
ep = &hp->e.elfhdr32;
if(ep->ident[CLASS] != ELFCLASS32) {
return elf64dotout(fd, fp, hp);
}
if(ep->ident[DATA] == ELFDATA2LSB) {
swab = leswab;
swal = leswal;
} else if(ep->ident[DATA] == ELFDATA2MSB) {
swab = beswab;
swal = beswal;
} else {
werrstr("bad ELF encoding - not big or little endian");
return 0;
}
ep->type = swab(ep->type);
ep->machine = swab(ep->machine);
ep->version = swal(ep->version);
ep->elfentry = swal(ep->elfentry);
ep->phoff = swal(ep->phoff);
ep->shoff = swal(ep->shoff);
ep->flags = swal(ep->flags);
ep->ehsize = swab(ep->ehsize);
ep->phentsize = swab(ep->phentsize);
ep->phnum = swab(ep->phnum);
ep->shentsize = swab(ep->shentsize);
ep->shnum = swab(ep->shnum);
ep->shstrndx = swab(ep->shstrndx);
if(ep->type != EXEC || ep->version != CURRENT)
return 0;
/* we could definitely support a lot more machines here */
fp->magic = ELF_MAG;
fp->hdrsz = (ep->ehsize+ep->phnum*ep->phentsize+16)&~15;
switch(ep->machine) {
case I386:
mach = &mi386;
fp->type = FI386;
break;
case MIPS:
mach = &mmips;
fp->type = FMIPS;
break;
case SPARC64:
mach = &msparc64;
fp->type = FSPARC64;
break;
case POWER:
mach = &mpower;
fp->type = FPOWER;
break;
case ARM:
mach = &marm;
fp->type = FARM;
break;
default:
return 0;
}
if(ep->phentsize != sizeof(Phdr32)) {
werrstr("bad ELF header size");
return 0;
}
phsz = sizeof(Phdr32)*ep->phnum;
ph = malloc(phsz);
if(!ph)
return 0;
seek(fd, ep->phoff, 0);
if(read(fd, ph, phsz) < 0) {
free(ph);
return 0;
}
hswal(ph, phsz/sizeof(uint32), swal);
shsz = sizeof(Shdr32)*ep->shnum;
sh = malloc(shsz);
if(sh) {
seek(fd, ep->shoff, 0);
if(read(fd, sh, shsz) < 0) {
free(sh);
sh = 0;
} else
hswal(sh, shsz/sizeof(uint32), swal);
}
/* find text, data and symbols and install them */
it = id = is = -1;
for(i = 0; i < ep->phnum; i++) {
//.........这里部分代码省略.........
开发者ID:8l,项目名称:go-learn,代码行数:101,代码来源:executable.c
示例11: initFileObject
//.........这里部分代码省略.........
std::string buffer(blockSize, 0);
if(file->readString(buffer))
{
lua_pushlstring(L, buffer.data(), buffer.size());
return 1;
}
return 0;
}},
{"readLine", [](lua_State* L)
{
auto file = script::ptr<File>(L, 1);
std::string value;
if(file->readLine(value))
{
script::push(L, value.c_str());
return 1;
}
return 0;
}},
{"readFully", [](lua_State* L)
{
auto file = script::ptr<File>(L, 1);
// Get current position.
auto pos = file->tell();
if(pos == -1)
{
return 0;
}
// Length to read = position of end - current.
auto length = 0;
if(!file->seek(pos, FileSeekMode::End))
{
return 0;
}
length = file->tell() - pos;
if(!file->seek(pos, FileSeekMode::Start))
{
return 0;
}
// Read the entire file into a string.
std::string buf(length, 0);
if(file->readString(buf))
{
lua_pushlstring(L, buf.data(), buf.size());
return 1;
}
return 0;
}},
{"writeUnsigned8", [](lua_State* L)
{
auto file = script::ptr<File>(L, 1);
auto value = script::get<int>(L, 2);
script::push(L, file->writeUnsigned8(value));
return 1;
}},
{"writeUnsigned16", [](lua_State* L)
{
auto file = script::ptr<File>(L, 1);
auto value = script::get<int>(L, 2);
script::push(L, file->writeUnsigned16(value));
开发者ID:bradparks,项目名称:Plum,代码行数:67,代码来源:file_object.cpp
示例12: outMessage
void ServerNetworkHandler::inMessage(std::string pMessage, int pSocket){
pMessage = Tokenizer::cleanEntry(pMessage);
std::string command = Tokenizer::getCommandSpace(pMessage, 1);
if (_sessionID == -1 && command != "connect" && command != "adduser"){
outMessage("?Error: No se ha inciado sesión\n", pSocket);
} else {
std::string param = Tokenizer::getParameters(pMessage);
std::cout<<param<<std::endl;
if (command == "get"){
get(param, pSocket);
} else if (command == "cd"){
cd(param, pSocket);
} else if (command == "rm"){
rm(param, pSocket);
} else if (command == "touch"){
touch(param, pSocket);
} else if (command == "connect"){
connect(param, pSocket);
} else if (command == "mkdir"){
mkdir(param, pSocket);
} else if (command == "adduser"){
adduser(param, pSocket);
} else if (command == "openfile"){
openfile(param, pSocket);
} else if (command == "appendReg"){
appendReg(param, pSocket);
} else if (command == "delReg"){
if (param == ""){
delActualReg(pSocket);
} else {
delReg(param, pSocket);
}
} else if (command == "write"){
write(param, pSocket);
} else if (command == "seek"){
seek(param, pSocket);
} else if (command == "addReg"){
addReg(param, pSocket);
} else if (command == "read"){
if (param == ""){
readActual(pSocket);
} else {
readRegister(param, pSocket);
}
} else if (command == "close"){
close(pSocket);
} else if (command == "consoleMode"){
consoleMode(param, pSocket);
} else {
outMessage("?Error: No se ha encontrado la instrucción " + command + '\n', pSocket);
}
consoleUI(pSocket);
}
}
开发者ID:jloaiza,项目名称:diglet,代码行数:71,代码来源:servernetworkhandler.cpp
示例13: fprintf
BOOL LASreaderQFIT::open(ByteStreamIn* stream)
{
U32 i;
if (stream == 0)
{
fprintf(stderr,"ERROR: ByteStreamIn* pointer is zero\n");
return FALSE;
}
this->stream = stream;
// read the QFIT header
try { stream->get32bitsLE((U8*)&version); } catch(...)
{
fprintf(stderr,"ERROR: reading QFIT header\n");
return FALSE;
}
// is QFIT file little-endian
if (version == 40 || version == 48 || version == 56)
{
little_endian = TRUE;
endian_swap = (IS_LITTLE_ENDIAN() == FALSE);
}
else
{
ENDIAN_SWAP_32((U8*)&version);
if (version == 40 || version == 48 || version == 56)
{
little_endian = FALSE;
endian_swap = (IS_LITTLE_ENDIAN() == TRUE);
}
else
{
fprintf(stderr,"ERROR: corrupt QFIT header.\n");
return FALSE;
}
}
// read version bytes until point start offset
try { stream->getBytes((U8*)buffer, version); } catch(...)
{
fprintf(stderr,"ERROR: reading %d bytes until point start offset from QFIT header\n", version);
return FALSE;
}
// read point start offset
try { if (little_endian) stream->get32bitsLE((U8*)&offset); else stream->get32bitsBE((U8*)&offset); } catch(...)
{
fprintf(stderr,"ERROR: reading point start offset from QFIT header\n");
return FALSE;
}
// seek to end of file find out number of points
stream->seekEnd();
npoints = (stream->tell() - offset) / version;
// seek back to start of points
stream->seek(offset);
// populate the header as much as possible
sprintf(header.system_identifier, "LAStools (c) by Martin Isenburg");
sprintf(header.generating_software, "via LASreaderQFIT (%d)", LAS_TOOLS_VERSION);
header.number_of_point_records = (U32)npoints;
header.number_of_points_by_return[0] = header.number_of_point_records;
header.extended_number_of_point_records = npoints;
header.extended_number_of_points_by_return[0] = npoints;
header.x_scale_factor = 0.000001;
header.y_scale_factor = 0.000001;
header.z_scale_factor = 0.001;
header.x_offset = 0;
header.y_offset = 0;
header.z_offset = 0;
try {
LASattribute scan_azimuth(LAS_ATTRIBUTE_I32, "scan azimuth", "Scan Azimuth (degrees X 1,000)");
scan_azimuth.set_scale(0.001);
scan_azimuth.set_min(0);
scan_azimuth.set_max(360000);
header.add_extra_attribute(scan_azimuth);
}
catch(...) {
fprintf(stderr,"ERROR: initializing attribute scan_azimuth\n");
return FALSE;
}
try {
LASattribute pitch(LAS_ATTRIBUTE_I32, "pitch", "Pitch (degrees X 1,000)");
//.........这里部分代码省略.........
开发者ID:bsmaldon,项目名称:lag,代码行数:101,代码来源:lasreader_qfit.cpp
示例14: writeat
virtual void writeat(uint64_t pos, const uint8_t* buf, size_t n) {
seek(pos);
write(buf, n);
}
开发者ID:poppingtonic,项目名称:mcm,代码行数:4,代码来源:Stream.hpp
示例15: seek
void GMAudioPlayer::setPosition(FXuint position) {
if (time.length>0) {
seek(FXMIN(1.0,(position/(double)time.length)));
}
}
开发者ID:gogglesmm,项目名称:gogglesmm,代码行数:5,代码来源:GMAudioPlayer.cpp
示例16: error
bool
FFmpegInput::open (const std::string &name, ImageSpec &spec)
{
// Temporary workaround: refuse to open a file whose name does not
// indicate that it's a movie file. This avoids the problem that ffmpeg
// is willing to open tiff and other files better handled by other
// plugins. The better long-term solution is to replace av_register_all
// with our own function that registers only the formats that we want
// this reader to handle. At some point, we will institute that superior
// approach, but in the mean time, this is a quick solution that 90%
// does the job.
bool valid_extension = false;
for (int i = 0; ffmpeg_input_extensions[i]; ++i)
if (Strutil::ends_with (name, ffmpeg_input_extensions[i])) {
valid_extension = true;
break;
}
if (! valid_extension) {
error ("\"%s\" could not open input", name);
return false;
}
static boost::once_flag init_flag = BOOST_ONCE_INIT;
boost::call_once (&av_register_all, init_flag);
const char *file_name = name.c_str();
av_log_set_level (AV_LOG_FATAL);
if (avformat_open_input (&m_format_context, file_name, NULL, NULL) != 0) // avformat_open_input allocs format_context
{
error ("\"%s\" could not open input", file_name);
return false;
}
if (avformat_find_stream_info (m_format_context, NULL) < 0)
{
error ("\"%s\" could not find stream info", file_name);
return false;
}
m_video_stream = -1;
for (unsigned int i=0; i<m_format_context->nb_streams; i++) {
if (m_format_context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (m_video_stream < 0) {
m_video_stream=i;
}
m_video_indexes.push_back (i); // needed for later use
break;
}
}
if (m_video_stream == -1) {
error ("\"%s\" could not find a valid videostream", file_name);
return false;
}
m_codec_context = m_format_context->streams[m_video_stream]->codec; // codec context for videostream
m_codec = avcodec_find_decoder (m_codec_context->codec_id);
if (!m_codec) {
error ("\"%s\" unsupported codec", file_name);
return false;
}
if (avcodec_open2 (m_codec_context, m_codec, NULL) < 0) {
error ("\"%s\" could not open codec", file_name);
return false;
}
if (!strcmp (m_codec_context->codec->name, "mjpeg") ||
!strcmp (m_codec_context->codec->name, "dvvideo")) {
m_offset_time = false;
}
m_codec_cap_delay = m_codec_context->codec->capabilities & CODEC_CAP_DELAY ;
AVStream *stream = m_format_context->streams[m_video_stream];
if (stream->r_frame_rate.num != 0 && stream->r_frame_rate.den != 0) {
m_frame_rate = stream->r_frame_rate;
}
m_frames = stream->nb_frames;
m_start_time = stream->start_time;
if (!m_frames) {
seek (0);
AVPacket pkt;
av_init_packet (&pkt);
av_read_frame (m_format_context, &pkt);
int64_t first_pts = pkt.pts;
int64_t max_pts = 0 ;
av_free_packet (&pkt); //because seek(int) uses m_format_context
seek (1 << 29);
av_init_packet (&pkt); //Is this needed?
while (stream && av_read_frame (m_format_context, &pkt) >= 0) {
int64_t current_pts = static_cast<int64_t> (av_q2d(stream->time_base) * (pkt.pts - first_pts) * fps());
if (current_pts > max_pts) {
max_pts = current_pts +1;
}
av_free_packet (&pkt); //Always free before format_context usage
}
m_frames = max_pts;
}
m_frame = av_frame_alloc();
m_rgb_frame = av_frame_alloc();
m_rgb_buffer.resize(
avpicture_get_size (AV_PIX_FMT_RGB24,
m_codec_context->width,
m_codec_context->height),
0
);
//.........这里部分代码省略.........
开发者ID:exavi,项目名称:oiio,代码行数:101,代码来源:ffmpeginput.cpp
示例17: safe_seek
static void
safe_seek(int fd, off_t pos, int whence) {
int ret = seek(fd, pos, whence);
assert(ret == 0);
}
开发者ID:HackLinux,项目名称:ucorebook_code,代码行数:5,代码来源:sfs_filetest2.c
示例18: seek
DbDataReader::SEEK_RESULT DbSqlCeDataReader::read()
{
return seek( 1 );
}
开发者ID:dictoss,项目名称:utils,代码行数:4,代码来源:DbDataReader.cpp
示例19: QWidget
PlayerWidget::PlayerWidget( int index, Database *database,
ControlWidget *controlWidget, Qt::WindowFlags flags )
: QWidget( controlWidget, flags )
, mPlayer( index )
, mpDatabase( database )
, mpControlWidget( controlWidget )
, mpScrollLine( new ScrollLine( this ) )
, mpStatusDisplay( new QLabel( this ) )
, mpTimeDisplay( new QLabel( this ) )
, mpPlayPosition( new TimeSlider( Qt::Horizontal, this ) )
, mpSocket( new QTcpSocket( this ) )
, mpFSM( new PlayerFSM( this ) )
, mStartOther( false )
, mAutoPlay( false )
, mTotalTime( 0 )
, mFrequency( 44100 )
, mSamples( 0 )
, mHeadStart( 10 )
, mUpdateSlider( true )
, mKioskMode( false )
, mDisplayPattern()
, mTrackInfo()
{
QVBoxLayout *mainLayout = new QVBoxLayout( this );
mainLayout->setContentsMargins( 0, 0, 0, 0 );
mainLayout->setSpacing( 5 );
mainLayout->addWidget( mpScrollLine );
mainLayout->addWidget( mpTimeDisplay );
mainLayout->addWidget( mpStatusDisplay );
mainLayout->addWidget( mpPlayPosition );
setLayout( mainLayout );
mpStatusDisplay->setAlignment( Qt::AlignLeft );
mpStatusDisplay->setFrameShape( QFrame::Box );
mpStatusDisplay->setContextMenuPolicy( Qt::CustomContextMenu );
mpStatusDisplay->setObjectName( QString("StatusLabel") );
mpTimeDisplay->setAlignment( Qt::AlignRight );
mpTimeDisplay->setFrameShape( QFrame::Box );
mpTimeDisplay->setObjectName( QString("TimeLabel") );
mpPlayPosition->setTickPosition( QSlider::TicksBelow );
mpPlayPosition->setTickInterval( 60 );
mpPlayPosition->setMaximum( 1 );
connect( mpSocket, SIGNAL(connected()),
this, SLOT(handleConnect()) );
connect( mpSocket, SIGNAL(disconnected()),
this, SLOT(handleDisconnect()) );
connect( mpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
this, SLOT(handleError(QAbstractSocket::SocketError)) );
connect( mpSocket, SIGNAL(readyRead()),
this, SLOT(handleResponse()) );
connect( mpPlayPosition, SIGNAL(sliderPressed()),
this, SLOT(lock()) );
connect( mpPlayPosition, SIGNAL(sliderReleased()),
this, SLOT(seek()) );
connect( mpPlayPosition, SIGNAL(actionTriggered(int)),
this, SLOT(playPosChange(int)) );
connect( mpStatusDisplay, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(unload()) );
mpFSM->changeState( PlayerFSM::disconnected );
}
开发者ID:SvOlli,项目名称:SLART,代码行数:64,代码来源:PlayerWidget.cpp
示例20: seek
void Seq::rewindStart()
{
seek(0);
}
开发者ID:alekseyrum,项目名称:MuseScore,代码行数:4,代码来源:seq.cpp
注:本文中的seek函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论