static void flic_play(Popot theflic) /***************************************************************************** * void FlicPlay(Flic *pflic) ****************************************************************************/ { if (Success > flic_integrity_check(theflic.pt)) return; builtin_err = do_play(theflic.pt); }
void SystemCmdSound::worker(void) { #ifdef _DEBUG wxLogMessage("SystemCmdSound::worker()"); #endif /* _DEBUG */ m_isPlaying = true; do_play(m_cmd.c_str(), m_path.c_str()); m_onFinished(m_callbackData); m_onFinished = 0; m_isPlaying = false; }
static void read_keypress() { // Get keypress int c = fgetc( stdin ); // Ignore EOF (e.g. when stdin is /dev/null) if (c == EOF) return; switch(c) { // Pause/Play case 'p': if (get_state() == MADJACK_STATE_PLAYING) { do_pause(); } else { do_play(); } break; // Load case 'l': { char* filepath = read_filepath(); do_load( filepath ); free( filepath ); break; } case 'e': do_eject(); break; case 's': do_stop(); break; case 'q': do_quit(); break; case 'c': do_cue(0.0f); break; case 'C': { float cuepoint = read_cuepoint(); do_cue( cuepoint ); break; } default: printf( "Unknown command '%c'.\n", (char)c ); case 'h': case '?': display_keyhelp(); break; // Ignore return and enter case 13: case 10: break; } }
void fruitlib::audio::sound_controller::play_positional( resource_tree::path const &target_path, sge::audio::sound::positional_parameters const &pp) { resource_tree_type &target_tree = resource_tree::navigate_to_path( sounds_, target_path); if(target_tree.value().is_leaf()) { do_play( fcppt::unique_ptr_to_base< sge::audio::sound::base >( target_tree.value().leaf_value()->create_positional( pp))); } else { resource_tree_type &target_file = *std::next( target_tree.begin(), static_cast<std::iterator_traits<resource_tree_type::const_iterator>::difference_type>( (*target_tree.value().node_value())())); if(!target_file.value().is_leaf()) throw fruitlib::exception(FCPPT_TEXT("The argument to play() must be either a file or a directory containing just files!\nThat was not the case for: ")+target_path.string()); do_play( fcppt::unique_ptr_to_base< sge::audio::sound::base >( target_file.value().leaf_value()->create_positional( pp))); } }
bool SystemCmdSound::Play() { #ifdef _DEBUG wxLogInfo("SystemCmdSound::Play()"); #endif /* _DEBUG */ if (m_isPlaying) { wxLogWarning("SystemCmdSound: cannot play: already playing"); return false; } if (m_onFinished) { std::thread t([this]() { worker(); }); t.detach(); return true; } int r = do_play(m_cmd.c_str(), m_path.c_str()); return r == 0; }
void gtk_gui::do_welcome() { const char *welcome_doc = find_datafile(welcome_locations); if (welcome_doc) { if( openSMILfile(welcome_doc, 0, true)) { do_play(); } } else { GtkMessageDialog* dialog = (GtkMessageDialog*) gtk_message_dialog_new (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, gettext("Cannot find Welcome.smil document")); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (GTK_WIDGET (dialog)); } }
int main (int argc, char **argv) { GstPlay *play; GPtrArray *playlist; gboolean verbose = FALSE; gboolean print_version = FALSE; gboolean interactive = TRUE; gboolean gapless = FALSE; gboolean shuffle = FALSE; gdouble volume = -1; gchar **filenames = NULL; gchar *audio_sink = NULL; gchar *video_sink = NULL; gchar **uris; gchar *flags = NULL; guint num, i; GError *err = NULL; GOptionContext *ctx; gchar *playlist_file = NULL; GOptionEntry options[] = { {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, N_("Output status information and property notifications"), NULL}, {"flags", 0, 0, G_OPTION_ARG_STRING, &flags, N_("Control playback behaviour setting playbin 'flags' property"), NULL}, {"version", 0, 0, G_OPTION_ARG_NONE, &print_version, N_("Print version information and exit"), NULL}, {"videosink", 0, 0, G_OPTION_ARG_STRING, &video_sink, N_("Video sink to use (default is autovideosink)"), NULL}, {"audiosink", 0, 0, G_OPTION_ARG_STRING, &audio_sink, N_("Audio sink to use (default is autoaudiosink)"), NULL}, {"gapless", 0, 0, G_OPTION_ARG_NONE, &gapless, N_("Enable gapless playback"), NULL}, {"shuffle", 0, 0, G_OPTION_ARG_NONE, &shuffle, N_("Shuffle playlist"), NULL}, {"no-interactive", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &interactive, N_("Disable interactive control via the keyboard"), NULL}, {"volume", 0, 0, G_OPTION_ARG_DOUBLE, &volume, N_("Volume"), NULL}, {"playlist", 0, 0, G_OPTION_ARG_FILENAME, &playlist_file, N_("Playlist file containing input media files"), NULL}, {"quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet, N_("Do not print any output (apart from errors)"), NULL}, {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL}, {NULL} }; setlocale (LC_ALL, ""); #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif g_set_prgname ("gst-play-" GST_API_VERSION); ctx = g_option_context_new ("FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."); g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", GST_STR_NULL (err->message)); g_option_context_free (ctx); g_clear_error (&err); return 1; } g_option_context_free (ctx); GST_DEBUG_CATEGORY_INIT (play_debug, "play", 0, "gst-play"); if (print_version) { gchar *version_str; version_str = gst_version_string (); g_print ("%s version %s\n", g_get_prgname (), PACKAGE_VERSION); g_print ("%s\n", version_str); g_print ("%s\n", GST_PACKAGE_ORIGIN); g_free (version_str); g_free (audio_sink); g_free (video_sink); g_free (playlist_file); return 0; } playlist = g_ptr_array_new (); if (playlist_file != NULL) { gchar *playlist_contents = NULL; gchar **lines = NULL; if (g_file_get_contents (playlist_file, &playlist_contents, NULL, &err)) { lines = g_strsplit (playlist_contents, "\n", 0); num = g_strv_length (lines); for (i = 0; i < num; i++) { if (lines[i][0] != '\0') { GST_LOG ("Playlist[%d]: %s", i + 1, lines[i]); add_to_playlist (playlist, lines[i]); } } g_strfreev (lines); g_free (playlist_contents); } else { g_printerr ("Could not read playlist: %s\n", err->message); g_clear_error (&err); } g_free (playlist_file); playlist_file = NULL; } if (playlist->len == 0 && (filenames == NULL || *filenames == NULL)) { g_printerr (_("Usage: %s FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."), "gst-play-" GST_API_VERSION); g_printerr ("\n\n"), g_printerr ("%s\n\n", _("You must provide at least one filename or URI to play.")); /* No input provided. Free array */ g_ptr_array_free (playlist, TRUE); g_free (audio_sink); g_free (video_sink); return 1; } /* fill playlist */ if (filenames != NULL && *filenames != NULL) { num = g_strv_length (filenames); for (i = 0; i < num; ++i) { GST_LOG ("command line argument: %s", filenames[i]); add_to_playlist (playlist, filenames[i]); } g_strfreev (filenames); } num = playlist->len; g_ptr_array_add (playlist, NULL); uris = (gchar **) g_ptr_array_free (playlist, FALSE); if (shuffle) shuffle_uris (uris, num); /* prepare */ play = play_new (uris, audio_sink, video_sink, gapless, volume, verbose, flags); if (play == NULL) { g_printerr ("Failed to create 'playbin' element. Check your GStreamer installation.\n"); return EXIT_FAILURE; } if (interactive) { if (gst_play_kb_set_key_handler (keyboard_cb, play)) { g_print (_("Press 'k' to see a list of keyboard shortcuts.\n")); atexit (restore_terminal); } else { g_print ("Interactive keyboard handling in terminal not available.\n"); } } /* play */ do_play (play); /* clean up */ play_free (play); g_free (audio_sink); g_free (video_sink); g_print ("\n"); gst_deinit (); return 0; }
int main (int argc, char **argv) { GstPlay *play; GPtrArray *playlist; gboolean print_version = FALSE; gboolean interactive = FALSE; /* FIXME: maybe enable by default? */ gboolean shuffle = FALSE; gdouble volume = 1.0; gchar **filenames = NULL; gchar **uris; guint num, i; GError *err = NULL; GOptionContext *ctx; gchar *playlist_file = NULL; GOptionEntry options[] = { {"version", 0, 0, G_OPTION_ARG_NONE, &print_version, "Print version information and exit", NULL}, {"shuffle", 0, 0, G_OPTION_ARG_NONE, &shuffle, "Shuffle playlist", NULL}, {"interactive", 0, 0, G_OPTION_ARG_NONE, &interactive, "Interactive control via keyboard", NULL}, {"volume", 0, 0, G_OPTION_ARG_DOUBLE, &volume, "Volume", NULL}, {"playlist", 0, 0, G_OPTION_ARG_FILENAME, &playlist_file, "Playlist file containing input media files", NULL}, {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL}, {NULL} }; g_set_prgname ("gst-play"); ctx = g_option_context_new ("FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."); g_option_context_add_main_entries (ctx, options, NULL); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", GST_STR_NULL (err->message)); return 1; } g_option_context_free (ctx); GST_DEBUG_CATEGORY_INIT (play_debug, "play", 0, "gst-play"); if (print_version) { gchar *version_str; version_str = gst_version_string (); g_print ("%s version %s\n", g_get_prgname (), "1.0"); g_print ("%s\n", version_str); g_free (version_str); g_free (playlist_file); return 0; } playlist = g_ptr_array_new (); if (playlist_file != NULL) { gchar *playlist_contents = NULL; gchar **lines = NULL; if (g_file_get_contents (playlist_file, &playlist_contents, NULL, &err)) { lines = g_strsplit (playlist_contents, "\n", 0); num = g_strv_length (lines); for (i = 0; i < num; i++) { if (lines[i][0] != '\0') { GST_LOG ("Playlist[%d]: %s", i + 1, lines[i]); add_to_playlist (playlist, lines[i]); } } g_strfreev (lines); g_free (playlist_contents); } else { g_printerr ("Could not read playlist: %s\n", err->message); g_clear_error (&err); } g_free (playlist_file); playlist_file = NULL; } if (playlist->len == 0 && (filenames == NULL || *filenames == NULL)) { g_printerr ("Usage: %s FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ...", "gst-play"); g_printerr ("\n\n"), g_printerr ("%s\n\n", "You must provide at least one filename or URI to play."); /* No input provided. Free array */ g_ptr_array_free (playlist, TRUE); return 1; } /* fill playlist */ if (filenames != NULL && *filenames != NULL) { num = g_strv_length (filenames); for (i = 0; i < num; ++i) { GST_LOG ("command line argument: %s", filenames[i]); add_to_playlist (playlist, filenames[i]); } g_strfreev (filenames); } num = playlist->len; g_ptr_array_add (playlist, NULL); uris = (gchar **) g_ptr_array_free (playlist, FALSE); if (shuffle) shuffle_uris (uris, num); /* prepare */ play = play_new (uris, volume); if (interactive) { if (gst_play_kb_set_key_handler (keyboard_cb, play)) { atexit (restore_terminal); } else { g_print ("Interactive keyboard handling in terminal not available.\n"); } } /* play */ do_play (play); /* clean up */ play_free (play); g_print ("\n"); return 0; }
/* * The main loop of the player thread, during playback. This is * basically a state machine, which multiplexes data between the * decoder thread and the output threads. */ static void do_play(struct player_control *pc, struct decoder_control *dc) { struct player player = { .pc = pc, .dc = dc, .buffering = true, .decoder_starting = false, .paused = false, .queued = true, .song = NULL, .xfade = XFADE_UNKNOWN, .cross_fading = false, .cross_fade_chunks = 0, .cross_fade_tag = NULL, .elapsed_time = 0.0, }; player_unlock(pc); player.pipe = music_pipe_new(); player_dc_start(&player, player.pipe); if (!player_wait_for_decoder(&player)) { player_dc_stop(&player); player_command_finished(pc); music_pipe_free(player.pipe); event_pipe_emit(PIPE_EVENT_PLAYLIST); player_lock(pc); return; } player_lock(pc); pc->state = PLAYER_STATE_PLAY; player_command_finished_locked(pc); while (true) { player_process_command(&player); if (pc->command == PLAYER_COMMAND_STOP || pc->command == PLAYER_COMMAND_EXIT || pc->command == PLAYER_COMMAND_CLOSE_AUDIO) { player_unlock(pc); audio_output_all_cancel(); break; } player_unlock(pc); if (player.buffering) { /* buffering at the start of the song - wait until the buffer is large enough, to prevent stuttering on slow machines */ if (music_pipe_size(player.pipe) < pc->buffered_before_play && !decoder_lock_is_idle(dc)) { /* not enough decoded buffer space yet */ if (!player.paused && audio_format_defined(&player.play_audio_format) && audio_output_all_check() < 4 && !player_send_silence(&player)) break; decoder_lock(dc); /* XXX race condition: check decoder again */ player_wait_decoder(pc, dc); decoder_unlock(dc); player_lock(pc); continue; } else { /* buffering is complete */ player.buffering = false; } } if (player.decoder_starting) { /* wait until the decoder is initialized completely */ if (!player_check_decoder_startup(&player)) break; player_lock(pc); continue; } #ifndef NDEBUG /* music_pipe_check_format(&play_audio_format, player.next_song_chunk, &dc->out_audio_format); */ #endif if (decoder_lock_is_idle(dc) && player.queued && dc->pipe == player.pipe) { /* the decoder has finished the current song; make it decode the next song */ assert(dc->pipe == NULL || dc->pipe == player.pipe); player_dc_start(&player, music_pipe_new()); } if (player_dc_at_next_song(&player) && player.xfade == XFADE_UNKNOWN && !decoder_lock_is_starting(dc)) { /* enable cross fading in this song? if yes, calculate how many chunks will be required for it */ player.cross_fade_chunks = cross_fade_calc(pc->cross_fade_seconds, dc->total_time, pc->mixramp_db, pc->mixramp_delay_seconds, dc->replay_gain_db, dc->replay_gain_prev_db, dc->mixramp_start, dc->mixramp_prev_end, &dc->out_audio_format, &player.play_audio_format, music_buffer_size(player_buffer) - pc->buffered_before_play); if (player.cross_fade_chunks > 0) { player.xfade = XFADE_ENABLED; player.cross_fading = false; } else /* cross fading is disabled or the next song is too short */ player.xfade = XFADE_DISABLED; } if (player.paused) { player_lock(pc); if (pc->command == PLAYER_COMMAND_NONE) player_wait(pc); continue; } else if (!music_pipe_empty(player.pipe)) { /* at least one music chunk is ready - send it to the audio output */ play_next_chunk(&player); } else if (audio_output_all_check() > 0) { /* not enough data from decoder, but the output thread is still busy, so it's okay */ /* XXX synchronize in a better way */ g_usleep(10000); } else if (player_dc_at_next_song(&player)) { /* at the beginning of a new song */ if (!player_song_border(&player)) break; } else if (decoder_lock_is_idle(dc)) { /* check the size of the pipe again, because the decoder thread may have added something since we last checked */ if (music_pipe_empty(player.pipe)) { /* wait for the hardware to finish playback */ audio_output_all_drain(); break; } } else { /* the decoder is too busy and hasn't provided new PCM data in time: send silence (if the output pipe is empty) */ if (!player_send_silence(&player)) break; } player_lock(pc); } player_dc_stop(&player); music_pipe_clear(player.pipe, player_buffer); music_pipe_free(player.pipe); if (player.cross_fade_tag != NULL) tag_free(player.cross_fade_tag); player_lock(pc); if (player.queued) { assert(pc->next_song != NULL); pc->next_song = NULL; } pc->state = PLAYER_STATE_STOP; player_unlock(pc); event_pipe_emit(PIPE_EVENT_PLAYLIST); player_lock(pc); } static gpointer player_task(gpointer arg) { struct player_control *pc = arg; struct decoder_control *dc = dc_new(pc->cond); decoder_thread_start(dc); player_buffer = music_buffer_new(pc->buffer_chunks); player_lock(pc); while (1) { switch (pc->command) { case PLAYER_COMMAND_QUEUE: assert(pc->next_song != NULL); do_play(pc, dc); break; case PLAYER_COMMAND_STOP: player_unlock(pc); audio_output_all_cancel(); player_lock(pc); /* fall through */ case PLAYER_COMMAND_SEEK: case PLAYER_COMMAND_PAUSE: pc->next_song = NULL; player_command_finished_locked(pc); break; case PLAYER_COMMAND_CLOSE_AUDIO: player_unlock(pc); audio_output_all_release(); player_lock(pc); player_command_finished_locked(pc); #ifndef NDEBUG /* in the DEBUG build, check for leaked music_chunk objects by freeing the music_buffer */ music_buffer_free(player_buffer); player_buffer = music_buffer_new(pc->buffer_chunks); #endif break; case PLAYER_COMMAND_UPDATE_AUDIO: player_unlock(pc); audio_output_all_enable_disable(); player_lock(pc); player_command_finished_locked(pc); break; case PLAYER_COMMAND_EXIT: player_unlock(pc); dc_quit(dc); dc_free(dc); audio_output_all_close(); music_buffer_free(player_buffer); player_command_finished(pc); return NULL; case PLAYER_COMMAND_CANCEL: pc->next_song = NULL; player_command_finished_locked(pc); break; case PLAYER_COMMAND_REFRESH: /* no-op when not playing */ player_command_finished_locked(pc); break; case PLAYER_COMMAND_NONE: player_wait(pc); break; } } } void player_create(struct player_control *pc) { assert(pc->thread == NULL); GError *e = NULL; pc->thread = g_thread_create(player_task, pc, true, &e); if (pc->thread == NULL) MPD_ERROR("Failed to spawn player task: %s", e->message); }
int main() { pololu_3pi_init(2000); play_mode(PLAY_CHECK); clear(); // start receiving data at 115.2 kbaud serial_set_baud_rate(115200); serial_receive_ring(buffer, 100); while(1) { // wait for a command char command = read_next_byte(); // The list of commands is below: add your own simply by // choosing a command byte and introducing another case // statement. switch(command) { case (char)0x00: // silent error - probable master resetting break; case (char)0x81: send_signature(); break; case (char)0x86: send_raw_sensor_values(); break; case (char)0x87: send_calibrated_sensor_values(1); break; case (char)0xB0: send_trimpot(); break; case (char)0xB1: send_battery_millivolts(); break; case (char)0xB3: do_play(); break; case (char)0xB4: calibrate_line_sensors(IR_EMITTERS_ON); send_calibrated_sensor_values(1); break; case (char)0xB5: line_sensors_reset_calibration(); break; case (char)0xB6: send_line_position(); break; case (char)0xB7: do_clear(); break; case (char)0xB8: do_print(); break; case (char)0xB9: do_lcd_goto_xy(); break; case (char)0xBA: auto_calibrate(); break; case (char)0xBB: set_pid(); break; case (char)0xBC: stop_pid(); break; case (char)0xC1: m1_forward(); break; case (char)0xC2: m1_backward(); break; case (char)0xC5: m2_forward(); break; case (char)0xC6: m2_backward(); break; default: clear(); print("Bad cmd"); lcd_goto_xy(0,1); print_hex_byte(command); play("o7l16crc"); continue; // bad command } } }
/*! process the message mothed, it will be called by playback task. \param[in] p_handle playback handle \param[in] p_msg new message */ static void pb_single_step(handle_t handle, os_msg_t *p_msg) { pb_handle_t *p_handle = (pb_handle_t *)handle; priv_data_t *p_data = &p_handle->data; play_param_t *p_play_param = NULL; if(p_msg != NULL) { switch(p_msg->content) { case NC_EVT_UNLOCKED: case NC_EVT_LOCKED: OS_PRINTF("!!!!!PB:PB_EVT_LOCK_RSL %d\n", NC_EVT_LOCKED == p_msg->content); if(p_data->status != PB_STOP) { if (check_same_tp(p_handle, &p_data->play_param)) { OS_PRINTF("PB play ticks %d\n", mtos_ticks_get()); do_play(p_handle, &p_data->play_param); p_data->status = PB_PLAYING; p_handle->data.pat_monitor_start = mtos_ticks_get(); p_handle->data.pat_monitor_interval = 100; p_handle->p_policy->on_play(p_handle->p_policy->p_data, &p_data->play_param); p_data->sm = PB_SM_WAIT_VIDEO; } send_evt_to_ui(PB_EVT_LOCK_RSL, NC_EVT_LOCKED == p_msg->content, 0); } break; case PB_CMD_PLAY: OS_PRINTF("do lock ticks %d\n", mtos_ticks_get()); p_play_param = (play_param_t *)p_msg->para1; memcpy(&p_data->play_param, p_play_param, sizeof(play_param_t)); p_data->status = PB_PLAYING; do_play_chan_open(p_handle, &p_data->play_param); log_perf(LOG_AP_CHANGE_CHANNEL, TAB_PB_START, 0, 0); lock_tuner_1(p_handle, &p_data->play_param); p_data->sm = PB_SM_WAIT_LOCK; break; case PB_CMD_STOP: log_perf(LOG_AP_CHANGE_CHANNEL, TAB_PB_STOP, (u32)(&p_data->play_param.inner.dvbs_lock_info.tp_rcv), (u32)(&p_data->play_param.pg_info)); do_stop(p_handle, p_msg->para1); //pat_free(p_handle); OS_PRINTF("PB stop ticks %d\n", mtos_ticks_get()); p_data->status = PB_STOP; //p_data->status.cur_pg_id = INVALID_PG_ID; p_data->sm = PB_SM_IDLE; break; case PB_CMD_STOP_SYNC: log_perf(LOG_AP_CHANGE_CHANNEL, TAB_PB_STOP_SYNC, (u32)(&p_data->play_param.inner.dvbs_lock_info.tp_rcv), (u32)(&p_data->play_param.pg_info)); do_stop(p_handle, p_msg->para1); OS_PRINTF("PB stop by sync ticks %d\n", mtos_ticks_get()); p_data->status = PB_STOP; p_data->sm = PB_SM_WAIT_STOP; send_evt_to_ui(PB_EVT_STOPPED, 0, 0); break; case PB_CMD_SWITCH_AUDIO_CHANNEL: switch_audio_channel(p_handle, p_msg->para1, p_msg->para2); break; case PB_CMD_SET_MUTE: //avc_set_mute((BOOL)p_msg->para1, (BOOL)p_msg->para2); send_evt_to_ui(PB_EVT_SET_MUTE, 0, 0); break; case PB_CMD_SET_VOL: //avc_setvolume((u8)p_msg->para1); send_evt_to_ui(PB_EVT_SET_VOL, 0, 0); break; case PB_CMD_RESET_TVMODE: p_data->play_param.pg_info.tv_mode = (u16)p_msg->para1; break; case PB_CMD_RESET_VIDEO_ASPECT_MODE: p_data->play_param.pg_info.aspect_ratio = p_msg->para1; break; case DVB_TABLE_TIMED_OUT: if(p_msg->para1 == DVB_TABLE_ID_PAT) { p_data->pat_request_flag = 0; } if(p_msg->para1 == DVB_TABLE_ID_NIT_ACTUAL) { p_data->nit_request_flag = 0; } break; case DVB_PAT_FOUND: p_data->pat_request_flag = 0; break; case DVB_PAT_PMT_INFO: if(p_data->play_param.pg_info.s_id == p_msg->para2) { pmt_request(p_handle, (u16)p_msg->para1, (u16)p_msg->para2); } break; case DVB_PMT_FOUND: if((p_data->status == PB_PLAYING) && (p_data->play_param.pg_info.s_id == (u32)(((pmt_t *)(p_msg->para1))->prog_num))) { do_dynamic_pid(p_handle, (pmt_t *)p_msg->para1); pmt_update_1(p_handle->data.p_sub_ttx_data, (pmt_t *)p_msg->para1); } else { subt_txt_info_reset_1(p_handle->data.p_sub_ttx_data); } break; case DVB_SDT_FOUND: if(p_data->status == PB_PLAYING) { do_revise_eid(p_handle, (sdt_t *)p_msg->para1); } if(p_data->play_param.lock_mode == SYS_DVBC) { pb_on_sdt_found(p_handle, (sdt_t *)p_msg->para1); } break; case DVB_NIT_FOUND: p_data->nit_request_flag = 0; pb_on_nit_found(p_handle, (nit_t *)p_msg->para1); break; //falcon debug case PB_CMD_START_TTX: vbi_ttx_start_vsb(p_msg->para1, p_msg->para2); break; case PB_CMD_STOP_TTX: vbi_ttx_stop_vsb(); break; case PB_CMD_SET_TTX_LANG: set_ttx_lang_1(p_handle->data.p_sub_ttx_data, p_msg->para1); break; case PB_CMD_POST_TTX_KEY: post_ttx_key_1(p_handle->data.p_sub_ttx_data, p_msg->para1); break; case PB_CMD_SHOW_TTX: show_ttx_1(p_handle->data.p_sub_ttx_data, p_msg->para1); break; case PB_CMD_HIDE_TTX: if(!hide_ttx_1(p_handle->data.p_sub_ttx_data)) { send_evt_to_ui(PB_EVT_HIDE_TTX, 0, 0); } break; case VBI_TTX_HIDED: case VBI_TTX_STOPPED: OS_PRINTF(">>>>>>VBI_TTX_HIDED!!!\n"); send_evt_to_ui(PB_EVT_HIDE_TTX, 0, 0); break; case PB_CMD_START_VBI_INSERTER: start_vbi_inserter_1(p_handle->data.p_sub_ttx_data); break; case PB_CMD_STOP_VBI_INSERTER: stop_vbi_inserter_1(p_handle->data.p_sub_ttx_data); break; case PB_CMD_START_SUBT: start_subt_dec_1(p_handle->data.p_sub_ttx_data); break; case PB_CMD_STOP_SUBT: stop_subt_dec_1(p_handle->data.p_sub_ttx_data); break; case PB_CMD_STOP_SUBT_SYNC: stop_subt_dec_1(p_handle->data.p_sub_ttx_data); break; case SUBT_EVT_STOPPED: //OS_PRINTF("\n\n\n=====OK======\n\n\n"); send_evt_to_ui(PB_EVT_SUBT_STOPED, 0, 0); break; case PB_CMD_SET_SUBT_SERVICE: set_subt_service_1(p_handle->data.p_sub_ttx_data, p_msg->para1, p_msg->para2); break; case PB_CMD_SHOW_SUBT: show_subtitle_1(p_handle->data.p_sub_ttx_data); break; case PB_CMD_HIDE_SUBT: if(FALSE == hide_subtitle_1(p_handle->data.p_sub_ttx_data)) { send_evt_to_ui(PB_EVT_HIDE_SUBT, 0, 0); } //send_evt_to_ui(PB_EVT_HIDE_SUBT, 0, 0); break; default: break; } } else { switch(p_data->sm) { case PB_SM_IDLE: break; case PB_SM_WAIT_LOCK: break; case PB_SM_WAIT_VIDEO: if(wait_video_frame_1(p_handle)) { log_perf(LOG_AP_CHANGE_CHANNEL, TAB_PB_DO_PLAY, (u32)(&p_data->play_param.inner.dvbs_lock_info.tp_rcv), (u32)(&p_data->play_param.pg_info)); OS_PRINTF("video out ticks %d\n", mtos_ticks_get()); p_data->signal_monitor_start = mtos_ticks_get(); p_data->sm = PB_SM_MONITOR_SIGNAL; sdt_request(p_handle); p_data->pat_request_flag = 0; } break; case PB_SM_MONITOR_SIGNAL: if((mtos_ticks_get() - p_data->signal_monitor_start) > 50) // 50ticks { p_data->signal_monitor_start = mtos_ticks_get(); monitor(p_handle); } if(((mtos_ticks_get() - p_data->pat_monitor_start) > p_data->pat_monitor_interval) && (!p_data->pat_request_flag)) // && (p_data->play_param.lock_mode == SYS_DVBS)) { pat_request(p_handle); p_data->pat_request_flag = 1; p_data->pat_monitor_start = mtos_ticks_get(); p_data->pat_monitor_interval = PAT_MONITOR_INTERVAL; } if(((mtos_ticks_get() - p_data->nit_monitor_start) > NIT_MONITOR_INTERVAL) && (!p_data->nit_request_flag) && (p_data->play_param.lock_mode == SYS_DVBC)) { nit_request(p_handle); p_data->nit_request_flag = 1; p_data->nit_monitor_start = mtos_ticks_get(); } break; case PB_SM_WAIT_STOP: p_data->sm = PB_SM_IDLE; break; default: break; } } }
/* playing raw data, this proc handels WAVE files and .VOCs (as one block) */ static int do_play (int fd, int loaded, u_long count, int rtype, char *name) { int l, real_l; u_long c; char one_chn = 0; char to_8 = 0; int tmps; sync_dsp (); tmps = samplesize; ioctl (audio, SNDCTL_DSP_SETFMT, &tmps); if (tmps != samplesize) { fprintf (stderr, "Unable to set %d bit sample size", samplesize); if (samplesize == 16) { samplesize = 8; ioctl (audio, SNDCTL_DSP_SETFMT, &samplesize); if (samplesize != 8) { fprintf (stderr, "Unable to set 8 bit sample size!\n"); return -1; } fprintf (stderr, "; playing 8 bit\n"); to_8 = 1; } else { fprintf (stderr, "\n"); return -1; } } #ifdef OSS_VERSION if (ioctl (audio, SNDCTL_DSP_STEREO, &dsp_stereo) < 0) { #else if (dsp_stereo != ioctl (audio, SNDCTL_DSP_STEREO, dsp_stereo)) { #endif fprintf (stderr, "Can't play in Stereo; playing only one channel\n"); dsp_stereo = MODE_MONO; one_chn = 1; } if (set_dsp_speed (&dsp_speed) < 0) return -1; abuf_size = 512; while (count) { c = count; if (c > abuf_size) c = abuf_size; if ((l = read (fd, (char *) audiobuf + loaded, c - loaded)) > 0) { l += loaded; loaded = 0; /* correct the count; ugly but ... */ real_l = (one_chn || to_8) ? one_channel (audiobuf, l, one_chn, to_8) : l; /* change byte order if necessary */ if (convert && (samplesize == 16)) { long i; for (i = 0; i < real_l; i += 2) *((short *) (audiobuf + i)) = htons (*((short *) (audiobuf + i))); } if (write (audio, (char *) audiobuf, real_l) != real_l) { perror (AUDIO); return -1; } count -= l; } else { if (l == -1) { perror (name); return -1; } count = 0; /* Stop */ } } /* while (count) */ return 0; } /* let's play) */ static int player (char *name) { int fd, ofs; if (!name) { fd = 0; name = "stdin"; } else if ((fd = open (name, O_RDONLY, 0)) == -1) { perror (name); return -1; } /* Read the smallest header first, then the missing bytes for the next, etc. */ /* read SND-header */ read (fd, (char *) audiobuf, sizeof (SndHeader)); if (test_sndfile (audiobuf, fd) >= 0) { if (do_play (fd, 0, count, SND_FMT, name) < 0) return -1; } else { /* read VOC-Header */ read (fd, (char *) audiobuf + sizeof (SndHeader), sizeof (VocHeader) - sizeof (SndHeader)); if ((ofs = test_vocfile (audiobuf)) >= 0) { if (vplay (fd, ofs, name) < 0) return -1; } else { /* read bytes for WAVE-header */ read (fd, (char *) audiobuf + sizeof (VocHeader), sizeof (WaveHeader) - sizeof (VocHeader)); if (test_wavefile (audiobuf) >= 0) { if (do_play (fd, 0, count, WAVE_FMT, name) < 0) return -1; } else { /* should be raw data */ init_raw_data (); count = calc_count (); if (do_play (fd, sizeof (WaveHeader), count, RAW_DATA, name) < 0) return -1; } } } if (fd != 0) close (fd); return 0; }
void PropValue(void) // PropValue = "[" ValueType "]" { yyaccept('['); ValueType(); // Property Value was read : use it to modify the game int size = board_size(game->pos); if (board_nmoves(game->pos) < nmoves-1 && strcmp(prop_name[prop], "B") == 0) { if (yytext[0] != 'B') do_play(game, BLACK, parse_sgf_coord(yytext, size)); else do_play(game, BLACK, PASS_MOVE); } else if (board_nmoves(game->pos) < nmoves-1 && strcmp(prop_name[prop], "W") == 0) { if (yytext[0] != 'W') do_play(game, WHITE, parse_sgf_coord(yytext, size)); else do_play(game, WHITE, PASS_MOVE); } else if (strcmp(prop_name[prop], "AB") == 0) { Point pt = parse_sgf_coord(yytext, size); slist_push(game->placed_black_stones, pt); board_place_stone(game->pos, pt, BLACK); } else if (strcmp(prop_name[prop], "AW") == 0) { Point pt = parse_sgf_coord(yytext, size); slist_push(game->placed_white_stones, pt); board_place_stone(game->pos, pt, WHITE); } else if (strcmp(prop_name[prop], "KM") == 0) board_set_komi(game->pos, atof(yytext)); else if (strcmp(prop_name[prop], "SZ") == 0) { if (is_game_board_empty(game)) { board_set_size(game->pos, atoi(yytext)); game_clear_board(game); } else { // Can happen if SZ occurs after AB or AW Point bstones[BOARDSIZE], wstones[BOARDSIZE]; Position *pos=game->pos; slist_clear(bstones); slist_clear(wstones); slist_append(bstones, game->placed_black_stones); slist_append(wstones, game->placed_white_stones); board_set_size(game->pos, atoi(yytext)); game_clear_board(game); FORALL_IN_SLIST(bstones, pt) { board_set_color_to_play(pos, BLACK); play_move(pos, pt); slist_push(game->placed_black_stones, pt); } FORALL_IN_SLIST(wstones, pt) { board_set_color_to_play(pos, WHITE); play_move(pos, pt); slist_push(game->placed_white_stones, pt); } }
int main (int argc, char **argv) { GstPlay *play; GPtrArray *playlist; gboolean print_version = FALSE; gboolean gapless = FALSE; gchar **filenames = NULL; gchar *audio_sink = NULL; gchar *video_sink = NULL; gchar **uris; guint num, i; GError *err = NULL; GOptionContext *ctx; GOptionEntry options[] = { {"version", 0, 0, G_OPTION_ARG_NONE, &print_version, N_("Print version information and exit"), NULL}, {"videosink", 0, 0, G_OPTION_ARG_STRING, &video_sink, N_("Video sink to use (default is autovideosink)"), NULL}, {"audiosink", 0, 0, G_OPTION_ARG_STRING, &audio_sink, N_("Audio sink to use (default is autoaudiosink)"), NULL}, {"gapless", 0, 0, G_OPTION_ARG_NONE, &gapless, N_("Enable gapless playback"), NULL}, {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL}, {NULL} }; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif g_set_prgname ("gst-play-" GST_API_VERSION); ctx = g_option_context_new ("FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."); g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE); g_option_context_add_group (ctx, gst_init_get_option_group ()); if (!g_option_context_parse (ctx, &argc, &argv, &err)) { g_print ("Error initializing: %s\n", GST_STR_NULL (err->message)); return 1; } g_option_context_free (ctx); GST_DEBUG_CATEGORY_INIT (play_debug, "play", 0, "gst-play"); if (print_version) { gchar *version_str; version_str = gst_version_string (); g_print ("%s version %s\n", g_get_prgname (), PACKAGE_VERSION); g_print ("%s\n", version_str); g_print ("%s\n", GST_PACKAGE_ORIGIN); g_free (version_str); return 0; } if (filenames == NULL || *filenames == NULL) { g_printerr (_("Usage: %s FILE1|URI1 [FILE2|URI2] [FILE3|URI3] ..."), "gst-play-" GST_API_VERSION); g_printerr ("\n\n"), g_printerr ("%s\n\n", _("You must provide at least one filename or URI to play.")); return 1; } playlist = g_ptr_array_new (); /* fill playlist */ num = g_strv_length (filenames); for (i = 0; i < num; ++i) { GST_LOG ("command line argument: %s", filenames[i]); add_to_playlist (playlist, filenames[i]); } g_strfreev (filenames); g_ptr_array_add (playlist, NULL); /* play */ uris = (gchar **) g_ptr_array_free (playlist, FALSE); play = play_new (uris, audio_sink, video_sink, gapless); do_play (play); /* clean up */ play_free (play); return 0; }
jint Java_com_thinpad_audiotransfer_AudiotransferActivity_doPlay() { do_play(); }