| 12 | #endif |
| 13 | |
| 14 | int command_loop(Cicada::MediaPlayer *player, void *arg) |
| 15 | { |
| 16 | #ifdef ENABLE_SDL |
| 17 | SDL_Event event; |
| 18 | |
| 19 | if (SDL_PollEvent(&event)) { |
| 20 | if (event.type == SDL_QUIT) { |
| 21 | return -1; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | #endif |
| 26 | commandsCase *pCase = static_cast<commandsCase *> (arg); |
| 27 | std::unique_lock <std::mutex>lock(pCase->mMutex); |
| 28 | |
| 29 | if (pCase->mCommands.empty()) { |
| 30 | if (pCase->mExitOnEmpty) { |
| 31 | return -1; |
| 32 | } |
| 33 | |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | player_command &cmd = pCase->mCommands.front(); |
| 38 | |
| 39 | if (cmd.timestamp < af_getsteady_ms()) { |
| 40 | switch (cmd.mID) { |
| 41 | case player_command::setLoop: |
| 42 | player->SetLoop(cmd.arg0); |
| 43 | break; |
| 44 | |
| 45 | case player_command::seek: |
| 46 | player->SeekTo(player->GetCurrentPosition() + cmd.arg0, SEEK_MODE_ACCURATE); |
| 47 | break; |
| 48 | |
| 49 | case player_command::setSpeed: |
| 50 | player->SetSpeed((float) cmd.arg0 / 10); |
| 51 | break; |
| 52 | |
| 53 | case player_command::setVolume: |
| 54 | player->SetVolume((float) cmd.arg0 / 10); |
| 55 | break; |
| 56 | |
| 57 | case player_command::selectStream: |
| 58 | player->SelectTrack(cmd.arg0); |
| 59 | break; |
| 60 | |
| 61 | case player_command::start: |
| 62 | player->Start(); |
| 63 | break; |
| 64 | |
| 65 | case player_command::backGround: |
| 66 | player->EnterBackGround(cmd.arg0 != 0); |
| 67 | break; |
| 68 | |
| 69 | default: |
| 70 | break; |
| 71 | } |
nothing calls this directly
no test coverage detected