Skip to content

Commit

Permalink
Replace av_init_packet in spdifencoder.
Browse files Browse the repository at this point in the history
This fix has not been specifically tested, but is the same as the
prior av_init_packet -> av_packet_alloc changes.
  • Loading branch information
linuxdude42 committed Dec 28, 2021
1 parent 8a815bf commit c8e49a1
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions mythtv/libs/libmyth/audio/spdifencoder.cpp
Expand Up @@ -99,17 +99,24 @@ SPDIFEncoder::~SPDIFEncoder(void)
*/
void SPDIFEncoder::WriteFrame(unsigned char *data, int size)
{
AVPacket packet;
av_init_packet(&packet);
AVPacket *packet = av_packet_alloc();
if (packet == nullptr)
{
LOG(VB_GENERAL, LOG_ERR, "packet allocation failed");
return;
}

static int s_pts = 1; // to avoid warning "Encoder did not produce proper pts"
packet.pts = s_pts++;
packet.data = data;
packet.size = size;
packet->pts = s_pts++;
packet->data = data;
packet->size = size;

if (av_write_frame(m_oc, &packet) < 0)
if (av_write_frame(m_oc, packet) < 0)
{
LOG(VB_AUDIO, LOG_ERR, LOC + "av_write_frame");
}

av_packet_free(&packet);
}

/**
Expand Down

0 comments on commit c8e49a1

Please sign in to comment.