2 #define WIN32_LEAN_AND_MEAN
8 inline void Sleep(uint32_t ms
)
10 struct timespec ts
, rem
;
11 ts
.tv_sec
= ms
/ 1000;
12 ts
.tv_nsec
= (ms
% 1000) * 1000000;
13 while(nanosleep(&ts
, &rem
) == -1 && errno
== EINTR
)
23 int main(int argc
, char *argv
[])
25 alure::DeviceManager
*devMgr
= alure::DeviceManager::get();
27 alure::Device
*dev
= devMgr
->openPlayback();
28 std::cout
<< "Opened \""<<dev
->getName(alure::PlaybackDevType_Basic
)<<"\"" <<std::endl
;
30 alure::Context
*ctx
= dev
->createContext();
31 alure::Context::MakeCurrent(ctx
);
33 for(int i
= 1;i
< argc
;i
++)
35 alure::Decoder
*decoder
= ctx
->createDecoder(argv
[i
]);
36 alure::Source
*source
= ctx
->getSource();
37 source
->play(decoder
, 32768, 4);
38 std::cout
<< "Playing "<<argv
[i
]<<" ("<<alure::GetSampleTypeName(decoder
->getSampleType())<<", "
39 <<alure::GetSampleConfigName(decoder
->getSampleConfig())<<", "
40 <<decoder
->getFrequency()<<"hz)" <<std::endl
;
42 float invfreq
= 1.0f
/ decoder
->getFrequency();
43 while(source
->isPlaying())
45 std::cout
<< "\r "<<std::setiosflags(std::ios::fixed
)<<std::setprecision(2)<<
46 (source
->getOffset()*invfreq
)<<" / "<<(decoder
->getLength()*invfreq
);
53 ctx
->finalize(source
);
59 alure::Context::MakeCurrent(0);