mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
raspi/avcodec_omx: various hacks to the state machine
* fix invalid locking when for MSG_NEWCHANNEL * fix restarting video decoder with proper omx teardown
This commit is contained in:
@@ -50,6 +50,7 @@ static void* acodec_omx_thread(struct codec_init_args_t* args)
|
|||||||
fprintf(stderr,"Starting acodec_omx_thread\n");
|
fprintf(stderr,"Starting acodec_omx_thread\n");
|
||||||
|
|
||||||
new_channel:
|
new_channel:
|
||||||
|
codec->first_packet = 1;
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
next_packet:
|
next_packet:
|
||||||
@@ -60,11 +61,10 @@ next_packet:
|
|||||||
//fprintf(stderr,"[acodec] - waiting for omx_active_mutex\n");
|
//fprintf(stderr,"[acodec] - waiting for omx_active_mutex\n");
|
||||||
pthread_mutex_lock(&pi->omx_active_mutex);
|
pthread_mutex_lock(&pi->omx_active_mutex);
|
||||||
//fprintf(stderr,"[acodec] - got omx_active_mutex\n");
|
//fprintf(stderr,"[acodec] - got omx_active_mutex\n");
|
||||||
while (!pi->omx_active) {
|
while (pi->omx_active != 1) {
|
||||||
pthread_cond_wait(&pi->omx_active_cv, &pi->omx_active_mutex);
|
pthread_cond_wait(&pi->omx_active_cv, &pi->omx_active_mutex);
|
||||||
//fprintf(stderr,"[acodec] - omx_active=%d\n",pi->omx_active);
|
//fprintf(stderr,"[acodec] - omx_active=%d\n",pi->omx_active);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_paused) {
|
if (is_paused) {
|
||||||
// Wait for resume message
|
// Wait for resume message
|
||||||
fprintf(stderr,"acodec: Waiting for resume\n");
|
fprintf(stderr,"acodec: Waiting for resume\n");
|
||||||
@@ -77,6 +77,7 @@ next_packet:
|
|||||||
if (current->msgtype == MSG_STOP) {
|
if (current->msgtype == MSG_STOP) {
|
||||||
printf("[acodec] Stopping\n");
|
printf("[acodec] Stopping\n");
|
||||||
codec_queue_free_item(codec,current);
|
codec_queue_free_item(codec,current);
|
||||||
|
pi->omx_active = 2; /* 2 == restarting, allows the vcodec to cleanly shutdown and restart */
|
||||||
pthread_mutex_unlock(&pi->omx_active_mutex);
|
pthread_mutex_unlock(&pi->omx_active_mutex);
|
||||||
goto new_channel;
|
goto new_channel;
|
||||||
} else if (current->msgtype == MSG_NEW_CHANNEL) {
|
} else if (current->msgtype == MSG_NEW_CHANNEL) {
|
||||||
@@ -115,6 +116,7 @@ next_packet:
|
|||||||
} else {
|
} else {
|
||||||
memcpy(buf->pBuffer, current->data->packet, current->data->packetlength);
|
memcpy(buf->pBuffer, current->data->packet, current->data->packetlength);
|
||||||
buf->nFilledLen = current->data->packetlength;
|
buf->nFilledLen = current->data->packetlength;
|
||||||
|
res = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -222,8 +224,8 @@ next_packet:
|
|||||||
goto stop;
|
goto stop;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"[vcodec] NEW_CHANNEL received, pipeline not active\n");
|
fprintf(stderr,"[vcodec] NEW_CHANNEL received, pipeline not active\n");
|
||||||
pthread_mutex_unlock(&pi->omx_active_mutex);
|
/// pthread_mutex_unlock(&pi->omx_active_mutex); /* next_channel wants the mutex already locked */
|
||||||
fprintf(stderr,"[vcodec] unlocked omx_active_mutex\n");
|
/// fprintf(stderr,"[vcodec] unlocked omx_active_mutex\n");
|
||||||
goto next_channel;
|
goto next_channel;
|
||||||
}
|
}
|
||||||
} else if (current->msgtype == MSG_PAUSE) {
|
} else if (current->msgtype == MSG_PAUSE) {
|
||||||
@@ -320,6 +322,7 @@ next_packet:
|
|||||||
height = codec->height;
|
height = codec->height;
|
||||||
fprintf(stderr,"Initialised video codec - %s width=%d, height=%d\n",((coding == OMX_VIDEO_CodingAVC) ? "H264" : "MPEG-2"), width, height);
|
fprintf(stderr,"Initialised video codec - %s width=%d, height=%d\n",((coding == OMX_VIDEO_CodingAVC) ? "H264" : "MPEG-2"), width, height);
|
||||||
codec->acodec->first_packet = 1;
|
codec->acodec->first_packet = 1;
|
||||||
|
codec->acodec->is_running = 1; /* hack, this makes avdec.cpp start feeding PCM data */
|
||||||
|
|
||||||
/* We are ready to go, allow the audio codec back in */
|
/* We are ready to go, allow the audio codec back in */
|
||||||
pi->omx_active = 1;
|
pi->omx_active = 1;
|
||||||
|
Reference in New Issue
Block a user