[outputs] Rename output_buffer.frame to .data
This commit is contained in:
parent
5c35e1a9db
commit
b811122566
|
@ -290,9 +290,9 @@ streaming_write(struct output_buffer *obuf)
|
||||||
if (!streaming_sessions)
|
if (!streaming_sessions)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!quality_is_equal(&obuf->frames[0].quality, &streaming_quality))
|
if (!quality_is_equal(&obuf->data[0].quality, &streaming_quality))
|
||||||
{
|
{
|
||||||
ret = write(streaming_meta[1], &obuf->frames[0].quality, sizeof(struct media_quality));
|
ret = write(streaming_meta[1], &obuf->data[0].quality, sizeof(struct media_quality));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_STREAMING, "Error writing to streaming pipe: %s\n", strerror(errno));
|
DPRINTF(E_LOG, L_STREAMING, "Error writing to streaming pipe: %s\n", strerror(errno));
|
||||||
|
@ -300,7 +300,7 @@ streaming_write(struct output_buffer *obuf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = write(streaming_pipe[1], obuf->frames[0].buffer, obuf->frames[0].bufsize);
|
ret = write(streaming_pipe[1], obuf->data[0].buffer, obuf->data[0].bufsize);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
if (errno == EAGAIN)
|
if (errno == EAGAIN)
|
||||||
|
|
|
@ -290,20 +290,20 @@ buffer_fill(struct output_buffer *obuf, void *buf, size_t bufsize, struct media_
|
||||||
// The resampling/encoding (transcode) contexts work for a given input quality,
|
// The resampling/encoding (transcode) contexts work for a given input quality,
|
||||||
// so if the quality changes we need to reset the contexts. We also do that if
|
// so if the quality changes we need to reset the contexts. We also do that if
|
||||||
// we have received a subscription for a new quality.
|
// we have received a subscription for a new quality.
|
||||||
if (!quality_is_equal(quality, &obuf->frames[0].quality) || output_got_new_subscription)
|
if (!quality_is_equal(quality, &obuf->data[0].quality) || output_got_new_subscription)
|
||||||
{
|
{
|
||||||
encoding_reset(quality);
|
encoding_reset(quality);
|
||||||
output_got_new_subscription = false;
|
output_got_new_subscription = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The first element of the output_buffer is always just the raw input frame
|
// The first element of the output_buffer is always just the raw input data
|
||||||
// TODO can we avoid the copy below? we can't use evbuffer_add_buffer_reference,
|
// TODO can we avoid the copy below? we can't use evbuffer_add_buffer_reference,
|
||||||
// because then the outputs can't use it and we would need to copy there instead
|
// because then the outputs can't use it and we would need to copy there instead
|
||||||
evbuffer_add(obuf->frames[0].evbuf, buf, bufsize);
|
evbuffer_add(obuf->data[0].evbuf, buf, bufsize);
|
||||||
obuf->frames[0].buffer = buf;
|
obuf->data[0].buffer = buf;
|
||||||
obuf->frames[0].bufsize = bufsize;
|
obuf->data[0].bufsize = bufsize;
|
||||||
obuf->frames[0].quality = *quality;
|
obuf->data[0].quality = *quality;
|
||||||
obuf->frames[0].samples = nsamples;
|
obuf->data[0].samples = nsamples;
|
||||||
|
|
||||||
for (i = 0, n = 1; output_quality_subscriptions[i].count > 0; i++)
|
for (i = 0, n = 1; output_quality_subscriptions[i].count > 0; i++)
|
||||||
{
|
{
|
||||||
|
@ -314,15 +314,15 @@ buffer_fill(struct output_buffer *obuf, void *buf, size_t bufsize, struct media_
|
||||||
if (!frame)
|
if (!frame)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ret = transcode_encode(obuf->frames[n].evbuf, output_quality_subscriptions[i].encode_ctx, frame, 0);
|
ret = transcode_encode(obuf->data[n].evbuf, output_quality_subscriptions[i].encode_ctx, frame, 0);
|
||||||
transcode_frame_free(frame);
|
transcode_frame_free(frame);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
obuf->frames[n].buffer = evbuffer_pullup(obuf->frames[n].evbuf, -1);
|
obuf->data[n].buffer = evbuffer_pullup(obuf->data[n].evbuf, -1);
|
||||||
obuf->frames[n].bufsize = evbuffer_get_length(obuf->frames[n].evbuf);
|
obuf->data[n].bufsize = evbuffer_get_length(obuf->data[n].evbuf);
|
||||||
obuf->frames[n].quality = output_quality_subscriptions[i].quality;
|
obuf->data[n].quality = output_quality_subscriptions[i].quality;
|
||||||
obuf->frames[n].samples = BTOS(obuf->frames[n].bufsize, obuf->frames[n].quality.bits_per_sample, obuf->frames[n].quality.channels);
|
obuf->data[n].samples = BTOS(obuf->data[n].bufsize, obuf->data[n].quality.bits_per_sample, obuf->data[n].quality.channels);
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,11 +332,11 @@ buffer_drain(struct output_buffer *obuf)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; obuf->frames[i].buffer; i++)
|
for (i = 0; obuf->data[i].buffer; i++)
|
||||||
{
|
{
|
||||||
evbuffer_drain(obuf->frames[i].evbuf, obuf->frames[i].bufsize);
|
evbuffer_drain(obuf->data[i].evbuf, obuf->data[i].bufsize);
|
||||||
obuf->frames[i].buffer = NULL;
|
obuf->data[i].buffer = NULL;
|
||||||
obuf->frames[i].bufsize = 0;
|
obuf->data[i].bufsize = 0;
|
||||||
// We don't reset quality and samples, would be a waste of time
|
// We don't reset quality and samples, would be a waste of time
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -982,8 +982,8 @@ outputs_init(void)
|
||||||
if (no_output)
|
if (no_output)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(output_buffer.frames); i++)
|
for (i = 0; i < ARRAY_SIZE(output_buffer.data); i++)
|
||||||
output_buffer.frames[i].evbuf = evbuffer_new();
|
output_buffer.data[i].evbuf = evbuffer_new();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1012,7 +1012,7 @@ outputs_deinit(void)
|
||||||
memset(&output_quality_subscriptions[i], 0, sizeof(struct output_quality_subscription));
|
memset(&output_quality_subscriptions[i], 0, sizeof(struct output_quality_subscription));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(output_buffer.frames); i++)
|
for (i = 0; i < ARRAY_SIZE(output_buffer.data); i++)
|
||||||
evbuffer_free(output_buffer.frames[i].evbuf);
|
evbuffer_free(output_buffer.data[i].evbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ struct output_metadata
|
||||||
struct output_metadata *next;
|
struct output_metadata *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct output_frame
|
struct output_data
|
||||||
{
|
{
|
||||||
struct media_quality quality;
|
struct media_quality quality;
|
||||||
struct evbuffer *evbuf;
|
struct evbuffer *evbuf;
|
||||||
|
@ -166,7 +166,7 @@ struct output_buffer
|
||||||
{
|
{
|
||||||
uint32_t write_counter; // REMOVE ME? not used for anything
|
uint32_t write_counter; // REMOVE ME? not used for anything
|
||||||
struct timespec pts;
|
struct timespec pts;
|
||||||
struct output_frame frames[OUTPUTS_MAX_QUALITY_SUBSCRIPTIONS + 1];
|
struct output_data data[OUTPUTS_MAX_QUALITY_SUBSCRIPTIONS + 1];
|
||||||
} output_buffer;
|
} output_buffer;
|
||||||
|
|
||||||
typedef void (*output_status_cb)(struct output_device *device, enum output_device_state status);
|
typedef void (*output_status_cb)(struct output_device *device, enum output_device_state status);
|
||||||
|
|
|
@ -413,13 +413,13 @@ fifo_write(struct output_buffer *obuf)
|
||||||
if (!fifo_session)
|
if (!fifo_session)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; obuf->frames[i].buffer; i++)
|
for (i = 0; obuf->data[i].buffer; i++)
|
||||||
{
|
{
|
||||||
if (quality_is_equal(&fifo_quality, &obuf->frames[i].quality))
|
if (quality_is_equal(&fifo_quality, &obuf->data[i].quality))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!obuf->frames[i].buffer)
|
if (!obuf->data[i].buffer)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_FIFO, "Bug! Did not get audio in quality required\n");
|
DPRINTF(E_LOG, L_FIFO, "Bug! Did not get audio in quality required\n");
|
||||||
return;
|
return;
|
||||||
|
@ -428,10 +428,10 @@ fifo_write(struct output_buffer *obuf)
|
||||||
fifo_session->state = OUTPUT_STATE_STREAMING;
|
fifo_session->state = OUTPUT_STATE_STREAMING;
|
||||||
|
|
||||||
CHECK_NULL(L_FIFO, packet = calloc(1, sizeof(struct fifo_packet)));
|
CHECK_NULL(L_FIFO, packet = calloc(1, sizeof(struct fifo_packet)));
|
||||||
CHECK_NULL(L_FIFO, packet->samples = malloc(obuf->frames[i].bufsize));
|
CHECK_NULL(L_FIFO, packet->samples = malloc(obuf->data[i].bufsize));
|
||||||
|
|
||||||
memcpy(packet->samples, obuf->frames[i].buffer, obuf->frames[i].bufsize);
|
memcpy(packet->samples, obuf->data[i].buffer, obuf->data[i].bufsize);
|
||||||
packet->samples_size = obuf->frames[i].bufsize;
|
packet->samples_size = obuf->data[i].bufsize;
|
||||||
packet->pts = obuf->pts;
|
packet->pts = obuf->pts;
|
||||||
|
|
||||||
if (buffer.head)
|
if (buffer.head)
|
||||||
|
|
|
@ -4868,16 +4868,16 @@ raop_write(struct output_buffer *obuf)
|
||||||
|
|
||||||
for (rms = raop_master_sessions; rms; rms = rms->next)
|
for (rms = raop_master_sessions; rms; rms = rms->next)
|
||||||
{
|
{
|
||||||
for (i = 0; obuf->frames[i].buffer; i++)
|
for (i = 0; obuf->data[i].buffer; i++)
|
||||||
{
|
{
|
||||||
if (!quality_is_equal(&obuf->frames[i].quality, &rms->rtp_session->quality))
|
if (!quality_is_equal(&obuf->data[i].quality, &rms->rtp_session->quality))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Sends sync packets to new sessions, and if it is sync time then also to old sessions
|
// Sends sync packets to new sessions, and if it is sync time then also to old sessions
|
||||||
packets_sync_send(rms, obuf->pts);
|
packets_sync_send(rms, obuf->pts);
|
||||||
|
|
||||||
evbuffer_add_buffer_reference(rms->evbuf, obuf->frames[i].evbuf);
|
evbuffer_add_buffer_reference(rms->evbuf, obuf->data[i].evbuf);
|
||||||
rms->evbuf_samples += obuf->frames[i].samples;
|
rms->evbuf_samples += obuf->data[i].samples;
|
||||||
|
|
||||||
// Send as many packets as we have data for (one packet requires rawbuf_size bytes)
|
// Send as many packets as we have data for (one packet requires rawbuf_size bytes)
|
||||||
while (evbuffer_get_length(rms->evbuf) >= rms->rawbuf_size)
|
while (evbuffer_get_length(rms->evbuf) >= rms->rawbuf_size)
|
||||||
|
|
Loading…
Reference in New Issue