本文整理汇总了C++中player_lock函数的典型用法代码示例。如果您正苦于以下问题:C++ player_lock函数的具体用法?C++ player_lock怎么用?C++ player_lock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了player_lock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: player_open_output
/**
* Wrapper for audio_output_all_open(). Upon failure, it pauses the
* player.
*
* @return true on success
*/
static bool
player_open_output(struct player *player)
{
assert(audio_format_defined(&player->play_audio_format));
assert(pc.state == PLAYER_STATE_PLAY ||
pc.state == PLAYER_STATE_PAUSE);
if (audio_output_all_open(&player->play_audio_format, player_buffer)) {
player->output_open = true;
player->paused = false;
player_lock();
pc.state = PLAYER_STATE_PLAY;
player_unlock();
return true;
} else {
player->output_open = false;
/* pause: the user may resume playback as soon as an
audio output becomes available */
player->paused = true;
player_lock();
pc.error = PLAYER_ERROR_AUDIO;
pc.state = PLAYER_STATE_PAUSE;
player_unlock();
return false;
}
}
示例2: playlist_sync
/**
* This is the "PLAYLIST" event handler. It is invoked by the player
* thread whenever it requests a new queued song, or when it exits.
*/
void
playlist_sync(struct playlist *playlist, struct player_control *pc)
{
if (!playlist->playing)
/* this event has reached us out of sync: we aren't
playing anymore; ignore the event */
return;
player_lock(pc);
enum player_state pc_state = pc_get_state(pc);
const struct song *pc_next_song = pc->next_song;
player_unlock(pc);
if (pc_state == PLAYER_STATE_STOP)
/* the player thread has stopped: check if playback
should be restarted with the next song. That can
happen if the playlist isn't filling the queue fast
enough */
playlist_resume_playback(playlist, pc);
else {
/* check if the player thread has already started
playing the queued song */
if (pc_next_song == NULL && playlist->queued != -1)
playlist_song_started(playlist, pc);
player_lock(pc);
pc_next_song = pc->next_song;
player_unlock(pc);
/* make sure the queued song is always set (if
possible) */
if (pc_next_song == NULL && playlist->queued < 0)
playlist_update_queued_song(playlist, pc, NULL);
}
}
示例3: player_check_decoder_startup
/**
* The decoder has acknowledged the "START" command (see
* player_wait_for_decoder()). This function checks if the decoder
* initialization has completed yet.
*
* The player lock is not held.
*/
static bool
player_check_decoder_startup(struct player *player)
{
struct player_control *pc = player->pc;
struct decoder_control *dc = player->dc;
assert(player->decoder_starting);
decoder_lock(dc);
GError *error = dc_get_error(dc);
if (error != NULL) {
/* the decoder failed */
decoder_unlock(dc);
player_lock(pc);
pc_set_error(pc, PLAYER_ERROR_DECODER, error);
player_unlock(pc);
return false;
} else if (!decoder_is_starting(dc)) {
/* the decoder is ready and ok */
decoder_unlock(dc);
if (player->output_open &&
!audio_output_all_wait(pc, 1))
/* the output devices havn't finished playing
all chunks yet - wait for that */
return true;
player_lock(pc);
pc->total_time = real_song_duration(dc->song, dc->total_time);
pc->audio_format = dc->in_audio_format;
player_unlock(pc);
player->play_audio_format = dc->out_audio_format;
player->decoder_starting = false;
if (!player->paused && !player_open_output(player)) {
char *uri = song_get_uri(dc->song);
g_warning("problems opening audio device "
"while playing \"%s\"", uri);
g_free(uri);
return true;
}
return true;
} else {
/* the decoder is not yet ready; wait
some more */
player_wait_decoder(pc, dc);
decoder_unlock(dc);
return true;
}
}
示例4: player_wait_for_decoder
/**
* After the decoder has been started asynchronously, wait for the
* "START" command to finish. The decoder may not be initialized yet,
* i.e. there is no audio_format information yet.
*
* The player lock is not held.
*/
static bool
player_wait_for_decoder(struct player *player)
{
struct player_control *pc = player->pc;
struct decoder_control *dc = player->dc;
assert(player->queued || pc->command == PLAYER_COMMAND_SEEK);
assert(pc->next_song != NULL);
player->queued = false;
GError *error = dc_lock_get_error(dc);
if (error != NULL) {
player_lock(pc);
pc_set_error(pc, PLAYER_ERROR_DECODER, error);
song_free(pc->next_song);
pc->next_song = NULL;
player_unlock(pc);
return false;
}
if (player->song != NULL)
song_free(player->song);
player->song = pc->next_song;
player->elapsed_time = 0.0;
/* set the "starting" flag, which will be cleared by
player_check_decoder_startup() */
player->decoder_starting = true;
player_lock(pc);
/* update player_control's song information */
pc->total_time = song_get_duration(pc->next_song);
pc->bit_rate = 0;
audio_format_clear(&pc->audio_format);
/* clear the queued song */
pc->next_song = NULL;
player_unlock(pc);
/* call syncPlaylistWithQueue() in the main thread */
event_pipe_emit(PIPE_EVENT_PLAYLIST);
return true;
}
示例5: player_song_border
/**
* This is called at the border between two songs: the audio output
* has consumed all chunks of the current song, and we should start
* sending chunks from the next one.
*
* The player lock is not held.
*
* @return true on success, false on error (playback will be stopped)
*/
static bool
player_song_border(struct player *player)
{
player->xfade = XFADE_UNKNOWN;
char *uri = song_get_uri(player->song);
g_message("played \"%s\"", uri);
g_free(uri);
music_pipe_free(player->pipe);
player->pipe = player->dc->pipe;
audio_output_all_song_border();
if (!player_wait_for_decoder(player))
return false;
struct player_control *const pc = player->pc;
player_lock(pc);
if (pc->border_pause) {
player->paused = true;
pc->state = PLAYER_STATE_PAUSE;
}
player_unlock(pc);
return true;
}
示例6: player_command
static void
player_command(enum player_command cmd)
{
player_lock();
player_command_locked(cmd);
player_unlock();
}
示例7: player_pause
void player_pause(void)
{
player_lock();
if (consumer_status == CS_STOPPED) {
__producer_play();
if (producer_status == PS_PLAYING) {
__consumer_play();
if (consumer_status != CS_PLAYING)
__producer_stop();
}
__player_status_changed();
if (consumer_status == CS_PLAYING)
__prebuffer();
player_unlock();
return;
}
if (ip && ip_is_remote(ip)) {
/* pausing not allowed */
player_unlock();
return;
}
__producer_pause();
__consumer_pause();
__player_status_changed();
player_unlock();
}
示例8: player_play_file
void player_play_file(struct track_info *ti)
{
player_lock();
__producer_set_file(ti);
if (producer_status == PS_UNLOADED) {
__consumer_stop();
goto out;
}
/* PS_STOPPED */
__producer_play();
/* PS_UNLOADED,PS_PLAYING */
if (producer_status == PS_UNLOADED) {
__consumer_stop();
goto out;
}
/* PS_PLAYING */
if (consumer_status == CS_STOPPED) {
__consumer_play();
if (consumer_status == CS_STOPPED)
__producer_stop();
} else {
op_drop();
change_sf(1);
}
out:
__player_status_changed();
if (producer_status == PS_PLAYING)
__prebuffer();
player_unlock();
}
示例9: player_command
static void
player_command(struct player_control *pc, enum player_command cmd)
{
player_lock(pc);
player_command_locked(pc, cmd);
player_unlock(pc);
}
示例10: player_command_finished
static void
player_command_finished(struct player_control *pc)
{
player_lock(pc);
player_command_finished_locked(pc);
player_unlock(pc);
}
开发者ID:degifted,项目名称:MPD-with-support-for-FLAC-CUE-and--CUE-files-as-virtual-directories,代码行数:7,代码来源:player_thread.c
示例11: play_chunk
/**
* Plays a #music_chunk object (after applying software volume). If
* it contains a (stream) tag, copy it to the current song, so MPD's
* playlist reflects the new stream tag.
*
* Player lock is not held.
*/
static bool
play_chunk(struct player_control *pc,
struct song *song, struct music_chunk *chunk,
const struct audio_format *format)
{
assert(music_chunk_check_format(chunk, format));
if (chunk->tag != NULL)
update_song_tag(song, chunk->tag);
if (chunk->length == 0) {
music_buffer_return(player_buffer, chunk);
return true;
}
player_lock(pc);
pc->bit_rate = chunk->bit_rate;
player_unlock(pc);
/* send the chunk to the audio outputs */
if (!audio_output_all_play(chunk))
return false;
pc->total_play_time += (double)chunk->length /
audio_format_time_to_size(format);
return true;
}
开发者ID:degifted,项目名称:MPD-with-support-for-FLAC-CUE-and--CUE-files-as-virtual-directories,代码行数:35,代码来源:player_thread.c
示例12: pc_set_border_pause
void
pc_set_border_pause(struct player_control *pc, bool border_pause)
{
player_lock(pc);
pc->border_pause = border_pause;
player_unlock(pc);
}
示例13: player_stop
void player_stop(void)
{
player_lock();
__consumer_stop();
__producer_stop();
__player_status_changed();
player_unlock();
}
示例14: pc_clear_error
void
pc_clear_error(void)
{
player_lock();
pc.error = PLAYER_ERROR_NOERROR;
pc.errored_song = NULL;
player_unlock();
}
示例15: pc_enqueue_song
void
pc_enqueue_song(struct song *song)
{
assert(song != NULL);
player_lock();
pc_enqueue_song_locked(song);
player_unlock();
}