| 107 | } |
| 108 | |
| 109 | void |
| 110 | PlaybackWorker::startPlayback() |
| 111 | { |
| 112 | if (this->player == nullptr) { |
| 113 | // Reset buffer list |
| 114 | this->instance->clear(); |
| 115 | |
| 116 | try { |
| 117 | #ifdef SIGDIGGER_HAVE_ALSA |
| 118 | this->player = new AlsaPlayer( |
| 119 | this->device, |
| 120 | this->sampRate, |
| 121 | this->bufferSize); |
| 122 | #elif defined(SIGDIGGER_HAVE_PORTAUDIO) |
| 123 | this->player = new PortAudioPlayer( |
| 124 | this->device, |
| 125 | this->sampRate, |
| 126 | this->bufferSize); |
| 127 | #else |
| 128 | throw std::runtime_error( |
| 129 | "Cannot create audio playback object: audio support disabled at compile time"); |
| 130 | #endif // SIGDIGGER_HAVE_ALSA |
| 131 | |
| 132 | emit ready(); |
| 133 | } catch (std::runtime_error &e) { |
| 134 | this->player = nullptr; |
| 135 | emit error(QString::fromStdString(e.what())); |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | void |
| 141 | PlaybackWorker::stopPlayback() |