304 |
|
|
305 |
|
/*------------------------------------------------------------------------------
|
306 |
|
* Test if we can switch back and forth between devices.
|
307 |
|
*----------------------------------------------------------------------------*/
|
308 |
|
void
|
309 |
|
AudioPlayerTest :: switchDevicesTest(void)
|
310 |
|
throw (CPPUNIT_NS::Exception)
|
311 |
|
{
|
312 |
|
Ptr<AudioPlayerFactory>::Ref audioPlayerFactory;
|
313 |
|
audioPlayerFactory = AudioPlayerFactory::getInstance();
|
314 |
|
CPPUNIT_ASSERT(audioPlayerFactory.get());
|
315 |
|
|
316 |
|
Ptr<AudioPlayerInterface>::Ref audioPlayer;
|
317 |
|
audioPlayer = audioPlayerFactory->getAudioPlayer();
|
318 |
|
CPPUNIT_ASSERT(audioPlayer.get());
|
319 |
|
|
320 |
|
audioPlayer->setAudioDevice("/dev/dsp");
|
321 |
|
CPPUNIT_ASSERT_NO_THROW(
|
322 |
|
audioPlayer->open("file:var/testAudio.ogg")
|
323 |
|
);
|
324 |
|
audioPlayer->start();
|
325 |
|
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
326 |
|
while (audioPlayer->isPlaying()) {
|
327 |
|
TimeConversion::sleep(sleepT);
|
328 |
|
}
|
329 |
|
audioPlayer->close();
|
330 |
|
|
331 |
|
audioPlayer->setAudioDevice("plughw:0,0");
|
332 |
|
CPPUNIT_ASSERT_NO_THROW(
|
333 |
|
audioPlayer->open("file:var/testAudio.ogg")
|
334 |
|
);
|
335 |
|
audioPlayer->start();
|
336 |
|
while (audioPlayer->isPlaying()) {
|
337 |
|
TimeConversion::sleep(sleepT);
|
338 |
|
}
|
339 |
|
audioPlayer->close();
|
340 |
|
}
|
341 |
|
|