bool MythRecorder::SetChannel(MythChannel &channel) { m_recorder_t->Lock(); if(!IsRecording()) { XBMC->Log(LOG_ERROR,"%s: Recorder %i is not recording",__FUNCTION__,ID(),channel.Name().c_str()); m_recorder_t->Unlock(); return false; } CStdString channelNum; channelNum.Format("%i",channel.Number()); if(CMYTH->RecorderPause(*m_recorder_t)!=0) { XBMC->Log(LOG_ERROR,"%s: Failed to pause recorder %i",__FUNCTION__,ID()); m_recorder_t->Unlock(); return false; } if(!CheckChannel(channel)) { XBMC->Log(LOG_ERROR,"%s: Recorder %i doesn't provide channel %s",__FUNCTION__,ID(),channel.Name().c_str()); m_recorder_t->Unlock(); return false; } if(CMYTH->RecorderSetChannel(*m_recorder_t,channelNum.GetBuffer())!=0) { XBMC->Log(LOG_ERROR,"%s: Failed to change recorder %i to channel %s",__FUNCTION__,ID(),channel.Name().c_str()); m_recorder_t->Unlock(); return false; } if(CMYTH->LivetvChainSwitchLast(*m_recorder_t)!=1) { XBMC->Log(LOG_ERROR,"%s: Failed to switch chain for recorder %i",__FUNCTION__,ID(),channel.Name().c_str()); m_recorder_t->Unlock(); return false; } *livechainupdated=0; int i=20; while(*livechainupdated==0&&i--!=0) { m_recorder_t->Unlock(); cSleep(100); m_recorder_t->Lock(); } m_recorder_t->Unlock(); for(int i=0;i<20;i++) { if(!IsRecording()) cSleep(1); else break; } return true; }
bool MythRecorder::SetChannel(MythChannel &channel) { // m_recorder_t->Lock(); m_conn.Lock(); if (!IsRecording()) { XBMC->Log(LOG_ERROR, "%s: Recorder %i is not recording", __FUNCTION__, ID(), const_cast<char*>(channel.Name().c_str())); // m_recorder_t->Unlock(); m_conn.Unlock(); return false; } CStdString channelNum = channel.Number(); if (cmyth_recorder_pause(*m_recorder_t) != 0) { XBMC->Log(LOG_ERROR, "%s: Failed to pause recorder %i", __FUNCTION__, ID()); // m_recorder_t->Unlock(); m_conn.Unlock(); return false; } if (!CheckChannel(channel)) { XBMC->Log(LOG_ERROR, "%s: Recorder %i doesn't provide channel %s", __FUNCTION__, ID(), channel.Name().c_str()); // m_recorder_t->Unlock(); m_conn.Unlock(); return false; } if (cmyth_recorder_set_channel(*m_recorder_t,channelNum.GetBuffer())!=0) { XBMC->Log(LOG_ERROR, "%s: Failed to change recorder %i to channel %s", __FUNCTION__, ID(), channel.Name().c_str()); // m_recorder_t->Unlock(); m_conn.Unlock(); return false; } if (cmyth_livetv_chain_switch_last(*m_recorder_t) != 1) { XBMC->Log(LOG_ERROR,"%s: Failed to switch chain for recorder %i", __FUNCTION__, ID(), channel.Name().c_str()); // m_recorder_t->Unlock(); m_conn.Unlock(); return false; } *m_liveChainUpdated = 0; int i = 20; while (*m_liveChainUpdated == 0 && i-- != 0) { //m_recorder_t->Unlock(); m_conn.Unlock(); usleep(100000); //m_recorder_t->Lock(); m_conn.Lock(); } //m_recorder_t->Unlock(); m_conn.Unlock(); for (int i = 0; i < 20; i++) { if (!IsRecording()) usleep(1000); else break; } return true; }