/*! \qmlmethod QtAudioEngine1::Sound::play() Creates a new \l SoundInstance and starts playing. Position, direction and velocity are all set to \c "0,0,0". */ void QDeclarativeSound::play() { play(QVector3D(), QVector3D(), QVector3D(), 1, 1); }
int main(int argc, char** argv){ int i, j, random, boolean, players, temp, money, act_x, vil_x, action, buy; if(argc != 2) { printf("Usage: ./testdominion [random seed]"); return 0; } else { random = atoi(argv[1]); } srand(random); struct gameState g; struct gameState* p = &g; int k[10]; for(i = 0; i < 10; i++) { temp = (rand() % 20) + 7; boolean = 1; for(j = 0; j < i; j++) if(k[j] == temp) boolean = 0; if(boolean) //If the number does not already exist k[i] = temp; else //If the number already exists in the array i--; } int not_bought[10]; int not_played[10]; for(i = 0; i < 10; i++) { not_bought[i] = k[i]; not_played[i] = k[i]; } players = (rand() % 3) + 2; int r = initializeGame(players, k, random, p); while(!isGameOver(p)) //Loop that continues for game { for(i = 0; i < players; i++) { //Loop the loops through each player action = 1; buy = 1; money = 0; while(action) //Loop that continues for each players actions { vil_x = -1; act_x = -1; for(j = 0; j < numHandCards(p); j++) //Loop runs through hand { if(handCard(j, p) == village) { vil_x = j; break; } else if(!played(not_played, p, handCard(j, p))) act_x = j; } if(vil_x > -1) { playCard(j, -1, -1, -1, p); printf("Player %d played a village\n", j); } else if(act_x > -1) { play(act_x, p); action = 0; } else action = 0; } buy_card(p, not_bought, k); endTurn(p); } } print_state(p, players); printf("\n"); return 0; }
void _ext_speak(const char* text) { if (is_playing == 0) play(text); }
Stream::Stream(const Stream &obj) { loadOgg(obj.sound.c_str()); if (obj.playing()) play(); }
/////////////////////////////////////////////////////////////////////////////// // virtual bool LLMediaImplGStreamer:: updateMedia () { DEBUGMSG("updating media..."); // sanity check if (NULL == mPump #ifdef LL_GST_SOUNDSINK || NULL == mAudioSink #endif || NULL == mPlaybin) { DEBUGMSG("dead media..."); return false; } // process next outstanding command switch (nextCommand()) { case LLMediaBase::COMMAND_START: DEBUGMSG("COMMAND_START"); if (getStatus() == LLMediaBase::STATUS_PAUSED || getStatus() == LLMediaBase::STATUS_NAVIGATING || getStatus() == LLMediaBase::STATUS_STOPPED) { DEBUGMSG("doing COMMAND_START"); play(); setStatus(LLMediaBase::STATUS_STARTED); clearCommand(); } break; case LLMediaBase::COMMAND_STOP: DEBUGMSG("COMMAND_STOP"); DEBUGMSG("doing COMMAND_STOP"); stop(); setStatus(LLMediaBase::STATUS_STOPPED); clearCommand(); break; case LLMediaBase::COMMAND_PAUSE: DEBUGMSG("COMMAND_PAUSE"); if (getStatus() == LLMediaBase::STATUS_STARTED) { DEBUGMSG("doing COMMAND_PAUSE"); pause(); setStatus(LLMediaBase::STATUS_PAUSED); clearCommand(); } break; default: DEBUGMSG("COMMAND_?"); clearCommand(); break; case LLMediaBase::COMMAND_NONE: break; } // deal with results if (g_main_context_pending(g_main_loop_get_context(mPump))) { g_main_context_iteration(g_main_loop_get_context(mPump), FALSE); } if (mVideoSink) { GST_OBJECT_LOCK(mVideoSink); if (mVideoSink->retained_frame_ready) { DEBUGMSG("NEW FRAME "); if (mVideoSink->retained_frame_width != getMediaWidth() || mVideoSink->retained_frame_height != getMediaHeight()) // *TODO: also check for change in format { // just resize containe int neww = mVideoSink->retained_frame_width; int newh = mVideoSink->retained_frame_height; int newd = SLVPixelFormatBytes[mVideoSink->retained_frame_format]; if (SLV_PF_RGBX == mVideoSink->retained_frame_format) { mTextureFormatPrimary = LL_MEDIA_RGBA; mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV; } else { mTextureFormatPrimary = LL_MEDIA_BGRA; mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV; } mMediaRowbytes = neww * newd; DEBUGMSG("video container resized to %dx%d", neww, newh); delete[] mediaData; mediaData = new unsigned char[mMediaRowbytes * newh]; GST_OBJECT_UNLOCK(mVideoSink); setMediaDepth(newd); setMediaSize(neww, newh); return true; } // we're gonna totally consume this frame - reset 'ready' flag mVideoSink->retained_frame_ready = FALSE; memcpy(mediaData, mVideoSink->retained_frame_data, mMediaRowbytes * getMediaHeight()); GST_OBJECT_UNLOCK(mVideoSink); LLMediaEvent event( this ); mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event ); return true; } else { // nothing to do yet. GST_OBJECT_UNLOCK(mVideoSink); return true; } } return true; }
void onOggFileCreation(OggFile* newFile, void* clientData) { oggFile = newFile; // Create a new demultiplexor for the file: oggDemux = oggFile->newDemux(); // Create source streams, "RTPSink"s, and "RTCPInstance"s for each preferred track; unsigned short rtpPortNum = 22222; const unsigned char ttl = 255; const unsigned maxCNAMElen = 100; unsigned char CNAME[maxCNAMElen+1]; gethostname((char*)CNAME, maxCNAMElen); CNAME[maxCNAMElen] = '\0'; // just in case numTracks = oggFile->numTracks(); trackState = new TrackState[numTracks]; for (unsigned i = 0; i < numTracks; ++i) { u_int32_t trackNumber; FramedSource* baseSource = oggDemux->newDemuxedTrack(trackNumber); trackState[i].trackNumber = trackNumber; unsigned estBitrate, numFiltersInFrontOfTrack; trackState[i].source = oggFile ->createSourceForStreaming(baseSource, trackNumber, estBitrate, numFiltersInFrontOfTrack); trackState[i].sink = NULL; // by default; may get changed below trackState[i].rtcp = NULL; // ditto if (trackState[i].source != NULL) { Groupsock* rtpGroupsock = new Groupsock(*env, destinationAddress, rtpPortNum, ttl); Groupsock* rtcpGroupsock = new Groupsock(*env, destinationAddress, rtpPortNum+1, ttl); rtpPortNum += 2; trackState[i].sink = oggFile->createRTPSinkForTrackNumber(trackNumber, rtpGroupsock, 96+i); if (trackState[i].sink != NULL) { if (trackState[i].sink->estimatedBitrate() > 0) { estBitrate = trackState[i].sink->estimatedBitrate(); // hack } trackState[i].rtcp = RTCPInstance::createNew(*env, rtcpGroupsock, estBitrate, CNAME, trackState[i].sink, NULL /* we're a server */, True /* we're a SSM source */); // Note: This starts RTCP running automatically // Having set up a track for streaming, add it to our RTSP server's "ServerMediaSession": sms->addSubsession(PassiveServerMediaSubsession::createNew(*trackState[i].sink, trackState[i].rtcp)); } } } if (sms->numSubsessions() == 0) { *env << "Error: The Ogg file \"" << inputFileName << "\" has no streamable tracks\n"; *env << "(Perhaps the file does not exist, is not an 'Ogg' file, or has no tracks that we know how to stream.)\n"; exit(1); } rtspServer->addServerMediaSession(sms); char* url = rtspServer->rtspURL(sms); *env << "Play this stream using the URL \"" << url << "\"\n"; delete[] url; // Start the streaming: play(); }
void MediaPluginGStreamer010::receiveMessage(const char *message_string) { //std::cerr << "MediaPluginGStreamer010::receiveMessage: received message: \"" << message_string << "\"" << std::endl; LLPluginMessage message_in; if(message_in.parse(message_string) >= 0) { std::string message_class = message_in.getClass(); std::string message_name = message_in.getName(); if(message_class == LLPLUGIN_MESSAGE_CLASS_BASE) { if(message_name == "init") { LLPluginMessage message("base", "init_response"); LLSD versions = LLSD::emptyMap(); versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION; versions[LLPLUGIN_MESSAGE_CLASS_MEDIA] = LLPLUGIN_MESSAGE_CLASS_MEDIA_VERSION; versions[LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME] = LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME_VERSION; message.setValueLLSD("versions", versions); if ( load() ) { DEBUGMSG("GStreamer010 media instance set up"); } else { WARNMSG("GStreamer010 media instance failed to set up"); } message.setValue("plugin_version", getVersion()); sendMessage(message); } else if(message_name == "idle") { // no response is necessary here. double time = message_in.getValueReal("time"); // Convert time to milliseconds for update() update((int)(time * 1000.0f)); if(GST_STATE(mPlaybin) == GST_STATE_PLAYING) { // update the current playback time if(update_counter == 10) { updateTime(); update_counter = 0; } update_counter++; } } else if(message_name == "cleanup") { unload(); closedown(); } else if(message_name == "shm_added") { SharedSegmentInfo info; info.mAddress = message_in.getValuePointer("address"); info.mSize = (size_t)message_in.getValueS32("size"); std::string name = message_in.getValue("name"); std::ostringstream str; INFOMSG("MediaPluginGStreamer010::receiveMessage: shared memory added, name: %s, size: %d, address: %p", name.c_str(), int(info.mSize), info.mAddress); mSharedSegments.insert(SharedSegmentMap::value_type(name, info)); } else if(message_name == "shm_remove") { std::string name = message_in.getValue("name"); DEBUGMSG("MediaPluginGStreamer010::receiveMessage: shared memory remove, name = %s", name.c_str()); SharedSegmentMap::iterator iter = mSharedSegments.find(name); if(iter != mSharedSegments.end()) { if(mPixels == iter->second.mAddress) { // This is the currently active pixel buffer. Make sure we stop drawing to it. mPixels = NULL; mTextureSegmentName.clear(); // Make sure the movie decoder is no longer pointed at the shared segment. sizeChanged(); } mSharedSegments.erase(iter); } else { WARNMSG("MediaPluginGStreamer010::receiveMessage: unknown shared memory region!"); } // Send the response so it can be cleaned up. LLPluginMessage message("base", "shm_remove_response"); message.setValue("name", name); sendMessage(message); } else { std::ostringstream str; INFOMSG("MediaPluginGStreamer010::receiveMessage: unknown base message: %s", message_name.c_str()); } } else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA) { if(message_name == "init") { // Plugin gets to decide the texture parameters to use. LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params"); // lame to have to decide this now, it depends on the movie. Oh well. mDepth = 4; mCurrentWidth = 1; mCurrentHeight = 1; mPreviousWidth = 1; mPreviousHeight = 1; mNaturalWidth = 1; mNaturalHeight = 1; mWidth = 1; mHeight = 1; mTextureWidth = 1; mTextureHeight = 1; message.setValueU32("format", GL_RGBA); message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8_REV); message.setValueS32("depth", mDepth); message.setValueS32("default_width", mWidth); message.setValueS32("default_height", mHeight); message.setValueU32("internalformat", GL_RGBA8); message.setValueBoolean("coords_opengl", true); // true == use OpenGL-style coordinates, false == (0,0) is upper left. message.setValueBoolean("allow_downsample", true); // we respond with grace and performance if asked to downscale sendMessage(message); } else if(message_name == "size_change") { std::string name = message_in.getValue("name"); S32 width = message_in.getValueS32("width"); S32 height = message_in.getValueS32("height"); S32 texture_width = message_in.getValueS32("texture_width"); S32 texture_height = message_in.getValueS32("texture_height"); std::ostringstream str; INFOMSG("---->Got size change instruction from application with shm name: %s - size is %d x %d", name.c_str(), width, height); LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_response"); message.setValue("name", name); message.setValueS32("width", width); message.setValueS32("height", height); message.setValueS32("texture_width", texture_width); message.setValueS32("texture_height", texture_height); sendMessage(message); if(!name.empty()) { // Find the shared memory region with this name SharedSegmentMap::iterator iter = mSharedSegments.find(name); if(iter != mSharedSegments.end()) { INFOMSG("*** Got size change with matching shm, new size is %d x %d", width, height); INFOMSG("*** Got size change with matching shm, texture size size is %d x %d", texture_width, texture_height); mPixels = (unsigned char*)iter->second.mAddress; mTextureSegmentName = name; mWidth = width; mHeight = height; if (texture_width > 1 || texture_height > 1) // not a dummy size from the app, a real explicit forced size { INFOMSG("**** = REAL RESIZE REQUEST FROM APP"); GST_OBJECT_LOCK(mVideoSink); mVideoSink->resize_forced_always = true; mVideoSink->resize_try_width = texture_width; mVideoSink->resize_try_height = texture_height; GST_OBJECT_UNLOCK(mVideoSink); } mTextureWidth = texture_width; mTextureHeight = texture_height; } } } else if(message_name == "load_uri") { std::string uri = message_in.getValue("uri"); navigateTo( uri ); sendStatus(); } else if(message_name == "mouse_event") { std::string event = message_in.getValue("event"); S32 x = message_in.getValueS32("x"); S32 y = message_in.getValueS32("y"); if(event == "down") { mouseDown(x, y); } else if(event == "up") { mouseUp(x, y); } else if(event == "move") { mouseMove(x, y); }; }; } else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME) { if(message_name == "stop") { stop(); } else if(message_name == "start") { double rate = 0.0; if(message_in.hasValue("rate")) { rate = message_in.getValueReal("rate"); } // NOTE: we don't actually support rate. play(rate); } else if(message_name == "pause") { pause(); } else if(message_name == "seek") { double time = message_in.getValueReal("time"); // defer the actual seek in case we haven't // really truly started yet in which case there // is nothing to seek upon mSeekWanted = true; mSeekDestination = time; } else if(message_name == "set_loop") { bool loop = message_in.getValueBoolean("loop"); mIsLooping = loop; } else if(message_name == "set_volume") { double volume = message_in.getValueReal("volume"); setVolume(volume); } } else { INFOMSG("MediaPluginGStreamer010::receiveMessage: unknown message class: %s", message_class.c_str()); } } }
/*! \qmlmethod QtAudioEngine1::Sound::play(position, velocity, direction, gain) Creates a new SoundInstance and starts playing with specified \a position, \a velocity, \a direction and adjusted \a gain. */ void QDeclarativeSound::play(const QVector3D& position, const QVector3D& velocity, const QVector3D& direction, qreal gain) { play(position, velocity, direction, gain, 1); }
/*! \qmlmethod QtAudioEngine1::Sound::play(position, velocity, gain, pitch) Creates a new SoundInstance and starts playing with specified \a position, \a velocity, adjusted \a gain and \a pitch. Direction is set to \c "0,0,0". */ void QDeclarativeSound::play(const QVector3D& position, const QVector3D& velocity, qreal gain, qreal pitch) { play(position, velocity, QVector3D(), gain, pitch); }
/*! \qmlmethod QtAudioEngine1::Sound::play(position, velocity) Creates a new SoundInstance and starts playing with specified \a position and \a velocity. Direction is set to \c "0,0,0". */ void QDeclarativeSound::play(const QVector3D& position, const QVector3D& velocity) { play(position, velocity, QVector3D(), 1, 1); }
/*! \qmlmethod QtAudioEngine1::Sound::play(position, gain) Creates a new SoundInstance and starts playing with specified \a position and adjusted \a gain. Direction and velocity are all set to \c "0,0,0". */ void QDeclarativeSound::play(const QVector3D& position, qreal gain) { play(position, QVector3D(), QVector3D(), gain, 1); }
/*! \qmlmethod QtAudioEngine1::Sound::play(position) Creates a new SoundInstance and starts playing with specified \a position. Direction and velocity are all set to \c "0,0,0". */ void QDeclarativeSound::play(const QVector3D& position) { play(position, QVector3D(), QVector3D(), 1, 1); }
/*! \qmlmethod QtAudioEngine1::Sound::play(gain, pitch) Creates a new SoundInstance and starts playing with the adjusted \a gain and \a pitch. Position, direction and velocity are all set to \c "0,0,0". */ void QDeclarativeSound::play(qreal gain, qreal pitch) { play(QVector3D(), QVector3D(), QVector3D(), gain, pitch); }
/*! \qmlmethod QtAudioEngine1::Sound::play(gain) Creates a new SoundInstance and starts playing with the adjusted \a gain. Position, direction and velocity are all set to \c "0,0,0". */ void QDeclarativeSound::play(qreal gain) { play(QVector3D(), QVector3D(), QVector3D(), gain, 1); }
void QSofaScene::playpause() { play( !_timer->isActive() ); }
bool AVPlayer::play(const QString& path) { setFile(path); play(); return true;//isPlaying(); }
void PCSpeaker::parseAndPlay(QString linia) { volume = config_file.readNumEntry("PC Speaker", "SpeakerVolume"); int sound[21], soundLength[20]; ParseStringToSound(linia, sound, soundLength); play(sound, soundLength); }
bool Window::forward() { if (movenr >= nmoves) return false; return play(moves[movenr]); }
const void GSquare::createMenu() { this->setMinimumSize(800, 600); this->setMaximumSize(800, 600); // Creer la scene scene = new QGraphicsScene(this); // Creer le fond QPixmap pix = QPixmap("fond.png", "PNG"); fond = new QGraphicsPixmapItem(pix, NULL, scene); // qreal scale = (qreal)((800.0 - pix.size().height()) / /*(pix.size().width())*/ 1000); qreal scale = 0.62; fond->setScale(scale); // Creer la vue this->vw_square = new QGraphicsView(scene); this->vw_square->setBaseSize(900, 700); this->vw_square->setMaximumSize(900, 700); this->vw_square->setMinimumSize(900, 700); QTransform matrice; // matrice.rotateRadians(-40, Qt::XAxis); // matrice.translate(100, 100, ); // matrice.scale(1.2, 1.2); this->vw_square->setTransform(matrice, true); this->vw_square->show(); //Boutton menu menu_btn = new QPushButton(NULL); menu_btn->setIcon(QIcon("ButtonPlay.png")); menu_btn->setFlat(true); menu_btn->setAutoFillBackground(false); // menu_btn->setTaken(false); menu_btn->setGeometry(QRect(800 / 2 - 100, 600 / 2 - 50, 200, 100)); menu_btn->setIconSize(QSize(200, 100)); proxy_btn = new QGraphicsProxyWidget(fond); proxy_btn->setWidget(menu_btn); proxy_btn->setPalette(QPalette(QColor(0, 0, 0, 0))); QObject::connect(menu_btn, SIGNAL(released()), this, SLOT(play())); QObject::connect(menu_btn, SIGNAL(pressed()), this, SLOT(changeIcon())); // bouton option du debut menu_opt = new QPushButton(NULL); menu_opt->setIcon(QIcon("ButtonOptions.png")); menu_opt->setFlat(true); menu_opt->setAutoFillBackground(false); // menu_btn->setTaken(false); menu_opt->setGeometry(QRect(800 / 2 - 100, 600 / 2 + 100, 200, 100)); menu_opt->setIconSize(QSize(200, 100)); proxy_opt = new QGraphicsProxyWidget(fond); proxy_opt->setWidget(menu_opt); proxy_opt->setPalette(QPalette(QColor(0, 0, 0, 0))); QObject::connect(menu_opt, SIGNAL(released()), this, SLOT(option())); QObject::connect(menu_opt, SIGNAL(pressed()), this, SLOT(changeIconOption())); //creation du bouton quit menu_quit = new QPushButton; menu_quit->setIcon(QIcon("ButtonQuit.png")); menu_quit->setFlat(true); menu_quit->setGeometry(QRect(800 / 2 - 100, 600 / 2 + 200, 200, 100)); menu_quit->setIconSize(QSize(200, 100)); proxy_menuQuit = new QGraphicsProxyWidget(fond); proxy_menuQuit->setWidget(menu_quit); proxy_menuQuit->setPalette(QPalette(QColor(0,0,0,0))); QObject::connect(menu_quit, SIGNAL(pressed()), this, SLOT(changeIconQuit())); QObject::connect(menu_quit,SIGNAL(clicked()), qApp, SLOT(quit())); }
// on "init" you need to initialize your instance bool MainState::init() { //衝突判定の追加 auto col = CollisionListener::create(); layer->addChild(col); //背景の追加 BackGround bg; bg.Initialize(layer); //ステージを作成 Stage::StageCreater sc; DeterminedStage::set(); m_Manager = sc.create(layer, DeterminedStage::determinedStageFailePath); auto node = Node::create(); auto func = CallFunc::create([&]() { auto bgm = RappingAudio::getInstance()->getBGM(BGMTag::PLAY); bgm->play(); }); auto delay = DelayTime::create(1.5f); auto seq = Sequence::create(delay, func, nullptr); node->runAction(seq); layer->addChild(node); //暗闇&ライト LightManager::getInstance()->init(); m_Blend = new AlphaBlendFunc(); m_Blend->setBlendFunc(GL_ZERO, GL_SRC_COLOR); layer->addChild(DarknessMask::create(Color4B(0, 0, 0, 240), Size(6400, 5376)), 50); LightManager::getInstance()->createLight(layer); //プレイヤーの追加 m_Player = Player::create(); auto playerSprite = m_Player->createPlayer(); m_Player->addChild(playerSprite); layer->addChild(m_Player, 60); //カメラをプレイヤーに追従させる(画像が移動するので画像に合わせる) layer->runAction(Follow::create(playerSprite, Rect(0, 0, 6400, 5376))); if (DeterminedStage::stageNum == 0){ m_Tutorial = new Scenes::Tutorial(); layer->addChild(m_Tutorial->createWindow(), 100); } return true; }
gboolean MediaPluginGStreamer010::processGSTEvents(GstBus *bus, GstMessage *message) { if (!message) return TRUE; // shield against GStreamer bug if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_STATE_CHANGED && GST_MESSAGE_TYPE(message) != GST_MESSAGE_BUFFERING) { DEBUGMSG("Got GST message type: %s", LLGST_MESSAGE_TYPE_NAME (message)); } else { // TODO: grok 'duration' message type DEBUGMSG("Got GST message type: %s", LLGST_MESSAGE_TYPE_NAME (message)); } switch (GST_MESSAGE_TYPE (message)) { case GST_MESSAGE_BUFFERING: { // NEEDS GST 0.10.11+ if (llgst_message_parse_buffering) { gint percent = 0; llgst_message_parse_buffering(message, &percent); DEBUGMSG("GST buffering: %d%%", percent); } break; } case GST_MESSAGE_STATE_CHANGED: { GstState old_state; GstState new_state; GstState pending_state; llgst_message_parse_state_changed(message, &old_state, &new_state, &pending_state); #ifdef LL_GST_REPORT_STATE_CHANGES // not generally very useful, and rather spammy. DEBUGMSG("state change (old,<new>,pending): %s,<%s>,%s", get_gst_state_name(old_state), get_gst_state_name(new_state), get_gst_state_name(pending_state)); #endif // LL_GST_REPORT_STATE_CHANGES switch (new_state) { case GST_STATE_VOID_PENDING: break; case GST_STATE_NULL: break; case GST_STATE_READY: setStatus(STATUS_LOADED); break; case GST_STATE_PAUSED: setStatus(STATUS_PAUSED); break; case GST_STATE_PLAYING: setStatus(STATUS_PLAYING); break; } break; } case GST_MESSAGE_ERROR: { GError *err = NULL; gchar *debug = NULL; llgst_message_parse_error (message, &err, &debug); WARNMSG("GST error: %s", err?err->message:"(unknown)"); if (err) g_error_free (err); g_free (debug); mCommand = COMMAND_STOP; setStatus(STATUS_ERROR); break; } case GST_MESSAGE_INFO: { if (llgst_message_parse_info) { GError *err = NULL; gchar *debug = NULL; llgst_message_parse_info (message, &err, &debug); INFOMSG("GST info: %s", err?err->message:"(unknown)"); if (err) g_error_free (err); g_free (debug); } break; } case GST_MESSAGE_WARNING: { GError *err = NULL; gchar *debug = NULL; llgst_message_parse_warning (message, &err, &debug); WARNMSG("GST warning: %s", err?err->message:"(unknown)"); if (err) g_error_free (err); g_free (debug); break; } case GST_MESSAGE_EOS: /* end-of-stream */ DEBUGMSG("GST end-of-stream."); if (mIsLooping) { DEBUGMSG("looping media..."); double eos_pos_sec = 0.0F; bool got_eos_position = getTimePos(eos_pos_sec); if (got_eos_position && eos_pos_sec < MIN_LOOP_SEC) { // if we know that the movie is really short, don't // loop it else it can easily become a time-hog // because of GStreamer spin-up overhead DEBUGMSG("really short movie (%0.3fsec) - not gonna loop this, pausing instead.", eos_pos_sec); // inject a COMMAND_PAUSE mCommand = COMMAND_PAUSE; } else { #undef LLGST_LOOP_BY_SEEKING // loop with a stop-start instead of a seek, because it actually seems rather // faster than seeking on remote streams. #ifdef LLGST_LOOP_BY_SEEKING // first, try looping by an explicit rewind bool seeksuccess = seek(0.0); if (seeksuccess) { play(1.0); } else #endif // LLGST_LOOP_BY_SEEKING { // use clumsy stop-start to loop DEBUGMSG("didn't loop by rewinding - stopping and starting instead..."); stop(); play(1.0); } } } else // not a looping media { // inject a COMMAND_STOP mCommand = COMMAND_STOP; } break; default: /* unhandled message */ break; } /* we want to be notified again the next time there is a message * on the bus, so return true (false means we want to stop watching * for messages on the bus and our callback should not be called again) */ return TRUE; }
void QAuServer::play(const QString& filename) { QSound s(filename); play(&s); }
static void clockTimer_callback(void* o) { u16 s; u8 i1, i2; // static event_t e; // e.type = kEventTimer; // e.data = 0; // event_post(&e); // print_dbg("\r\ntimer."); // clock_phase++; // if(clock_phase>1) clock_phase=0; // (*clock_pulse)(clock_phase); if(shape_counter) { if(shape_counter == 1) { s = 0; for(i1=0;i1<3;i1++) if(min_y + i1 < 16) for(i2=0;i2<3;i2++) { s <<= 1; if(min_x + i2 < 16) if(key_map[(min_y+i1)*16+(min_x+i2)]) s |= 1; } // print_dbg("\r\nfound shape pattern: "); // print_dbg_ulong(s); for(i1=0;i1<15;i1++) if(s == SHAPE_PATTERN[i1]) break; if(i1 < 9) { if(r_status != rOff) rec(i1, min_x, min_y + SHAPE_OFF_Y[i1]); shape(i1, min_x, min_y + SHAPE_OFF_Y[i1]); legato = 1; } else if(i1 < 15) { // MAGICS if(i1==9) all_edit = 1; else if(i1==10) pattern_linearize(); else if(i1==11) pattern_time_half(); else if(i1==12) pattern_time_double(); else if(i1==13) { if(p_select<15) p_select++; else p_select = 0; play(); } else if(i1==14) { if(p_select > 0) p_select--; else p_select = 15; play(); } } else { if(r_status != rOff) rec(0,last_x,last_y); shape(0, last_x, last_y); legato = 1; } } shape_counter--; } if(edge_counter) { if(edge_counter == 1) { gpio_clr_gpio_pin(B00); edge_state = 0; monomeFrameDirty++; // print_dbg("\r\ntrig done."); } edge_counter--; } if(r_status == rRec) { rec_timer++; } if(p_playing) { if(p_timer == 0) { if(p_play_pos == es.p[p_select].length && !es.p[p_select].loop) { // print_dbg("\r\nPATTERN DONE"); p_playing = 0; } else { if(p_play_pos == es.p[p_select].length && es.p[p_select].loop) { // print_dbg("\r\nLOOP"); p_play_pos = 0; p_timer_total = 0; } u8 i = p_play_pos; p_timer = es.p[p_select].e[i].interval; s8 x = es.p[p_select].e[i].x + es.p[p_select].x; s8 y = es.p[p_select].e[i].y + es.p[p_select].y; if(x<0) x = 0; else if(x>15) x=15; if(y<0) y = 0; else if(y>7) y=7; // print_dbg("\r\n"); // print_dbg_ulong(i); // print_dbg(" : "); // print_dbg_ulong(es.p[p_select].e[i].shape); // print_dbg(" @ ("); // print_dbg_ulong(es.p[p_select].e[i].x); // print_dbg(", "); // print_dbg_ulong(es.p[p_select].e[i].y); // print_dbg(") NEXT: "); // print_dbg_ulong(es.p[p_select].e[i].interval); pattern_shape(es.p[p_select].e[i].shape, (u8)x, (u8)y); p_play_pos++; } } else p_timer--; p_timer_total++; monomeFrameDirty++; } if(r_status == rRec || all_edit || !VARI) { blinker++; if(blinker == 48) blinker = 0; if(blinker == 0 || blinker == 24) monomeFrameDirty++; } }
Checkers::Checkers(CheckerHuman player1, CheckerAI player2) { terminalStatus = false; std::cout << "Thanks for choosing Checkers." << std::endl; play(); }
void runProgram() { statusBar()->showMessage(tr("Running program...")); playAction->setDisabled(true); emit play(); }
int run (int cmd, char *arg) { long speed; int l, r, rc, count; switch (cmd) { case CMD_QUIT: exit (0); case CMD_INFO: if (fd < 0 && ! open_cd ()) return (0); return info (arg); case CMD_CDID: if (fd < 0 && ! open_cd ()) return (0); return cdid (); case CMD_STATUS: if (fd < 0 && ! open_cd ()) return (0); return pstatus (arg); case CMD_NEXT: case CMD_PREVIOUS: if (fd < 0 && ! open_cd ()) return (0); while (isspace (*arg)) arg++; return next_prev (arg, cmd); case CMD_PAUSE: if (fd < 0 && ! open_cd ()) return (0); return ioctl (fd, CDIOCPAUSE); case CMD_RESUME: if (fd < 0 && ! open_cd ()) return (0); return ioctl (fd, CDIOCRESUME); case CMD_STOP: if (fd < 0 && ! open_cd ()) return (0); rc = ioctl (fd, CDIOCSTOP); (void) ioctl (fd, CDIOCALLOW); return (rc); case CMD_RESET: if (fd < 0 && ! open_cd ()) return (0); rc = ioctl (fd, CDIOCRESET); if (rc < 0) return rc; close(fd); fd = -1; return (0); case CMD_DEBUG: if (fd < 0 && ! open_cd ()) return (0); if (! strcasecmp (arg, "on")) return ioctl (fd, CDIOCSETDEBUG); if (! strcasecmp (arg, "off")) return ioctl (fd, CDIOCCLRDEBUG); warnx("invalid command arguments"); return (0); case CMD_EJECT: if (fd < 0 && ! open_cd ()) return (0); (void) ioctl (fd, CDIOCALLOW); rc = ioctl (fd, CDIOCEJECT); if (rc < 0) return (rc); return (0); case CMD_CLOSE: if (fd < 0 && ! open_cd ()) return (0); (void) ioctl (fd, CDIOCALLOW); rc = ioctl (fd, CDIOCCLOSE); if (rc < 0) return (rc); close(fd); fd = -1; return (0); case CMD_PLAY: if (fd < 0 && ! open_cd ()) return (0); while (isspace (*arg)) arg++; return play (arg); case CMD_SET: if (! strcasecmp (arg, "msf")) msf = 1; else if (! strcasecmp (arg, "lba")) msf = 0; else warnx("invalid command arguments"); return (0); case CMD_VOLUME: if (fd < 0 && !open_cd ()) return (0); if (! strlen (arg)) return pstatus ("volume"); if (! strncasecmp (arg, "left", strlen(arg))) return ioctl (fd, CDIOCSETLEFT); if (! strncasecmp (arg, "right", strlen(arg))) return ioctl (fd, CDIOCSETRIGHT); if (! strncasecmp (arg, "mono", strlen(arg))) return ioctl (fd, CDIOCSETMONO); if (! strncasecmp (arg, "stereo", strlen(arg))) return ioctl (fd, CDIOCSETSTERIO); if (! strncasecmp (arg, "mute", strlen(arg))) return ioctl (fd, CDIOCSETMUTE); count = sscanf (arg, "%d %d", &l, &r); if (count == 1) return setvol (l, l); if (count == 2) return setvol (l, r); warnx("invalid command arguments"); return (0); case CMD_SPEED: if (fd < 0 && ! open_cd ()) return (0); errno = 0; if (strcasecmp("max", arg) == 0) speed = CDR_MAX_SPEED; else speed = strtol(arg, NULL, 10) * 177; if (speed <= 0 || speed > INT_MAX) { warnx("invalid command arguments %s", arg); return (0); } return ioctl(fd, CDRIOCREADSPEED, &speed); default: case CMD_HELP: help (); return (0); } }
int main(int argc, char **argv) { int optind; char **playlist_array; int items; struct stat stat_buf; int i; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); ao_initialize(); stat_format = stat_format_create(); options_init(&options); file_options_init(file_opts); parse_std_configs(file_opts); options.playlist = playlist_create(); optind = parse_cmdline_options(argc, argv, &options, file_opts); audio_play_arg.devices = options.devices; audio_play_arg.stat_format = stat_format; /* Add remaining arguments to playlist */ for (i = optind; i < argc; i++) { if (stat(argv[i], &stat_buf) == 0) { if (S_ISDIR(stat_buf.st_mode)) { if (playlist_append_directory(options.playlist, argv[i]) == 0) fprintf(stderr, _("WARNING: Could not read directory %s.\n"), argv[i]); } else { playlist_append_file(options.playlist, argv[i]); } } else /* If we can't stat it, it might be a non-disk source */ playlist_append_file(options.playlist, argv[i]); } /* Do we have anything left to play? */ if (playlist_length(options.playlist) == 0) { cmdline_usage(); exit(1); } else { playlist_array = playlist_to_array(options.playlist, &items); playlist_destroy(options.playlist); options.playlist = NULL; } /* Don't use status_message until after this point! */ status_init(options.verbosity); print_audio_devices_info(options.devices); /* Setup buffer */ if (options.buffer_size > 0) { /* Keep sample size alignment for surround sound with up to 10 channels */ options.buffer_size = (options.buffer_size + PRIMAGIC - 1) / PRIMAGIC * PRIMAGIC; audio_buffer = buffer_create(options.buffer_size, options.buffer_size * options.prebuffer / 100, audio_play_callback, &audio_play_arg, AUDIO_CHUNK_SIZE); if (audio_buffer == NULL) { status_error(_("Error: Could not create audio buffer.\n")); exit(1); } } else audio_buffer = NULL; /* Setup signal handlers and callbacks */ signal (SIGINT, signal_handler); signal (SIGTSTP, signal_handler); signal (SIGCONT, signal_handler); signal (SIGTERM, signal_handler); if (options.remote) { /* run the mainloop for the remote interface */ remote_mainloop(); } else { do { /* Shuffle playlist */ if (options.shuffle) { int i; srandom(time(NULL)); for (i = 0; i < items; i++) { int j = i + random() % (items - i); char *temp = playlist_array[i]; playlist_array[i] = playlist_array[j]; playlist_array[j] = temp; } } /* Play the files/streams */ i = 0; while (i < items && !sig_request.exit) { play(playlist_array[i]); i++; } } while (options.repeat); } playlist_array_destroy(playlist_array, items); status_deinit(); if (audio_buffer != NULL) { buffer_destroy (audio_buffer); audio_buffer = NULL; } ao_onexit (options.devices); exit (exit_status); }
void QSofaScene::pause() { play(false); }
AnimatedSprite::AnimatedSprite() { mf_timeSicneLastFrame = 0; play(); mi_currentFrame = 0; }
/** * \brief Stops playing any music. * * The callback if any is not called. */ void Music::stop_playing() { play(none, false); }