本文整理汇总了C++中player_lock函数的典型用法代码示例。如果您正苦于以下问题:C++ player_lock函数的具体用法?C++ player_lock怎么用?C++ player_lock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了player_lock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:raumzeitlabor,项目名称:mpd,代码行数:37,代码来源:player_thread.c
示例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);
}
}
开发者ID:pallotron,项目名称:MPD,代码行数:39,代码来源:playlist.c
示例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;
}
}
开发者ID:pallotron,项目名称:MPD,代码行数:65,代码来源:player_thread.c
示例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;
}
开发者ID:pallotron,项目名称:MPD,代码行数:58,代码来源:player_thread.c
示例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;
}
开发者ID:pallotron,项目名称:MPD,代码行数:38,代码来源:player_thread.c
示例6: player_command
static void
player_command(enum player_command cmd)
{
player_lock();
player_command_locked(cmd);
player_unlock();
}
开发者ID:OpenInkpot-archive,项目名称:iplinux-mpd,代码行数:7,代码来源:player_control.c
示例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();
}
开发者ID:ayoucai,项目名称:cmus,代码行数:28,代码来源:player.c
示例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();
}
开发者ID:ayoucai,项目名称:cmus,代码行数:33,代码来源:player.c
示例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);
}
开发者ID:seebag,项目名称:mpd,代码行数:7,代码来源:player_control.c
示例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);
}
开发者ID:seebag,项目名称:mpd,代码行数:7,代码来源:player_control.c
示例13: player_stop
void player_stop(void)
{
player_lock();
__consumer_stop();
__producer_stop();
__player_status_changed();
player_unlock();
}
开发者ID:ayoucai,项目名称:cmus,代码行数:8,代码来源:player.c
示例14: pc_clear_error
void
pc_clear_error(void)
{
player_lock();
pc.error = PLAYER_ERROR_NOERROR;
pc.errored_song = NULL;
player_unlock();
}
开发者ID:radioanonymous,项目名称:mpd,代码行数:8,代码来源:player_control.c
示例15: pc_enqueue_song
void
pc_enqueue_song(struct song *song)
{
assert(song != NULL);
player_lock();
pc_enqueue_song_locked(song);
player_unlock();
}
开发者ID:radioanonymous,项目名称:mpd,代码行数:9,代码来源:player_control.c
示例16: pc_enqueue_song
void
pc_enqueue_song(struct player_control *pc, struct song *song)
{
assert(song != NULL);
player_lock(pc);
pc_enqueue_song_locked(pc, song);
player_unlock(pc);
}
开发者ID:seebag,项目名称:mpd,代码行数:9,代码来源:player_control.c
示例17: player_init
void player_init(const struct player_callbacks *callbacks)
{
int rc;
#ifdef REALTIME_SCHEDULING
pthread_attr_t attr;
#endif
pthread_attr_t *attrp = NULL;
/* This mutex is locked inside of the mpris implementation which is
* called into from many different places. It is not trivial to see if
* those places do already hold this lock and so the mpris functions
* always acquires it. To avoid deadlocks in the places where the lock
* is already held by the calling context, we use a recursive mutex.
*/
cmus_mutex_init_recursive(&player_info.mutex);
/* 1 s is 176400 B (0.168 MB)
* 10 s is 1.68 MB
*/
buffer_nr_chunks = 10 * 44100 * 16 / 8 * 2 / CHUNK_SIZE;
buffer_init();
player_cbs = callbacks;
#ifdef REALTIME_SCHEDULING
rc = pthread_attr_init(&attr);
BUG_ON(rc);
rc = pthread_attr_setschedpolicy(&attr, SCHED_RR);
if (rc) {
d_print("could not set real-time scheduling priority: %s\n", strerror(rc));
} else {
struct sched_param param;
d_print("using real-time scheduling\n");
param.sched_priority = sched_get_priority_max(SCHED_RR);
d_print("setting priority to %d\n", param.sched_priority);
rc = pthread_attr_setschedparam(&attr, ¶m);
BUG_ON(rc);
attrp = &attr;
}
#endif
rc = pthread_create(&producer_thread, NULL, producer_loop, NULL);
BUG_ON(rc);
rc = pthread_create(&consumer_thread, attrp, consumer_loop, NULL);
if (rc && attrp) {
d_print("could not create thread using real-time scheduling: %s\n", strerror(rc));
rc = pthread_create(&consumer_thread, NULL, consumer_loop, NULL);
}
BUG_ON(rc);
/* update player_info.cont etc. */
player_lock();
_player_status_changed();
player_unlock();
}
开发者ID:jmerdich,项目名称:cmus,代码行数:57,代码来源:player.c
示例18: 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 decoder_control *dc = player->dc;
assert(player->queued || pc.command == PLAYER_COMMAND_SEEK);
assert(pc.next_song != NULL);
player->queued = false;
if (decoder_lock_has_failed(dc)) {
player_lock();
pc.errored_song = dc->song;
pc.error = PLAYER_ERROR_FILE;
pc.next_song = NULL;
player_unlock();
return false;
}
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();
/* 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();
/* call syncPlaylistWithQueue() in the main thread */
event_pipe_emit(PIPE_EVENT_PLAYLIST);
return true;
}
开发者ID:raumzeitlabor,项目名称:mpd,代码行数:51,代码来源:player_thread.c
示例19: pc_get_error_message
char *
pc_get_error_message(struct player_control *pc)
{
player_lock(pc);
char *message = pc->error_type != PLAYER_ERROR_NONE
? g_strdup(pc->error->message)
: NULL;
player_unlock(pc);
return message;
}
开发者ID:seebag,项目名称:mpd,代码行数:10,代码来源:player_control.c
示例20: player_set_rg_preamp
void player_set_rg_preamp(double db)
{
player_lock();
replaygain_preamp = db;
player_info_lock();
update_rg_scale();
player_info_unlock();
player_unlock();
}
开发者ID:ayoucai,项目名称:cmus,代码行数:11,代码来源:player.c
注:本文中的player_lock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论