void FramelessMainWindow::reconnectMediaPlayer() { VlcMediaPlayer *player = VLC::_player; if ( !player ) return; connect( m_closeButton, SIGNAL( clicked() ), player, SLOT( stop() ) ); connect( player, SIGNAL( opening() ), this, SLOT( playbackStarted() ) ); connect( player, SIGNAL( opening() ), m_control, SLOT( onPlaying() ) ); connect( player, SIGNAL( stopped() ), this, SLOT( playbackStopped() ) ); connect( player, SIGNAL( stopped() ), m_hostApp, SLOT( cancelTorrent() ) ); connect( player, SIGNAL( stopped() ), m_control, SLOT( resetPlayback() ) ); connect( player, SIGNAL( stopped() ), m_control, SLOT( resetPlayback() ) ); }
CarPI::CarPI(QObject * parent): QObject(parent) { qDebug() << "CarPI: Starting"; _sourceCurrent = sourceUnknown; _sourcePaused = false; /* Kontroler płyty głównej urządzenia */ _mainboard = MainBoard::getInstance(); /* Emulator wyświetlacza radia */ _displayEmulator = DisplayEmulator::getInstance(); /* Emulator zmieniarki CD */ _changerEmulator = ChangerEmulator::getInstance(); /* Kontroler modułu bluetooth */ _bluetooth = Bluetooth::getInstance(); /* Odtwarzacz MP3 */ _mp3Player = MP3Player::getInstance(); /* Nawigacja */ _navit = Navit::getInstance(); /* Interfejs OBD II */ _elm327 = Elm327::getInstance(); _atmosphericPressure = 100; /* Zakładamy ciśnienie 1000hPa */ connect(_mainboard, SIGNAL(radioPowerChanged(bool)), _displayEmulator, SLOT(radioPowerChanged(bool))); connect(_mainboard, SIGNAL(keyStateChanged(int)), this, SLOT(_pilotKeyStateChanged(int))); connect(_mainboard, SIGNAL(ignitionChanged(bool)), this, SLOT(_ignitionStateChanged(bool))); connect(_mainboard, SIGNAL(shutdown()), this, SLOT(shutdown())); connect(_displayEmulator, SIGNAL(displayTextChanged(QString)), this, SLOT(_displayTextChanged(QString))); connect(_displayEmulator, SIGNAL(displayIconsChanged(int)), this, SLOT(_displayIconsChanged(int))); connect(_displayEmulator, SIGNAL(displayMenuShow(int)), this, SLOT(_displayMenuShow(int))); connect(_displayEmulator, SIGNAL(displayMenuHide()), this, SLOT(_displayMenuHide())); connect(_displayEmulator, SIGNAL(displayMenuItemUpdate(int,QString,bool)), this, SLOT(_displayMenuSetItem(int,QString,bool))); connect(this, SIGNAL(radioNewKeyEvent(int)), _displayEmulator, SLOT(sendKeyEvent(int))); connect(_bluetooth, SIGNAL(connectionStateChanged(bool)), this, SLOT(_bluetoothConnectionStateChanged(bool))); connect(_bluetooth, SIGNAL(callStateChanged(BluetoothCallState,QString)), this, SLOT(_bluetoothCallStateChanged(BluetoothCallState,QString))); connect(_changerEmulator, SIGNAL(playbackStarted()), _mp3Player, SLOT(play())); connect(_changerEmulator, SIGNAL(playbackPaused()), _mp3Player, SLOT(pause())); connect(_changerEmulator, SIGNAL(playbackStopped()), _mp3Player, SLOT(stop())); connect(_changerEmulator, SIGNAL(nextTrack()), _mp3Player, SLOT(nextTrack())); connect(_changerEmulator, SIGNAL(prevTrack()), _mp3Player, SLOT(prevTrack())); connect(_changerEmulator, SIGNAL(loadCD(int)), this, SLOT(_changerEmulatorLoadCD(int))); connect(_mp3Player, SIGNAL(textChanged(QString)), this, SLOT(_mp3PlayerTextChanged(QString))); connect(this, SIGNAL(mp3PlayerNextAlbum()), _mp3Player, SLOT(nextAlbum())); connect(this, SIGNAL(mp3PlayerPrevAlbum()), _mp3Player, SLOT(prevAlbum())); connect(this, SIGNAL(mp3PlayerSwitchDisplayMode()), _mp3Player, SLOT(switchDisplayMode())); connect(_elm327, SIGNAL(pidValueChanged(int,QVector<int>)), this, SLOT(_elm327PidChanged(int,QVector<int>))); connect(_elm327, SIGNAL(voltageChanged(double)), this, SLOT(_elm327VoltageChanged(double))); connect(this, SIGNAL(elm327addWatchPid(int)), _elm327, SLOT(addWatchPid(int))); connect(this, SIGNAL(elm327start()), _elm327, SLOT(start())); connect(this, SIGNAL(elm327stop()), _elm327, SLOT(stop())); _mainboard->readState(); emit elm327addWatchPid(0x05); /* Temperatura wody */ emit elm327addWatchPid(0x04); /* Obciążenie silnika */ emit elm327addWatchPid(0x0B); /* Ciśnienie absolutne w kolektorze dolotowym */ emit elm327addWatchPid(0x0F); /* Temperatura powietrza w dolocie */ emit elm327addWatchPid(0x23); /* Ciśnienie paliwa */ }
void AudioPlayer::play(const QString &file)/*{{{*/ { SNDFILE *sndfile ; SF_INFO sndfileinfo ; if (file.isEmpty()) { fprintf (stderr, "no soundfile given\n"); //TODO: emit error signals emit playbackStopped(true); return; } // Open the soundfile. sndfileinfo.format = 0 ; sndfile = sf_open (file.toUtf8().constData(), SFM_READ, &sndfileinfo) ; if (sndfile == NULL) { //TODO: emit error signals fprintf (stderr, "Could not open soundfile '%s'\n", file.toUtf8().constData()) ; emit playbackStopped(true); return; } // Init the thread info struct. info.can_process = 0 ; info.read_done = 0 ; info.play_done = 0 ; info.sndfile = sndfile ; info.channels = sndfileinfo.channels ; info.client = m_client ; info.pos = 0 ; if(info.seek && info.seek < sndfileinfo.frames) { //qDebug("Preseting seek point"); sf_seek(sndfile, info.seek, SEEK_CUR); info.seek = 0; } if(!startClient()) return; // Start the disk thread. pthread_create (&info.thread_id, NULL, AudioPlayer::read_file, &info); info.can_read = 1 ; m_isPlaying = true; emit nowPlaying(QString(file).append("@--,--@").append(calcTimeString((int)sndfileinfo.frames)), sndfileinfo.frames); while (!info.play_done) { printTime() ; usleep (50000) ; } printTime(); //memset (ringbuf->buf, 0, ringbuf->size); m_isPlaying = false; info.can_process = 0; stopClient(); sf_close (sndfile) ; info.sndfile = 0; emit playbackStopped(true); }/*}}}*/
bool AudioPlayer::startClient()/*{{{*/ { // create jack client if(!m_client) { int channels = info.channels; jack_status_t status; m_client = jack_client_open("OOMidi_ClipList", JackNoStartServer, &status); if (!m_client) { fprintf (stderr, "Jack server not running?\n") ; emit playbackStopped(true); return false; } m_srate = jack_get_sample_rate (m_client) ; // Set up callbacks. jack_set_process_callback (m_client, AudioPlayer::process, &info) ; jack_on_shutdown (m_client, jack_shutdown, 0); //Default to two channels and we will just fill one if mono file output_port = (jack_port_t**)calloc (channels, sizeof (jack_port_t *)) ; outs = (jack_default_audio_sample_t**)calloc(channels, sizeof (jack_default_audio_sample_t *)) ; for (int i = 0 ; i < channels ; i++) { char name [16] ; snprintf (name, sizeof (name), "out_%d", i + 1) ; output_port [i] = jack_port_register (m_client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0) ; } // Allocate and clear ringbuffer. ringbuf = jack_ringbuffer_create (sizeof (jack_default_audio_sample_t) * RB_SIZE) ; memset (ringbuf->buf, 0, ringbuf->size) ; // Activate client. if (jack_activate (m_client)) { fprintf (stderr, "Cannot activate client.\n") ; emit playbackStopped(true); m_client = 0; return false; } // Auto connect all channels. for (int i = 0 ; i < channels ; i++) { char name [64] ; snprintf (name, sizeof (name), "system:playback_%d", i + 1) ; if(jack_connect (m_client, jack_port_name (output_port [i]), name)) fprintf (stderr, "Cannot connect output port %d (%s).\n", i, name) ; // connect mono files to playback_2 if (channels == 1) { snprintf (name, sizeof (name), "system:playback_%d", i + 2) ; if(jack_connect (m_client, jack_port_name (output_port [i]), name)) fprintf (stderr, "Cannot connect output port %d (%s).\n", i, name) ; } } return true; } else { return true; } }/*}}}*/