summaryrefslogtreecommitdiff
path: root/src/liana/handlers
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-10-30 15:24:58 -0400
committerAndrew Opalach <andrew@akon.city> 2025-10-30 15:24:58 -0400
commitf7e23d3c5e47ec0c105bf506e58e23f635faa20e (patch)
tree99dfc4f34da05d16bdfac6a437bb86a65d9b32f8 /src/liana/handlers
parent90da3b27d939b3b7af1cf7fed10dfaaa7e271622 (diff)
downloadcamu-f7e23d3c5e47ec0c105bf506e58e23f635faa20e.tar.gz
camu-f7e23d3c5e47ec0c105bf506e58e23f635faa20e.tar.bz2
camu-f7e23d3c5e47ec0c105bf506e58e23f635faa20e.zip
Wip sink changes around errored/ended buffers
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/liana/handlers')
-rw-r--r--src/liana/handlers/codec_client.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/src/liana/handlers/codec_client.c b/src/liana/handlers/codec_client.c
index c246a24..abb5b9a 100644
--- a/src/liana/handlers/codec_client.c
+++ b/src/liana/handlers/codec_client.c
@@ -32,7 +32,12 @@ static bool codec_client_init(struct lia_client_handler *handler, struct camu_re
#ifdef CAMU_HAVE_FFMPEG
static bool push_av_packet(struct lia_codec_client *codec, AVPacket *pkt)
{
- return codec->dec->push_av_packet(codec->dec, pkt) == CAMU_OK;
+ s32 ret = codec->dec->push_av_packet(codec->dec, pkt);
+ if (ret == AVERROR(EAGAIN)) {
+ codec->dec->process(codec->dec);
+ ret = codec->dec->push_av_packet(codec->dec, pkt);
+ }
+ return ret == CAMU_OK;
}
static void passthrough_subtitle(struct lia_codec_client *codec, AVPacket *pkt)
@@ -82,17 +87,17 @@ static bool codec_client_handle_packet(struct lia_client_handler *handler, struc
u32 rindex = packet->rindex;
bool success;
u8 mode = nn_packet_read_u8(packet);
+ // @TODO: default: shouldn't be a case. We should check for an invalid packet.
switch (mode) {
case CAMU_NORMAL: {
if (codec->dec) {
- // @TODO: Store pointer over r/windex (64 bits) if needed.
- //if (packet->opaque) {
- // success = push_packet(codec, (struct nn_buffer *)packet->opaque);
- //} else {
+ if (packet->opaque) {
+ success = push_packet(codec, (struct nn_buffer *)packet->opaque);
+ } else {
struct nn_buffer buffer;
nn_packet_read_buffer(packet, &buffer);
success = push_packet(codec, &buffer);
- //}
+ }
} else {
success = true;
}
@@ -101,13 +106,13 @@ static bool codec_client_handle_packet(struct lia_client_handler *handler, struc
#ifdef CAMU_HAVE_FFMPEG
case CAMU_FFMPEG_COMPAT: {
AVPacket *pkt;
- //if (packet->opaque) {
- // pkt = (AVPacket *)packet->opaque;
- //} else {
+ if (packet->opaque) {
+ pkt = (AVPacket *)packet->opaque;
+ } else {
pkt = av_packet_alloc();
nn_packet_read_av_packet(packet, pkt);
- // packet->opaque = pkt;
- //}
+ packet->opaque = pkt;
+ }
if (codec->dec) {
success = push_av_packet(codec, pkt);
if (!success) {
@@ -137,20 +142,10 @@ static bool codec_client_handle_packet(struct lia_client_handler *handler, struc
packet->rindex = rindex;
if (!success) {
- // Forcing in an EOF on an error is not necessary but behaves better in the sink.
- codec->handler.callback(codec->handler.userdata, LIANA_CLIENT_EOF, codec->handler.stream, NULL);
+ codec->handler.callback(codec->handler.userdata, LIANA_CLIENT_ERRORED, codec->handler.stream, NULL);
return false;
}
- // Process, if needed.
- if (codec->dec) {
- s32 ret = codec->dec->process(codec->dec);
- if (!(ret == CAMU_ERR_AGAIN || ret == CAMU_ERR_EOF)) {
- codec->handler.callback(codec->handler.userdata, LIANA_CLIENT_EOF, codec->handler.stream, NULL);
- return false;
- }
- }
-
return true;
}