Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa9ea48d authored by John Grossman's avatar John Grossman
Browse files

LibAAH_RTP: Get rid of PipeEvent



Bionic/Android support eventfd, so there is really no reason to have
PipeEvent around any more.  This change gets rid of it in LibAAH_RTP
and replaces it with eventfds.

Change-Id: I841fcb71bf5015d521d7517c69f44eac0ea92278
Signed-off-by: default avatarJohn Grossman <johngro@google.com>
parent 2921612d
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@ LOCAL_SRC_FILES := \
    aah_tx_group.cpp \
    aah_tx_group.cpp \
    aah_tx_packet.cpp \
    aah_tx_packet.cpp \
    aah_tx_player.cpp \
    aah_tx_player.cpp \
    pipe_event.cpp \
    utils.cpp
    utils.cpp


LOCAL_C_INCLUDES := \
LOCAL_C_INCLUDES := \
+12 −0
Original line number Original line Diff line number Diff line
@@ -17,6 +17,8 @@
#define LOG_TAG "LibAAH_RTP"
#define LOG_TAG "LibAAH_RTP"
//#define LOG_NDEBUG 0
//#define LOG_NDEBUG 0


#include <sys/eventfd.h>

#include <binder/IServiceManager.h>
#include <binder/IServiceManager.h>
#include <media/MediaPlayerInterface.h>
#include <media/MediaPlayerInterface.h>
#include <utils/Log.h>
#include <utils/Log.h>
@@ -49,6 +51,7 @@ AAH_RXPlayer::AAH_RXPlayer()


    memset(&data_source_addr_, 0, sizeof(data_source_addr_));
    memset(&data_source_addr_, 0, sizeof(data_source_addr_));
    memset(&transmitter_addr_, 0, sizeof(transmitter_addr_));
    memset(&transmitter_addr_, 0, sizeof(transmitter_addr_));
    wakeup_work_thread_evt_fd_ = eventfd(0, EFD_NONBLOCK);


    fetchAudioFlinger();
    fetchAudioFlinger();
}
}
@@ -57,6 +60,10 @@ AAH_RXPlayer::~AAH_RXPlayer() {
    reset_l();
    reset_l();
    CHECK(substreams_.size() == 0);
    CHECK(substreams_.size() == 0);
    omx_.disconnect();
    omx_.disconnect();

    if (wakeup_work_thread_evt_fd_ >= 0) {
        ::close(wakeup_work_thread_evt_fd_);
    }
}
}


