Exemple #1
0
static void
sig_recv_message(XMPP_SERVER_REC *server, LmMessage *lmsg, const int type,
    const char *id, const char *from, const char *to)
{
	LmMessageNode *node;

	if ((type != LM_MESSAGE_SUB_TYPE_NOT_SET
	    && type != LM_MESSAGE_SUB_TYPE_HEADLINE
	    && type != LM_MESSAGE_SUB_TYPE_NORMAL
	    && type != LM_MESSAGE_SUB_TYPE_CHAT)
	    || server->ischannel(SERVER(server), from))
		return;
	node = lm_find_node(lmsg->node, "x", XMLNS, XMLNS_EVENT);
	if (node == NULL) {
		signal_emit("xmpp composing hide", 2, server, from);
		return;
	}
	if (lm_message_node_get_child(lmsg->node, "body") != NULL
	    || lm_message_node_get_child(lmsg->node, "subject") != NULL) {
		if (lm_message_node_get_child(node, "composing") != NULL)
			datalist_add(composings, server, from, g_strdup(id));
		else
			datalist_remove(composings, server, from);
		signal_emit("xmpp composing hide", 2, server, from);
	} else {
		if (lm_message_node_get_child(node, "composing") != NULL)
			signal_emit("xmpp composing show", 2, server, from);
		else
			signal_emit("xmpp composing hide", 2, server, from);
	}
}
Exemple #2
0
static int
copy_input_buffer (void **srcbuf, void *srcend, int *pneed_input,
		   int *pinbuf_added, void *data, int datalen)
{
	uint8_t *_srcbuf;
	int _srclen, copylen;

	if (srcbuf == NULL) {
		handle_last_input_buffer (pneed_input, pinbuf_added);
		return 1;
	}
	_srcbuf = (uint8_t *)*srcbuf;
	_srclen = (uint8_t *)srcend - _srcbuf;
	if (inbuf_copying == NULL) {
	get_inbuf:
		inbuf_copying = buflist_pop (&inbuf_free);
		inbuf_copied = 0;
	}
	while (inbuf_copying != NULL) {
		copylen = inbuf_copying->alen - inbuf_copied;
		if (copylen == 0) {
			inbuf_copying->flen = inbuf_copied;
			if (buflist_add (&inbuf_used, inbuf_copying))
				*pneed_input = 1;
			*pinbuf_added = 1;
			goto get_inbuf;
		}
		if (_srclen == 0)
			break;
		if (copylen > _srclen)
			copylen = _srclen;
		memcpy ((uint8_t *)inbuf_copying->buf + inbuf_copied,
			_srcbuf, copylen);
		_srcbuf += copylen;
		_srclen -= copylen;
		inbuf_copied += copylen;
		datalist_add (&indata, data, datalen, copylen);
	}
	if (*srcbuf == (void *)_srcbuf && *srcbuf != srcend)
		return 0;
	*srcbuf = (void *)_srcbuf;
	return 1;
}
Exemple #3
0
static void
decode_end_cb (RSACPDS_AAC *aac, long ret, unsigned long bcnt,
	       RSACPDS_OUT_INFO outInfo, unsigned long pcnt, unsigned long n)
{
	static const int freqlist[2][0xc] = {
		{
			96000, 88200, 64000, 48000,
			44100, 32000, 24000, 22050,
			16000, 12000, 11025, 8000,
		},
		{
			0, 0, 0, 0,
			0, 0, 24000 * 2, 22050 * 2,
			16000 * 2, 12000 * 2, 11025 * 2, 8000 * 2,
		},
	};
	long end_block_size;
	void *data;
	int datalen;
	int outputlen;
	struct spu_aac_decode_fmt _format_next;

	decode_end_status = paac->statusCode;
	end_block_size = 1024;
	if (_format_current.aacplus != 0)
		end_block_size = 2048;
	if (ret == 0) {
		if (n >= 1) {
			switch (pcnt - (n - 1) * end_block_size) {
			case 1024:
				_format_next.aacplus = 0;
				break;
			case 2048:
				_format_next.aacplus = 1;
				break;
			default:
				ERR ("unknown block size");
				_format_next.aacplus = 0;
				break;
			}
		}
		if (next_sampling_frequency_index >= 0 &&
		    next_sampling_frequency_index < 0xc)
			_format_next.sampling_frequency = freqlist
				[_format_next.aacplus]
				[next_sampling_frequency_index];
		else
			_format_next.sampling_frequency = 0;
		if (_format_next.sampling_frequency == 0)
			ERR ("sampling frequency error");
		switch (outInfo.channelMode) {
		case 0:		/* monaural */
			_format_next.channel = 1;
			break;
		case 1:		/* stereo */
		case 2:		/* dual monaural */
		case 3:		/* parametric stereo */
			_format_next.channel = 2;
			break;
		case 4:		/* 3/0 */
			_format_next.channel = 3;
			break;
		case 5:		/* 3/1 */
			_format_next.channel = 4;
			break;
		case 6:		/* 3/2 */
			_format_next.channel = 5;
			break;
		case 7:		/* 3/2 + LFE (5.1) */
			_format_next.channel = 6;
			break;
		case 8:		/* 2/1 */
		case 9:		/* 2/2 */
			ERR ("channel mode 2/1 or 2/2 not supported");
			_format_next.channel = 0;
			break;
		case -1:
			ERR ("channel mode error");
			_format_next.channel = 0;
			break;
		}
	}
	if (ret == -1)
		n++;		/* last block */
	if (state.first_block != 0 && n >= 1)
		n--;		/* first block */
	if (bcnt != 0) {
		datalist_sub (&indata, &data, &datalen, bcnt);
		datalist_add (&delaydata, data, datalen, 1);
		/* fprintf (stderr, "input %d n %lu c %d b %ld\n", bcnt, n, _format_current.channel, end_block_size); */
		if (datalen != 0)
			free (data);
	}
	outputlen = n * _format_current.channel * end_block_size * 2;
	if (outputlen != 0) {
		datalist_sub (&delaydata, &data, &datalen, 1);
		datalist_add (&outdata, data, datalen, outputlen);
		if (datalen != 0)
			free (data);
		/* fprintf (stderr, "output %d\n", outputlen); */
	}
	pthread_mutex_lock (&transfer_lock);
	if (outputlen != 0) {
		datalist_add (&outlendata, &outputlen, sizeof outputlen, 1);
		datalist_add (&outfmtdata, &_format_current,
			      sizeof _format_current, 1);
	}
	state.decode_end = 1;
	if (ret == -1 && decode_end_status == RSACPDS_ERR_DATA_EMPTY)
		state.decode_really_end = 1;
	if (transfer_flag != 0) {
		transfer_flag = 0;
		pthread_mutex_unlock (&transfer_done);
	}
	pthread_mutex_unlock (&transfer_lock);
	_format_current = _format_next;
}