Loading media/liboboe/examples/write_sine/src/write_sine_threaded.cpp +15 −11 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include "SineGenerator.h" #define NUM_SECONDS 10 #define SHARING_MODE OBOE_SHARING_MODE_EXCLUSIVE //#define SHARING_MODE OBOE_SHARING_MODE_LEGACY Loading Loading @@ -133,7 +134,9 @@ public: } oboe_result_t close() { if (mStream != OBOE_HANDLE_INVALID) { stop(); printf("call OboeStream_close(0x%08x)\n", mStream); fflush(stdout); OboeStream_close(mStream); mStream = OBOE_HANDLE_INVALID; OboeStreamBuilder_delete(mBuilder); Loading @@ -142,6 +145,7 @@ public: mOutputBuffer = nullptr; delete mConversionBuffer; mConversionBuffer = nullptr; } return OBOE_OK; } Loading Loading @@ -274,9 +278,9 @@ int main(int argc, char **argv) printf("player.getFramesPerSecond() = %d\n", player.getFramesPerSecond()); printf("player.getSamplesPerFrame() = %d\n", player.getSamplesPerFrame()); myData.sineOsc1.setup(440.0, 48000); myData.sineOsc1.setSweep(300.0, 2000.0, 5.0); myData.sineOsc1.setSweep(300.0, 600.0, 5.0); myData.sineOsc2.setup(660.0, 48000); myData.sineOsc2.setSweep(400.0, 3000.0, 7.0); myData.sineOsc2.setSweep(350.0, 900.0, 7.0); myData.samplesPerFrame = player.getSamplesPerFrame(); result = player.start(); Loading media/liboboe/include/oboe/OboeAudio.h +1 −1 Original line number Diff line number Diff line Loading @@ -154,7 +154,7 @@ OBOE_API oboe_result_t OboeStreamBuilder_getSamplesPerFrame(OboeStreamBuilder bu /** * Request a sample data format, for example OBOE_AUDIO_FORMAT_PCM16. * Request a sample data format, for example OBOE_AUDIO_FORMAT_PCM_I16. * The application should query for the actual format after the stream is opened. * * @return OBOE_OK or a negative error. Loading media/liboboe/include/oboe/OboeDefinitions.h +10 −4 Original line number Diff line number Diff line Loading @@ -67,12 +67,17 @@ enum oboe_direction_t { enum oboe_audio_format_t { OBOE_AUDIO_FORMAT_INVALID = -1, OBOE_AUDIO_FORMAT_UNSPECIFIED = 0, OBOE_AUDIO_FORMAT_PCM16, // TODO rename to _PCM_I16 OBOE_AUDIO_FORMAT_PCM_I16, OBOE_AUDIO_FORMAT_PCM_FLOAT, OBOE_AUDIO_FORMAT_PCM824, // TODO rename to _PCM_I8_24 OBOE_AUDIO_FORMAT_PCM32 // TODO rename to _PCM_I32 OBOE_AUDIO_FORMAT_PCM_I8_24, OBOE_AUDIO_FORMAT_PCM_I32 }; // TODO These are deprecated. Remove these aliases once all references are replaced. #define OBOE_AUDIO_FORMAT_PCM16 OBOE_AUDIO_FORMAT_PCM_I16 #define OBOE_AUDIO_FORMAT_PCM824 OBOE_AUDIO_FORMAT_PCM_I8_24 #define OBOE_AUDIO_FORMAT_PCM32 OBOE_AUDIO_FORMAT_PCM_I32 enum { OBOE_OK, OBOE_ERROR_BASE = -900, // TODO review Loading @@ -93,7 +98,8 @@ enum { OBOE_ERROR_TIMEOUT, OBOE_ERROR_WOULD_BLOCK, OBOE_ERROR_INVALID_ORDER, OBOE_ERROR_OUT_OF_RANGE OBOE_ERROR_OUT_OF_RANGE, OBOE_ERROR_NO_SERVICE }; typedef enum { Loading media/liboboe/src/binding/IOboeAudioService.cpp +16 −28 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "binding/OboeStreamRequest.h" #include "binding/OboeStreamConfiguration.h" #include "binding/IOboeAudioService.h" #include "utility/OboeUtilities.h" namespace android { Loading @@ -44,7 +45,7 @@ public: request.writeToParcel(&data); status_t err = remote()->transact(OPEN_STREAM, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_handle_t stream; Loading @@ -53,14 +54,14 @@ public: return stream; } virtual oboe_result_t closeStream(int32_t streamHandle) override { virtual oboe_result_t closeStream(oboe_handle_t streamHandle) override { Parcel data, reply; // send command data.writeInterfaceToken(IOboeAudioService::getInterfaceDescriptor()); data.writeInt32(streamHandle); status_t err = remote()->transact(CLOSE_STREAM, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_result_t res; Loading @@ -69,14 +70,14 @@ public: } virtual oboe_result_t getStreamDescription(oboe_handle_t streamHandle, AudioEndpointParcelable &parcelable) { oboe::AudioEndpointParcelable &parcelable) { Parcel data, reply; // send command data.writeInterfaceToken(IOboeAudioService::getInterfaceDescriptor()); data.writeInt32(streamHandle); status_t err = remote()->transact(GET_STREAM_DESCRIPTION, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply parcelable.readFromParcel(&reply); Loading @@ -97,7 +98,7 @@ public: data.writeInt32(streamHandle); status_t err = remote()->transact(START_STREAM, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_result_t res; Loading @@ -112,7 +113,7 @@ public: data.writeInt32(streamHandle); status_t err = remote()->transact(PAUSE_STREAM, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_result_t res; Loading @@ -127,7 +128,7 @@ public: data.writeInt32(streamHandle); status_t err = remote()->transact(FLUSH_STREAM, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_result_t res; Loading @@ -135,13 +136,6 @@ public: return res; } virtual void tickle() override { // TODO remove after service thread implemented Parcel data; // send command data.writeInterfaceToken(IOboeAudioService::getInterfaceDescriptor()); remote()->transact(TICKLE, data, nullptr); } virtual oboe_result_t registerAudioThread(oboe_handle_t streamHandle, pid_t clientThreadId, oboe_nanoseconds_t periodNanoseconds) override { Loading @@ -153,7 +147,7 @@ public: data.writeInt64(periodNanoseconds); status_t err = remote()->transact(REGISTER_AUDIO_THREAD, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_result_t res; Loading @@ -170,7 +164,7 @@ public: data.writeInt32((int32_t) clientThreadId); status_t err = remote()->transact(UNREGISTER_AUDIO_THREAD, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_result_t res; Loading @@ -189,8 +183,8 @@ IMPLEMENT_META_INTERFACE(OboeAudioService, "IOboeAudioService"); status_t BnOboeAudioService::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { OboeStream stream; OboeStreamRequest request; OboeStreamConfiguration configuration; oboe::OboeStreamRequest request; oboe::OboeStreamConfiguration configuration; pid_t pid; oboe_nanoseconds_t nanoseconds; oboe_result_t result; Loading @@ -201,7 +195,7 @@ status_t BnOboeAudioService::onTransact(uint32_t code, const Parcel& data, case OPEN_STREAM: { request.readFromParcel(&data); stream = openStream(request, configuration); ALOGD("BnOboeAudioService::onTransact OPEN_STREAM 0x%08X", stream); ALOGD("BnOboeAudioService::onTransact OPEN_STREAM server handle = 0x%08X", stream); reply->writeInt32(stream); configuration.writeToParcel(reply); return NO_ERROR; Loading @@ -221,12 +215,12 @@ status_t BnOboeAudioService::onTransact(uint32_t code, const Parcel& data, oboe::AudioEndpointParcelable parcelable; result = getStreamDescription(stream, parcelable); if (result != OBOE_OK) { return -1; // FIXME return OboeConvert_oboeToAndroidStatus(result); } parcelable.dump(); result = parcelable.validate(); if (result != OBOE_OK) { return -1; // FIXME return OboeConvert_oboeToAndroidStatus(result); } parcelable.writeToParcel(reply); reply->writeInt32(result); Loading Loading @@ -281,12 +275,6 @@ status_t BnOboeAudioService::onTransact(uint32_t code, const Parcel& data, return NO_ERROR; } break; case TICKLE: { ALOGV("BnOboeAudioService::onTransact TICKLE"); tickle(); return NO_ERROR; } break; default: // ALOGW("BnOboeAudioService::onTransact not handled %u", code); return BBinder::onTransact(code, data, reply, flags); Loading media/liboboe/src/binding/IOboeAudioService.h +4 −19 Original line number Diff line number Diff line Loading @@ -29,13 +29,6 @@ #include "binding/OboeStreamRequest.h" #include "binding/OboeStreamConfiguration.h" //using android::status_t; //using android::IInterface; //using android::BnInterface; using oboe::AudioEndpointParcelable; using oboe::OboeStreamRequest; using oboe::OboeStreamConfiguration; namespace android { Loading @@ -45,16 +38,16 @@ public: DECLARE_META_INTERFACE(OboeAudioService); virtual oboe_handle_t openStream(OboeStreamRequest &request, OboeStreamConfiguration &configuration) = 0; virtual oboe_handle_t openStream(oboe::OboeStreamRequest &request, oboe::OboeStreamConfiguration &configuration) = 0; virtual oboe_result_t closeStream(int32_t streamHandle) = 0; virtual oboe_result_t closeStream(oboe_handle_t streamHandle) = 0; /* Get an immutable description of the in-memory queues * used to communicate with the underlying HAL or Service. */ virtual oboe_result_t getStreamDescription(oboe_handle_t streamHandle, AudioEndpointParcelable &parcelable) = 0; oboe::AudioEndpointParcelable &parcelable) = 0; /** * Start the flow of data. Loading @@ -79,14 +72,6 @@ public: virtual oboe_result_t unregisterAudioThread(oboe_handle_t streamHandle, pid_t clientThreadId) = 0; /** * Poke server instead of running a background thread. * Cooperative multi-tasking for early development only. * TODO remove tickle() when service has its own thread. */ virtual void tickle() { }; }; class BnOboeAudioService : public BnInterface<IOboeAudioService> { Loading Loading
media/liboboe/examples/write_sine/src/write_sine_threaded.cpp +15 −11 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ #include "SineGenerator.h" #define NUM_SECONDS 10 #define SHARING_MODE OBOE_SHARING_MODE_EXCLUSIVE //#define SHARING_MODE OBOE_SHARING_MODE_LEGACY Loading Loading @@ -133,7 +134,9 @@ public: } oboe_result_t close() { if (mStream != OBOE_HANDLE_INVALID) { stop(); printf("call OboeStream_close(0x%08x)\n", mStream); fflush(stdout); OboeStream_close(mStream); mStream = OBOE_HANDLE_INVALID; OboeStreamBuilder_delete(mBuilder); Loading @@ -142,6 +145,7 @@ public: mOutputBuffer = nullptr; delete mConversionBuffer; mConversionBuffer = nullptr; } return OBOE_OK; } Loading Loading @@ -274,9 +278,9 @@ int main(int argc, char **argv) printf("player.getFramesPerSecond() = %d\n", player.getFramesPerSecond()); printf("player.getSamplesPerFrame() = %d\n", player.getSamplesPerFrame()); myData.sineOsc1.setup(440.0, 48000); myData.sineOsc1.setSweep(300.0, 2000.0, 5.0); myData.sineOsc1.setSweep(300.0, 600.0, 5.0); myData.sineOsc2.setup(660.0, 48000); myData.sineOsc2.setSweep(400.0, 3000.0, 7.0); myData.sineOsc2.setSweep(350.0, 900.0, 7.0); myData.samplesPerFrame = player.getSamplesPerFrame(); result = player.start(); Loading
media/liboboe/include/oboe/OboeAudio.h +1 −1 Original line number Diff line number Diff line Loading @@ -154,7 +154,7 @@ OBOE_API oboe_result_t OboeStreamBuilder_getSamplesPerFrame(OboeStreamBuilder bu /** * Request a sample data format, for example OBOE_AUDIO_FORMAT_PCM16. * Request a sample data format, for example OBOE_AUDIO_FORMAT_PCM_I16. * The application should query for the actual format after the stream is opened. * * @return OBOE_OK or a negative error. Loading
media/liboboe/include/oboe/OboeDefinitions.h +10 −4 Original line number Diff line number Diff line Loading @@ -67,12 +67,17 @@ enum oboe_direction_t { enum oboe_audio_format_t { OBOE_AUDIO_FORMAT_INVALID = -1, OBOE_AUDIO_FORMAT_UNSPECIFIED = 0, OBOE_AUDIO_FORMAT_PCM16, // TODO rename to _PCM_I16 OBOE_AUDIO_FORMAT_PCM_I16, OBOE_AUDIO_FORMAT_PCM_FLOAT, OBOE_AUDIO_FORMAT_PCM824, // TODO rename to _PCM_I8_24 OBOE_AUDIO_FORMAT_PCM32 // TODO rename to _PCM_I32 OBOE_AUDIO_FORMAT_PCM_I8_24, OBOE_AUDIO_FORMAT_PCM_I32 }; // TODO These are deprecated. Remove these aliases once all references are replaced. #define OBOE_AUDIO_FORMAT_PCM16 OBOE_AUDIO_FORMAT_PCM_I16 #define OBOE_AUDIO_FORMAT_PCM824 OBOE_AUDIO_FORMAT_PCM_I8_24 #define OBOE_AUDIO_FORMAT_PCM32 OBOE_AUDIO_FORMAT_PCM_I32 enum { OBOE_OK, OBOE_ERROR_BASE = -900, // TODO review Loading @@ -93,7 +98,8 @@ enum { OBOE_ERROR_TIMEOUT, OBOE_ERROR_WOULD_BLOCK, OBOE_ERROR_INVALID_ORDER, OBOE_ERROR_OUT_OF_RANGE OBOE_ERROR_OUT_OF_RANGE, OBOE_ERROR_NO_SERVICE }; typedef enum { Loading
media/liboboe/src/binding/IOboeAudioService.cpp +16 −28 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include "binding/OboeStreamRequest.h" #include "binding/OboeStreamConfiguration.h" #include "binding/IOboeAudioService.h" #include "utility/OboeUtilities.h" namespace android { Loading @@ -44,7 +45,7 @@ public: request.writeToParcel(&data); status_t err = remote()->transact(OPEN_STREAM, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_handle_t stream; Loading @@ -53,14 +54,14 @@ public: return stream; } virtual oboe_result_t closeStream(int32_t streamHandle) override { virtual oboe_result_t closeStream(oboe_handle_t streamHandle) override { Parcel data, reply; // send command data.writeInterfaceToken(IOboeAudioService::getInterfaceDescriptor()); data.writeInt32(streamHandle); status_t err = remote()->transact(CLOSE_STREAM, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_result_t res; Loading @@ -69,14 +70,14 @@ public: } virtual oboe_result_t getStreamDescription(oboe_handle_t streamHandle, AudioEndpointParcelable &parcelable) { oboe::AudioEndpointParcelable &parcelable) { Parcel data, reply; // send command data.writeInterfaceToken(IOboeAudioService::getInterfaceDescriptor()); data.writeInt32(streamHandle); status_t err = remote()->transact(GET_STREAM_DESCRIPTION, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply parcelable.readFromParcel(&reply); Loading @@ -97,7 +98,7 @@ public: data.writeInt32(streamHandle); status_t err = remote()->transact(START_STREAM, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_result_t res; Loading @@ -112,7 +113,7 @@ public: data.writeInt32(streamHandle); status_t err = remote()->transact(PAUSE_STREAM, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_result_t res; Loading @@ -127,7 +128,7 @@ public: data.writeInt32(streamHandle); status_t err = remote()->transact(FLUSH_STREAM, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_result_t res; Loading @@ -135,13 +136,6 @@ public: return res; } virtual void tickle() override { // TODO remove after service thread implemented Parcel data; // send command data.writeInterfaceToken(IOboeAudioService::getInterfaceDescriptor()); remote()->transact(TICKLE, data, nullptr); } virtual oboe_result_t registerAudioThread(oboe_handle_t streamHandle, pid_t clientThreadId, oboe_nanoseconds_t periodNanoseconds) override { Loading @@ -153,7 +147,7 @@ public: data.writeInt64(periodNanoseconds); status_t err = remote()->transact(REGISTER_AUDIO_THREAD, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_result_t res; Loading @@ -170,7 +164,7 @@ public: data.writeInt32((int32_t) clientThreadId); status_t err = remote()->transact(UNREGISTER_AUDIO_THREAD, data, &reply); if (err != NO_ERROR) { return OBOE_ERROR_INTERNAL; // TODO consider another error return OboeConvert_androidToOboeResult(err); } // parse reply oboe_result_t res; Loading @@ -189,8 +183,8 @@ IMPLEMENT_META_INTERFACE(OboeAudioService, "IOboeAudioService"); status_t BnOboeAudioService::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { OboeStream stream; OboeStreamRequest request; OboeStreamConfiguration configuration; oboe::OboeStreamRequest request; oboe::OboeStreamConfiguration configuration; pid_t pid; oboe_nanoseconds_t nanoseconds; oboe_result_t result; Loading @@ -201,7 +195,7 @@ status_t BnOboeAudioService::onTransact(uint32_t code, const Parcel& data, case OPEN_STREAM: { request.readFromParcel(&data); stream = openStream(request, configuration); ALOGD("BnOboeAudioService::onTransact OPEN_STREAM 0x%08X", stream); ALOGD("BnOboeAudioService::onTransact OPEN_STREAM server handle = 0x%08X", stream); reply->writeInt32(stream); configuration.writeToParcel(reply); return NO_ERROR; Loading @@ -221,12 +215,12 @@ status_t BnOboeAudioService::onTransact(uint32_t code, const Parcel& data, oboe::AudioEndpointParcelable parcelable; result = getStreamDescription(stream, parcelable); if (result != OBOE_OK) { return -1; // FIXME return OboeConvert_oboeToAndroidStatus(result); } parcelable.dump(); result = parcelable.validate(); if (result != OBOE_OK) { return -1; // FIXME return OboeConvert_oboeToAndroidStatus(result); } parcelable.writeToParcel(reply); reply->writeInt32(result); Loading Loading @@ -281,12 +275,6 @@ status_t BnOboeAudioService::onTransact(uint32_t code, const Parcel& data, return NO_ERROR; } break; case TICKLE: { ALOGV("BnOboeAudioService::onTransact TICKLE"); tickle(); return NO_ERROR; } break; default: // ALOGW("BnOboeAudioService::onTransact not handled %u", code); return BBinder::onTransact(code, data, reply, flags); Loading
media/liboboe/src/binding/IOboeAudioService.h +4 −19 Original line number Diff line number Diff line Loading @@ -29,13 +29,6 @@ #include "binding/OboeStreamRequest.h" #include "binding/OboeStreamConfiguration.h" //using android::status_t; //using android::IInterface; //using android::BnInterface; using oboe::AudioEndpointParcelable; using oboe::OboeStreamRequest; using oboe::OboeStreamConfiguration; namespace android { Loading @@ -45,16 +38,16 @@ public: DECLARE_META_INTERFACE(OboeAudioService); virtual oboe_handle_t openStream(OboeStreamRequest &request, OboeStreamConfiguration &configuration) = 0; virtual oboe_handle_t openStream(oboe::OboeStreamRequest &request, oboe::OboeStreamConfiguration &configuration) = 0; virtual oboe_result_t closeStream(int32_t streamHandle) = 0; virtual oboe_result_t closeStream(oboe_handle_t streamHandle) = 0; /* Get an immutable description of the in-memory queues * used to communicate with the underlying HAL or Service. */ virtual oboe_result_t getStreamDescription(oboe_handle_t streamHandle, AudioEndpointParcelable &parcelable) = 0; oboe::AudioEndpointParcelable &parcelable) = 0; /** * Start the flow of data. Loading @@ -79,14 +72,6 @@ public: virtual oboe_result_t unregisterAudioThread(oboe_handle_t streamHandle, pid_t clientThreadId) = 0; /** * Poke server instead of running a background thread. * Cooperative multi-tasking for early development only. * TODO remove tickle() when service has its own thread. */ virtual void tickle() { }; }; class BnOboeAudioService : public BnInterface<IOboeAudioService> { Loading