<commit_before>#include "audio/playback.h"

namespace loftili {

namespace audio {

void Playback::Start() {
  if(m_state == PLAYBACK_STATE_PLAYING) return;
  spdlog::get(LOFTILI_SPDLOG_ID)->info("playback starting, opening playback thread");
  m_state = PLAYBACK_STATE_PLAYING;
  m_stateclient.Update("playback", 1);
  m_thread = std::unique_ptr<std::thread>(new std::thread(std::bind(&Playback::Run, this)));
}

void Playback::Skip() {
  Stop();
  m_queue.Pop();
  Start();
}

void Playback::Stop() {
  spdlog::get(LOFTILI_SPDLOG_ID)->info("stopping player and playback run thread");
  m_state = PLAYBACK_STATE_STOPPED;
  m_player.Stop();
  m_thread->join();
}

void Playback::Run() {
  m_state = PLAYBACK_STATE_PLAYING;

  while(m_queue >> m_player && m_state == PLAYBACK_STATE_PLAYING) { 
    spdlog::get(LOFTILI_SPDLOG_ID)->info("player finished, getting next track from queue");
  }

  spdlog::get(LOFTILI_SPDLOG_ID)->info("playback run thread finishing");
  m_state = PLAYBACK_STATE_STOPPED;
  m_stateclient.Update("playback", 0);
}

}

}<commit_msg>[LFTCE-36] checking that device state playing before attempting to stop in playback skip<commit_after>#include "audio/playback.h"

namespace loftili {

namespace audio {

void Playback::Start() {
  if(m_state == PLAYBACK_STATE_PLAYING) return;
  spdlog::get(LOFTILI_SPDLOG_ID)->info("playback starting, opening playback thread");
  m_state = PLAYBACK_STATE_PLAYING;
  m_stateclient.Update("playback", 1);
  m_thread = std::unique_ptr<std::thread>(new std::thread(std::bind(&Playback::Run, this)));
}

void Playback::Skip() {
  if(m_state == PLAYBACK_STATE_PLAYING) Stop();
  m_queue.Pop();
  Start();
}

void Playback::Stop() {
  spdlog::get(LOFTILI_SPDLOG_ID)->info("stopping player and playback run thread");
  m_state = PLAYBACK_STATE_STOPPED;
  m_player.Stop();
  m_thread->join();
}

void Playback::Run() {
  m_state = PLAYBACK_STATE_PLAYING;

  while(m_queue >> m_player && m_state == PLAYBACK_STATE_PLAYING) { 
    spdlog::get(LOFTILI_SPDLOG_ID)->info("player finished, getting next track from queue");
  }

  spdlog::get(LOFTILI_SPDLOG_ID)->info("playback run thread finishing");
  m_state = PLAYBACK_STATE_STOPPED;
  m_stateclient.Update("playback", 0);
}

}

}
{'fraction_non_alphanumeric': 0.14683430624158061, 'fraction_numerical': 0.002694207453973956, 'mean_word_length': 6.118210862619808, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2845870', 'n_tokens_mistral': 844, 'n_tokens_neox': 808, 'n_words': 142}