void decoder_initialized(G_GNUC_UNUSED struct decoder * decoder, const struct audio_format *audio_format, bool seekable, float total_time) { assert(dc.state == DECODE_STATE_START); assert(decoder != NULL); assert(decoder->stream_tag == NULL); assert(decoder->decoder_tag == NULL); assert(!decoder->seeking); assert(audio_format != NULL); assert(audio_format_defined(audio_format)); assert(audio_format_valid(audio_format)); dc.in_audio_format = *audio_format; getOutputAudioFormat(audio_format, &dc.out_audio_format); dc.seekable = seekable; dc.total_time = total_time; dc.state = DECODE_STATE_DECODE; notify_signal(&pc.notify); g_debug("audio_format=%u:%u:%u, seekable=%s", dc.in_audio_format.sample_rate, dc.in_audio_format.bits, dc.in_audio_format.channels, seekable ? "true" : "false"); if (!audio_format_equals(&dc.in_audio_format, &dc.out_audio_format)) g_debug("converting to %u:%u:%u", dc.out_audio_format.sample_rate, dc.out_audio_format.bits, dc.out_audio_format.channels); }
static void ao_command_finished(struct audio_output *ao) { assert(ao->command != AO_COMMAND_NONE); ao->command = AO_COMMAND_NONE; g_mutex_unlock(ao->mutex); notify_signal(&audio_output_client_notify); g_mutex_lock(ao->mutex); }
static void player_command(enum player_command cmd) { assert(pc.command == PLAYER_COMMAND_NONE); pc.command = cmd; while (pc.command != PLAYER_COMMAND_NONE) { notify_signal(&pc.notify); notify_wait(&main_notify); } }
HCGBaseWindow::HCGBaseWindow() : QMainWindow() { connect(this, SIGNAL(notify_signal(QString)), this, SLOT(notify_slot(QString)), Qt::BlockingQueuedConnection); connect(this, SIGNAL(notify_nonmodal_signal(QString)), this, SLOT(notify_nonmodal_slot(QString)), Qt::BlockingQueuedConnection); connect(this, SIGNAL(notify_console_signal(QString)), this, SLOT(notify_console_slot(QString)), Qt::BlockingQueuedConnection); connect(this, SIGNAL(notify_error_signal(QString)), this, SLOT(notify_error_slot(QString)), Qt::BlockingQueuedConnection); connect(this, SIGNAL(disp_rgb_signal(unsigned int, unsigned int, void *, int, char *, char *, char *, char *, char *)), this, SLOT(disp_rgb_slot(unsigned int, unsigned int, void *, int, char *, char *, char *, char *, char *)), Qt::BlockingQueuedConnection); connect(this, SIGNAL(prompt_signal(QString, QString *)), this, SLOT(prompt_slot(QString, QString *)), Qt::BlockingQueuedConnection); #ifdef WIN32 connect(this, SIGNAL(updateStatus_signal(int)), this, SLOT(updateStatus_slot(int)), Qt::QueuedConnection); #endif connect(hcgcore, SIGNAL(closeAll_signal()), this, SLOT(close())); QShortcut *sc = new QShortcut(QKeySequence(tr("Ctrl+Q")), this); QObject::connect(sc, SIGNAL(activated()), this, SLOT(close())); log_edit = NULL; #ifdef WIN32 updateBar = NULL; #endif }
void decoder_command_finished(G_GNUC_UNUSED struct decoder * decoder) { assert(dc.command != DECODE_COMMAND_NONE); assert(dc.command != DECODE_COMMAND_SEEK || dc.seek_error || decoder->seeking); if (dc.command == DECODE_COMMAND_SEEK) { /* delete frames from the old song position */ if (decoder->chunk != NULL) { music_buffer_return(dc.buffer, decoder->chunk); decoder->chunk = NULL; } music_pipe_clear(dc.pipe, dc.buffer); } dc.command = DECODE_COMMAND_NONE; notify_signal(&pc.notify); }
/** * Sends a #tag as-is to the music pipe. Flushes the current chunk * (decoder.chunk) if there is one. */ static enum decoder_command do_send_tag(struct decoder *decoder, struct input_stream *is, const struct tag *tag) { struct music_chunk *chunk; if (decoder->chunk != NULL) { /* there is a partial chunk - flush it, we want the tag in a new chunk */ decoder_flush_chunk(decoder); notify_signal(&pc.notify); } assert(decoder->chunk == NULL); chunk = decoder_get_chunk(decoder, is); if (chunk == NULL) { assert(dc.command != DECODE_COMMAND_NONE); return dc.command; } chunk->tag = tag_dup(tag); return DECODE_COMMAND_NONE; }
enum decoder_command decoder_data(struct decoder *decoder, struct input_stream *is, const void *_data, size_t length, float data_time, uint16_t bitRate, struct replay_gain_info *replay_gain_info) { const char *data = _data; assert(dc.state == DECODE_STATE_DECODE); assert(length % audio_format_frame_size(&dc.in_audio_format) == 0); if (dc.command == DECODE_COMMAND_STOP || dc.command == DECODE_COMMAND_SEEK || length == 0) return dc.command; /* send stream tags */ if (update_stream_tag(decoder, is)) { enum decoder_command cmd; if (decoder->decoder_tag != NULL) { /* merge with tag from decoder plugin */ struct tag *tag; tag = tag_merge(decoder->stream_tag, decoder->decoder_tag); cmd = do_send_tag(decoder, is, tag); tag_free(tag); } else /* send only the stream tag */ cmd = do_send_tag(decoder, is, decoder->stream_tag); if (cmd != DECODE_COMMAND_NONE) return cmd; } if (!audio_format_equals(&dc.in_audio_format, &dc.out_audio_format)) { data = pcm_convert(&decoder->conv_state, &dc.in_audio_format, data, length, &dc.out_audio_format, &length); /* under certain circumstances, pcm_convert() may return an empty buffer - this condition should be investigated further, but for now, do this check as a workaround: */ if (data == NULL) return DECODE_COMMAND_NONE; } while (length > 0) { struct music_chunk *chunk; char *dest; size_t nbytes; bool full; chunk = decoder_get_chunk(decoder, is); if (chunk == NULL) { assert(dc.command != DECODE_COMMAND_NONE); return dc.command; } dest = music_chunk_write(chunk, &dc.out_audio_format, data_time, bitRate, &nbytes); if (dest == NULL) { /* the chunk is full, flush it */ decoder_flush_chunk(decoder); notify_signal(&pc.notify); continue; } assert(nbytes > 0); if (nbytes > length) nbytes = length; /* copy the buffer */ memcpy(dest, data, nbytes); /* apply replay gain or normalization */ if (replay_gain_info != NULL && replay_gain_mode != REPLAY_GAIN_OFF) replay_gain_apply(replay_gain_info, dest, nbytes, &dc.out_audio_format); else if (normalizationEnabled) normalizeData(dest, nbytes, &dc.out_audio_format); /* expand the music pipe chunk */ full = music_chunk_expand(chunk, &dc.out_audio_format, nbytes); if (full) { /* the chunk is full, flush it */ decoder_flush_chunk(decoder); notify_signal(&pc.notify); } data += nbytes; length -= nbytes; } return DECODE_COMMAND_NONE; }