status_t AAH_RXPlayer::initCheck() {
status_t AAH_RXPlayer::initCheck() {
@@ -70,6 +77,11 @@ status_t AAH_RXPlayer::initCheck() {
        return NO_MEMORY;
        return NO_MEMORY;
    }
    }


    if (wakeup_work_thread_evt_fd_ < 0) {
        LOGE("Failed to allocate wakeup eventfd");
        return NO_MEMORY;
    }

    // Check for the presense of the common time service by attempting to query
    // Check for the presense of the common time service by attempting to query
    // for CommonTime's frequency.  If we get an error back, we cannot talk to
    // for CommonTime's frequency.  If we get an error back, we cannot talk to
    // the service at all and should abort now.
    // the service at all and should abort now.
+1 −2
Original line number Original line Diff line number Diff line
@@ -30,7 +30,6 @@
#include <utils/threads.h>
#include <utils/threads.h>


#include "aah_decoder_pump.h"
#include "aah_decoder_pump.h"
#include "pipe_event.h"
#include "utils.h"
#include "utils.h"


namespace android {
namespace android {
@@ -273,7 +272,7 @@ class AAH_RXPlayer : public MediaPlayerInterface {
    void                sendUnicastGroupLeave();
    void                sendUnicastGroupLeave();
    void                fetchAudioFlinger();
    void                fetchAudioFlinger();


    PipeEvent           wakeup_work_thread_evt_;
    int                 wakeup_work_thread_evt_fd_;
    sp<ThreadWrapper>   thread_wrapper_;
    sp<ThreadWrapper>   thread_wrapper_;
    Mutex               api_lock_;
    Mutex               api_lock_;
    bool                is_playing_;
    bool                is_playing_;
+4 −4
Original line number Original line Diff line number Diff line
@@ -66,7 +66,7 @@ status_t AAH_RXPlayer::startWorkThread() {


void AAH_RXPlayer::stopWorkThread() {
void AAH_RXPlayer::stopWorkThread() {
    thread_wrapper_->requestExit();  // set the exit pending flag
    thread_wrapper_->requestExit();  // set the exit pending flag
    wakeup_work_thread_evt_.setEvent();
    signalEventFD(wakeup_work_thread_evt_fd_);


    status_t res;
    status_t res;
    res = thread_wrapper_->requestExitAndWait(); // block until thread exit.
    res = thread_wrapper_->requestExitAndWait(); // block until thread exit.
@@ -74,7 +74,7 @@ void AAH_RXPlayer::stopWorkThread() {
        LOGE("Failed to stop work thread (res = %d)", res);
        LOGE("Failed to stop work thread (res = %d)", res);
    }
    }


    wakeup_work_thread_evt_.clearPendingEvents();
    clearEventFD(wakeup_work_thread_evt_fd_);
}
}


void AAH_RXPlayer::cleanupSocket() {
void AAH_RXPlayer::cleanupSocket() {
@@ -292,7 +292,7 @@ bool AAH_RXPlayer::threadLoop() {
        if ((0 != timeout) && (!process_more_right_now)) {
        if ((0 != timeout) && (!process_more_right_now)) {
            // Set up the events to wait on.  Start with the wakeup pipe.
            // Set up the events to wait on.  Start with the wakeup pipe.
            memset(&poll_fds, 0, sizeof(poll_fds));
            memset(&poll_fds, 0, sizeof(poll_fds));
            poll_fds[0].fd     = wakeup_work_thread_evt_.getWakeupHandle();
            poll_fds[0].fd     = wakeup_work_thread_evt_fd_;
            poll_fds[0].events = POLLIN;
            poll_fds[0].events = POLLIN;


            // Add the RX socket.
            // Add the RX socket.
@@ -313,7 +313,7 @@ bool AAH_RXPlayer::threadLoop() {
            break;
            break;
        }
        }


        wakeup_work_thread_evt_.clearPendingEvents();
        clearEventFD(wakeup_work_thread_evt_fd_);
        process_more_right_now = false;
        process_more_right_now = false;


        // Step 2: Do we have data waiting in the socket?  If so, drain the
        // Step 2: Do we have data waiting in the socket?  If so, drain the
+3 −16
Original line number Original line Diff line number Diff line
@@ -955,20 +955,6 @@ bool AAH_TXGroup::CmdAndControlRXer::init() {
    return (mWakeupEventFD >= 0);
    return (mWakeupEventFD >= 0);
}
}


void AAH_TXGroup::CmdAndControlRXer::wakeupThread() {
    if (mWakeupEventFD >= 0) {
        uint64_t tmp = 1;
        ::write(mWakeupEventFD, &tmp, sizeof(tmp));
    }
}

void AAH_TXGroup::CmdAndControlRXer::clearWakeupEvent() {
    if (mWakeupEventFD >= 0) {
        uint64_t tmp;
        ::read(mWakeupEventFD, &tmp, sizeof(tmp));
    }
}

bool AAH_TXGroup::CmdAndControlRXer::threadLoop() {
bool AAH_TXGroup::CmdAndControlRXer::threadLoop() {
    // Implementation for main command and control receiver thread.  Its primary
    // Implementation for main command and control receiver thread.  Its primary
    // job is to service command and control requests from clients.  These
    // job is to service command and control requests from clients.  These
@@ -1053,8 +1039,9 @@ bool AAH_TXGroup::CmdAndControlRXer::threadLoop() {
    }
    }


    // clear the wakeup event if needed.
    // clear the wakeup event if needed.
    if (pollFds[0].revents)
    if (pollFds[0].revents) {
        clearWakeupEvent();
        clearEventFD(mWakeupEventFD);
    }


    // Handle any pending C&C requests and heartbeat timeouts.  Also, trim the
    // Handle any pending C&C requests and heartbeat timeouts.  Also, trim the
    // retry buffers if its time to do so.
    // retry buffers if its time to do so.
Loading